Heightcharts click on the graph to obtain the returned value (the first time a chart is clicked on ios, the click event cannot be triggered), heightchartsios
Requirement: Use the heightcharts plug-in to click the graph to obtain the return value of the clicked point,
Problem code:
(Function chart_line (){
Var data = {"title": ["01", "02", "03", "04", "05", "06", "07 ", "08", "09", "10", "11", "12"], "data": [10, 30, 50, 65, 80,340, 0,]};
Var chart = new Highcharts. Chart ('lineraph1 ',{
Chart :{
Type: 'spline'
},
Title :{
Text: 'Demo'
},
XAxis :{
Categories: data. title
},
YAxis :{
Title :{
Text :''
}
},
Legend :{
Enabled: false
},
Credits :{
Enabled: false
},
PlotOptions :{
Spline :{
DataLabels :{
Enabled: true // enable the data tag
},
EnableMouseTracking: true // when the mouse tracking is disabled, the corresponding prompt box and click event will become invalid.
},
Series :{
Cursor: 'pointer ',
Events :{
Click: function (event) {// normally, you can use this click event on the pc end and Android server.
Document. getElementById ('month'). innerText = event. point. x + 1 + 'month ';
Document. getElementById ('num'). innerText = this. data [event. point. x]. y;
},
},
}
},
Series :[{
Name: name,
Data: data. data
}]
});
})()
The Code obtains the values of x and y in the click event. when running the code, you will find that the click event is not triggered when you click the button for the first time on ios, but is triggered only when you start the second time.
The point. events. mouseOver attribute was found almost once in the heightcharts document. After being added, the expected result was achieved perfectly. The following is the code.
(Function chart_line (){
Var data = {"title": ["01", "02", "03", "04", "05", "06", "07 ", "08", "09", "10", "11", "12"], "data": [10, 30, 50, 65, 80,340, 0,]};
Var chart = new Highcharts. Chart ('lineraph1 ',{
Chart :{
Type: 'spline'
},
Title :{
Text: 'Demo'
},
XAxis :{
Categories: data. title
},
YAxis :{
Title :{
Text :''
}
},
Legend :{
Enabled: false
},
Credits :{
Enabled: false
},
PlotOptions :{
Spline :{
DataLabels :{
Enabled: true // enable the data tag
},
EnableMouseTracking: true // when the mouse tracking is disabled, the corresponding prompt box and click event will become invalid.
},
Series :{
Cursor: 'pointer ',
Point :{
Events :{
MouseOver: function (){
Document. getElementById ('month'). innerText = this. x + 1 + 'month ';
Document. getElementById ('num'). innerText = this. y;
}
}
},
}
},
Series :[{
Name: name,
Data: data. data
}]
});
})()
Conclusion: The first thought was to get the returned value after clicking. Therefore, I have been thinking about clicking events and ignoring other attributes. so the Fixed Thinking is terrible, think more about similar problems in the future, hahaha