问题
I want to take 12 inputs from the user using multiple areas in a popup dialog box.I want these inputs to be shown as tool-tips for multiple points of this graph http://www.highcharts.com/demo/line-labels Whichever examples i have come across till now don't mention anything about how to do this.Does anyone have any idea how to implement tooltips using text-area input given by user ???
回答1:
You can use the tooltip formatter option of the chart to render a custom tooltip for each point of the graph. In my example for every point I get the corresponding value of the nth input using eq selector and use its value in the tooltip.
The code look like this:
tooltip: {
formatter: function() {
var index = dataValues.indexOf(this.y);
var comment=$("input:eq("+(index)+")").val()
return 'The value for <b>'+ this.x +
'</b> is <b>'+ this.y +'</b> -->'+comment;
}
},
Here is a working fiddle: http://jsfiddle.net/IrvinDominin/RbenU/1/
Obviously you can change the logic according to your needs.
来源:https://stackoverflow.com/questions/16373013/dynamically-display-user-input-as-tool-tip-in-highcharts