Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8097482

LineChart renders noisy lines when the number of data points is large

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 8u60
    • 8u25
    • javafx
    • Windows 8.1, x64

      When a large number of data points are used to draw a straight line in the chart, the rendered line is not straight.
      For example:

      import javafx.application.Application;
      import javafx.scene.Scene;
      import javafx.scene.chart.LineChart;
      import javafx.scene.chart.NumberAxis;
      import javafx.scene.chart.XYChart;
      import javafx.stage.Stage;

      public class ChartBug extends Application {
          
          @Override
          public void start(Stage primaryStage) {
              //defining the axes
              final NumberAxis xAxis = new NumberAxis();
              final NumberAxis yAxis = new NumberAxis();

              //creating the chart
              final LineChart<Number,Number> lineChart =
                      new LineChart<>(xAxis,yAxis);
              // Disable symbols
              lineChart.setCreateSymbols(false);
              //defining a series
              XYChart.Series series = new XYChart.Series();
              for(int i=0; i<=100; i++)
              {
                  series.getData().add(new XYChart.Data<>(i,i));
              }
              lineChart.getData().add(series);
              
              Scene scene = new Scene(lineChart,800,600);
              primaryStage.setScene(scene);
              primaryStage.show();
          }

          /**
           * @param args the command line arguments
           */
          public static void main(String[] args) {
              launch(args);
          }
          
      }

      This produces the following chart : http://imgur.com/ddSQT9i,lQ8nNMx#0

      While changing
      for(int i=0; i<=100; i++)
              {
                  series.getData().add(new XYChart.Data<>(i,i));
              }

      To
      for(int i=0; i<=10; i++)
              {
                  series.getData().add(new XYChart.Data<>(10*i,10*i));
              }

      produces a straight line as expected. http://imgur.com/ddSQT9i,lQ8nNMx#1

            vadim Vadim Pakhnushev
            duke J. Duke
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: