1

I am trying to generate a time series with the area underneath filled with color.

Looking at examples of the jfreechart library there is this method:

ChartFactory.createAreaChart(...)

However the dataset required is a Category dataset, something quite different from the Time Series Dataset that I currently create:

ChartFactory.createTimeSeriesChart(...)

Which methods should I use to fill with color the area underneath the plotted line?

Thank you!

George Pligoropoulos
  • 2,919
  • 3
  • 33
  • 65

1 Answers1

2

Add the following after you create the a chart (using createTimeSeriesChart)

XYPlot plot = (XYPlot) chart.getPlot();
plot.setRenderer(new XYAreaRenderer());
GrahamA
  • 5,875
  • 29
  • 39
  • Thanks a lot GrahamA ! Any may I add that I just found out you can use these lines of code to set your own color (written in scala language): inline `val areaRenderer = new XYAreaRenderer();` areaRenderer.setSeriesPaint(0, Color.green); plot.setRenderer(areaRenderer); – George Pligoropoulos Dec 03 '12 at 12:33