如何解决“错误:<rect>属性宽度:预期长度,“ 7.33929396359861…”。在比较多个系列中

时间:2019-06-06 14:37:17

标签: highcharts

我正在将动态数据传递到股票图表,如下面的代码所示,并且收到报告的错误。

我试图长时间接收数据并且可以正常工作,但是我需要尽快接收。

ngDoCheck() {
      this._inputPayloads.forEach((elt) => {
        if (this.objDiffer[elt.cookieWidget] === undefined) {
          this.objDiffer[elt.cookieWidget] = this.differs.find(elt).create<null, null>();
        } else {
          const objChanges = this.objDiffer[elt.cookieWidget].diff(elt);
          if (objChanges !== null) {
            if (elt.payload !== undefined && elt.dataServiceType === 'getHistoricalData') {
              this.chart.addSeries(this.mapHistoricalData(new HistoricalData().deserialize(JSON.parse(elt.payload))), true);
            } else if (elt.payload !== undefined && elt.dataServiceType === 'getRealTimeData') {
              const parsedPayload = JSON.parse(elt.payload);
              const serieName = parsedPayload.deviceId + '/' + parsedPayload.iobjectId + '/' + parsedPayload.dataId;
              const serie = this.chart.series.filter(srie => srie.name === serieName)[0];
              if (serie !== undefined) {
                console.log(parsedPayload.timestamp, parsedPayload.value);
                serie.addPoint([parsedPayload.timestamp, parseFloat(parsedPayload.value)], true);
              } else {
                console.log(parsedPayload.timestamp, parsedPayload.value);
                const seriesPart: any = {
                  name: serieName,
                  data: [parsedPayload.timestamp, parseFloat(parsedPayload.value)]
                };
                this.chart.addSeries(seriesPart, true);
              }
            }
          }
        }
      });
    }
this.chart = Highcharts.stockChart('container' + this.cell.widget.id, {

        chart: {
          width: null,
          height: null
        },
        rangeSelector: {
          selected: 4
        },

        yAxis: {
          plotLines: [{
            value: 0,
            width: 2,
            color: 'silver'
          }]
        },

        plotOptions: {
          series: {
            compare: 'percent',
            showInNavigator: true
          }
        },
        series: [],



      });

我每500毫秒传递一次数据。这是在console.log代码行上方打印的数据示例:

 1. 1559830450655 "133"
 2. 1559830451154 "110"
 3. 1559830451154 "113"
 4. 1559830451655 "100"
 5. 1559830451655 "118"
 6. 1559830452155 "110"
 7. 1559830452155 "133"
 8. 1559830452655 "120"
 9. 1559830452655 "113"
 10. 1559830453153 "125"
 11. ...

将时间增加到1000毫秒时,它确实起作用。

0 个答案:

没有答案