列数が動的で、1 列から n 列に変更できる積み上げ棒グラフがあります。チャート間の間隔とバーの幅を一定にしたい。どうすれば修正できますか。解決策/アイデアを提案してください。
16706 次
2 に答える
5
積み上げ棒グラフでは、次の方法で棒の間隔を変更できます。
- CategoryAxis.setLowerMargin
- CategoryAxis.setMargin および
- CategoryAxis.setUpperMargin
コードは以下です
protected JFreeChart generateGraph() {
CategoryAxis categoryAxis = new CategoryAxis("Categories");
categoryAxis.setLowerMargin(.01);
categoryAxis.setCategoryMargin(.01);
categoryAxis.setUpperMargin(.01);
categoryAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90);
ValueAxis valueAxis = new NumberAxis("Values");
StackedBarRenderer renderer = new StackedBarRenderer();
renderer.setBarPainter(new StandardBarPainter());
renderer.setDrawBarOutline(false);
renderer.setShadowVisible(false);
renderer.setBaseItemLabelsVisible(true);
renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
CategoryPlot plot = new CategoryPlot( _dataset,
categoryAxis,
valueAxis,
renderer);
plot.setOrientation(PlotOrientation.VERTICAL);
JFreeChart chart = new JFreeChart( "Title",
JFreeChart.DEFAULT_TITLE_FONT,
plot,
true);
//ChartFactory.getChartTheme().apply(_chart);
return chart;
}
于 2011-11-22T08:40:46.013 に答える
2
StackedBarRenderer
「[バー]間の間隔とバーの幅を一定にする」ために、ある程度の努力を払っています。列の数が変化するにつれて、どのように異なる方法で実行するかは明確ではありません。BarRenderer
関連するジオメトリは、などの方法で親によって決定calculateBarWidth()
されます。これは、必要に応じてオーバーライドできます。また、各シリーズの各カテゴリに値があることを確認してください。
于 2010-05-11T17:21:04.550 に答える