首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Angular-Chart无法读取未定义的属性“skip”

Angular-Chart无法读取未定义的属性“skip”
EN

Stack Overflow用户
提问于 2017-05-02 12:10:39
回答 1查看 2.1K关注 0票数 5

我在angular- chart上有以下图表:

代码语言:javascript
复制
<canvas id="line" class="chart chart-line" chart-data="data"  chart-colors="colors"
        chart-series="series" chart-options="options">
</canvas>

使用此选项:

代码语言:javascript
复制
$scope.options = {
  type:'line',
  tooltips: {
    enabled: false
  },
  showTooltips: false,
  hover: {mode: null},
  scales: {
    xAxes: [{
      type:"time"
    }]
  }
};

我正在通过websocket更新数据,如下所示:

代码语言:javascript
复制
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});

});

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

代码语言:javascript
复制
TypeError: Cannot read property 'skip' of undefined.

以下是应用程序崩溃的Chart js上的函数:

代码语言:javascript
复制
/**
     * 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);
                }
            }
        }
    }

有人能帮我解决这个问题吗?

EN

回答 1

Stack Overflow用户

发布于 2018-12-04 12:12:53

降级到2.3.0修复了这个问题!

代码语言:javascript
复制
npm install chart.js@2.3.0 --save

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

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/43729976

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档