【发布时间】:2016-08-04 07:56:01
【问题描述】:
我想得到堆叠面积图,开始图表在第一点,在最后一点完成,如下所示:
如何使堆叠区域从第一点开始精确到最后一点? (使用 dateAxis.setLowerMargin(-0.075D) dateAxis.setUpperMargin(-0.075D) 的不同操作没有帮助)
JFreeChart stackedAreaChart = ChartFactory.createStackedAreaChart(name, X_AXIS_TITLE, Y_AXIS_TITLE, dataset,
PlotOrientation.VERTICAL, true, true, false);
CategoryPlot plot = stackedAreaChart.getCategoryPlot();
CategoryAxis dateAxis = plot.getDomainAxis();
dateAxis.setLowerMargin(-0.075D);
dateAxis.setUpperMargin(-0.075D);
dateAxis.setCategoryMargin(0.0D);
StackArea renderer = new StackArea();
dateAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);
...
plot.setRenderer(renderer);
renderer.setBaseItemLabelGenerator(new LabelGenerator());
renderer.setBaseItemLabelsVisible(true);
...
plot.setRenderer(renderer);
plot.setAxisOffset(new RectangleInsets(5.0, 1.0, 5.0, 1.0));
ValueAxis rangeAxis = plot.getRangeAxis();
NumberAxis axis2 = new NumberAxis(Y_AXIS_TITLE);
axis2.setAutoRangeIncludesZero(false);
axis2.setLabelFont(rangeAxis.getLabelFont());
axis2.setTickLabelFont(rangeAxis.getTickLabelFont());
...
plot.setRangeAxis(1, axis2);
plot.setRangeAxisLocation(1, AxisLocation.TOP_OR_RIGHT);
plot.mapDatasetToRangeAxes(0, Arrays.asList(0, 1));
setAxisColor(rangeAxis, axisColor);
rangeAxis.setTickLabelPaint(ColorUtils.VaadinAWTColor(params.getColorParams().getFontSlideColor()));
rangeAxis.setLabelPaint(ColorUtils.VaadinAWTColor(params.getColorParams().getFontSlideColor()));
【问题讨论】:
-
这个问题太笼统了。如果您无法明确您想要获得什么,并且不会提供代码 - 它可能会被视为已关闭。请编辑您的问题,发送至best practices
标签: jfreechart stacked-area-chart