public static JFreeChart createChart() { DefaultCategoryDataset defaultcategorydataset = new DefaultCategoryDataset(); defaultcategorydataset.addValue(1.0D, "S1", "Category 1"); defaultcategorydataset.addValue(4D, "S1", "Category 2"); defaultcategorydataset.addValue(3D, "S1", "Category 3"); defaultcategorydataset.addValue(5D, "S1", "Category 4"); defaultcategorydataset.addValue(5D, "S1", "Category 5"); defaultcategorydataset.addValue(7D, "S1", "Category 6"); defaultcategorydataset.addValue(7D, "S1", "Category 7"); defaultcategorydataset.addValue(8D, "S1", "Category 8"); defaultcategorydataset.addValue(5D, "S2", "Category 1"); defaultcategorydataset.addValue(7D, "S2", "Category 2"); defaultcategorydataset.addValue(6D, "S2", "Category 3"); defaultcategorydataset.addValue(8D, "S2", "Category 4"); defaultcategorydataset.addValue(4D, "S2", "Category 5"); defaultcategorydataset.addValue(4D, "S2", "Category 6"); defaultcategorydataset.addValue(2D, "S2", "Category 7"); defaultcategorydataset.addValue(1.0D, "S2", "Category 8"); StandardCategoryItemLabelGenerator standardcategoryitemlabelgenerator = new StandardCategoryItemLabelGenerator(); BarRenderer barrenderer = new BarRenderer(); barrenderer.setBaseItemLabelGenerator(standardcategoryitemlabelgenerator); barrenderer.setBaseItemLabelsVisible(true); CategoryPlot categoryplot = new CategoryPlot(); categoryplot.setDataset(defaultcategorydataset); categoryplot.setRenderer(barrenderer); categoryplot.setDomainAxis(new CategoryAxis("Category")); categoryplot.setRangeAxis(new NumberAxis("Value")); categoryplot.setOrientation(PlotOrientation.VERTICAL); categoryplot.setRangeGridlinesVisible(true); categoryplot.setDomainGridlinesVisible(true); DefaultCategoryDataset defaultcategorydataset1 = new DefaultCategoryDataset(); defaultcategorydataset1.addValue(9D, "T1", "Category 1"); defaultcategorydataset1.addValue(7D, "T1", "Category 2"); defaultcategorydataset1.addValue(2D, "T1", "Category 3"); defaultcategorydataset1.addValue(6D, "T1", "Category 4"); defaultcategorydataset1.addValue(6D, "T1", "Category 5"); defaultcategorydataset1.addValue(9D, "T1", "Category 6"); defaultcategorydataset1.addValue(5D, "T1", "Category 7"); defaultcategorydataset1.addValue(4D, "T1", "Category 8"); LineAndShapeRenderer lineandshaperenderer = new LineAndShapeRenderer(); categoryplot.setDataset(1, defaultcategorydataset1); categoryplot.setRenderer(1, lineandshaperenderer); NumberAxis numberaxis = new NumberAxis("Axis 2"); categoryplot.setRangeAxis(1, numberaxis); DefaultCategoryDataset defaultcategorydataset2 = new DefaultCategoryDataset(); defaultcategorydataset2.addValue(94D, "R1", "Category 1"); defaultcategorydataset2.addValue(75D, "R1", "Category 2"); defaultcategorydataset2.addValue(22D, "R1", "Category 3"); defaultcategorydataset2.addValue(74D, "R1", "Category 4"); defaultcategorydataset2.addValue(83D, "R1", "Category 5"); defaultcategorydataset2.addValue(9D, "R1", "Category 6"); defaultcategorydataset2.addValue(23D, "R1", "Category 7"); defaultcategorydataset2.addValue(98D, "R1", "Category 8"); categoryplot.setDataset(2, defaultcategorydataset2); LineAndShapeRenderer lineandshaperenderer1 = new LineAndShapeRenderer(); categoryplot.setRenderer(2, lineandshaperenderer1); categoryplot.mapDatasetToRangeAxis(2, 1); categoryplot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); categoryplot.getDomainAxis().setCategoryLabelPositions(CategoryLabelPositions.UP_45); JFreeChart jfreechart = new JFreeChart(categoryplot); jfreechart.setTitle("Overlaid Bar Chart"); return jfreechart; }