I have a function which produces a load of doubles up to the size of the array. What I am curious to know is how I can then plot these values using a XYLineChart
? I am unsure of how to put these doubles into the correct format so that they can then be plotted. How do I change my double[]
variables into a suitable format that the XYSeries
will accept and then plot. My code listing is below.
public XYSeries inputOutputGraph() {
XYSeries graph = new XYSeries();
XYDataset xyDataset = new XYSeriesCollection(graph);
graph.add(valuesToPlot.outputArray); //This line here is the issue
JFreeChart chart = ChartFactory.createXYLineChart(
" Array values", "Time", "values",
xyDataset, PlotOrientation.VERTICAL, true, true, false);
ChartFrame graphFrame = new ChartFrame("XYLine Chart", chart);
graphFrame.setVisible(true);
graphFrame.setSize(300, 300);
return graph;
}
This is the error message I get:
no suitable method found for add(double[]) method org.jfree.data.xy.XYSeries.add(org.jfree.data.xy.XYDataItem,boolean) is not applicable
(actual and formal argument lists differ in length)