JFreeChart: overlapping bars in XY chart that have the same value

人盡茶涼 提交于 2019-12-01 09:45:28

问题


I have this problem where 2 bars from a different series overlap each other when they have the same value. And I would like 1 of both on top of the other. Unfortunately, I want the one that is now in the back, up front :

I already tried changing the order of the category expression, but to no avail. Anyone can tell me how I can get the orange bar on top of the blue one please ?


回答1:


You may try DatasetRenderingOrder:

XYPlot plot = jFreeChart.getXYPlot();
plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); // or reverse

or

plot.setSeriesRenderingOrder(DatasetRenderingOrder.FORWARD);

If neither works, it isn't a bad idea to use stacked bar.




回答2:


Instead of the factory default, use ClusteredXYBarRenderer, which "displays bars for different series values at the same x next to each other."



来源:https://stackoverflow.com/questions/9162450/jfreechart-overlapping-bars-in-xy-chart-that-have-the-same-value

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