Jfreechart中条形的宽度 [英] Width of the bar in Jfreechart

查看:157
本文介绍了Jfreechart中条形的宽度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法调整条形图中条形的宽度?

Is there a way to adjust the width of the bars in a Barchart?

我使用以下代码创建我的图表。

I create my chart with the following code.

final JFreeChart chart = ChartFactory.createBarChart("Report", // chart title
                "Date", // domain axis label
                "Number", // range axis label
                dataset, // data
                PlotOrientation.VERTICAL, // orientation
                true, // include legend
                true, // tooltips?
                false // URLs?
                );  


推荐答案

您还可以设置条形图的最大宽度。如果你有一个宽图表,但是偶尔只有一个或两个数据点而且你不希望一个大的胖棒占据整个区域,这很有用。

You can also set the maximum width of a bar. This is useful if you have a wide chart but occasionally there are only one or two data points and you don't want a single big fat bar taking up the whole area.

CategoryPlot categoryPlot = chart.getCategoryPlot();
BarRenderer br = (BarRenderer) categoryPlot.getRenderer();
br.setMaximumBarWidth(.35); // set maximum width to 35% of chart

这篇关于Jfreechart中条形的宽度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆