Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you change the inner circle color of a LineGraph in MPAndroidChart?

I am using MPAndroidChart to make charts in Android app.

I need to make circle blue with just white border of that circle, like this on the image below.

enter image description here

This is my code:

        LineDataSet set1 = new LineDataSet(yVals,"DataSet");
        set1.setFillAlpha(65);
        set1.setFillColor(Color.RED);
        set1.setColor(Color.WHITE);
        set1.setCircleColor(Color.BLUE);
        set1.setLineWidth(2f);
        set1.setCircleSize(5f);
        set1.setDrawValues(false);

And this is the result:

enter image description here

like image 443
Zookey Avatar asked May 21 '15 08:05

Zookey


2 Answers

From the image above, it looks like you need to use setCircleColorHole(int color).

According to the docs:

Sets the color of the inner circle of the line-circles

So this may be what you are after:

 LineDataSet set1 = new LineDataSet(yVals,"DataSet");
        set1.setFillAlpha(65);
        set1.setFillColor(Color.RED);
        set1.setColor(Color.WHITE);
        set1.setCircleColor(Color.WHITE);
        set1.setCircleColorHole(Color.BLUE)
        set1.setLineWidth(2f);
        set1.setCircleSize(5f);
        set1.setDrawValues(false);

I haven't used this library but you may also need to add setDrawCircleHole(true) should that not work on its own.

like image 103
Ed George Avatar answered Sep 20 '22 08:09

Ed George


If this is done within a fragment

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
       trendsDataSet.setCircleColor(getActivity().getColor(R.color.colorAccent));
       trendsDataSet.setCircleHoleColor(getActivity().getColor(R.color.colorAccent));
          }
like image 30
Shravya Manety Avatar answered Sep 19 '22 08:09

Shravya Manety