Dynamically display User Input as tool-tip in Highcharts

风流意气都作罢 提交于 2020-01-03 07:06:05

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!