Search in sources :

Example 1 with EntryXComparator

use of com.github.mikephil.charting.utils.EntryXComparator in project MPAndroidChart by PhilJay.

the class InvertedLineChartActivity method setData.

private void setData(int count, float range) {
    ArrayList<Entry> entries = new ArrayList<Entry>();
    for (int i = 0; i < count; i++) {
        float xVal = (float) (Math.random() * range);
        float yVal = (float) (Math.random() * range);
        entries.add(new Entry(xVal, yVal));
    }
    // sort by x-value
    Collections.sort(entries, new EntryXComparator());
    // create a dataset and give it a type
    LineDataSet set1 = new LineDataSet(entries, "DataSet 1");
    set1.setLineWidth(1.5f);
    set1.setCircleRadius(4f);
    // create a data object with the datasets
    LineData data = new LineData(set1);
    // set data
    mChart.setData(data);
}
Also used : Entry(com.github.mikephil.charting.data.Entry) EntryXComparator(com.github.mikephil.charting.utils.EntryXComparator) 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)

Aggregations

Entry (com.github.mikephil.charting.data.Entry)1 LineData (com.github.mikephil.charting.data.LineData)1 LineDataSet (com.github.mikephil.charting.data.LineDataSet)1 ILineDataSet (com.github.mikephil.charting.interfaces.datasets.ILineDataSet)1 EntryXComparator (com.github.mikephil.charting.utils.EntryXComparator)1 ArrayList (java.util.ArrayList)1