ELECTRON App加载动态图时出现问题

时间:2018-09-20 06:16:39

标签: electron

以下给出的代码可在Browserlike(CHROME,MOZILLA)上运行,但不适用于我的ELECTRON App。 我是为Linux系统构建电子应用程序的新手。 我正在使用电子2.0.9  请帮助我进行必要的更改,以使其适用于电子应用。

  <html>
   <head>
    <script>
      window.onload = function () {

      var dps = []; // dataPoints
      var chart = new CanvasJS.Chart("chartContainer", {
      title :{
      text: "Dynamic Data"
      },
      axisX:{
      title:"time",
      valueFormatString: "HH:mm:ss" 
   },
   axisY: {
    includeZero: false
   },      
   data: [{
    type: "line",
    dataPoints: dps
    }] 
   });

 var xVal = 0;
 var yVal = 100; a
 var updateInterval = 1000;
 var dataLength = 20; // number of dataPoints visible at any point

var updateChart = function (count) {
var time=new Date();
count = count || 1;

for (var j = 0; j < count; j++) {
xVal=time;
    yVal = yVal +  Math.round(5 + Math.random() *(-5-5));
    dps.push({
        x: xVal,
        y: yVal
    });
    xVal++;
}

if (dps.length > dataLength) {
    dps.shift();
}

chart.render();
   };

 updateChart(dataLength);
 setInterval(function(){updateChart()}, updateInterval);

 }
   </script>
  </head>
   <body>
   <div id="chartContainer" style="height: 300px; width: 100%;"></div>
  <script src="https://canvasjs.com/assets/script/canvasjs.min.js"></script>    
  </body>
   </html>

0 个答案:

没有答案