AndroidPlot: XYPlot 如何制作带圆角的条形图

AndroidPlot: XYPlot How to make Bars with rounded corners

大约一年以来,我一直在使用 AndroidPlot 在我的应用程序中显示不同的图表。 现在我正在使用 BarCharts,图表已经完成,但我怎样才能使角变圆?

我找到了一些线条的结果: How to make line with rounded (smooth) corners with AndroidPlot

我已经试过了:

BarFormatter formatter1,formatter2, formatter3;
formatter1.getBorderPaint().setStrokeJoin(Paint.Join.ROUND);
formatter1.getFillPaint().setStrokeJoin(Paint.Join.ROUND);

似乎没有任何影响。

然后我尝试了:

XYPlot plot; //Initialized with UI-Diagrammm above
...
plot.setBorderStyle(XYPlot.BorderStyle.ROUNDED,5f,5f);

有没有人遇到过这个问题并且得到了解决方法的答案。

感谢您的帮助,

弗兰齐

条形图由 Androidplot 的 BarRenderer class 呈现,它使用 Canvas.drawRect(...) 方法绘制单个条形图。为了获得圆边,它要么需要调用 Canvas.drawRoundRect 或者可能更好,使用 Path.lineTo(...)Path.arcTo(...) 方法将每个条形图绘制为路径,以便只有条形图的顶部圆形。不幸的是,此功能尚不存在,但如果需要,您可以打开功能请求。

或者您可以通过创建一个扩展 BarRenderer 并覆盖 drawBar(...) 的自定义渲染器来自己实现它。 Documentation available here