I'm trying to get rid of the label "undefined" from showing at all at the top of my chart, as I only have one dataset and don't need a legend.
Here's my code:
// Radar chart data
var radarData = {
labels : ["Abs","Arms","Back","Butt","Chest","Legs","Shoulders"],
datasets : [
{
lavel: "test",
fillColor: "rgba(102,45,145,.1)",
strokeColor: "rgba(102,45,145,1)",
pointColor : "rgba(220,220,220,1)",
pointStrokeColor : "#fff",
data : [65,59,90,81,56,55,40]
}
]
};
// Create Radar chart
var ctx = document.getElementById("radarChart").getContext("2d");
var myNewChart = new Chart(ctx, {
type: "radar",
data: radarData
});
Adding "options: [scaleShowLabels=false]" doesn't work for some reason.
var myNewChart = new Chart(ctx, {
type: "radar",
data: radarData,
});
myNewChart.options.title.text = "top of chart"; // test, total fail
myNewChart.options.legend.display = false; // This one does it!
So apparently on the radar chart, that top element is called the legend. I was able to place a watch on myNewChart object in Chrome and step thru the code in dev tools.
Keep in mind that in Chart.js version 3, the options
now have a plugins
inner field, in which such options are to be configured.
So now it is:
options:{
plugins:{
legend:{
display:false
}
}
}
Or programmatically:
myNewChart.options.plugins.legend.display = false;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With