Improvements to example
This commit is contained in:
parent
2e5217edef
commit
e5af5692e4
7 changed files with 7 additions and 21 deletions
|
@ -224,7 +224,7 @@ public class BarChartActivity extends DemoBase implements OnSeekBarChangeListene
|
|||
|
||||
private void setData(int count, float range) {
|
||||
|
||||
float start = 1f;
|
||||
float start = 0f;
|
||||
|
||||
mChart.getXAxis().setAxisMinValue(start);
|
||||
mChart.getXAxis().setAxisMaxValue(start + count + 2);
|
||||
|
|
|
@ -45,6 +45,7 @@ public class ScrollViewActivity extends DemoBase {
|
|||
mChart.getLegend().setEnabled(false);
|
||||
|
||||
setData(10);
|
||||
mChart.setFitBars(true);
|
||||
}
|
||||
|
||||
private void setData(int count) {
|
||||
|
|
|
@ -210,6 +210,7 @@ public class StackedBarActivity extends DemoBase implements OnSeekBarChangeListe
|
|||
mChart.setData(data);
|
||||
}
|
||||
|
||||
mChart.setFitBars(true);
|
||||
mChart.invalidate();
|
||||
}
|
||||
|
||||
|
|
|
@ -26,9 +26,6 @@ public class DayAxisValueFormatter implements AxisValueFormatter {
|
|||
|
||||
int days = (int) value;
|
||||
|
||||
if (days == 0)
|
||||
return "";
|
||||
|
||||
int year = determineYear(days);
|
||||
|
||||
int month = determineMonth(days);
|
||||
|
@ -72,7 +69,7 @@ public class DayAxisValueFormatter implements AxisValueFormatter {
|
|||
break;
|
||||
}
|
||||
|
||||
return dayOfMonth + appendix + " " + monthName;
|
||||
return dayOfMonth == 0 ? "" : dayOfMonth + appendix + " " + monthName;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -41,7 +41,6 @@ public class ComplexityFragment extends SimpleFragment {
|
|||
|
||||
YAxis leftAxis = mChart.getAxisLeft();
|
||||
leftAxis.setTypeface(tf);
|
||||
leftAxis.setAxisMinValue(0f); // this replaces setStartAtZero(true)
|
||||
|
||||
mChart.getAxisRight().setEnabled(false);
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ public abstract class SimpleFragment extends Fragment {
|
|||
// entries = FileUtils.loadEntriesFromAssets(getActivity().getAssets(), "stacked_bars.txt");
|
||||
|
||||
for(int j = 0; j < count; j++) {
|
||||
entries.add(new BarEntry((float) (Math.random() * range) + range / 4, j));
|
||||
entries.add(new BarEntry(j, (float) (Math.random() * range) + range / 4));
|
||||
}
|
||||
|
||||
BarDataSet ds = new BarDataSet(entries, getLabel(i));
|
||||
|
@ -78,7 +78,7 @@ public abstract class SimpleFragment extends Fragment {
|
|||
ArrayList<Entry> entries = new ArrayList<Entry>();
|
||||
|
||||
for(int j = 0; j < count; j++) {
|
||||
entries.add(new Entry((float) (Math.random() * range) + range / 4, j));
|
||||
entries.add(new Entry(j, (float) (Math.random() * range) + range / 4));
|
||||
}
|
||||
|
||||
ScatterDataSet ds = new ScatterDataSet(entries, getLabel(i));
|
||||
|
@ -122,11 +122,6 @@ public abstract class SimpleFragment extends Fragment {
|
|||
|
||||
protected LineData generateLineData() {
|
||||
|
||||
// DataSet ds1 = new DataSet(n, "O(n)");
|
||||
// DataSet ds2 = new DataSet(nlogn, "O(nlogn)");
|
||||
// DataSet ds3 = new DataSet(nsquare, "O(n\u00B2)");
|
||||
// DataSet ds4 = new DataSet(nthree, "O(n\u00B3)");
|
||||
|
||||
ArrayList<ILineDataSet> sets = new ArrayList<ILineDataSet>();
|
||||
|
||||
LineDataSet ds1 = new LineDataSet(FileUtils.loadEntriesFromAssets(getActivity().getAssets(), "sine.txt"), "Sine function");
|
||||
|
@ -145,13 +140,6 @@ public abstract class SimpleFragment extends Fragment {
|
|||
sets.add(ds1);
|
||||
sets.add(ds2);
|
||||
|
||||
// sets.add(FileUtils.dataSetFromAssets(getActivity().getAssets(), "n.txt"));
|
||||
// sets.add(FileUtils.dataSetFromAssets(getActivity().getAssets(), "nlogn.txt"));
|
||||
// sets.add(FileUtils.dataSetFromAssets(getActivity().getAssets(), "square.txt"));
|
||||
// sets.add(FileUtils.dataSetFromAssets(getActivity().getAssets(), "three.txt"));
|
||||
|
||||
int max = Math.max(sets.get(0).getEntryCount(), sets.get(1).getEntryCount());
|
||||
|
||||
LineData d = new LineData(sets);
|
||||
d.setValueTypeface(tf);
|
||||
return d;
|
||||
|
|
|
@ -122,7 +122,7 @@ public class FileUtils {
|
|||
String[] split = line.split("#");
|
||||
|
||||
if (split.length <= 2) {
|
||||
entries.add(new Entry(Float.parseFloat(split[0]), Integer.parseInt(split[1])));
|
||||
entries.add(new Entry(Float.parseFloat(split[1]), Float.parseFloat(split[0])));
|
||||
} else {
|
||||
|
||||
float[] vals = new float[split.length - 1];
|
||||
|
|
Loading…
Add table
Reference in a new issue