use of com.github.mikephil.charting.data.LineDataSet in project MPAndroidChart by PhilJay.
the class DrawChartActivity method initWithDummyData.
private void initWithDummyData() {
ArrayList<Entry> yVals = new ArrayList<Entry>();
// create a dataset and give it a type (0)
LineDataSet set1 = new LineDataSet(yVals, "DataSet");
set1.setLineWidth(3f);
set1.setCircleRadius(5f);
// create a data object with the datasets
LineData data = new LineData(set1);
mChart.setData(data);
}
use of com.github.mikephil.charting.data.LineDataSet in project MPAndroidChart by PhilJay.
the class DynamicalAddingActivity method addDataSet.
private void addDataSet() {
LineData data = mChart.getData();
if (data != null) {
int count = (data.getDataSetCount() + 1);
ArrayList<Entry> yVals = new ArrayList<Entry>();
for (int i = 0; i < data.getEntryCount(); i++) {
yVals.add(new Entry(i, (float) (Math.random() * 50f) + 50f * count));
}
LineDataSet set = new LineDataSet(yVals, "DataSet " + count);
set.setLineWidth(2.5f);
set.setCircleRadius(4.5f);
int color = mColors[count % mColors.length];
set.setColor(color);
set.setCircleColor(color);
set.setHighLightColor(color);
set.setValueTextSize(10f);
set.setValueTextColor(color);
data.addDataSet(set);
data.notifyDataChanged();
mChart.notifyDataSetChanged();
mChart.invalidate();
}
}
use of com.github.mikephil.charting.data.LineDataSet in project MPAndroidChart by PhilJay.
the class LineChartActivityColored method getData.
private LineData getData(int count, float range) {
ArrayList<Entry> yVals = new ArrayList<Entry>();
for (int i = 0; i < count; i++) {
float val = (float) (Math.random() * range) + 3;
yVals.add(new Entry(i, val));
}
// create a dataset and give it a type
LineDataSet set1 = new LineDataSet(yVals, "DataSet 1");
// set1.setFillAlpha(110);
// set1.setFillColor(Color.RED);
set1.setLineWidth(1.75f);
set1.setCircleRadius(5f);
set1.setCircleHoleRadius(2.5f);
set1.setColor(Color.WHITE);
set1.setCircleColor(Color.WHITE);
set1.setHighLightColor(Color.WHITE);
set1.setDrawValues(false);
// create a data object with the datasets
LineData data = new LineData(set1);
return data;
}
use of com.github.mikephil.charting.data.LineDataSet in project MPAndroidChart by PhilJay.
the class LineChartTime method setData.
private void setData(int count, float range) {
// now in hours
long now = TimeUnit.MILLISECONDS.toHours(System.currentTimeMillis());
ArrayList<Entry> values = new ArrayList<Entry>();
float from = now;
// count = hours
float to = now + count;
// increment by 1 hour
for (float x = from; x < to; x++) {
float y = getRandom(range, 50);
// add one entry per hour
values.add(new Entry(x, y));
}
// create a dataset and give it a type
LineDataSet set1 = new LineDataSet(values, "DataSet 1");
set1.setAxisDependency(AxisDependency.LEFT);
set1.setColor(ColorTemplate.getHoloBlue());
set1.setValueTextColor(ColorTemplate.getHoloBlue());
set1.setLineWidth(1.5f);
set1.setDrawCircles(false);
set1.setDrawValues(false);
set1.setFillAlpha(65);
set1.setFillColor(ColorTemplate.getHoloBlue());
set1.setHighLightColor(Color.rgb(244, 117, 117));
set1.setDrawCircleHole(false);
// create a data object with the datasets
LineData data = new LineData(set1);
data.setValueTextColor(Color.WHITE);
data.setValueTextSize(9f);
// set data
mChart.setData(data);
}
use of com.github.mikephil.charting.data.LineDataSet in project MPAndroidChart by PhilJay.
the class ListViewMultiChartActivity method generateDataLine.
/**
* generates a random ChartData object with just one DataSet
*
* @return
*/
private LineData generateDataLine(int cnt) {
ArrayList<Entry> e1 = new ArrayList<Entry>();
for (int i = 0; i < 12; i++) {
e1.add(new Entry(i, (int) (Math.random() * 65) + 40));
}
LineDataSet d1 = new LineDataSet(e1, "New DataSet " + cnt + ", (1)");
d1.setLineWidth(2.5f);
d1.setCircleRadius(4.5f);
d1.setHighLightColor(Color.rgb(244, 117, 117));
d1.setDrawValues(false);
ArrayList<Entry> e2 = new ArrayList<Entry>();
for (int i = 0; i < 12; i++) {
e2.add(new Entry(i, e1.get(i).getY() - 30));
}
LineDataSet d2 = new LineDataSet(e2, "New DataSet " + cnt + ", (2)");
d2.setLineWidth(2.5f);
d2.setCircleRadius(4.5f);
d2.setHighLightColor(Color.rgb(244, 117, 117));
d2.setColor(ColorTemplate.VORDIPLOM_COLORS[0]);
d2.setCircleColor(ColorTemplate.VORDIPLOM_COLORS[0]);
d2.setDrawValues(false);
ArrayList<ILineDataSet> sets = new ArrayList<ILineDataSet>();
sets.add(d1);
sets.add(d2);
LineData cd = new LineData(sets);
return cd;
}
Aggregations