Removing legend from chart.js Radar chart - javascript

I am using the Radar chart from Chart.js and I want to hide the legend(label) I did this:
new Chart("myChart", {
type: "radar",
data: data,
options: {
legend:{
display: false,
},
}
});
But is not working for some reasons also checked those:
Removing legend on charts with chart.js v2
Removing legend on charts with chart.js v2
I'm doing the same but not working

As described in the migration guide (https://www.chartjs.org/docs/master/getting-started/v3-migration.html#specific-changes) the legend has been moved to the plugins namespace so you will need to put it like so:
new Chart("myChart", {
type: "radar",
data: data,
options: {
plugins: {
legend: {
display: false,
},
}
}
});

Related

Is there a way to display legend's data over the chart in chart.js?

I've created a pie chart using the chart.js and react-chartjs-2 library but I was wondering if there is a way to display the data over the chart component and not as a tooltip while hovering about each area of the pie chart
What I wanted to do is display the data related to each area over itself, like on top of it.
The options can be added while creating new chart
var pieChart = new Chart(canvas, {
type: "pie",
data: data,
options: {
legend: {
display: true,
position : 'top'
},
tooltips: {
enabled: false
}
}
});

Chartjs - Changing legend as a line with pointsyle of circle?

const myLineChart = new Chart(viewsCount, {
type: 'line',
data: lineChartStats.data,
options: {
elements: {
line: {
tension: 0 // disables bezier curves
},
point: {
pointStyle: 'line'
}
},
legend: {
display: true,
position: "top",
align: "start",
labels: {
boxHeight: 3
usePointStyle : true,
}
}
}
Chartjs - Changing legend as a line with pointsyle of circle? What can I do to style the legend I'm using latest cdn of chartjs
Please read the migration guide to chart.js version 3, it has some.breaking changes for example legend config has been moved to the plugins section so you will have to do options: { plugins: { legend: {} } }
After that it should work, otherwise they have an example online where you can look at to see what's different https://www.chartjs.org/docs/latest/samples/legend/point-style.html

Adding zoom property to chartOptions doesn't add any zoom feature

I have a simple timeline chart built with vue-apexcharts (v.1.6.0).
As instructed by docs I added zoom property to chartOptions.chart:
chartOptions: {
chart: {
height: 350,
type: 'rangeBar',
zoom: {
enabled: true,
type: 'x',
resetIcon: {
offsetX: -10,
offsetY: 0,
fillColor: '#fff',
strokeColor: '#37474F'
},
selection: {
background: '#90CAF9',
border: '#0D47A1'
}
}
},
but it didn't add any zoom feature to the chart. The only additional features I have is Download SVG & Download PNG:
Since version 3.23.0, zoom works with the rangeBar charts too. Please update to the latest ApexCharts version and it will work.
Checkout the demo
UPDATE #junedchhipa just added support for zoomable rangeBar charts in v3.23.0 (updated demo)
In v3.22.x, the zoom option is not compatible with bar charts. You'll see it work for line charts:
chartOptions: {
chart: {
// type: 'rangeBar', // ❌ zoom does not work with bar charts
type: 'line', // ✅ ok
}
}
demo

Why the draggable plugin does not work for a radar chart in ChartJS?

Currently I am building a frontend application, that uses data like AirQuality and information about POIs. For displaying the rating of the single points I am using a radar chart with ChartJS (using it the First Time ever!).
I can already change the chart with input data, that is pushed to the chart after a button click. Another functionality I wanted to implement is the possibility to drag the endpoints of the radar chart to change the values.
I found the draggable plugin and I have tried to implement it, but it does not work like I thought it would.
This is the first time I am working with chartJS and I have found myself confused with the documentation about the plugin.
I am using plain JavaScript. No frameworks at all.
Here is the code for my chart:
var data = {
labels: ["Air", "POI", "Noise"],
datasets: [{
backgroundColor: "#50237f",
borderColor: "#50237f",
data: [33.3333333333, 33.3333333333, 33.3333333333],
label: 'Rating'
}]
};
var options = {
scale: {
ticks: {
min: 0,
max: 100,
stepSize: 25,
showLabelBackdrop: false
}
},
maintainAspectRatio: true,
spanGaps: false,
elements: {
line: {
tension: 0.000001
}
},
};
var ctx = document.getElementById("ratingChart");
var myChart = new Chart(ctx, {
type: 'radar',
data: data,
options: options,
config: {
plugins: {
// maybe set the plugin here? but how?
}
}
});

Remove tooltip from charts.js

I am using a plugin: charts.js
On hovering a radar chart (the bullets in it) a tooltip is shown. How can I remove it?
A layout for a chart with no tooltips would look like this:
var chart = new Chart(ctx, {
type: 'line',
data: data,
options: {
tooltips: { enabled: false },
...
}
})
I know some others have said exactly this, but this is a more complete example.
This is the code to Disable the tooltip option..
Chart.defaults.global.tooltips.enabled = false;
In ChartJS version 3.4.1 the tooltip configuration is located under options.plugins.tooltip - source
So a chart without tooltips would look like this:
var chart = new Chart(ctx, {
type: 'line',
data: data,
options: {
plugins: {
tooltip: { enabled: false },
...
}
}
})

Categories

Resources