Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(symbol): fix emphasis.scale can't be reset and specified values may not be respected #17442

Merged
merged 4 commits into from
Jul 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions src/chart/helper/Symbol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { ColorString, BlurScope, AnimationOption, ZRColor, AnimationOptionMixin
import SeriesModel from '../../model/Series';
import { PathProps } from 'zrender/src/graphic/Path';
import { SymbolDrawSeriesScope, SymbolDrawItemModelOption } from './SymbolDraw';
import { extend, isNumber } from 'zrender/src/core/util';
import { extend } from 'zrender/src/core/util';
import { setLabelStyle, getLabelStatesModels } from '../../label/labelStyle';
import ZRImage from 'zrender/src/graphic/Image';
import { saveOldStyle } from '../../animation/basicTransition';
Expand Down Expand Up @@ -336,11 +336,19 @@ class Symbol extends graphic.Group {
symbolPath.ensureState('select').style = selectItemStyle;
symbolPath.ensureState('blur').style = blurItemStyle;

if (hoverScale) {
const scaleRatio = Math.max(isNumber(hoverScale) ? hoverScale : 1.1, 3 / this._sizeY);
emphasisState.scaleX = this._sizeX * scaleRatio;
emphasisState.scaleY = this._sizeY * scaleRatio;
}
// null / undefined / true means to use default strategy.
// 0 / false / negative number / NaN / Infinity means no scale.
const scaleRatio =
hoverScale == null || hoverScale === true
? Math.max(1.1, 3 / this._sizeY)
// PENDING: restrict hoverScale > 1? It seems unreasonable to scale down
: isFinite(hoverScale as number) && hoverScale > 0
? +hoverScale
: 1;
// always set scale to allow resetting
emphasisState.scaleX = this._sizeX * scaleRatio;
emphasisState.scaleY = this._sizeY * scaleRatio;

this.setSymbolScale(1);

toggleHoverEmphasis(this, focus, blurScope, emphasisDisabled);
Expand Down
1 change: 1 addition & 0 deletions test/runTest/actions/__meta__.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions test/runTest/actions/symbol.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions test/runTest/runtime/ActionPlayback.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

72 changes: 60 additions & 12 deletions test/symbol.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.