JFreeChart line not displayed correctly

A discussion forum for JFreeChart (a 2D chart library for the Java platform).

JFreeChart line not displayed correctly

Postby KK12 » Tue Jan 23, 2018 11:20 am

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");     

        XYSeriesCollection dataset2 = new XYSeriesCollection();
        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);


Posts: 1
Joined: Tue Jan 23, 2018 11:13 am

Re: JFreeChart line not displayed correctly

Postby paradoxoff » Tue Jan 23, 2018 3:23 pm

Use the XYSeries constructor that accepts a boolean parameter and set that to "false".
Posts: 1623
Joined: Sat Feb 17, 2007 1:51 pm

Return to JFreeChart

Who is online

Users browsing this forum: Bing [Bot], Google [Bot], Majestic-12 [Bot] and 8 guests