Home forums Using CanvasJS Holding Memory

Tagged: 

This topic contains 1 reply, has 2 voices, and was last updated by  Sunil Urs 3 years, 6 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #4612

    sumanparia
    Participant

    I have 17K datapoints.
    Every time i am calling makechart, heap is getting heavy.
    Only after 6 time calling makechart heap size 1mb.
    Any solution?

    function makechart() {
    $.getJSON(‘project/getCanvasJSdata?’+$(“#form_1”).serialize(), function(_dataLoc) {
    createChart(“chartContainer_1”,_dataLoc);

    });
    }
    function createChart(_divId, _dataLoc) {
    new CanvasJS.Chart(_divId, {
    title: {
    text: “Sample report”,
    },
    data: _dataLoc.D,
    legend: {
    verticalAlign: “bottom”,
    horizontalAlign: “center”
    },
    toolTip: {
    enabled: false,
    },
    axisX: {
    title: “”,
    labelAngle: 0,
    interval: 50,
    labelFontColor: “black”,
    labelFontSize: 10
    },
    axisY: {
    title: “”,
    interval: 60,
    labelFontSize: 10,
    labelFontColor: “black”,
    gridThickness: 0,
    }
    }).render();
    }

    #4613

    Sunil Urs
    Keymaster

    Suman,

    Looking at the code, I can say that the problem is because you are creating the an entirely new Chart every time – while previous chart is still there – check using firebug. Instead you should create only one Chart object and call chart.render() each time you want to update (after modifying the data).

    Here is a section on creating Dynamic Charts.

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

You must be logged in to reply to this topic.