How to make MPAndroidChart RadarChart round

爱⌒轻易说出口 提交于 2021-02-11 16:38:05

问题


I would like to present some Values inside a Radar Chart. Long-time I was working with AndroidPlot which works great but it doesn't support Radar charts. So I swapped to MPAndroidCharts. But MPCharts only supports angular RadarCharts by default.

I found the following Link in the Issues, but there is no Code given https://github.com/PhilJay/MPAndroidChart/issues/1446

Another Stack Overflow Entry I found is this, but I can't combine it with MPAndroid Charts Radar Chart for Android

At the Android Charts Library: https://github.com/limccn/Android-Charts rounded Charts are mentioned, but I can't find the according Class in Code

Is there already a solution to make MPAndroidCharts RadarCharts round, or any other Library that supports rounded RadarCharts. Thanks for Help


回答1:


As mention in the issue link, you can implement it by yourself, just see https://github.com/PhilJay/MPAndroidChart/blob/c1f6fcebf0c3516e067b34312b283189f909bde5/MPChartLib/src/main/java/com/github/mikephil/charting/charts/RadarChart.java as a reference,

  1. write your RoundRadarChart class to extend the RadarChart
  2. write your RoundRadarChartRenderer, YAxisRendererRoundRadarChart and XAxisRendererRoundRadarChart to extend the RadarChart ones, mainly you should to override the drawXXX functions
  3. use your new renderer classes in your chart class to replace the RadarChart renderers

You need to re-caculate the factory of drawing lines, points and labels

And about the Android-Charts project, you may have a look at https://github.com/limccn/Android-Charts/tree/master/src/src/cn/limc/androidcharts/view. Not sure if the RoundChart is what you want.




回答2:


go to RadarChartRenderer class. and edit the method inside class like below:

protected void drawDataSet(Canvas c, IRadarDataSet dataSet, int mostEntries) {

  ..........................
  ..........................

        mRenderPaint.setStrokeWidth(dataSet.getLineWidth());
        mRenderPaint.setStyle(Paint.Style.STROKE);
        mRenderPaint.setDither(true);                   
        mRenderPaint.setStrokeJoin(Paint.Join.ROUND);  
        mRenderPaint.setStrokeCap(Paint.Cap.ROUND); 
        mRenderPaint.setPathEffect(new CornerPathEffect(30) );  
        mRenderPaint.setAntiAlias(true); 

  ............................
  ............................
}

my results like:



来源:https://stackoverflow.com/questions/57698749/how-to-make-mpandroidchart-radarchart-round

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!