public void init() {

    chart = new ScatterChart<Number, Number>(xAxis, yAxis);
    chart.setPrefWidth(1400);
    chart.setPrefHeight(800);

    Series<Number, Number> seriesThumb = new Series<Number, Number>();
    seriesThumb.setName("Thumb");
    Series<Number, Number> seriesIndex = new Series<Number, Number>();
    seriesIndex.setName("Index");
    Series<Number, Number> seriesMiddle = new Series<Number, Number>();
    seriesMiddle.setName("Middle");

    int index = 0;
    for (ExFrame f : frames) {
      ExHand h = hand == 1 ? f.getRight() : f.getLeft();
      seriesThumb
          .getData()
          .add(new Data<Number, Number>(index + 1, h.getThumbVelocity().magnitude()));
      seriesIndex
          .getData()
          .add(new Data<Number, Number>(index + 1, h.getIndexVelocity().magnitude()));
      seriesMiddle
          .getData()
          .add(new Data<Number, Number>(index + 1, h.getMiddleVelocity().magnitude()));

      index++;
    }

    chart.getData().addAll(seriesThumb, seriesIndex, seriesMiddle);

    this.getChildren().add(chart);
  }
示例#2
0
 public Parent createContent() {
   final NumberAxis xAxis = new NumberAxis();
   xAxis.setForceZeroInRange(false);
   final NumberAxis yAxis = new NumberAxis(-100, 100, 10);
   final ScatterChart<Number, Number> sc = new ScatterChart<>(xAxis, yAxis);
   // setup chart
   sc.getStylesheets()
       .add(LiveScatterChartApp.class.getResource("LiveScatterChart.css").toExternalForm());
   sc.setTitle("Animated Sine Wave ScatterChart");
   xAxis.setLabel("X Axis");
   xAxis.setAnimated(false);
   yAxis.setLabel("Y Axis");
   yAxis.setAutoRanging(false);
   // add starting data
   series = new ScatterChart.Series<>();
   series.setName("Sine Wave");
   series.getData().add(new ScatterChart.Data<Number, Number>(5d, 5d));
   sc.getData().add(series);
   return sc;
 }