【问题标题】:Reduce the width of the bar graph in java [duplicate]减少java中条形图的宽度[重复]
【发布时间】:2015-08-03 11:36:41
【问题描述】:

我使用 JFreeChart 来显示条形图,图表中条形的宽度很大。我想减小条的宽度,有没有相关的API,请告诉我..

【问题讨论】:

    标签: java jfreechart bar-chart


    【解决方案1】:
    BarRenderer renderer = (BarRenderer) chart.getCategoryPlot().getRenderer();
    renderer.setItemMargin(-2);
    

    试试上面的代码。试着看看这个线程。

    Width of the bar in Jfreechart

    请注意上面的 sn-p 来自同一个线程。

    作为对您评论的回答,以下是相同方法的 Java Doc

    public void setItemMargin(double percent)
    Sets the item margin and sends a RendererChangeEvent to all registered listeners. The value is expressed as a percentage of the available width for plotting all the bars, with the resulting amount to be distributed between all the bars evenly.
    Parameters:
    percent - the margin (where 0.10 is ten percent).
    

    【讨论】:

    • 是的,我试过了,但它不适用于 renderer.setItemMargin(-2);使用此代码,条形就会消失,但是当我将其更改为 renderer.setItemMargin(.10);它完成了大小减少了一半。我想知道这个方法的参数是做什么的?
    • BarRenderer 渲染器 = (BarRenderer) plot.getRenderer();渲染器.setMaximumBarWidth(.10);这行代码解决了我的问题。
    猜你喜欢
    • 2018-10-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多