score:3
Accepted answer
You can do this,
<canvas id="pie" chart-click="onClick" class="chart chart-pie"chart-data="data" chart-labels="labels"></canvas>
Controller:
app.controller('AppCtrl', ['$scope', function($scope){
$scope.labels = ["Download Sales", "In-Store Sales", "Mail-Order Sales"];
$scope.data = [300, 500, 100];
$scope.onClick = function (points, evt) {
console.log(points, evt);
};
}]);
score:1
If you still need help with that, for the recent version, you get the label with:
$scope.onClick = function (points, evt) {
console.log(points[0]._view.label);
}
score:2
A solution that worked for me to get the data when you click on a bar is the following
$scope.clickBar = (points, evt, element) => {
if (element != undefined) {
console.log(points,evt,element);
}
};
Source: stackoverflow.com
Related Query
- chart.js chart-click pass parameter in Angular controller
- Chart.js and Angular - Click Event on Chart
- How to pass a chart.js chart data object in json from a controller in asp.net mvc
- Angular Chart Js legends click event not working
- Chart.js: Bar Chart Click Events
- How to add an on click event to my Line chart using Chart.js
- Click event on stacked bar chart - ChartJs
- Chart.js & Angular 2 - ng2-charts Custom on Click Event
- Problem for display a chart with Chart.js and Angular
- Angular 2 chart - change point radius
- Chart.js dataset controller 'null' when chart drawn
- Angular Chart JS prevent x label causing overflow
- Series Details Not Showing in Angular Chart with Charts.js
- chart.js - link to other page when click on specific section in chart
- Ng2-charts / chart.js - how to refresh/update chart - angular 4
- Extending Existing Chart Types angular chart js using chart js 2.0
- Chart.js Chart in Angular does not load until resizing browser window
- How to update data Chart in async way in Angular Chart.js?
- Angular 8 & ChartJs change color in pie chart
- Create multiple dynamic stacked chart using chart.js in Angular 10?
- Show labels on each sector to polar chart using angular js chart
- How to set single color on each bar in angular chart js
- Chart not rendering w/Chart.js on button click
- Angular chart how to show the legend data value by default along with legend name
- How to pass values to a chart (chart.js / morris.js)
- Removing chart on click event produces 'removeHoverStyle' of null error
- Click event of stacked line chart not working
- How to show percentage (%) using chartjs-plugin-labels ( Pie chart ) in angular 2/8
- How to add title inside doughnut chart in Angular Chart?
- Chart.js click on labels, using bar chart
More Query from same tag
- Polar Area Chart
- Set Scope in Angular-Charts.js after rendering
- Charts.js rendering issue on page load
- How to customize the title and tooltip in ux-chartjs?
- Chartjs tooltip out of page
- is there a way in JavaScript/TypeScript of adding two arrays in an object and sort them?
- Chartjs - show elements in all datasets on hover using bar chart
- How to set minimum height for bars graph
- how to put a y-axis and x-axis label while using html and chartjs
- How can I specify "per dataset" parsing with Chart.js?
- Line ChartJS empty / null values doesn't break the line
- Remove gap when updating ChartJS
- Get hash value Rails / Chart.JS
- How to update css for doughnut chart with ng2-charts
- Unable to draw a scatter chart with vue-charts
- Data not displaying in django admin - using chart.js (no errors)
- Custom scatter chart extended from scatter chart becomes line chart
- Is there a way to export chartjs-chart-treemap?
- Getting chart js bar chart to fill window
- ChartJS: Bar chart with axis ticks wider than categories
- Chartjs inner separation
- Refresh chart.config.data
- Can you do regions in line charts with Chart.js?
- How to create a charjs bar graph with many bars?
- Chart.js Time series - x axis that change depending on timestamp
- Fixed time frame in Chart.JS
- how to use vuechartkick in nuxt js
- Generate an indefinite number of charts as images (chart.js)
- Separating results in chartjs line chart
- The bar that contains a low value is almost invisible on the chartjs