在Highcharts中动态显示用户输入作为工具提示 [英] Dynamically display User Input as tool-tip in Highcharts
问题描述
我想在弹出对话框中使用多个区域的用户输入12个输入。我希望这些输入显示为此图中多个点的工具提示。
http://www.highcharts.com/demo/line-labels
我到目前为止所遇到的任何例子没有提及如何做到这一点。任何人都有任何想法如何使用用户给出的文本区域输入实现工具提示???解决方案 / div>
您可以使用 工具提示格式化程序
选项来为图的每个点呈现自定义工具提示。
在我的例子中,我得到了第n个输入的相应值,使用
代码如下所示:
tooltip:{
formatter:function(){
var index = dataValues.indexOf(this.y);
var comment = $(input:eq(+(index)+))。val()
return'< b>'的值+ this.x +
'< / b>是< b>'+ this.y +'< / b> - > +评论;
$ b 下面是一个工作小提琴: http://jsfiddle.net/IrvinDominin/RbenU/1/
显然,您可以根据需要更改逻辑。
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 ???
解决方案 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.
这篇关于在Highcharts中动态显示用户输入作为工具提示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!