macroAbc
macroAbc

Reputation: 23

How to combine two line graphs into one graph using jfreechart?

I am using a jfreechart to show a line graph. I want to use same graph to show another line graph. Can anyone tell me how to do that? Thanks in advance

Upvotes: 0

Views: 4452

Answers (1)

RollingBoy
RollingBoy

Reputation: 2817

JFreeChart chart = ... //Get the chart with your first dataset.
CategoryPlot plot = chart.getCategoryPlot();
plot.setDataset(1, anotherDataset);  //The '1' at the first parameter is 
                                     //the index of dataset. 
                                     //Thus, '1' for the second dataset.
...  //some other settings to the plot, with index=1.
plot.setRenderer(1, someRenderer);

Then we can get the graph with this chart.

Upvotes: 1

Related Questions