I am creating a chart and notice that the points are not connected in the right order.
In the code mentioned below, the point (3,6) with point (4,5) would actually have to pass
through connected to a line, instead it is connected to point (4,3).
Does anyone have an idea how to solve this?
Thanks in advance
Code: Select all
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.plot.XYPlot;
import org.jfree.data.xy.DefaultXYDataset;
import org.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection;
import org.jfree.ui.ApplicationFrame;
import org.jfree.chart.renderer.xy.*;
public class TestChart {
public static void main(String[] args) {
XYSeries series1 = new XYSeries("Punkte1");
series1.add(4,3);
series1.add(4,4);
series1.add(4,5);
series1.add(3,6);
XYSeriesCollection dataset2 = new XYSeriesCollection();
dataset2.addSeries(series1);
XYLineAndShapeRenderer dot = new XYLineAndShapeRenderer();
NumberAxis xyx = new NumberAxis("x");
NumberAxis yax = new NumberAxis("y");
XYPlot plot = new XYPlot(dataset2, xyx, yax, dot);
JFreeChart chart2 = new JFreeChart(plot);
ApplicationFrame punkteframe = new ApplicationFrame("Punkte");
ChartPanel chartPanel2 = new ChartPanel(chart2);
punkteframe.setContentPane(chartPanel2);
punkteframe.pack();
punkteframe.setVisible(true);
}
}