Stacked Area Chart, fixed y axis label width

白昼怎懂夜的黑 提交于 2019-12-10 17:17:00

问题


I am creating a JFreeChart stacked area chart.

I want my y axis label's width to be fixed, and I don't want to shift the chart as the width increases. See the image explaining the problem.

I am facing similar problem as posted on the JFreeChart forum. As per the forum it is fixed, but it is not yet released. Does any body knows its fix. We can't wait for next release, does any body knows a hack which we can apply?

Hoping for some solution.


回答1:


A possible solution is to override the findMaximumTickLabelWidth() for rangeaxis of the chart. The maximum width can be hardcoded to a specific value or can be taken as max value of maximum width and calculated maximum width.




回答2:


As an alternative, consider a CombinedDomainCategoryPlot, illustrated here. A CombinedDomainXYPlot is shown here.




回答3:


There is another method to get the plots aligned. You can reserve some space on the left, right top or bottom of your plot to display the Range axes.

      AxisSpace space = new AxisSpace();
      space.setRight(50); //reserved space on the left side of the plot
      space.setLeft(50);
      plot.setFixedRangeAxisSpace(space);
      plot2.setFixedRangeAxisSpace(space);

I know, this is not the best solution for multiple plots. But you can solve the problem in a quick way.



来源:https://stackoverflow.com/questions/13156012/stacked-area-chart-fixed-y-axis-label-width

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