0

I'd like to save from my array a point chart as Image(PNG), with this Java Programm I can show my Schatter Diagram but I don't know how to save it. Perhaps with ImageIO.write, and how?

public class Graph extends Application {

public void start(Stage primaryStage) {
    Pane root = new Pane();
    int[] mydata = {
            12, 9, 0, 1, 38, 19, 21, 72, 33, 83, 14, 10, 65, 46, 10, 17, 27, 38, 65, 98, 8, 58, 38, 79, 37, 69, 26, 15};

            NumberAxis xAxis = new NumberAxis();
    NumberAxis yAxis = new NumberAxis();
    ScatterChart scatterChart=new ScatterChart(xAxis,yAxis);


    XYChart.Series data=new XYChart.Series();
    for (int i=0; i< mydata.length; i++) {
        data.getData().add(new XYChart.Data(i,mydata[i]));
    }       
     scatterChart.getData().addAll(data);


root.getChildren().add(scatterChart);
Scene scene = new Scene(root, 600, 400);

primaryStage.setScene(scene);
primaryStage.show();

File file = new File("c:\\Images\\Image.png");

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

can anybody give me some advice to solve this problem. Thank you

Lolitta
  • 79
  • 7
  • 1
    Search for "java scatter plot example" – Stephen C Apr 18 '16 at 14:03
  • 1
    ok you are in the same class as this guy http://stackoverflow.com/questions/36689284/how-to-create-an-image-from-graph/36689901#36689901 talk to him! – gpasch Apr 18 '16 at 14:04
  • 1
    You don't have a graph, you have some raw data. You need an code that plots your data. This is usually a job of a plotting library. – Robert Apr 18 '16 at 14:06

0 Answers0