【问题标题】:Angular-Chart cannot read propery 'skip' of undefinedAngular-Chart 无法读取未定义的属性“跳过”
【发布时间】:2017-05-02 04:10:38
【问题描述】:

我在角度图表上有以下图表:

<canvas id="line" class="chart chart-line" chart-data="data"  chart-colors="colors"
        chart-series="series" chart-options="options">
</canvas>

使用此选项:

$scope.options = {
  type:'line',
  tooltips: {
    enabled: false
  },
  showTooltips: false,
  hover: {mode: null},
  scales: {
    xAxes: [{
      type:"time"
    }]
  }
};

我通过这样的 websocket 更新数据:

channel.on("create:entry", function (msg) {
  // Before updating the data, set the new time to the current time
  $log.log("received entry");
  $log.log(msg);
  // Refetch the data points
  $scope.data[0].push(
    {
      x: new Date(),
      y: msg.sonnar
    });
  vm.current = msg.sonnar;
  vm.logEntries.splice(0, 0, {time: moment(new Date()).format("MMMM Do YYYY, h:mm:ss a"), level: msg.sonnar});

});

图表更新了几个条目的正确方式。但是,如果我将鼠标悬停在图表上,则会出现错误:

TypeError: Cannot read property 'skip' of undefined.

这是 Chart js 上应用崩溃的函数:

/**
     * Helper function to traverse all of the visible elements in the chart
     * @param chart {chart} the chart
     * @param handler {Function} the callback to execute for each visible item
     */
    function parseVisibleItems(chart, handler) {
        var datasets = chart.data.datasets;
        var meta, i, j, ilen, jlen;

        for (i = 0, ilen = datasets.length; i < ilen; ++i) {
            if (!chart.isDatasetVisible(i)) {
                continue;
            }

            meta = chart.getDatasetMeta(i);
            for (j = 0, jlen = meta.data.length; j < jlen; ++j) {
                var element = meta.data[j];
                if (!element._view.skip) {
                    handler(element);
                }
            }
        }
    }

谁能帮我解决这个问题?

【问题讨论】:

  • 这里有点问题,找了一天lol
  • 我最终改用 d3.js ......哈哈

标签: javascript angularjs charts


【解决方案1】:

降级到 2.3.0 修复它!

npm install chart.js@2.3.0 --save

https://github.com/chartjs/Chart.js/issues/3753

【讨论】:

  • 这也为我解决了这个问题。谢谢。
  • 移至 2.8,因为我遇到了 2.9.3 的问题。再次
猜你喜欢
  • 2018-04-20
  • 2017-11-09
  • 1970-01-01
  • 1970-01-01
  • 2022-01-20
  • 2016-01-12
  • 2015-09-08
  • 2016-05-12
  • 2019-07-25
相关资源
最近更新 更多