Search in sources :

Example 31 with LineDataSet

use of com.github.mikephil.charting.data.LineDataSet in project Weather by Sparker0i.

the class GraphsFragment method loadPressureChart.

public void loadPressureChart() {
    pressureChart.setDrawGridBackground(false);
    pressureChart.setBackgroundColor(Color.BLACK);
    pressureChart.setTouchEnabled(true);
    pressureChart.setDragEnabled(true);
    pressureChart.setMaxHighlightDistance(300);
    pressureChart.setPinchZoom(true);
    pressureChart.setPadding(2, 2, 2, 2);
    pressureChart.getLegend().setEnabled(true);
    pressureChart.getLegend().setTextColor(Color.WHITE);
    YAxis yAxisRight = pressureChart.getAxisRight();
    yAxisRight.setDrawGridLines(false);
    yAxisRight.setDrawAxisLine(false);
    yAxisRight.setDrawLabels(false);
    yAxisRight.setTextColor(Color.WHITE);
    yAxisRight.enableAxisLineDashedLine(2f, 4f, 2f);
    YAxis yAxisLeft = pressureChart.getAxisLeft();
    yAxisLeft.setTextColor(Color.WHITE);
    XAxis x = pressureChart.getXAxis();
    x.setEnabled(true);
    x.setPosition(XAxis.XAxisPosition.BOTTOM);
    x.setDrawGridLines(false);
    x.setTextColor(Color.parseColor("#FFFFFF"));
    x.setValueFormatter(new XFormatter(dates));
    LineDataSet set;
    if (pressureChart.getData() != null) {
        pressureChart.getData().removeDataSet(pressureChart.getData().getDataSetByIndex(pressureChart.getData().getDataSetCount() - 1));
        pressureChart.getLegend().setTextColor(Color.parseColor("#FFFFFF"));
    }
    set = new LineDataSet(pressureEntries, getString(R.string.g_pressure));
    set.setMode(LineDataSet.Mode.HORIZONTAL_BEZIER);
    set.setCubicIntensity(0.2f);
    set.setDrawCircles(false);
    set.setLineWidth(2f);
    set.setDrawValues(false);
    set.setValueTextSize(10f);
    set.setColor(Color.CYAN);
    set.setHighlightEnabled(false);
    set.setValueFormatter(mValueFormatter);
    LineData data = new LineData(set);
    pressureChart.setData(data);
    pressureChart.invalidate();
}
Also used : LineData(com.github.mikephil.charting.data.LineData) LineDataSet(com.github.mikephil.charting.data.LineDataSet) XFormatter(com.a5corp.weather.utils.XFormatter) XAxis(com.github.mikephil.charting.components.XAxis) YAxis(com.github.mikephil.charting.components.YAxis)

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