5

I have the following chart on angular-chart:

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

With this options:

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

Im updating the data via a websocket like this:

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});

});

The chart updates the right way for a couple of entries. But if I hover on the chart I get the error:

TypeError: Cannot read property 'skip' of undefined.

This is the function on Chart js where the app crashes:

/**
     * 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);
                }
            }
        }
    }

Can anyone help me solve the problem?

2
  • some issue here, been searching for a day lol Commented Aug 25, 2017 at 16:40
  • I ended up using d3.js instead... lol Commented Aug 25, 2017 at 17:46

1 Answer 1

1

Downgrade to 2.3.0 fixed it !

npm install [email protected] --save

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

Sign up to request clarification or add additional context in comments.

2 Comments

This also fixed the issue for me. Thanks.
moved to 2.8 because i had the issue with 2.9.3. again

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.