Chartjs-Manipulate objects from inside a function

1👍

The issue is that your variable is only live within your function. Do something like

function createchart(...) {
    var kdchart = ...
    ...
    return kdchart;
}

And when you call this function go stick kdchart somewhere where you can find it–on the window object is no where else

0👍

It is because of scope of variable kdChart is not global. It is live until execution is inside that function otherwise it is dead.

Either you can create it globally or create that object onside one function and return but you have to call that function everywhere you need that and not necessary that you will get same reference.

Create Global object so that it will have only one copy to access.

Leave a comment