【问题标题】:Updating column zIndex on legendItem mouseover/mouseout in Highcharts在 Highcharts 中更新 legendItem mouseover/mouseout 上的 zIndex 列
【发布时间】:2020-08-07 17:29:10
【问题描述】:

我有一张图表,其中提供的系列之一是其他值的“总”和。

我想要做的是让这个列最初位于其他列之后(或隐藏),然后在该系列的legendItem 悬停时将其置于最前面。

到目前为止,我已经能够增加系列中的 zIndex 以在“鼠标悬停”时将“总”列放在前面没问题,但在“鼠标悬停”上触发反向对我不起作用并且“总计”列保持在前面。

我也尝试过使用.toFront() 的类似解决方案,这很有效,但同样的问题是在鼠标移出时将列向后移动。

如何在 legendItem 悬停时将此列正确移动到前/后?

https://codesandbox.io/s/cold-night-9p0gk?file=/src/components/BarChart.vue:1272-1325

【问题讨论】:

    标签: javascript vue.js highcharts


    【解决方案1】:

    在“mouseout”上,您只能在堆叠系列上调用toFront 方法:

    chart.series.forEach(s => {
        if (s.name === 'Total') {
            s.legendItem.on('mouseover', () => {
                s.group.toFront();
            });
    
            s.legendItem.on('mouseout', () => {
                s.chart.series.forEach(item => {
                    if (s !== item) {
                        item.group.toFront();
                    }
                });
            });
        }
    });
    

    现场演示: http://jsfiddle.net/BlackLabel/mpduxwkh/

    API 参考: https://api.highcharts.com/class-reference/Highcharts.SVGElement#toFront

    【讨论】:

      猜你喜欢
      • 2013-01-13
      • 1970-01-01
      • 1970-01-01
      • 2011-03-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-04-05
      • 1970-01-01
      相关资源
      最近更新 更多