我在jfreechart API中使用StackedBarChart来显示来自数据库的表中的no.records。有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上的,但都是徒劳的..
感谢任何帮助
此致