score:0
I know i am late here but his might help someone. The angular2-highchart package does provide the access to series event.
<chart [options]="options">
<series (click)="methodToCall($event)"
</series>
</chart>
<p>Series-Clicked={{data}}</p>
JS code.
methodToCall(e){
console.log("Method called");
this.data = e.originalEvent.point.name
}
Here is the updated Plunk.
score:0
**/*----- component method to generate Pie-chart from high chart Library -----*/**
drawPieChart() {
HighCharts.chart("pie_chart", {
accessibility: { enabled: false },
chart: {
type: 'pie',
plotBackgroundColor: '#FFF',
plotShadow: true
},
title: {
text: 'My Title'
},
tooltip: {
// pointFormat: '{point.y}<br/><b>{point.percentage:.1f}%</b>'
},
plotOptions: {
pie: {
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: true,
//format: '<b>{point.name}</b>: {point.y} '*//change .name & .y according to your data-set*
},
showInLegend: true,
events: {
click:
this.myCustomMethod.bind(this)
},
},//pie
},
series: [{
name: 'TA',
colorByPoint: true,
type: 'pie',
data: this.data,*// <<< here you need to put your JSON variable or Json object*
}]
});
}
**/* ---- on click event of pie myCustomMethos() 'll get call ---- */**
myCustomMethod(t:any) {
console.log(t.point.name)
}
score:9
You just need to replace the anonymous function by an arrow function or bind it to the component:
point: {
events: {
click: () => {
console.log(this);
// I want to call a component method here
}
}
}
or
point: {
events: {
click: (function(){
console.log(this);
// I want to call a component method here
}).bind(this)
}
}
or even :
point: {
events: {
click: this.myComponentMethod.bind(this)
}
}
score:13
To have access to the informations that the click event returns and also have access to your component methods you can do something like this:
plotOptions: {
series: {
turboThreshold:3000,
cursor: 'pointer',
point: {
events: {
click: function(e){
const p = e.point
this.myComponentMethod(p.category,p.series.name);
}.bind(this)
}
}
}
},
I hope this will help.
Source: stackoverflow.com
Related Query
- Call an angular component method when we click on highchart series
- Angular 5 is not rendering the component until click or hover anywhere
- using angular directive to draw highchart pie chart but when i am using it in success function it is not working
- HighChart hide other series on click legend
- Use a symfony route with parameters in a click event for highchart series
- Highchart is not resizing dynamically when used as a angular directive
- Vue js + HighChart - how can I make a synchronous axios call before the component get rendered?
- TypeError: p is not a function while calling map function in angular 4 for fetching series for bellcurve highchart
- Unable to trigger a click event on series data | Highchart
- Why is the legend of my HighChart PieChart behaving irradically, when I update my series data?
- pie chart legend overlap with older legend when replace series in highchart
- Call a function from within highchart click event in reactjs
- Hide a category when a series name has no value attributed to it highchart
- Highchart Drilldown with data call when clicked
- How to update HighChart series inside setInterval method
- Get all series values when click on single line chart
- Highcharts click events not firing when displaying multiple line series
- Why does my Highchart look different when I transfer my code from Jsfiddle to my server?
- Highcharts custom legend SVG symbol does not fade when you click to turn off series
- scrollable highchart works in JS but has issues when running through Angular HighCharts?
- Column based Highchart drilldown series assign color code to each column
- x-axis, y-axis lines does not appear, when I include 3D chart library of HighChart in my code
- Highcharts column chart returning incorrect series index on click when using shared tooltip
- How to trigger legend click event on outside when using Highchart and no using JQuery
- Angular 9 Highcharts - when using series of type pie with type gauge the innerSize of pie is not working
- How to show series dataLabels inside the Highchart pyramid in angular
- I am getting same highchart in pdf using jspdf when I am downloading the pdf with dynamic ids on click
- Plotting data onto highchart chart when series data uses named objects
- dynamic highchart series based on click
- Old highchart data in react component when going back and forward
More Query from same tag
- Implement Gantt Highcharts in react
- Array not passing data
- How do I modify the page I'm serving in node.js
- Highcharts not rendering after post ajax request
- How to customize graph title and subtitle
- width for the Highcharts/Highstock Export
- realign Labels inside and outside the bar chart on highcharts
- How to add the text boxes at bottom of the Highchart?
- Displaying Data in Django using HighCharts
- Highchart show percentage on group column highcharts
- Javascript - Convert timestamp into milliseconds for Highcharts Y axis
- Shared tooltips on a pie in a donut?
- Highcharts determine if text is outside of data point
- Can't get category labels to display
- Changing month names of a highchart plot
- Highcharts and Excel Slicers
- Is there a specific way to add data points from fetch() after a chart has been built?
- JSON parseString similar to parseInt per javascript?
- Second yAxis does not scale according to series in Highcharts
- Download Highchart Graph on different button click
- See Highcharts tooltip under a image
- Highcharts Default Colors Are Not Same at Pie and Column?
- Angular2 and Highcharts map - map bubbles not showing up
- Highcharts - Return string to other container on hover
- Highcharts xrange refuses to exhibit drilldown behavior
- How to loop through highcharts theme
- Highcharts Onclick a PieChart slice should refresh the chart
- highcharts on top of google map
- How to build chart in highchart.js where xAxis(miliseconds) and yAxis(days)?
- Highcharts: Custom area outline for line joining each marker