Search code examples
androidpie-chart

How to add max/min values to a PieChart


I`m making a step counter and I would like to show the steps result alongside the goal. I used hellocharts-android by " lecho " from Github. Everything went smoothly but I would like to add a max and a min value for the chart.

How can this be done?

Activity.Xml:

    <lecho.lib.hellocharts.view.PieChartView
        android:id="@+id/barchart"
        android:layout_width="277dp"
        android:layout_height="250dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="20dp"
        android:layout_marginEnd="8dp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/t2" />

activity.java

  pieData.add(new SliceValue(15, getRandomColor()).setLabel(String.valueOf(counter)));
        PieChartData pieChartData = new PieChartData(pieData);
        pieChartData.setHasLabels(true);
        pieChartData.setHasCenterCircle(true).setCenterText1("Total Steps").setCenterText1FontSize(15).setCenterText1Color(Color.parseColor("#0097A7"));
        pieChartView.setPieChartData(pieChartData);

I want to have the piechart out of 1000 for example. Now it is percentage.


Solution

  • Just for the future reference, I have used DecoView "you can find it on GitHub".

            final SeriesItem seriesItem1 = new SeriesItem.Builder(Color.parseColor("#00b0ff"))
                .setRange(0, "Maximum Value", 0)
                .build();