提交 601259d7 编写于 作者: P pissang

fix: fix hover scale in graph and tree

上级 0bb61d02
......@@ -448,8 +448,8 @@ class GraphView extends ChartView {
const nodeScale = getNodeGlobalScale(seriesModel);
data.eachItemGraphicEl(function (el, idx) {
el.scaleX = el.scaleY = nodeScale;
data.eachItemGraphicEl(function (el: Symbol, idx) {
el.setSymbolScale(nodeScale);
});
}
......
......@@ -46,8 +46,8 @@ class Symbol extends graphic.Group {
/**
* Original scale
*/
private _scaleX: number;
private _scaleY: number;
private _sizeX: number;
private _sizeY: number;
private _z2: number;
......@@ -174,8 +174,8 @@ class Symbol extends graphic.Group {
const fadeIn = true;
const target: PathProps = {
scaleX: this._scaleX,
scaleY: this._scaleY
scaleX: this._sizeX,
scaleY: this._sizeY
};
fadeIn && (target.style = {
opacity: symbolPath.style.opacity
......@@ -276,16 +276,14 @@ class Symbol extends graphic.Group {
return useNameLabel ? data.getName(idx) : getDefaultLabel(data, idx);
}
this._scaleX = symbolSize[0] / 2;
this._scaleY = symbolSize[1] / 2;
this._sizeX = symbolSize[0] / 2;
this._sizeY = symbolSize[1] / 2;
symbolPath.ensureState('emphasis').style = hoverItemStyle;
if (hoverAnimation && seriesModel.isAnimationEnabled()) {
const scaleEmphasisState = this.ensureState('emphasis');
const scale = Math.max(1.1, 3 / this._scaleY + 1);
scaleEmphasisState.scaleX = scale;
scaleEmphasisState.scaleY = scale;
this.ensureState('emphasis');
this.setSymbolScale(1);
}
else {
this.states.emphasis = null;
......@@ -294,6 +292,17 @@ class Symbol extends graphic.Group {
graphic.enableHoverEmphasis(this);
}
setSymbolScale(scale: number) {
const emphasisState = this.states.emphasis;
if (emphasisState) {
const hoverScale = Math.max(scale * 1.1, 3 / this._sizeY + scale);
emphasisState.scaleX = hoverScale;
emphasisState.scaleY = hoverScale;
}
this.scaleX = this.scaleY = scale;
}
fadeOut(cb: () => void, opt?: {
keepLabel: boolean
}) {
......
......@@ -358,8 +358,8 @@ class TreeView extends ChartView {
const nodeScale = this._getNodeGlobalScale(seriesModel);
data.eachItemGraphicEl(function (el, idx) {
el.scaleX = el.scaleY = nodeScale;
data.eachItemGraphicEl(function (el: SymbolClz, idx) {
el.setSymbolScale(nodeScale);
});
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册