use of com.github.mikephil.charting.interfaces.datasets.IBarDataSet in project MPAndroidChart by PhilJay.
the class AnotherBarActivity method onProgressChanged.
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
tvX.setText("" + (mSeekBarX.getProgress() + 1));
tvY.setText("" + (mSeekBarY.getProgress()));
ArrayList<BarEntry> yVals1 = new ArrayList<BarEntry>();
for (int i = 0; i < mSeekBarX.getProgress() + 1; i++) {
float mult = (mSeekBarY.getProgress() + 1);
float val = (float) (Math.random() * mult) + mult / 3;
yVals1.add(new BarEntry(i, val));
}
BarDataSet set1;
if (mChart.getData() != null && mChart.getData().getDataSetCount() > 0) {
set1 = (BarDataSet) mChart.getData().getDataSetByIndex(0);
set1.setValues(yVals1);
mChart.getData().notifyDataChanged();
mChart.notifyDataSetChanged();
} else {
set1 = new BarDataSet(yVals1, "Data Set");
set1.setColors(ColorTemplate.VORDIPLOM_COLORS);
set1.setDrawValues(false);
ArrayList<IBarDataSet> dataSets = new ArrayList<IBarDataSet>();
dataSets.add(set1);
BarData data = new BarData(dataSets);
mChart.setData(data);
mChart.setFitBars(true);
}
mChart.invalidate();
}
use of com.github.mikephil.charting.interfaces.datasets.IBarDataSet in project MPAndroidChart by PhilJay.
the class RealmDatabaseActivityBar method setData.
private void setData() {
RealmResults<RealmDemoData> result = mRealm.where(RealmDemoData.class).findAll();
//RealmBarDataSet<RealmDemoData> set = new RealmBarDataSet<RealmDemoData>(result, "stackValues", "xIndex"); // normal entries
// stacked entries
RealmBarDataSet<RealmDemoData> set = new RealmBarDataSet<RealmDemoData>(result, "xValue", "yValue");
set.setColors(new int[] { ColorTemplate.rgb("#FF5722"), ColorTemplate.rgb("#03A9F4") });
set.setLabel("Realm BarDataSet");
ArrayList<IBarDataSet> dataSets = new ArrayList<IBarDataSet>();
// add the dataset
dataSets.add(set);
// create a data object with the dataset list
BarData data = new BarData(dataSets);
styleData(data);
// set data
mChart.setData(data);
mChart.setFitBars(true);
mChart.animateY(1400, Easing.EasingOption.EaseInOutQuart);
}
use of com.github.mikephil.charting.interfaces.datasets.IBarDataSet in project MPAndroidChart by PhilJay.
the class ListViewBarChartActivity method generateData.
/**
* generates a random ChartData object with just one DataSet
*
* @return
*/
private BarData generateData(int cnt) {
ArrayList<BarEntry> entries = new ArrayList<BarEntry>();
for (int i = 0; i < 12; i++) {
entries.add(new BarEntry(i, (float) (Math.random() * 70) + 30));
}
BarDataSet d = new BarDataSet(entries, "New DataSet " + cnt);
d.setColors(ColorTemplate.VORDIPLOM_COLORS);
d.setBarShadowColor(Color.rgb(203, 203, 203));
ArrayList<IBarDataSet> sets = new ArrayList<IBarDataSet>();
sets.add(d);
BarData cd = new BarData(sets);
cd.setBarWidth(0.9f);
return cd;
}
use of com.github.mikephil.charting.interfaces.datasets.IBarDataSet in project MPAndroidChart by PhilJay.
the class RealmDatabaseActivityHorizontalBar method setData.
private void setData() {
RealmResults<RealmDemoData> result = mRealm.where(RealmDemoData.class).findAll();
//RealmBarDataSet<RealmDemoData> set = new RealmBarDataSet<RealmDemoData>(result, "stackValues", "xIndex"); // normal entries
// stacked entries
RealmBarDataSet<RealmDemoData> set = new RealmBarDataSet<RealmDemoData>(result, "xValue", "stackValues", "floatValue");
set.setColors(new int[] { ColorTemplate.rgb("#8BC34A"), ColorTemplate.rgb("#FFC107"), ColorTemplate.rgb("#9E9E9E") });
set.setLabel("Mobile OS distribution");
set.setStackLabels(new String[] { "iOS", "Android", "Other" });
ArrayList<IBarDataSet> dataSets = new ArrayList<IBarDataSet>();
// add the dataset
dataSets.add(set);
// create a data object with the dataset list
BarData data = new BarData(dataSets);
styleData(data);
data.setValueTextColor(Color.WHITE);
// set data
mChart.setData(data);
mChart.animateY(1400, Easing.EasingOption.EaseInOutQuart);
}
use of com.github.mikephil.charting.interfaces.datasets.IBarDataSet in project MPAndroidChart by PhilJay.
the class RealmWikiExample method setData.
private void setData() {
// LINE-CHART
final RealmResults<Score> results = mRealm.where(Score.class).findAll();
IAxisValueFormatter formatter = new IAxisValueFormatter() {
@Override
public String getFormattedValue(float value, AxisBase axis) {
return results.get((int) value).getPlayerName();
}
};
lineChart.getXAxis().setValueFormatter(formatter);
barChart.getXAxis().setValueFormatter(formatter);
RealmLineDataSet<Score> lineDataSet = new RealmLineDataSet<Score>(results, "scoreNr", "totalScore");
lineDataSet.setMode(LineDataSet.Mode.CUBIC_BEZIER);
lineDataSet.setLabel("Result Scores");
lineDataSet.setDrawCircleHole(false);
lineDataSet.setColor(ColorTemplate.rgb("#FF5722"));
lineDataSet.setCircleColor(ColorTemplate.rgb("#FF5722"));
lineDataSet.setLineWidth(1.8f);
lineDataSet.setCircleRadius(3.6f);
ArrayList<ILineDataSet> dataSets = new ArrayList<ILineDataSet>();
dataSets.add(lineDataSet);
LineData lineData = new LineData(dataSets);
styleData(lineData);
// set data
lineChart.setData(lineData);
lineChart.animateY(1400, Easing.EasingOption.EaseInOutQuart);
// BAR-CHART
RealmBarDataSet<Score> barDataSet = new RealmBarDataSet<Score>(results, "scoreNr", "totalScore");
barDataSet.setColors(new int[] { ColorTemplate.rgb("#FF5722"), ColorTemplate.rgb("#03A9F4") });
barDataSet.setLabel("Realm BarDataSet");
ArrayList<IBarDataSet> barDataSets = new ArrayList<IBarDataSet>();
barDataSets.add(barDataSet);
BarData barData = new BarData(barDataSets);
styleData(barData);
barChart.setData(barData);
barChart.setFitBars(true);
barChart.animateY(1400, Easing.EasingOption.EaseInOutQuart);
}
Aggregations