Chart.js icon indicating copy to clipboard operation
Chart.js copied to clipboard

Changing Default Values

Open mikemedoro opened this issue 13 years ago • 4 comments

Could someone provide an example of how to change the defaults? I am trying to remove the point dots on the line chart but am not having any luck.

Here's my code: var lineChartData = { labels : ["Year","Week","Current"], datasets : [{ fillColor : "rgba(173,215,116,0.4)", strokeColor : "#4a9c45", pointColor : "rgba(220,220,220,1)", pointStrokeColor : "#fff", pointDot : false, data : [3,2.5,currentPrice] }] } var myLine = new Chart(document.getElementById("chart").getContext("2d")).Line(lineChartData);

mikemedoro avatar Mar 22 '13 22:03 mikemedoro

To remove the point dots on the line, you need to pass in pointDot: false from another object, not as a property on lineChartData.

For example,

var lineChartData = {
    labels : ["Year","Week","Current"],
        datasets : [{
        fillColor : "rgba(173,215,116,0.4)",
        strokeColor : "#4a9c45",
        pointColor : "rgba(220,220,220,1)",
        pointStrokeColor : "#fff",
        data : [2.5,3,4,5,10]
    }]
};

var opts = { pointDot: false };

var myLine = new Chart(document.getElementById("chart").getContext("2d")).Line(lineChartData, opts);

chenzihui avatar Mar 25 '13 05:03 chenzihui

mikemedora: Thanks for asking this question as I was puzzling over it as well. Having gone back and looked at the documentation, knowing the answer already, I can see that it was mentioned. However, it really seems like an example in the documentation is in order! Cheers, Will

ghost avatar Jun 22 '13 07:06 ghost

I believe this is now documented on http://www.chartjs.org/docs/ search for pointDot

Recommending to close issue

fulldecent avatar Sep 15 '14 16:09 fulldecent

Yep you can change default options globally or a chart typespecific level.

Docs here:http://www.chartjs.org/docs/#getting-started-global-chart-configuration

nnnick avatar Sep 25 '14 16:09 nnnick