Search in sources :

Example 1 with LineDataSet

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);
}
Also used : Entry(com.github.mikephil.charting.data.Entry) LineData(com.github.mikephil.charting.data.LineData) ILineDataSet(com.github.mikephil.charting.interfaces.datasets.ILineDataSet) LineDataSet(com.github.mikephil.charting.data.LineDataSet) ArrayList(java.util.ArrayList)

Example 2 with LineDataSet

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();
    }
}
Also used : LineData(com.github.mikephil.charting.data.LineData) Entry(com.github.mikephil.charting.data.Entry) ILineDataSet(com.github.mikephil.charting.interfaces.datasets.ILineDataSet) LineDataSet(com.github.mikephil.charting.data.LineDataSet) ArrayList(java.util.ArrayList)

Example 3 with LineDataSet

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;
}
Also used : Entry(com.github.mikephil.charting.data.Entry) LineData(com.github.mikephil.charting.data.LineData) LineDataSet(com.github.mikephil.charting.data.LineDataSet) ArrayList(java.util.ArrayList)

Example 4 with LineDataSet

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);
}
Also used : Entry(com.github.mikephil.charting.data.Entry) LineData(com.github.mikephil.charting.data.LineData) ILineDataSet(com.github.mikephil.charting.interfaces.datasets.ILineDataSet) LineDataSet(com.github.mikephil.charting.data.LineDataSet) ArrayList(java.util.ArrayList)

Example 5 with LineDataSet

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;
}
Also used : Entry(com.github.mikephil.charting.data.Entry) BarEntry(com.github.mikephil.charting.data.BarEntry) PieEntry(com.github.mikephil.charting.data.PieEntry) LineData(com.github.mikephil.charting.data.LineData) ILineDataSet(com.github.mikephil.charting.interfaces.datasets.ILineDataSet) ILineDataSet(com.github.mikephil.charting.interfaces.datasets.ILineDataSet) LineDataSet(com.github.mikephil.charting.data.LineDataSet) ArrayList(java.util.ArrayList)

Aggregations

LineDataSet (com.github.mikephil.charting.data.LineDataSet)31 LineData (com.github.mikephil.charting.data.LineData)22 Entry (com.github.mikephil.charting.data.Entry)18 ArrayList (java.util.ArrayList)18 ILineDataSet (com.github.mikephil.charting.interfaces.datasets.ILineDataSet)14 XAxis (com.github.mikephil.charting.components.XAxis)6 YAxis (com.github.mikephil.charting.components.YAxis)6 Paint (android.graphics.Paint)5 XFormatter (com.a5corp.weather.utils.XFormatter)5 BarEntry (com.github.mikephil.charting.data.BarEntry)3 Legend (com.github.mikephil.charting.components.Legend)2 IFillFormatter (com.github.mikephil.charting.formatter.IFillFormatter)2 LineDataProvider (com.github.mikephil.charting.interfaces.dataprovider.LineDataProvider)2 DashPathEffect (android.graphics.DashPathEffect)1 Drawable (android.graphics.drawable.Drawable)1 BarData (com.github.mikephil.charting.data.BarData)1 BarDataSet (com.github.mikephil.charting.data.BarDataSet)1 BubbleEntry (com.github.mikephil.charting.data.BubbleEntry)1 CandleEntry (com.github.mikephil.charting.data.CandleEntry)1 CombinedData (com.github.mikephil.charting.data.CombinedData)1