Search in sources :

Example 6 with YAxis

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

the class LiveActivityFragment method addEntries.

private void addEntries(int timestamp) {
    mTotalStepsChart.setSingleEntryYValue(mSteps.getTotalSteps());
    YAxis stepsPerMinuteCurrentYAxis = mStepsPerMinuteCurrentChart.getAxisLeft();
    int maxStepsPerMinute = mSteps.getMaxStepsPerMinute();
    //        int extraRoom = maxStepsPerMinute/5;
    //        buggy in MPAndroidChart? Disable.
    //        stepsPerMinuteCurrentYAxis.setAxisMaxValue(Math.max(MIN_STEPS_PER_MINUTE, maxStepsPerMinute + extraRoom));
    LimitLine target = new LimitLine(maxStepsPerMinute);
    stepsPerMinuteCurrentYAxis.removeAllLimitLines();
    stepsPerMinuteCurrentYAxis.addLimitLine(target);
    int stepsPerMinute = mSteps.getStepsPerMinute(true);
    mStepsPerMinuteCurrentChart.setSingleEntryYValue(stepsPerMinute);
    if (!addHistoryDataSet(false)) {
        return;
    }
    ChartData data = mStepsPerMinuteHistoryChart.getData();
    if (stepsPerMinute < 0) {
        stepsPerMinute = 0;
    }
    mHistorySet.addEntry(new Entry(timestamp, stepsPerMinute));
    int hr = getCurrentHeartRate();
    if (hr < 0) {
        hr = 0;
    }
    mHeartRateSet.addEntry(new Entry(timestamp, hr));
}
Also used : Entry(com.github.mikephil.charting.data.Entry) BarEntry(com.github.mikephil.charting.data.BarEntry) ChartData(com.github.mikephil.charting.data.ChartData) LimitLine(com.github.mikephil.charting.components.LimitLine) Paint(android.graphics.Paint) YAxis(com.github.mikephil.charting.components.YAxis)

Example 7 with YAxis

use of com.github.mikephil.charting.components.YAxis 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 8 with YAxis

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

Example 9 with YAxis

use of com.github.mikephil.charting.components.YAxis in project AmazeFileManager by TeamAmaze.

the class ProcessViewerFragment method chartInit.

/**
 * Initialize chart for the first time
 * @param totalBytes maximum value for x-axis
 */
private void chartInit(long totalBytes) {
    mLineChart.setBackgroundColor(accentColor);
    mLineChart.getLegend().setEnabled(false);
    // no description text
    mLineChart.getDescription().setEnabled(false);
    XAxis xAxis = mLineChart.getXAxis();
    YAxis yAxisLeft = mLineChart.getAxisLeft();
    mLineChart.getAxisRight().setEnabled(false);
    yAxisLeft.setTextColor(Color.WHITE);
    yAxisLeft.setAxisLineColor(Color.TRANSPARENT);
    yAxisLeft.setTypeface(Typeface.DEFAULT_BOLD);
    yAxisLeft.setGridColor(Utils.getColor(getContext(), R.color.white_translucent));
    xAxis.setAxisMaximum(FileUtils.readableFileSizeFloat(totalBytes));
    xAxis.setAxisMinimum(0.0f);
    xAxis.setAxisLineColor(Color.TRANSPARENT);
    xAxis.setGridColor(Color.TRANSPARENT);
    xAxis.setTextColor(Color.WHITE);
    xAxis.setTypeface(Typeface.DEFAULT_BOLD);
    mLineChart.setData(mLineData);
    mLineChart.invalidate();
}
Also used : XAxis(com.github.mikephil.charting.components.XAxis) YAxis(com.github.mikephil.charting.components.YAxis)

Example 10 with YAxis

use of com.github.mikephil.charting.components.YAxis in project android-client by GenesisVision.

the class ProfitChartView method initView.

private void initView() {
    inflate(getContext(), R.layout.view_profit_chart, this);
    ButterKnife.bind(this);
    chart.getDescription().setEnabled(false);
    chart.setDrawGridBackground(false);
    chart.setDragEnabled(false);
    chart.setTouchEnabled(false);
    chart.getXAxis().setEnabled(false);
    chart.getLegend().setEnabled(false);
    chart.getAxisLeft().setEnabled(true);
    chart.getAxisRight().setEnabled(false);
    chart.setDrawBorders(false);
    chart.setAutoScaleMinMaxEnabled(true);
    chart.setNoDataText(getContext().getResources().getString(R.string.not_enough_data));
    chart.setNoDataTextColor(ContextCompat.getColor(getContext(), R.color.colorPrimaryDark));
    YAxis yAxis = chart.getAxisLeft();
    yAxis.setDrawLabels(false);
    yAxis.setDrawAxisLine(false);
    yAxis.setDrawGridLines(false);
    LimitLine ll = new LimitLine(0f, "");
    ll.setLineColor(ContextCompat.getColor(getContext(), R.color.grey400));
    ll.setLineWidth(1f);
    int lineLength = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 2, getContext().getResources().getDisplayMetrics());
    int spaceLength = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 7, getContext().getResources().getDisplayMetrics());
    ll.enableDashedLine(lineLength, spaceLength, 0);
    yAxis.setDrawLimitLinesBehindData(true);
    yAxis.addLimitLine(ll);
    chart.setHardwareAccelerationEnabled(false);
}
Also used : LimitLine(com.github.mikephil.charting.components.LimitLine) YAxis(com.github.mikephil.charting.components.YAxis)

Aggregations

YAxis (com.github.mikephil.charting.components.YAxis)51 XAxis (com.github.mikephil.charting.components.XAxis)45 Legend (com.github.mikephil.charting.components.Legend)22 IAxisValueFormatter (com.github.mikephil.charting.formatter.IAxisValueFormatter)11 AxisBase (com.github.mikephil.charting.components.AxisBase)10 LineData (com.github.mikephil.charting.data.LineData)8 LineDataSet (com.github.mikephil.charting.data.LineDataSet)7 XFormatter (com.a5corp.weather.utils.XFormatter)5 Entry (com.github.mikephil.charting.data.Entry)5 MyMarkerView (com.xxmassdeveloper.mpchartexample.custom.MyMarkerView)5 ArrayList (java.util.ArrayList)5 Typeface (android.graphics.Typeface)4 View (android.view.View)4 OsmandSettings (net.osmand.plus.OsmandSettings)4 SuppressLint (android.annotation.SuppressLint)3 Paint (android.graphics.Paint)3 SpannableString (android.text.SpannableString)3 LimitLine (com.github.mikephil.charting.components.LimitLine)3 MarkerView (com.github.mikephil.charting.components.MarkerView)2 YAxisRenderer (com.github.mikephil.charting.renderer.YAxisRenderer)2