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

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.