diff --git a/src/component/legend/LegendView.ts b/src/component/legend/LegendView.ts index e1c3bf7101..35b0779f2b 100644 --- a/src/component/legend/LegendView.ts +++ b/src/component/legend/LegendView.ts @@ -226,12 +226,14 @@ class LegendView extends ComponentView { .on('mouseover', curry(dispatchHighlightAction, seriesModel.name, null, api, excludeSeriesId)) .on('mouseout', curry(dispatchDownplayAction, seriesModel.name, null, api, excludeSeriesId)); - itemGroup.eachChild(child => { - const ecData = getECData(child); - ecData.seriesIndex = seriesModel.seriesIndex; - ecData.dataIndex = dataIndex; - ecData.ssrType = 'legend'; - }); + if (ecModel.ssr) { + itemGroup.eachChild(child => { + const ecData = getECData(child); + ecData.seriesIndex = seriesModel.seriesIndex; + ecData.dataIndex = dataIndex; + ecData.ssrType = 'legend'; + }); + } legendDrawnMap.set(name, true); } @@ -277,12 +279,14 @@ class LegendView extends ComponentView { .on('mouseover', curry(dispatchHighlightAction, null, name, api, excludeSeriesId)) .on('mouseout', curry(dispatchDownplayAction, null, name, api, excludeSeriesId)); - itemGroup.eachChild(child => { - const ecData = getECData(child); - ecData.seriesIndex = seriesModel.seriesIndex; - ecData.dataIndex = dataIndex; - ecData.ssrType = 'legend'; - }); + if (ecModel.ssr) { + itemGroup.eachChild(child => { + const ecData = getECData(child); + ecData.seriesIndex = seriesModel.seriesIndex; + ecData.dataIndex = dataIndex; + ecData.ssrType = 'legend'; + }); + } legendDrawnMap.set(name, true); } diff --git a/src/component/tooltip/TooltipView.ts b/src/component/tooltip/TooltipView.ts index 461db0174c..2a6f55f091 100644 --- a/src/component/tooltip/TooltipView.ts +++ b/src/component/tooltip/TooltipView.ts @@ -463,6 +463,11 @@ class TooltipView extends ComponentView { this._showAxisTooltip(dataByCoordSys, e); } else if (el) { + const ecData = getECData(el); + if (ecData.ssrType === 'legend') { + // Don't trigger tooltip for legend tooltip item + return; + } this._lastDataByCoordSys = null; let seriesDispatcher: Element; diff --git a/src/core/echarts.ts b/src/core/echarts.ts index 69978fd34b..3c0763a474 100644 --- a/src/core/echarts.ts +++ b/src/core/echarts.ts @@ -427,18 +427,20 @@ class ECharts extends Eventful { } - zrender.registerSSRDataGetter(el => { - const ecData = getECData(el); - const dataIndex = ecData.dataIndex; - if (dataIndex == null) { - return; - } - const hashMap = createHashMap(); - hashMap.set('series_index', ecData.seriesIndex); - hashMap.set('data_index', dataIndex); - ecData.ssrType && hashMap.set('ssr_type', ecData.ssrType); - return hashMap; - }); + if (opts.ssr) { + zrender.registerSSRDataGetter(el => { + const ecData = getECData(el); + const dataIndex = ecData.dataIndex; + if (dataIndex == null) { + return; + } + const hashMap = createHashMap(); + hashMap.set('series_index', ecData.seriesIndex); + hashMap.set('data_index', dataIndex); + ecData.ssrType && hashMap.set('ssr_type', ecData.ssrType); + return hashMap; + }); + } const zr = this._zr = zrender.init(dom, { renderer: opts.renderer || defaultRenderer,