You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by sh...@apache.org on 2020/07/23 05:06:46 UTC

[incubator-echarts] branch optimize-style updated: refact(state): useHoverLayer all replaced with states.emphasis.hoverLayer

This is an automated email from the ASF dual-hosted git repository.

shenyi pushed a commit to branch optimize-style
in repository https://gitbox.apache.org/repos/asf/incubator-echarts.git


The following commit(s) were added to refs/heads/optimize-style by this push:
     new 7a09ecc  refact(state): useHoverLayer all replaced with states.emphasis.hoverLayer
7a09ecc is described below

commit 7a09ecca29f56d6fd53fe8a4dd77c8e887cd4072
Author: pissang <bm...@gmail.com>
AuthorDate: Thu Jul 23 13:06:11 2020 +0800

    refact(state): useHoverLayer all replaced with states.emphasis.hoverLayer
---
 src/ExtensionAPI.ts                |  2 --
 src/chart/bar/BarView.ts           |  1 -
 src/chart/custom.ts                |  2 +-
 src/chart/heatmap/HeatmapView.ts   |  2 +-
 src/chart/helper/LineDraw.ts       |  3 ++-
 src/chart/helper/SymbolDraw.ts     |  3 ++-
 src/component/legend/LegendView.ts | 19 ++++++++++++++-----
 src/util/types.ts                  |  1 -
 8 files changed, 20 insertions(+), 13 deletions(-)

diff --git a/src/ExtensionAPI.ts b/src/ExtensionAPI.ts
index cb72d65..5211f67 100644
--- a/src/ExtensionAPI.ts
+++ b/src/ExtensionAPI.ts
@@ -55,8 +55,6 @@ abstract class ExtensionAPI {
 
     // Implemented in echarts.js
     abstract getCoordinateSystems(): CoordinateSystemMaster[];
-
-    // Implemented in echarts.js
     abstract getComponentByElement(el: Element): ComponentModel;
 }
 
diff --git a/src/chart/bar/BarView.ts b/src/chart/bar/BarView.ts
index eecb05d..2233b7f 100644
--- a/src/chart/bar/BarView.ts
+++ b/src/chart/bar/BarView.ts
@@ -626,7 +626,6 @@ const elementCreator: {
             shape: extend({}, layout),
             z2: 1
         });
-        // rect.autoBatch = true;
 
         rect.name = 'item';
 
diff --git a/src/chart/custom.ts b/src/chart/custom.ts
index e1775f5..3925f90 100644
--- a/src/chart/custom.ts
+++ b/src/chart/custom.ts
@@ -500,7 +500,7 @@ class CustomSeriesView extends ChartView {
         function setIncrementalAndHoverLayer(el: Displayable) {
             if (!el.isGroup) {
                 el.incremental = true;
-                el.useHoverLayer = true;
+                el.ensureState('emphasis').hoverLayer = true;
             }
         }
         for (let idx = params.start; idx < params.end; idx++) {
diff --git a/src/chart/heatmap/HeatmapView.ts b/src/chart/heatmap/HeatmapView.ts
index 2f04944..648168c 100644
--- a/src/chart/heatmap/HeatmapView.ts
+++ b/src/chart/heatmap/HeatmapView.ts
@@ -281,7 +281,7 @@ class HeatmapView extends ChartView {
             // PENDING
             if (incremental) {
                 // Rect must use hover layer if it's incremental.
-                rect.useHoverLayer = true;
+                rect.states.emphasis.hoverLayer = true;
             }
 
             group.add(rect);
diff --git a/src/chart/helper/LineDraw.ts b/src/chart/helper/LineDraw.ts
index 1aa100e..1dde5d3 100644
--- a/src/chart/helper/LineDraw.ts
+++ b/src/chart/helper/LineDraw.ts
@@ -154,7 +154,8 @@ class LineDraw {
     incrementalUpdate(taskParams: StageHandlerProgressParams, lineData: ListForLineDraw) {
         function updateIncrementalAndHover(el: Displayable) {
             if (!el.isGroup && !isEffectObject(el)) {
-                el.incremental = el.useHoverLayer = true;
+                el.incremental = true;
+                el.ensureState('emphasis').hoverLayer = true;
             }
         }
 
diff --git a/src/chart/helper/SymbolDraw.ts b/src/chart/helper/SymbolDraw.ts
index 756a15d..1fd78ae 100644
--- a/src/chart/helper/SymbolDraw.ts
+++ b/src/chart/helper/SymbolDraw.ts
@@ -256,7 +256,8 @@ class SymbolDraw {
 
         function updateIncrementalAndHover(el: Displayable) {
             if (!el.isGroup) {
-                el.incremental = el.useHoverLayer = true;
+                el.incremental = true;
+                el.ensureState('emphasis').hoverLayer = true;
             }
         }
         for (let idx = taskParams.start; idx < taskParams.end; idx++) {
diff --git a/src/component/legend/LegendView.ts b/src/component/legend/LegendView.ts
index 241b63b..8fcd734 100644
--- a/src/component/legend/LegendView.ts
+++ b/src/component/legend/LegendView.ts
@@ -39,7 +39,7 @@ import {
     ColorString
 } from '../../util/types';
 import Model from '../../model/Model';
-import Displayable from 'zrender/src/graphic/Displayable';
+import Displayable, { DisplayableState } from 'zrender/src/graphic/Displayable';
 import { PathStyleProps } from 'zrender/src/graphic/Path';
 import { parse, stringify } from 'zrender/src/tool/color';
 
@@ -585,6 +585,17 @@ function dispatchSelectAction(
     dispatchHighlightAction(seriesName, dataName, api, excludeSeriesId);
 }
 
+function isUseHoverLayer(api: ExtensionAPI) {
+    const list = api.getZr().storage.getDisplayList();
+    let emphasisState: DisplayableState;
+    let i = 0;
+    const len = list.length;
+    while (!(emphasisState = list[i].states.emphasis) && i < len) {
+        i++;
+    }
+    return emphasisState && emphasisState.hoverLayer;
+}
+
 function dispatchHighlightAction(
     seriesName: string,
     dataName: string,
@@ -592,8 +603,7 @@ function dispatchHighlightAction(
     excludeSeriesId: string[]
 ) {
     // If element hover will move to a hoverLayer.
-    const el = api.getZr().storage.getDisplayList()[0];
-    if (!(el && el.useHoverLayer)) {
+    if (!isUseHoverLayer(api)) {
         api.dispatchAction({
             type: 'highlight',
             seriesName: seriesName,
@@ -610,8 +620,7 @@ function dispatchDownplayAction(
     excludeSeriesId: string[]
 ) {
     // If element hover will move to a hoverLayer.
-    const el = api.getZr().storage.getDisplayList()[0];
-    if (!(el && el.useHoverLayer)) {
+    if (!isUseHoverLayer(api)) {
         api.dispatchAction({
             type: 'downplay',
             seriesName: seriesName,
diff --git a/src/util/types.ts b/src/util/types.ts
index 8bb7658..8d6ff52 100644
--- a/src/util/types.ts
+++ b/src/util/types.ts
@@ -99,7 +99,6 @@ export interface ComponentTypeInfo {
 }
 
 export interface ECElement extends Element {
-    useHoverLayer?: boolean;
     tooltip?: CommonTooltipOption<unknown> & {
         content?: string;
         formatterParams?: unknown;


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org