Search in sources :

Example 36 with LineData

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

the class GraphsFragment method loadWindChart.

public void loadWindChart() {
    windChart.setDrawGridBackground(false);
    windChart.setBackgroundColor(Color.BLACK);
    windChart.setTouchEnabled(true);
    windChart.setDragEnabled(true);
    windChart.setMaxHighlightDistance(300);
    windChart.setPinchZoom(true);
    windChart.setPadding(2, 2, 2, 2);
    windChart.getLegend().setEnabled(true);
    windChart.getLegend().setTextColor(Color.WHITE);
    YAxis yAxisRight = windChart.getAxisRight();
    yAxisRight.setDrawGridLines(false);
    yAxisRight.setDrawAxisLine(false);
    yAxisRight.setDrawLabels(false);
    yAxisRight.setTextColor(Color.WHITE);
    yAxisRight.enableAxisLineDashedLine(2f, 4f, 2f);
    YAxis yAxisLeft = windChart.getAxisLeft();
    yAxisLeft.setTextColor(Color.WHITE);
    XAxis x = windChart.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 (windChart.getData() != null) {
        windChart.getData().removeDataSet(windChart.getData().getDataSetByIndex(windChart.getData().getDataSetCount() - 1));
        windChart.getLegend().setTextColor(Color.parseColor("#FFFFFF"));
    }
    String wind = String.format(Locale.ENGLISH, getString(R.string.g_wind), pf.getUnits().equals("metric") ? getString(R.string.mps) : getString(R.string.mph));
    set = new LineDataSet(windEntries, wind);
    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.RED);
    set.setHighlightEnabled(false);
    set.setValueFormatter(mValueFormatter);
    LineData data = new LineData(set);
    windChart.setData(data);
    windChart.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)

Example 37 with LineData

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

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