Create ScatterChart from NumberAxis : ScatterChart « JavaFX « Java






Create ScatterChart from NumberAxis

 
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.chart.NumberAxis;
import javafx.scene.chart.ScatterChart;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
 
public class Main extends Application {

    @Override
    public void start(final Stage stage) {
        stage.setTitle("");
        stage.setWidth(500);
        stage.setHeight(500);
        Scene scene = new Scene(new Group());

        VBox root = new VBox();     

        NumberAxis yAxis =
            new NumberAxis(0.0,5.0,1.0);
        NumberAxis xAxis =
            new NumberAxis(0.0,5.0,1.0);
        ScatterChart scatterChart = new ScatterChart(xAxis,yAxis);

        
        root.getChildren().addAll(scatterChart);
        scene.setRoot(root);

        stage.setScene(scene);
        stage.show();
    }
 
    public static void main(String[] args) {
        launch(args);
    }
}

   
  








Related examples in the same category

1.ScatterChart from ObservableList>
2.Scatter Chart Sample