I tried the following code to change the color below my graph line to green:
I dont know why JFreeChart just ignores my wanted color - but I get no error.
JFreeChart chart = ChartFactory.createLineChart(
"# of Sales by Month", // chart title
"Month", // domain axis label
"# of Sales", // range axis label
dataset, // data
PlotOrientation.VERTICAL, // orientation
true, // include legend
true, // tooltips
false // urls
);
chart.setBackgroundPaint(Color.BLUE);
CategoryPlot plot = (CategoryPlot) chart.getPlot();
plot.setRangePannable(true);
plot.setRangeGridlinesVisible(true);
plot.setBackgroundAlpha(1);
plot.setBackgroundPaint(Color.BLUE);
// Paint p = new GradientPaint(0, 0, Color.white, 1000, 0, Color.green);
// plot.setBackgroundPaint(p);
NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
chart.getCategoryPlot().getRenderer().setDefaultFillPaint(Color.GREEN);
ChartUtils.applyCurrentTheme(chart);
LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer();
renderer.setDrawOutlines(true);
renderer.setSeriesStroke(0, new BasicStroke(3.0f));
renderer.setSeriesOutlineStroke(0, new BasicStroke(2.0f));
renderer.setSeriesShape(0, new Ellipse2D.Double(0, 0, 0, 0));
return chart;
The problem is, that it doesnt change, i cant find any way to fix that