score:1
You can get the clicked legend by this code. then you can select the same legend. I have created something similar like this with help of SO.
var canvas = document.getElementById('yourChartDiv');
var myChart = new Chart(canvas, chartData);
canvas.onclick = function(evt) {
var activePoint = myChart.getElementAtEvent(evt)[0];
var data = activePoint._chart.data;
var datasetIndex = activePoint._datasetIndex;
var lagend = data.datasets[datasetIndex].label;
//var value = data.datasets[datasetIndex].data[activePoint._index];
};
console.log(legend); // here is the legend
//Now select the bars with same legend.
Hope you can get at least a clue.
Source: stackoverflow.com
Related Query
- how to highlight the bars in stacked bar chart of chart.js on clicking a legend
- How to make bar chart animation where all bars grow at the same speed?
- In Stacked horizontal bar chart how to remove the vertical line in Chart.js?
- ChartJS: Highlight dataset in a stacked bar chart when hovering over the legend?
- How can I reduce the spacing between my legend and chart proper in my Chart.JS bar chart, and increase it in the graph area?
- Chart.js stacked bar chart text on top of the stacked bars
- How to fix a stacked logarithmic bar chart values to fit the grid
- How to reduce the gap between bars on bar chart
- Chart.js Bar Chart: How to remove space between the bars in v2.3?
- Chart.js Bar Chart - how to chart bars from 0
- How to create stacked bar chart using react-chartjs-2?
- Hide empty bars in Grouped Stacked Bar Chart - chart.js
- How to display inline values in a stacked bar chart with Chart.js?
- ChartJs bar chart - keep bars left instead of equally spread across the width
- How to hide the y axis and x axis line and label in my bar chart for chart.js
- How to have solid colored bars in angular-chart bar chart
- Chart js: how can I align the legend and the title
- PrimeNg bar chart how to show a label for the y-axis
- Stacked bar chart results in misaligned bars
- Add a custom label to the top or bottom of a stacked bar chart
- How can I datalabels and Sum display in the same time on a stacked bar
- Angular chart how to show the legend data value by default along with legend name
- Can I offset the bars in chart.js stacked bar chart?
- PrimeNg bar chart how do I hide the bar labels?
- how to customize tool tip while mouse go over bars on Chart js bar chart
- How to highlight a section of a stack in all bars in a stacked barchart in chartjs
- angular-chart.js : how to show numbers in each bar of stacked bar chart
- Chart.js: How to get x-axis labels to show on top of bars in bar chart
- Chart.Js how to hide datapoints with "0" value in Stacked Bar Chart
- How to use set the color for each bar in a bar chart using chartjs?
More Query from same tag
- Chart.js donut chart remains grey - no color
- Multiple datasets with one data value chartjs
- Using zoom/pan with ChartJS
- Chart.js extra undefined column
- Blazor Chart.js 2.0.2 raises onClick error
- how to setting chart js customization
- How to change default label of each bubble in bubble chart using chartjs-plugin-datalabels
- Updating a chart from chart.js in vue
- How to change line chart data label to icon or image in chart.js
- Timeline on Y axis, with chart.js
- Chart isn't updating with Response data (Chart.js 3.2.1, ng2-charts 3.0.0-beta.9)
- Chartjs Bar Chart showing old data when hovering
- Remove blank space in chart.js chart
- Need help adding Chart.js chart to a Modal window (I'm Using AngularJS)
- Chart JS Replace All Dataset Data
- Setting ticks of Chart.js in html.erb file
- How to make Laravel Charts
- Making the labels responsive in chart js
- How do I get a chart.js chart to display data in a Node/React web application?
- Images in ChartJS CustomTooltips
- Chart.js Line graph y-axis not starting from 0
- ChartJS add tooltip to a grouped bar chart
- ChartJS 3.x How to place tick label inside graph?
- chart.js break line in a label with a tooltip callback
- Add Extra label in a pie chart
- How to improve PDF rasterization quality in PhantomJS?
- how to make a chart linked to the C# database?
- Chart.js - doughnut show active segment tooltip (on click of external button)
- cartesian coordinate system with chart.js
- Have the time on x axes to show the last 24 hours from current time