LineChart JavaFX性能 [英] LineChart JavaFX Performance

查看:344
本文介绍了LineChart JavaFX性能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Raspian上的LineChart响应速度比正常慢 - Raspberry Pi。我正在对示波器进行编码,并不断重新绘制2个500点(总共1000点)。动画已关闭。数据收集性能良好(低于2毫秒)。当前数据重绘时间大约为800毫秒。所需的重绘时间至少为100毫秒。我在下面列出了代码段。在覆盆子pi上进行高性能javafx图表显示的最佳做法是什么?我采取了错误的做法吗?我应该使用不同类型的图表来连续重绘两行吗?

I'm experiencing slower than normal response for a LineChart on Raspian - Raspberry Pi. I'm coding an oscilloscope and continuously redrawing 2 series of 500 points (total of 1000 points). Animation is off. Data collection is performant (under 2ms). Current data redraw time is 800 ms or so. Desired redraw time is at least 100ms. I've included code snippets below. What is the best practice for performant javafx chart display on a raspberry pi? Am I taking the wrong approach? Should I be using a different kind of chart for continuously redrawing two lines?

平台:


  • Raspberry Pi v.3


    • OS:Raspian release 8(jessie)

    • Java版本:


      • java版本1.8.0_65

      • Java(TM)SE运行时环境( build 1.8.0_65-b17)

      • Java HotSpot(TM)客户端VM(版本25.65-b01,混合模式)

      • Raspberry Pi v. 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)
          • Java HotSpot(TM) Client VM (build 25.65-b01, mixed mode)

          显示代码

          @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()
          


          推荐答案

          我发现从图表中删除网格线有很大帮助。

          I found that removing gridlines from the charts helps immensely.

          例如

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

          未尝试减少网格线的数量。

          Haven't tried to reduce the number of grid lines.

          这篇关于LineChart JavaFX性能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆