3

我已经搜索了答案,但没有找到任何有用的东西。因此,也许您可​​以帮助我如何使工具提示仅在我悬停点(标记)时出现在悬停时。区域类型使工具提示显示在图表的任何位置。我想要的只是当我的鼠标在标记上时显示工具提示。当我在指针下移动指针标记时,图表似乎“认为”我的鼠标已经在标记上。试图绑定系列对象的事件,但没有成功。

var chartOptions = {
            chart: {
                height: $('.sidebar').height()-100,
                zoomType: 'xy',
                spacingRight: 20,
                animation: true,
                renderTo: 'chart-container',

            },
            xAxis: {
                gridLineWidth: 1,
                type: 'linear',
                maxZoom: 1, // fourteen days
                title: {
                    text: 'Frequency (HZ)'
                }
            },
            yAxis: {
                min: 0,
                title: {
                    text: 'Acceleration (g)'
                }
            },
            tooltip: {

                enabled: true,
                formatter: function(){
                    if(this.series.name != 'Acceleration (g): '){
                        return false ;

                    }else {
                        return 'Frequency: <b>'+ parseFloat(this.x).toFixed(2) + '</b> Hz<br/>'+
                            'Acceleration: <b>' + parseFloat(this.y).toFixed(4) + '</b> g';
                    }

                },

            },
            legend: {
                enabled: false
            },
            plotOptions: {
                area: {
                    trackByArea: false,
                    fillColor: {
                        linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1},
                        stops: [
                            [0, Highcharts.getOptions().colors[0]],
                            [1, Highcharts.Color(Highcharts.getOptions().colors[0]).setOpacity(0).get('rgba')]
                        ]
                    },
                    lineWidth: 1,
                    marker: {
                        enabled: false,
                    },
                    shadow: false,
                    states: {
                        hover: {
                            lineWidth: 1
                        }
                    },
                    threshold: null,

                },
            },

            series: [{
                type: 'area',
                name: 'Acceleration (g): ',
                pointInterval: 1.953125,
                pointStart: 0,
                data: dataFFT.y,

            }]
        };
4

1 回答 1

3

这种行为不可能改变 - 相反,您禁用区域系列的标记和工具提示(在格式化程序中返回 false)并使用分散系列。完全按照您需要的方式分散系列。参见示例:http: //jsfiddle.net/mZt3r/

        tooltip :{ 
            shared: true,
            formatter: function() {
                if(this.points && this.points.length == 1) {
                    return false;   
                } else {
                    var p = this;
                    return 'x: ' + p.x + '<br/>y: ' + p.y;
                }
            }
        },
于 2013-07-08T13:39:53.297 回答