我在jFreeChart直方图中有两个系列。通常情况下,一个较小,然后另一个较小,我们想缩小较小的尺寸,因此它与较大的系列相似,我想验证是否可以使用jFreeChart的常用API和两个单独的范围轴来实现,大概一个在右边,另一个在左边。
答案 0 :(得分:1)
官方示例非常有帮助。这是我基于它们的解决方案,这要归功于垃圾桶的建议。
public void generateChart(List<FmsData> data, Valve valve) {
HistogramDataset aggDs = createAggDataset(data);
chart = createChart(aggDs, valve.getNumber());
HistogramDataset valveDs = createValveDataset(data,valve.getNumber());
XYPlot plot = chart.getXYPlot();
// configure the second dataset
plot.setDataset(0, aggDs);
plot.setDataset(1, valveDs);
plot.setRangeAxisLocation(0, AxisLocation.BOTTOM_OR_LEFT);
plot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_RIGHT);
plot.mapDatasetToRangeAxis(0, 0);
plot.mapDatasetToRangeAxis(1, 1);
NumberAxis valveRangeAxis = new NumberAxis();
plot.setRangeAxis(1, valveRangeAxis);
XYBarRenderer renderer2 = new XYBarRenderer();
plot.setRenderer(1, renderer2);
plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);
renderer2.setDrawBarOutline(false);
// flat bars look best...
renderer2.setBarPainter(new StandardXYBarPainter());
renderer2.setShadowVisible(false);
// end config second dataset