JavaFX LineChart Performance

I experience a slower than usual answer for LineChart on Raspian - Raspberry Pi. I encode an oscilloscope and continuously redraw 2 episodes of 500 points each (a total of 1000 points). Animation is disabled. Data collection completed (up to 2 ms). The current data overwrite time is 800 ms or so. The desired redraw time is at least 100 ms. The following are snippets of code. What is the best practice for showing the javafx graph shown on a raspberry pi? Am I taking the wrong approach? Should I use a different type of chart to continuously redraw two lines?

Platform:

  • Raspberry Pi vs 3
    • OS: Raspian release 8 (jessie)
    • Java version:
      • java version "1.8.0_65"
      • Java (TM) SE Runtime Environment (build 1.8.0_65-b17)
      • HotSpot (TM) Java Client Virtual Machine (build 25.65-b01, mixed mode)
    • JavaFX version: armv6hf-sdk 8.0.102 (build b00)
    • Memory sharing: 512 MB graphics, 512 MB systems.
    • Video: HDMI
    • SoC: Broadcom BCM2837
    • CPU: 4 × ARM Cortex-A53, 1.2 GHz

Display code

@FXML
LineChart oscilloscope;

//indicates that the previous data has been displayed
//and that the latest data should now be displayed
//didn't bother to synchronize
boolean needsUpdating = true;

protected void startDisplay() {
    oscilloscope.setAnimated(false);
    oscilloscope.setCreateSymbols(false);
    oscilloscope.getXAxis().setLabel("Time (ms)");
    oscilloscope.getXAxis().setAutoRanging(false);
    oscilloscope.getYAxis().setLabel("Volts (v)");
    oscilloscope.getYAxis().setAutoRanging(false);

    new Thread() {
        public void run() {
             while (!done) {
               XYChart.Series ch1 = getChan1Data();
               XYChart.Series ch2 = getChan2Data();
               ch1.setName("Channel 1");
               ch2.setName("Channel 2");

              if (needsUpdated) {
                  needsUpdated = false;
                  Platform.runLater(new Runnable() {
                      @Override
                      public void run() {
                           //performance is the same whether I use this or
                           //oscilloscope.getData().clear()
                          oscilloscope.setData(FXCollections.observableArrayList());
                          oscilloscope.getData().addAll(ch1, ch2);
                          needsUpdating = true;
                      }  //end run()
                  }      //end Platform.runLater()
              }          //end if(needsUpdating)
        }                //end while(!done)
    }.start();           //end new Thread
}                        //end startDisplay()
+2
source share
1 answer

I found that removing grid lines from charts helps a lot.

eg.

chart.setHorizontalGridLinesVisible(false);
chart.setVerticalGridLinesVisible(false);

They did not try to reduce the number of grid lines.

+1
source

All Articles