【问题标题】:Unable to hide y axis line in a stacked bar graph无法在堆积条形图中隐藏 y 轴线
【发布时间】:2020-11-02 03:19:54
【问题描述】:

我试图在 JFreeChart 的堆积条形图中隐藏 y 轴线,我已经尝试过以下方法:

Setoutlinepaint(null)
Setbackgroundpaint(color.white)
Setoutlinevisible(false)
Categoryaxis.setaxislinevisible(false)
Categoryaxis.setvisible(false)

非常感谢您的帮助。

【问题讨论】:

    标签: java hide jfreechart stacked-chart yaxis


    【解决方案1】:

    调用父方法setAxisLineVisible() 似乎会产生CategoryAxisValueAxis 的预期结果。从此example 开始,createChart() 中的以下更改会产生所示的结果。我更改了绘图方向以使域轴垂直,并且在两个轴上都调用了setAxisLineVisible(false)

    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setOrientation(PlotOrientation.HORIZONTAL);
    CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setAxisLineVisible(false);
    plot.setDomainAxis(domainAxis);
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setAxisLineVisible(false);
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    

    轴线不可见:

    轴线可见:

    请注意,两个条形图堆叠条形图的 factory methods 使用相同的轴。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-08-27
      相关资源
      最近更新 更多