Sandip Patel
Sandip Patel

Reputation: 267

Unable to set Global Options in Chart.js

I am using following code to set global options in Chart.js

Chart.defaults.global = {
    animationSteps: 30,
    tooltipCornerRadius: 0
}

var ctx = document.getElementById("canvas").getContext("2d");
    var LChart = new Chart(ctx).Line(data, {
});

It however gives me error

TypeError: fn is not a function

on line 499 in Chart.js

How can I resolve this issue?

Upvotes: 4

Views: 4405

Answers (1)

potatopeelings
potatopeelings

Reputation: 41065

Instead of doing this

Chart.defaults.global = {
    animationSteps: 30,
    tooltipCornerRadius: 0
}

you should do this

Chart.defaults.global.animationSteps = 30;
Chart.defaults.global.tooltipCornerRadius = 0;

When you do the former, you are wiping out all the default values by putting in an entirely new global object (instead of just changing the properties you want to). The only way to get that to work would be define each and every property.

Upvotes: 10

Related Questions