官方案例:
https://www.highcharts.com.cn/demo/highcharts/synchronized-charts
展示图:

vue中使用
触发:
watch: {
chartList: {
handler (n) {
if (!this.mouseMove) {
this.mouseMove = true
setTimeout(() => {
this.handleMouse()
this.mouseMove = false
}, 50)
}
},
deep: false
}
},
mounted () {
this.handleMouse()
const _this = this
window.onresize = function () {
_this.isFullScreen = document.fullscreen
}
}
methods:
handleMouse () {
this.$refs.chartArea.$el.removeEventListener('mousemove', this.hoverCharts, false)
this.$refs.chartArea.$el.addEventListener('mousemove', this.hoverCharts)
},
hoverCharts (e) {
if (!this.chartList.length) return
this.highcharts.Pointer.prototype.reset = function () {
return undefined
}
let event = null
this.chartList.forEach(chart => {
event = chart.pointer.normalize(e)
const points = []
if (chart.series && chart.series.length) {
chart.series.forEach((serie, index) => {
const point = serie.searchPoint(event, true)
if (point) {
points.push(point)
point.highlight(e)
}
})
}
if (points.length) {
chart.tooltip.refresh(points)
}
})
this.highcharts.Point.prototype.highlight = function (event) {
this.onMouseOver()
}
}