score:1
Accepted answer
After you have looped through both data sets, i = 2 and k = 1. So the mouse events are always trying to use i=2 and k=1 to access the data point, which of course is out of bounds. See this fiddle: http://jsfiddle.net/bLvfS/1/
for (var i = 0; i < chartObj.series.length; i++) {
for (var k = 0; k < chartObj.series[i].data.length; k++) {
var onmouseover = function(u, j) {
return function() {chartObj.series[u].data[j].setState('hover');};
}
var onmouseout = function(u, j) {
return function() {chartObj.series[u].data[j].setState();};
}
chartObj.series[i].data[k].dataLabel.on("mouseover", onmouseover(i,k));
chartObj.series[i].data[k].dataLabel.on("mouseout", onmouseout(i,k));
}
}
I've added functions that get passed the current i,k pair and return the actual function you want to run on the mouse events. Maybe someone has a better solution... but it seems to work.
score:1
Problem is with closures, see working fiddle: http://jsfiddle.net/Fusher/bLvfS/2/
for (var i = 0; i < chartObj.series.length; i++) {
for (var k = 0; k < chartObj.series[i].data.length; k++) {
(function(i,k){
chartObj.series[i].data[k].dataLabel.on("mouseover", function () {
chartObj.series[i].data[k].setState('hover');
});
chartObj.series[i].data[k].dataLabel.on("mouseout", function () {
chartObj.series[i].data[k].setState();
});
})(i,k);
}
}
Source: stackoverflow.com
Related Query
- add each dataLabel a function on mouseover/mouseout
- highcharts.js add mouseOver function or hover states (implement breaks chart?)
- Highcharts saying undefined is not a function when trying to add a new chart
- HighCharts Pie Chart - Add text inside each slice
- How to add a label above each bar in HighCharts
- Add dataLabel to Area chart in Highcharts.js
- I want to add a line to each column in a Highcharts column chart
- How do i add mouse wheel code in Angular2 highcharts in typescript
- How to add different click events on each pie of a pie chart created by highcharts usin jquery
- Highcharts - how to show/hide multiple data labels on mouseOver and mouseOut
- Highcharts datalabel for each stacked column
- How to add one more value against at the end of each bar with a legend
- Add mouseover to outliers but not other points?
- Highcharts - how to get consistent mouseover and mouseout events for columns?
- Can I add my own property in 'this' of xAxis labels formatter function in High Charts?
- Javascript Highcharts: series datalabel formatter function to loop data not formatting all data form the array
- Add Title To Each Bubble in Packed Bubble Highcharts
- Add Source to Highcharts Export CSV
- how to add above each column a different pie chart
- Strange character in the Highstock source code
- How to add labels for highcharts activity gauge for each series
- How can add fade In() effect to each appearance of a div when the mouse click?
- (HighCharts) Color reverts on mouseOut after manual mouseOver
- highcharts.NET Add Additional Data to datalabel
- Column based Highchart drilldown series assign color code to each column
- Variable changing value at each function call
- How to add table on click over each column in Highcharts Reactjs?
- Add a line on each bar for stacked and grouped column in HighCharts
- How to add footer for each series stacked horizontal bars in highcharts?
- Add series / data to highchart gantt from function
More Query from same tag
- Setting tick interval dynamically in highstock chart
- Spider Chart (High Chart) in rails with Prawn PDF How to generate?
- Legend Item pattern rotation or mirroring problem
- Highcharts Org chart children links are overlapping
- how to import highcharts sub modules in React app
- bar chart with vertical scrollbar in (highstock/highchart)
- highcharts change rendered image source on click
- Fixed bar width, tick interval in Highstock
- how to disable or override the fonts inherited from svg in the web pages by default
- Highstocks - Display year when hovering over a point
- highchart custom menu with when i drilldown and drillup custom event (contextmenu) not working
- Highcharts draggable glitchy tooltip
- How to make click on area above / below small column, in unstacked column chart, fire the point click event
- Child component not loading correctly in ngFor (but updates after resizing windows)
- Displaying multiple series in the navigator of an HighStock chart
- ColorAxis in percentage bar. Approach. Highcharts
- Share tooltip between all series types
- Formatting JSON data monthwise for HighCharts using MySQL
- Highcharts datetimex axis incorrect start time and interval
- Highchart columnrange with scrollbar
- To rotate X (or) Y axis of rect ?
- highcharts tooltip not moving next point
- Highcharts - append % to first axis label?
- Highcharts piechart labels going out of parent
- Highcharts y-axis's max value is not what I expect it to be
- Bar graph background
- Wrong start date in irregular intervals chart
- Highcharts yaxis labels not working
- Primary and Secondary yAxis zero on different levels
- Highcharts - Show tooltip on points click instead mouseover