get serieName and category value using highcharts

不羁岁月 提交于 2019-12-25 03:54:23

问题


I am using basic column chart from highchart component, and one feature that I need to implement is draw a popup (using popover) with information related with the selected series and selected category. In the code below you can see that I am attaching popover component to every column:

load: function(e) {  
    $(".highcharts-tracker rect").hover(function() {                            
        $(this).attr('data-content',  
                'here should be a nice call to my web api method');
    }).popover({trigger:'hover', placement:'right'}).hover(function() {

As you see above, what I have done is the creation of the popup using popover component. My question now is related with get the series name and the category for the selected series in order to call to my web API method. If you see image below, for the selected column I need to get the values (serie1, 2016).

Any ideas? JSFiddle: Column chart


回答1:


You can hook into the point events to detect when the mouse is over a series. At that point, you have access to the series name etc.

 plotOptions: {
        series: {
            point: {
                events: {
                    mouseOver: function () {
                        $(".popover").text(
                        this.series.name);
                    }
                }
            }
        }
    },

http://jsfiddle.net/65VtA/



来源:https://stackoverflow.com/questions/25018716/get-seriename-and-category-value-using-highcharts

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