有没有办法在使用JFreeChart创建的条形图中沿x轴缩放? 如果图表包含时间序列,我看到我可以放大两个方向,但即使存在普通条形图,我也希望这样做。当有数百个柱子时,这特别有用。
以下是我的代码:
Random rand = new Random();
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
for(int i=1;i<201;i++)
dataset.addValue(rand.nextInt(50) + 1, "test", ""+i);
JFreeChart chart = ChartFactory.createBarChart(title, // chart title
"pages", // domain axis label
"Value", dataset, // data
PlotOrientation.VERTICAL, // orientation
true, // include legend
true, // tooltips?
false // URLs?
);
ChartPanel chart_panel = new ChartPanel(chart);
chart_panel.setMouseZoomable(true);
chart_panel.setMouseWheelEnabled(true);
CategoryPlot plot = (CategoryPlot) chart.getPlot();
plot.setBackgroundPaint(Color.WHITE);
BarRenderer renderer = (BarRenderer) plot.getRenderer();
//renderer.setSeriesPaint(0, color_map.get(entity));
renderer.setBarPainter(new StandardBarPainter());
renderer.setDrawBarOutline(false);
this.add(chart_panel);