我在 jfreechart API 中使用 StackedBarChart 来显示来自数据库的表中的记录数。域轴上有 82 个表,编号为 82。范围轴中的记录数。但我面临的问题是,由于域轴中的表太多,条形的宽度减小了。
以下是我的代码:
private JFreeChart createChart(CategoryDataset dataset)
{
JFreeChart chart = ChartFactory.createStackedBarChart(
"Stacked Bar Chart", "Task Description", "No_Of_Records", dataset,
PlotOrientation.VERTICAL, true, true, false);
CategoryPlot categoryplot = (CategoryPlot)chart.getPlot();
CategoryAxis categoryaxis = categoryplot.getDomainAxis();
categoryaxis.setMaximumCategoryLabelWidthRatio(100);
categoryaxis.setLowerMargin(0.02D);
categoryaxis.setUpperMargin(0.02D);
NumberAxis numberaxis = (NumberAxis)categoryplot.getRangeAxis();
numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
numberaxis.setRange(0.0D, 1000D);
BarRenderer barrenderer = (BarRenderer)categoryplot.getRenderer();
barrenderer.setDrawBarOutline(false);
GradientPaint gradientpaint = new GradientPaint(0.0F, 0.0F, Color.blue, 0.0F, 0.0F, new Color(0, 0, 64));
barrenderer.setSeriesPaint(0, gradientpaint);
return chart;
}
我尝试过使用
setItemMargin();
setMaxWidth();
setMaximumBarWidth();
在 BarRenderer 上,但一切都是徒劳的..
感谢任何帮助
问候,
最佳答案
您可以尝试使用 setCategoryMargin()
。另外,请查看右键单击并放大时的外观。
关于java - 使用 jfreechart 时增加条形宽度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9910230/