带有连接点的散点图 javafx

Scatter chart with connected dots javafx

我正在学习用于创建 GUI 的 javafx。我想实现一个简单的 X-Y NumberAxis 折线图。根据折线图属性,连接数据点的线从不相交。

例如-假设数据点

 series.getData().add(new XYChart.Data(1.5,1.5));
 series.getData().add(new XYChart.Data(2.5,4.5));
 series.getData().add(new XYChart.Data(4.5,2.5));
 series.getData().add(new XYChart.Data(1.0,2.0));
 series.getData().add(new XYChart.Data(3.0,3.0));`

折线图中这些点的输出是 - ]1)

因为它应该像下面相同点的散点图输出的编辑图像 -

有没有办法改变折线图的这种行为?或 连接散点图的点?

请注意,我将动态添加点,两个轴的下限、上限将连续变化。

关闭图表的 sorting policy

lineChart.setAxisSortingPolicy(LineChart.SortingPolicy.NONE);

当我使用它时,我得到了这个漂亮的 child 涂鸦。

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 LineChartSample extends Application {

    @Override public void start(Stage stage) {
        final NumberAxis xAxis = new NumberAxis();
        final NumberAxis yAxis = new NumberAxis();

        final LineChart<Number,Number> lineChart =
                new LineChart<>(xAxis, yAxis);

        XYChart.Series<Number, Number> series = new XYChart.Series<>();
        series.getData().addAll(
                new XYChart.Data<>(4, 24),
                new XYChart.Data<>(1, 23),
                new XYChart.Data<>(6, 36),
                new XYChart.Data<>(8, 45),
                new XYChart.Data<>(2, 14),
                new XYChart.Data<>(9, 43),
                new XYChart.Data<>(7, 22),
                new XYChart.Data<>(12, 25),
                new XYChart.Data<>(10, 17),
                new XYChart.Data<>(5, 34),
                new XYChart.Data<>(3, 15),
                new XYChart.Data<>(11, 29)
        );
        lineChart.setAxisSortingPolicy(LineChart.SortingPolicy.NONE);

        Scene scene  = new Scene(lineChart,800,600);
        lineChart.getData().add(series);
        lineChart.setLegendVisible(false);

        stage.setScene(scene);
        stage.show();
    }

    public static void main(String[] args) {
        launch(args);
    }
}