【问题标题】:Removing grid lines from stacked bar chart using JFreeChart使用 JFreeChart 从堆积条形图中删除网格线
【发布时间】:2020-11-11 09:51:16
【问题描述】:

我使用 JasperStudio 创建了一个图表。我想删除图表中显示的网格线。我已尝试自定义图表,但自定义程序代码不起作用。这是我的代码:

    public void customize(JFreeChart chart, JRChart jrChart) {
    CategoryPlot cplot = (CategoryPlot) chart.getPlot();
    
    BarRenderer renderer = ((BarRenderer) cplot.getRenderer());
    renderer.setBarPainter(new StandardBarPainter());
    
    CategoryAxis xaxis = cplot.getDomainAxis();
    xaxis.setLabelLocation(AxisLabelLocation.MIDDLE);}

此代码不起作用。网格仍然保持显示。我该怎么做才能删除它。谢谢

【问题讨论】:

    标签: java jasper-reports jfreechart


    【解决方案1】:

    我自己想出来的。这可以用来隐藏网格线:

        public void customize(JFreeChart chart, JRChart jrChart) {
        CategoryPlot cplot = (CategoryPlot) chart.getPlot();
    //this will remove the horizontal grid lines    
        chart.getCategoryPlot().setRangeGridlinesVisible(false);
    //if there are vertical grid lines, this line can be uncommented to hide those ones 
    //  chart.getCategoryPlot().setDomainGridlinesVisible(false);}
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-09-01
      • 2012-08-24
      • 1970-01-01
      • 1970-01-01
      • 2019-06-13
      • 2021-07-03
      相关资源
      最近更新 更多