Search in sources :

Example 16 with XAxis

use of com.github.mikephil.charting.components.XAxis in project Weather by Sparker0i.

the class GraphsFragment method loadRainChart.

public void loadRainChart() {
    rainChart.setDrawGridBackground(false);
    rainChart.setBackgroundColor(Color.BLACK);
    rainChart.setTouchEnabled(true);
    rainChart.setDragEnabled(true);
    rainChart.setMaxHighlightDistance(300);
    rainChart.setPinchZoom(true);
    rainChart.setPadding(2, 2, 2, 2);
    rainChart.getLegend().setEnabled(true);
    rainChart.getLegend().setTextColor(Color.WHITE);
    YAxis yAxisRight = rainChart.getAxisRight();
    yAxisRight.setDrawGridLines(false);
    yAxisRight.setDrawAxisLine(false);
    yAxisRight.setDrawLabels(false);
    yAxisRight.setTextColor(Color.WHITE);
    yAxisRight.enableAxisLineDashedLine(2f, 4f, 2f);
    YAxis yAxisLeft = rainChart.getAxisLeft();
    yAxisLeft.setTextColor(Color.WHITE);
    XAxis x = rainChart.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 (rainChart.getData() != null) {
        rainChart.getData().removeDataSet(rainChart.getData().getDataSetByIndex(rainChart.getData().getDataSetCount() - 1));
        rainChart.getLegend().setTextColor(Color.parseColor("#FFFFFF"));
    }
    set = new LineDataSet(rainEntries, getString(R.string.g_rain));
    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.GREEN);
    set.setHighlightEnabled(false);
    set.setValueFormatter(mValueFormatter);
    LineData data = new LineData(set);
    rainChart.setData(data);
    rainChart.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 17 with XAxis

use of com.github.mikephil.charting.components.XAxis in project Weather by Sparker0i.

the class GraphsFragment method loadTemperatureChart.

public void loadTemperatureChart() {
    temperatureChart.setDrawGridBackground(false);
    temperatureChart.setBackgroundColor(Color.BLACK);
    temperatureChart.setTouchEnabled(true);
    temperatureChart.setDragEnabled(true);
    temperatureChart.setMaxHighlightDistance(300);
    temperatureChart.setPinchZoom(true);
    temperatureChart.setPadding(2, 2, 2, 2);
    temperatureChart.getLegend().setEnabled(true);
    temperatureChart.getLegend().setTextColor(Color.WHITE);
    YAxis yAxisRight = temperatureChart.getAxisRight();
    yAxisRight.setDrawGridLines(false);
    yAxisRight.setDrawAxisLine(false);
    yAxisRight.setDrawLabels(false);
    yAxisRight.setTextColor(Color.WHITE);
    yAxisRight.enableAxisLineDashedLine(2f, 4f, 2f);
    YAxis yAxisLeft = temperatureChart.getAxisLeft();
    yAxisLeft.setTextColor(Color.WHITE);
    XAxis x = temperatureChart.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 (temperatureChart.getData() != null) {
        temperatureChart.getData().removeDataSet(temperatureChart.getData().getDataSetByIndex(temperatureChart.getData().getDataSetCount() - 1));
        temperatureChart.getLegend().setTextColor(Color.parseColor("#FFFFFF"));
    }
    String temp = String.format(Locale.ENGLISH, getString(R.string.g_temp), pf.getUnits().equals("metric") ? getString(R.string.c) : getString(R.string.f));
    set = new LineDataSet(tempEntries, temp);
    set.setMode(LineDataSet.Mode.CUBIC_BEZIER);
    set.setCubicIntensity(0.2f);
    set.setDrawCircles(false);
    set.setLineWidth(2f);
    set.setDrawValues(false);
    set.setValueTextSize(10f);
    set.setColor(Color.MAGENTA);
    set.setHighlightEnabled(false);
    set.setValueFormatter(mValueFormatter);
    LineData data = new LineData(set);
    temperatureChart.setData(data);
    temperatureChart.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 18 with XAxis

use of com.github.mikephil.charting.components.XAxis in project Gadgetbridge by Freeyourgadget.

the class LiveActivityFragment method setupHistoryChart.

private void setupHistoryChart(BarLineChartBase chart) {
    configureBarLineChartDefaults(chart);
    // no zooming or anything, because it's updated all the time
    chart.setTouchEnabled(false);
    chart.setBackgroundColor(BACKGROUND_COLOR);
    chart.getDescription().setTextColor(DESCRIPTION_COLOR);
    chart.getDescription().setText(getString(R.string.live_activity_steps_per_minute_history));
    chart.setNoDataText(getString(R.string.live_activity_start_your_activity));
    chart.getLegend().setEnabled(false);
    Paint infoPaint = chart.getPaint(Chart.PAINT_INFO);
    infoPaint.setTextSize(Utils.convertDpToPixel(20f));
    infoPaint.setFakeBoldText(true);
    chart.setPaint(infoPaint, Chart.PAINT_INFO);
    XAxis x = chart.getXAxis();
    x.setDrawLabels(true);
    x.setDrawGridLines(false);
    x.setEnabled(true);
    x.setTextColor(CHART_TEXT_COLOR);
    x.setDrawLimitLinesBehindData(true);
    YAxis y = chart.getAxisLeft();
    y.setDrawGridLines(false);
    y.setDrawTopYLabelEntry(false);
    y.setTextColor(CHART_TEXT_COLOR);
    y.setEnabled(true);
    y.setAxisMinimum(0);
    YAxis yAxisRight = chart.getAxisRight();
    yAxisRight.setDrawGridLines(false);
    yAxisRight.setEnabled(true);
    yAxisRight.setDrawLabels(true);
    yAxisRight.setDrawTopYLabelEntry(false);
    yAxisRight.setTextColor(CHART_TEXT_COLOR);
    yAxisRight.setAxisMaximum(HeartRateUtils.MAX_HEART_RATE_VALUE);
    yAxisRight.setAxisMinimum(HeartRateUtils.MIN_HEART_RATE_VALUE);
    mHistorySet = new LineDataSet(new ArrayList<Entry>(), getString(R.string.live_activity_steps_history));
    mHistorySet.setAxisDependency(YAxis.AxisDependency.LEFT);
    mHistorySet.setColor(akActivity.color);
    mHistorySet.setDrawCircles(false);
    mHistorySet.setMode(LineDataSet.Mode.CUBIC_BEZIER);
    mHistorySet.setDrawFilled(true);
    mHistorySet.setDrawValues(false);
    mHeartRateSet = createHeartrateSet(new ArrayList<Entry>(), getString(R.string.live_activity_heart_rate));
    mHeartRateSet.setDrawValues(false);
}
Also used : LineDataSet(com.github.mikephil.charting.data.LineDataSet) ArrayList(java.util.ArrayList) Paint(android.graphics.Paint) XAxis(com.github.mikephil.charting.components.XAxis) YAxis(com.github.mikephil.charting.components.YAxis)

Example 19 with XAxis

use of com.github.mikephil.charting.components.XAxis in project Gadgetbridge by Freeyourgadget.

the class ActivitySleepChartFragment method setupChart.

private void setupChart() {
    mChart.setBackgroundColor(BACKGROUND_COLOR);
    mChart.getDescription().setTextColor(DESCRIPTION_COLOR);
    configureBarLineChartDefaults(mChart);
    XAxis x = mChart.getXAxis();
    x.setDrawLabels(true);
    x.setDrawGridLines(false);
    x.setEnabled(true);
    x.setTextColor(CHART_TEXT_COLOR);
    x.setDrawLimitLinesBehindData(true);
    YAxis y = mChart.getAxisLeft();
    y.setDrawGridLines(false);
    //        y.setDrawLabels(false);
    // TODO: make fixed max value optional
    y.setAxisMaximum(1f);
    y.setAxisMinimum(0);
    y.setDrawTopYLabelEntry(false);
    y.setTextColor(CHART_TEXT_COLOR);
    //        y.setLabelCount(5);
    y.setEnabled(true);
    YAxis yAxisRight = mChart.getAxisRight();
    yAxisRight.setDrawGridLines(false);
    yAxisRight.setEnabled(supportsHeartrate(getChartsHost().getDevice()));
    yAxisRight.setDrawLabels(true);
    yAxisRight.setDrawTopYLabelEntry(true);
    yAxisRight.setTextColor(CHART_TEXT_COLOR);
    yAxisRight.setAxisMaximum(HeartRateUtils.MAX_HEART_RATE_VALUE);
    yAxisRight.setAxisMinimum(HeartRateUtils.MIN_HEART_RATE_VALUE);
    // refresh immediately instead of use refreshIfVisible(), for perceived performance
    refresh();
}
Also used : XAxis(com.github.mikephil.charting.components.XAxis) YAxis(com.github.mikephil.charting.components.YAxis)

Example 20 with XAxis

use of com.github.mikephil.charting.components.XAxis in project Gadgetbridge by Freeyourgadget.

the class SleepChartFragment method setupActivityChart.

private void setupActivityChart() {
    mActivityChart.setBackgroundColor(BACKGROUND_COLOR);
    mActivityChart.getDescription().setTextColor(DESCRIPTION_COLOR);
    configureBarLineChartDefaults(mActivityChart);
    XAxis x = mActivityChart.getXAxis();
    x.setDrawLabels(true);
    x.setDrawGridLines(false);
    x.setEnabled(true);
    x.setTextColor(CHART_TEXT_COLOR);
    x.setDrawLimitLinesBehindData(true);
    YAxis y = mActivityChart.getAxisLeft();
    y.setDrawGridLines(false);
    //        y.setDrawLabels(false);
    // TODO: make fixed max value optional
    y.setAxisMaximum(1f);
    y.setAxisMinimum(0);
    y.setDrawTopYLabelEntry(false);
    y.setTextColor(CHART_TEXT_COLOR);
    //        y.setLabelCount(5);
    y.setEnabled(true);
    YAxis yAxisRight = mActivityChart.getAxisRight();
    yAxisRight.setDrawGridLines(false);
    yAxisRight.setEnabled(supportsHeartrate(getChartsHost().getDevice()));
    yAxisRight.setDrawLabels(true);
    yAxisRight.setDrawTopYLabelEntry(true);
    yAxisRight.setTextColor(CHART_TEXT_COLOR);
    yAxisRight.setAxisMaxValue(HeartRateUtils.MAX_HEART_RATE_VALUE);
    yAxisRight.setAxisMinValue(HeartRateUtils.MIN_HEART_RATE_VALUE);
}
Also used : XAxis(com.github.mikephil.charting.components.XAxis) YAxis(com.github.mikephil.charting.components.YAxis)

Aggregations

XAxis (com.github.mikephil.charting.components.XAxis)40 YAxis (com.github.mikephil.charting.components.YAxis)35 Legend (com.github.mikephil.charting.components.Legend)21 IAxisValueFormatter (com.github.mikephil.charting.formatter.IAxisValueFormatter)7 Typeface (android.graphics.Typeface)6 AxisBase (com.github.mikephil.charting.components.AxisBase)6 LineData (com.github.mikephil.charting.data.LineData)6 LineDataSet (com.github.mikephil.charting.data.LineDataSet)6 XFormatter (com.a5corp.weather.utils.XFormatter)5 MyMarkerView (com.xxmassdeveloper.mpchartexample.custom.MyMarkerView)5 View (android.view.View)4 ArrayList (java.util.ArrayList)3 Paint (android.graphics.Paint)2 BarData (com.github.mikephil.charting.data.BarData)2 MyAxisValueFormatter (com.xxmassdeveloper.mpchartexample.custom.MyAxisValueFormatter)2 ValueAnimator (android.animation.ValueAnimator)1 AnimatorUpdateListener (android.animation.ValueAnimator.AnimatorUpdateListener)1 FrameLayout (android.widget.FrameLayout)1 TextView (android.widget.TextView)1 ChartAnimator (com.github.mikephil.charting.animation.ChartAnimator)1