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/06/09 05:11:13 UTC
[incubator-echarts] branch label-enhancement updated: fix(toolbox):
fix icon emphasis status not keep when selected.
This is an automated email from the ASF dual-hosted git repository.
shenyi pushed a commit to branch label-enhancement
in repository https://gitbox.apache.org/repos/asf/incubator-echarts.git
The following commit(s) were added to refs/heads/label-enhancement by this push:
new 3a80a47 fix(toolbox): fix icon emphasis status not keep when selected.
3a80a47 is described below
commit 3a80a47a777f9852981477e07d4f6fd9ae67e1d1
Author: pissang <bm...@gmail.com>
AuthorDate: Tue Jun 9 13:10:08 2020 +0800
fix(toolbox): fix icon emphasis status not keep when selected.
---
src/component/toolbox/ToolboxView.ts | 62 +++++++++++++++++++++---------------
src/echarts.ts | 4 +--
2 files changed, 38 insertions(+), 28 deletions(-)
diff --git a/src/component/toolbox/ToolboxView.ts b/src/component/toolbox/ToolboxView.ts
index 4ecee54..f875032 100644
--- a/src/component/toolbox/ToolboxView.ts
+++ b/src/component/toolbox/ToolboxView.ts
@@ -143,8 +143,9 @@ class ToolboxView extends ComponentView {
const iconPaths = this.iconPaths;
option.iconStatus = option.iconStatus || {};
option.iconStatus[iconName] = status;
- // FIXME
- iconPaths[iconName] && iconPaths[iconName].trigger(status);
+ if (iconPaths[iconName]) {
+ graphic[status === 'emphasis' ? 'enterEmphasis' : 'leaveEmphasis'](iconPaths[iconName]);
+ }
};
if (feature instanceof ToolboxFeature) {
@@ -240,31 +241,40 @@ class ToolboxView extends ComponentView {
}, tooltipModel.option);
}
- graphic.enableHoverEmphasis(path);
-
- if (toolboxModel.get('showTitle')) {
- (path as ExtendedPath).__title = titlesMap[iconName];
- (path as graphic.Path).on('mouseover', function () {
- // Should not reuse above hoverStyle, which might be modified.
- const hoverStyle = iconStyleEmphasisModel.getItemStyle();
- const defaultTextPosition = toolboxModel.get('orient') === 'vertical'
- ? (toolboxModel.get('right') == null ? 'right' as const : 'left' as const)
- : (toolboxModel.get('bottom') == null ? 'bottom' as const : 'top' as const);
- textContent.setStyle({
- fill: (iconStyleEmphasisModel.get('textFill')
- || hoverStyle.fill || hoverStyle.stroke || '#000') as string,
- backgroundColor: iconStyleEmphasisModel.get('textBackgroundColor')
- });
- path.setTextConfig({
- position: iconStyleEmphasisModel.get('textPosition') || defaultTextPosition
- });
- textContent.ignore = false;
- })
- .on('mouseout', function () {
- textContent.ignore = true;
+ // graphic.enableHoverEmphasis(path);
+
+ (path as ExtendedPath).__title = titlesMap[iconName];
+ (path as graphic.Path).on('mouseover', function () {
+ // Should not reuse above hoverStyle, which might be modified.
+ const hoverStyle = iconStyleEmphasisModel.getItemStyle();
+ const defaultTextPosition = toolboxModel.get('orient') === 'vertical'
+ ? (toolboxModel.get('right') == null ? 'right' as const : 'left' as const)
+ : (toolboxModel.get('bottom') == null ? 'bottom' as const : 'top' as const);
+ textContent.setStyle({
+ fill: (iconStyleEmphasisModel.get('textFill')
+ || hoverStyle.fill || hoverStyle.stroke || '#000') as string,
+ backgroundColor: iconStyleEmphasisModel.get('textBackgroundColor')
});
- }
- path.trigger(featureModel.get(['iconStatus', iconName]) || 'normal');
+ path.setTextConfig({
+ position: iconStyleEmphasisModel.get('textPosition') || defaultTextPosition
+ });
+ textContent.ignore = !toolboxModel.get('showTitle');
+
+ // Use enterEmphasis and leaveEmphasis provide by ec.
+ // There are flags managed by the echarts.
+ graphic.enterEmphasis(this);
+ })
+ .on('mouseout', function () {
+ if (featureModel.get(['iconStatus', iconName]) !== 'emphasis') {
+ graphic.leaveEmphasis(this);
+ }
+ textContent.hide();
+ });
+
+ graphic[
+ featureModel.get(['iconStatus', iconName]) === 'emphasis'
+ ? 'enterEmphasis' : 'leaveEmphasis'
+ ](path);
group.add(path);
(path as graphic.Path).on('click', zrUtil.bind(
diff --git a/src/echarts.ts b/src/echarts.ts
index 4ce37ef..393808c 100644
--- a/src/echarts.ts
+++ b/src/echarts.ts
@@ -1668,10 +1668,10 @@ class ECharts extends Eventful {
): void {
each(dirtyList || ecIns._componentsViews, function (componentView: ComponentView) {
const componentModel = componentView.__model;
- componentView.render(componentModel, ecModel, api, payload);
-
clearStates(componentModel, componentView);
+ componentView.render(componentModel, ecModel, api, payload);
+
updateZ(componentModel, componentView);
updateHoverEmphasisHandler(componentView);
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org