Home Forums Chart Support Problem disabling all data series

Problem disabling all data series

Viewing 6 posts - 1 through 6 (of 6 total)
  • #19800

    I’ve written a simple function to hide all data series on a graph (after a click on a link); this is what it does:

    for(var key in chart.options.data) {
    if (chart.options.data[key].visible)
    chart.options.data[key].visible = false;

    the problem is that it’s very very slow and I don’t understand why (it take 5-6 seconds, much more then disabling the single lines individually by clicking on them). Moreover very often I get this error after hiding the lines:

    Uncaught TypeError: Cannot set property ‘dataSeries’ of null
    at Y._updateToolTip (jquery.canvasjs.min.js:807)
    at Y.mouseMoveHandler (jquery.canvasjs.min.js:801)
    at q._plotAreaMouseMove (jquery.canvasjs.min.js:249)
    at q._mouseEventHandler (jquery.canvasjs.min.js:239)
    at HTMLCanvasElement.<anonymous> (jquery.canvasjs.min.js:114)
    Y._updateToolTip @ jquery.canvasjs.min.js:807
    Y.mouseMoveHandler @ jquery.canvasjs.min.js:801
    q._plotAreaMouseMove @ jquery.canvasjs.min.js:249
    q._mouseEventHandler @ jquery.canvasjs.min.js:239
    (anonymous) @ jquery.canvasjs.min.js:114

    Please note that I’ve a function adding every few seconds new points to the dataseries using jquery and then calling the render method chart.render();

    Any idea?




    Can you please create a jsfiddle reproducing the issue so that we can look into the code and help you out.

    Indranil Deo,
    Team CanvasJS


    it’s not that easy because this is a big project with tens of lines to plot, external jquery scripts and so on; if possible I could try to provide more data if you request. Eg this morning I’ve made other 2 tests and they don’t give errors, but in any case were very slow, more then 22 seconds.
    Doing a profiling i see that 21.5 seconds on 22.5 the script was idle; disabling the jquery calls doesn’t change this behaviour.
    On of the test during profiling never completed, remained idle fot 80 seconds without disabling lines

    I’ll try to create a jsfiddle, but perhaps will not be that easy.


    I also have this issue. It seems to happen when you destroy a chart, then null the reference. It looks like there are event handlers that aren’t being destroyed correctly. The minified source shows a lot of guards against undefined, but zero guards against null. This is a bit worrying considering that “null” is the suggested action after destroy.


    How much data series do you have? It works fine for me with ~ 20 data series

    Maybe try to change “if” condition with:

    chart.options.data[key].visible = !chart.options.data[key].visible


    I only have a single data series of ~8000 points. It might be that I need to decimate them.

    I think the destroy function isn’t fully destroying things though. Part of the issue might be the speed at which things happen. The playground for destroy doesn’t seem to stop the interactivity though…

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.