GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [*] Updated UsingMPChartsLib to v3.0.1 · balim/Android@39fa76a

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • UsingMPChartsLib/app/src/main/java/github/nisrulz/usingmpchartslib
    • MainActivity.java
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎UsingMPChartsLib/app/src/main/java/github/nisrulz/usingmpchartslib/MainActivity.java‎

Copy file name to clipboardExpand all lines: UsingMPChartsLib/app/src/main/java/github/nisrulz/usingmpchartslib/MainActivity.java
+76-86Lines changed: 76 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -9,101 +9,91 @@
99
import android.view.Menu;
1010
import android.view.MenuItem;
1111
import android.view.View;
12-
1312
import com.github.mikephil.charting.charts.BarChart;
13+
import com.github.mikephil.charting.components.Description;
1414
import com.github.mikephil.charting.data.BarData;
1515
import com.github.mikephil.charting.data.BarDataSet;
1616
import com.github.mikephil.charting.data.BarEntry;
1717
import com.github.mikephil.charting.utils.ColorTemplate;
18-
1918
import java.util.ArrayList;
2019

2120
public class MainActivity extends AppCompatActivity {
2221

23-
// Library at : https://github.com/PhilJay/MPAndroidChart/
24-
25-
@Override
26-
protected void onCreate(Bundle savedInstanceState) {
27-
super.onCreate(savedInstanceState);
28-
setContentView(R.layout.activity_main);
29-
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
30-
setSupportActionBar(toolbar);
31-
32-
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
33-
fab.setOnClickListener(new View.OnClickListener() {
34-
@Override
35-
public void onClick(View view) {
36-
Snackbar.make(view, "Using MPAndroidCharts 2.2.3", Snackbar.LENGTH_LONG).show();
37-
}
38-
});
39-
40-
41-
// Data Sets
42-
ArrayList<BarEntry> entries = new ArrayList<>();
43-
entries.add(new BarEntry(4f, 0));
44-
entries.add(new BarEntry(8f, 1));
45-
entries.add(new BarEntry(6f, 2));
46-
entries.add(new BarEntry(12f, 3));
47-
entries.add(new BarEntry(18f, 4));
48-
entries.add(new BarEntry(9f, 5));
49-
BarDataSet dataset = new BarDataSet(entries, "# of Calls");
50-
51-
52-
// Defining X Axis
53-
ArrayList<String> labels = new ArrayList<String>();
54-
labels.add("January");
55-
labels.add("February");
56-
labels.add("March");
57-
labels.add("April");
58-
labels.add("May");
59-
labels.add("June");
60-
61-
// Declare the bar chart and set it as the view for this activity
62-
final BarChart chart = (BarChart) findViewById(R.id.bar_chart);
63-
64-
// Set data for the bar chart
65-
BarData data = new BarData(labels, dataset);
66-
chart.setData(data);
67-
68-
// Set description
69-
chart.setDescription("# of times Alice called Bob");
70-
71-
// Set themes
72-
dataset.setColors(ColorTemplate.COLORFUL_COLORS);
73-
74-
// Animate
75-
chart.animateY(5000);
76-
77-
// Save the chart aftre its drawn
78-
new Handler().postDelayed(new Runnable() {
79-
@Override
80-
public void run() {
81-
// Save the chart to gallery/path
82-
chart.saveToGallery("mychart.jpg", 85); // 85 is the quality of the image
83-
}
84-
}, 2000);
85-
86-
}
87-
88-
@Override
89-
public boolean onCreateOptionsMenu(Menu menu) {
90-
// Inflate the menu; this adds items to the action bar if it is present.
91-
getMenuInflater().inflate(R.menu.menu_main, menu);
92-
return true;
22+
// Library at : https://github.com/PhilJay/MPAndroidChart/
23+
24+
@Override
25+
protected void onCreate(Bundle savedInstanceState) {
26+
super.onCreate(savedInstanceState);
27+
setContentView(R.layout.activity_main);
28+
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
29+
setSupportActionBar(toolbar);
30+
31+
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
32+
fab.setOnClickListener(new View.OnClickListener() {
33+
@Override
34+
public void onClick(View view) {
35+
Snackbar.make(view, "Using MPAndroidCharts 3.0.1", Snackbar.LENGTH_LONG).show();
36+
}
37+
});
38+
39+
// Data Sets
40+
ArrayList<BarEntry> entries = new ArrayList<>();
41+
entries.add(new BarEntry(4f, 0));
42+
entries.add(new BarEntry(8f, 1));
43+
entries.add(new BarEntry(6f, 2));
44+
entries.add(new BarEntry(12f, 3));
45+
entries.add(new BarEntry(18f, 4));
46+
entries.add(new BarEntry(9f, 5));
47+
BarDataSet dataset = new BarDataSet(entries, "# of Calls");
48+
49+
// Declare the bar chart and set it as the view for this activity
50+
final BarChart chart = (BarChart) findViewById(R.id.bar_chart);
51+
52+
// Set data for the bar chart
53+
BarData data = new BarData(dataset);
54+
chart.setData(data);
55+
chart.setFitBars(true); // make the x-axis fit exactly all bars
56+
57+
// Set description
58+
Description description = new Description();
59+
description.setText("# of times Alice called Bob");
60+
chart.setDescription(description);
61+
62+
// Set themes
63+
dataset.setColors(ColorTemplate.COLORFUL_COLORS);
64+
65+
// Animate
66+
chart.animateY(5000);
67+
68+
// Save the chart aftre its drawn
69+
new Handler().postDelayed(new Runnable() {
70+
@Override
71+
public void run() {
72+
// Save the chart to gallery/path
73+
chart.saveToGallery("mychart.jpg", 85); // 85 is the quality of the image
74+
}
75+
}, 2000);
76+
}
77+
78+
@Override
79+
public boolean onCreateOptionsMenu(Menu menu) {
80+
// Inflate the menu; this adds items to the action bar if it is present.
81+
getMenuInflater().inflate(R.menu.menu_main, menu);
82+
return true;
83+
}
84+
85+
@Override
86+
public boolean onOptionsItemSelected(MenuItem item) {
87+
// Handle action bar item clicks here. The action bar will
88+
// automatically handle clicks on the Home/Up button, so long
89+
// as you specify a parent activity in AndroidManifest.xml.
90+
int id = item.getItemId();
91+
92+
//noinspection SimplifiableIfStatement
93+
if (id == R.id.action_settings) {
94+
return true;
9395
}
9496

95-
@Override
96-
public boolean onOptionsItemSelected(MenuItem item) {
97-
// Handle action bar item clicks here. The action bar will
98-
// automatically handle clicks on the Home/Up button, so long
99-
// as you specify a parent activity in AndroidManifest.xml.
100-
int id = item.getItemId();
101-
102-
//noinspection SimplifiableIfStatement
103-
if (id == R.id.action_settings) {
104-
return true;
105-
}
106-
107-
return super.onOptionsItemSelected(item);
108-
}
97+
return super.onOptionsItemSelected(item);
98+
}
10999
}

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.