工具提示在whilte区域以及lat-lon mappoint Highmaps

时间:2018-03-14 11:54:13

标签: highcharts highmaps

我正在与Highmaps合作,并且陷入了关于用lat-lon位置绘制的mappoints的工具提示问题。

一切都是正确的,但工具提示是针对最接近鼠标光标的点。 这导致即使在地图的白色容器区域上也显示工具提示。

当地图上有多个lat-lon点时,这会导致问题。

我尝试在点上使用鼠标悬停和鼠标移出事件,但结果相同,从鼠标远处检测到点。

问题也出现在Highmaps lat-lon演示中。

http://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/maps/demo/mappoint-latlon/

[<script src="https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.3.6/proj4.js"></script>
<script src="https://code.highcharts.com/maps/highmaps.js"></script>
<script src="https://code.highcharts.com/maps/modules/exporting.js"></script>
<script src="https://code.highcharts.com/maps/modules/offline-exporting.js"></script>
<script src="https://code.highcharts.com/mapdata/countries/gb/gb-all.js"></script>

<div id="container"></div>


// Initiate the chart
Highcharts.mapChart('container', {

    chart: {
        map: 'countries/gb/gb-all'
    },

    title: {
        text: 'Highmaps basic lat/lon demo'
    },

    mapNavigation: {
        enabled: true
    },

    tooltip: {
        headerFormat: '',
        pointFormat: '<b>{point.name}</b><br>Lat: {point.lat}, Lon: {point.lon}'
    },

    series: \[{
        // Use the gb-all map with no data as a basemap
        name: 'Basemap',
        borderColor: '#A0A0A0',
        nullColor: 'rgba(200, 200, 200, 0.3)',
        showInLegend: false
    }, {
        name: 'Separators',
        type: 'mapline',
        nullColor: '#707070',
        showInLegend: false,
        enableMouseTracking: false
    }, {
        // Specify points using lat/lon
        type: 'mappoint',
        name: 'Cities',
        color: Highcharts.getOptions().colors\[1\],
        data: \[{
            name: 'London',
            lat: 51.507222,
            lon: -0.1275
        }, {
            name: 'Birmingham',
            lat: 52.483056,
            lon: -1.893611
        }, {
            name: 'Leeds',
            lat: 53.799722,
            lon: -1.549167
        }, {
            name: 'Glasgow',
            lat: 55.858,
            lon: -4.259
        }, {
            name: 'Sheffield',
            lat: 53.383611,
            lon: -1.466944
        }, {
            name: 'Liverpool',
            lat: 53.4,
            lon: -3
        }, {
            name: 'Bristol',
            lat: 51.45,
            lon: -2.583333
        }, {
            name: 'Belfast',
            lat: 54.597,
            lon: -5.93
        }, {
            name: 'Lerwick',
            lat: 60.155,
            lon: -1.145,
            dataLabels: {
                align: 'left',
                x: 5,
                verticalAlign: 'middle'
            }
        }\]
    }\]
});]

当鼠标完全出现在该点上时,有没有办法显示工具提示。

1 个答案:

答案 0 :(得分:1)

您正在寻找stickyTracking

  

粘性跟踪鼠标事件。如果为true,则直到鼠标移动到另一个系列或超出绘图区域时才会触发系列上的mouseOut事件。如果为false,则当鼠标离开系列图形或标记周围的区域时,将触发系列上的mouseOut事件。这也意味着不共享时的工具提示。当stickyTracking为false且tooltip.shared为false时,在系列之间移动鼠标时将隐藏工具提示。对于行和区域类型系列,默认为true,但对于列,饼等,则默认为false。

因此,通过设置这样的plotOptions,它将被禁用:

plotOptions: {
  mappoint: {
    stickyTracking: false,
  }
}

工作示例: http://jsfiddle.net/ewolden/qgoc1p5z/

相关问题