From 20bed531f173cb17e1dc6d963e6e7e55f6117868 Mon Sep 17 00:00:00 2001 From: sushuang Date: Mon, 10 Jun 2019 18:47:42 +0800 Subject: [PATCH] Prevent treamap from using hover layer by default. Fix #10521 . Ref #10635 . --- src/chart/treemap/TreemapSeries.js | 3 ++- src/echarts.js | 25 ++++++++++++++++--------- test/tooltip-axisPointer.html | 8 +++++++- 3 files changed, 25 insertions(+), 11 deletions(-) diff --git a/src/chart/treemap/TreemapSeries.js b/src/chart/treemap/TreemapSeries.js index fca01740a5..be917ba8e8 100644 --- a/src/chart/treemap/TreemapSeries.js +++ b/src/chart/treemap/TreemapSeries.js @@ -32,6 +32,8 @@ export default SeriesModel.extend({ dependencies: ['grid', 'polar'], + preventUsingHoverLayer: true, + /** * @type {module:echarts/data/Tree~Node} */ @@ -40,7 +42,6 @@ export default SeriesModel.extend({ defaultOption: { // Disable progressive rendering progressive: 0, - hoverLayerThreshold: Infinity, // center: ['50%', '50%'], // not supported in ec3. // size: ['80%', '80%'], // deprecated, compatible with ec2. left: 'center', diff --git a/src/echarts.js b/src/echarts.js index bcbfddb4a7..e6ab5f13e7 100644 --- a/src/echarts.js +++ b/src/echarts.js @@ -1500,7 +1500,7 @@ function renderSeries(ecIns, ecModel, api, payload, dirtyMap) { scheduler.unfinished |= unfinished; // If use hover layer - updateHoverLayerStatus(ecIns._zr, ecModel); + updateHoverLayerStatus(ecIns, ecModel); // Add aria aria(ecIns._zr.dom, ecModel); @@ -1655,19 +1655,26 @@ echartsProto.dispose = function () { zrUtil.mixin(ECharts, Eventful); -function updateHoverLayerStatus(zr, ecModel) { +function updateHoverLayerStatus(ecIns, ecModel) { + var zr = ecIns._zr; var storage = zr.storage; var elCount = 0; + storage.traverse(function (el) { - if (!el.isGroup) { - elCount++; - } + elCount++; }); + if (elCount > ecModel.get('hoverLayerThreshold') && !env.node) { - storage.traverse(function (el) { - if (!el.isGroup) { - // Don't switch back. - el.useHoverLayer = true; + ecModel.eachSeries(function (seriesModel) { + if (seriesModel.preventUsingHoverLayer) { + return; + } + var chartView = ecIns._chartsMap[seriesModel.__viewId]; + if (chartView.__alive) { + chartView.group.traverse(function (el) { + // Don't switch back. + el.useHoverLayer = true; + }); } }); } diff --git a/test/tooltip-axisPointer.html b/test/tooltip-axisPointer.html index 4ae8da37f2..38adc911a6 100644 --- a/test/tooltip-axisPointer.html +++ b/test/tooltip-axisPointer.html @@ -460,7 +460,13 @@

tooltip.axisPointer.label.show: fasle

tooltip: { trigger: 'axis', axisPointer: { - type: 'cross' + type: 'cross', + label: { + formatter: function (params) { + console.log(params); + return 'asdfa'; + } + } } } };