Combining JDBCXYDatasets in one graph

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
petersteenb
Posts: 2
Joined: Mon May 11, 2020 9:30 pm
antibot: No, of course not.

Combining JDBCXYDatasets in one graph

Post by petersteenb » Mon May 11, 2020 9:42 pm

Hi everybody,
I am looking for a way to perform 2 or more queries and combine the query results into a single graph. The statements return X, Y datasets.
JDBCXYDataset dataSet1 = new JDBCXYDataset(con1, query1);
JDBCXYDataset dataSet2 = new JDBCXYDataset(con2, query2);
This works perfectly, but, if possible, I would like to show dataSets1 and 2 as 2 separate lines in one XY graph. Unfortunatelyt I cannot find a way to combine both results into one graph that I could display using:
JFreeChart graph = ChartFactory.createXYLineChart(..., ..., ..., XYSeriesCollection)
Is there a way to cast dataSets1 and 2 to a XYSeriesCollection?
Thanks in advance for your tips!
Peter

John Matthews
Posts: 513
Joined: Wed Sep 12, 2007 3:18 pm

Re: Combining JDBCXYDatasets in one graph

Post by John Matthews » Thu Sep 17, 2020 11:55 pm

JDBCXYDataset can hold multiple series by including additional columns in the query.

Locked