Search in sources :

Example 1 with LineData

use of com.github.mikephil.charting.data.LineData 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 LineData

use of com.github.mikephil.charting.data.LineData 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 LineData

use of com.github.mikephil.charting.data.LineData in project MPAndroidChart by PhilJay.

the class DynamicalAddingActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.activity_linechart_noseekbar);
    mChart = (LineChart) findViewById(R.id.chart1);
    mChart.setOnChartValueSelectedListener(this);
    mChart.setDrawGridBackground(false);
    mChart.getDescription().setEnabled(false);
    // add an empty data object
    mChart.setData(new LineData());
    //        mChart.getXAxis().setDrawLabels(false);
    //        mChart.getXAxis().setDrawGridLines(false);
    mChart.invalidate();
}
Also used : LineData(com.github.mikephil.charting.data.LineData)

Example 4 with LineData

use of com.github.mikephil.charting.data.LineData in project MPAndroidChart by PhilJay.

the class LineChartActivityColored method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.activity_colored_lines);
    mCharts[0] = (LineChart) findViewById(R.id.chart1);
    mCharts[1] = (LineChart) findViewById(R.id.chart2);
    mCharts[2] = (LineChart) findViewById(R.id.chart3);
    mCharts[3] = (LineChart) findViewById(R.id.chart4);
    mTf = Typeface.createFromAsset(getAssets(), "OpenSans-Bold.ttf");
    for (int i = 0; i < mCharts.length; i++) {
        LineData data = getData(36, 100);
        data.setValueTypeface(mTf);
        // add some transparency to the color with "& 0x90FFFFFF"
        setupChart(mCharts[i], data, mColors[i % mColors.length]);
    }
}
Also used : LineData(com.github.mikephil.charting.data.LineData)

Example 5 with LineData

use of com.github.mikephil.charting.data.LineData 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)

Aggregations

LineData (com.github.mikephil.charting.data.LineData)37 LineDataSet (com.github.mikephil.charting.data.LineDataSet)22 Entry (com.github.mikephil.charting.data.Entry)19 ILineDataSet (com.github.mikephil.charting.interfaces.datasets.ILineDataSet)19 ArrayList (java.util.ArrayList)19 XAxis (com.github.mikephil.charting.components.XAxis)6 YAxis (com.github.mikephil.charting.components.YAxis)6 XFormatter (com.a5corp.weather.utils.XFormatter)5 BarEntry (com.github.mikephil.charting.data.BarEntry)3 Legend (com.github.mikephil.charting.components.Legend)2 BarData (com.github.mikephil.charting.data.BarData)2 RealmLineDataSet (com.github.mikephil.charting.data.realm.implementation.RealmLineDataSet)2 IAxisValueFormatter (com.github.mikephil.charting.formatter.IAxisValueFormatter)2 IFillFormatter (com.github.mikephil.charting.formatter.IFillFormatter)2 LineDataProvider (com.github.mikephil.charting.interfaces.dataprovider.LineDataProvider)2 IBarDataSet (com.github.mikephil.charting.interfaces.datasets.IBarDataSet)2 Bitmap (android.graphics.Bitmap)1 Canvas (android.graphics.Canvas)1 DashPathEffect (android.graphics.DashPathEffect)1 Paint (android.graphics.Paint)1