使系列的边缘很简单,但是如何使图2所示的图形我没有找到任何例子。接下来的代码生成如图1所示的图。我想找到一种方法来获得图2所示的图。
有些人曾经遇到过这种需求吗?有没有简单的方法来获得结果?
非常感谢。
private static CategoryDataset createDataset()
{
DefaultCategoryDataset defaultcategorydataset = new DefaultCategoryDataset();
defaultcategorydataset.addValue(10D, "Series 1", "Jan");
defaultcategorydataset.addValue(12D, "Series 1", "Feb");
defaultcategorydataset.addValue(13D, "Series 1", "Mar");
defaultcategorydataset.addValue(4D, "Series 2", "Jan");
defaultcategorydataset.addValue(3D, "Series 2", "Feb");
defaultcategorydataset.addValue(2D, "Series 2", "Mar");
defaultcategorydataset.addValue(2D, "Series 3", "Jan");
defaultcategorydataset.addValue(3D, "Series 3", "Feb");
defaultcategorydataset.addValue(2D, "Series 3", "Mar");
defaultcategorydataset.addValue(2D, "Series 4", "Jan");
defaultcategorydataset.addValue(3D, "Series 4", "Feb");
defaultcategorydataset.addValue(4D, "Series 4", "Mar");
return defaultcategorydataset;
}
private static JFreeChart createChart(CategoryDataset categorydataset)
{
JFreeChart jfreechart = ChartFactory.createStackedBarChart("Stacked Bar Chart Demo 3", "Category", "Value", categorydataset, PlotOrientation.VERTICAL, true, false, false);
CategoryPlot categoryplot = (CategoryPlot)jfreechart.getPlot();
ExtendedStackedBarRenderer extendedstackedbarrenderer = new ExtendedStackedBarRenderer();
extendedstackedbarrenderer.setBaseItemLabelsVisible(true);
extendedstackedbarrenderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
extendedstackedbarrenderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
categoryplot.setRenderer(extendedstackedbarrenderer);
NumberAxis numberaxis = (NumberAxis)categoryplot.getRangeAxis();
numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
numberaxis.setLowerMargin(0.14999999999999999D);
numberaxis.setUpperMargin(0.14999999999999999D);
numberaxis.setNumberFormatOverride(NumberFormat.getPercentInstance());
ChartUtilities.applyCurrentTheme(jfreechart);
return jfreechart;
}