提交 4d979f8d 编写于 作者: S sushuang

Fix default hover style of label in circular layout of graph.

上级 41b21425
...@@ -62,7 +62,7 @@ function fadeOutItem(item, opacityPath, opacityRatio) { ...@@ -62,7 +62,7 @@ function fadeOutItem(item, opacityPath, opacityRatio) {
function fadeInItem(item, opacityPath) { function fadeInItem(item, opacityPath) {
var opacity = getItemOpacity(item, opacityPath); var opacity = getItemOpacity(item, opacityPath);
var el = item.getGraphicEl(); var el = item.getGraphicEl();
// Should go back to normal opacity first, consider hoverLayer, // Should go back to normal opacity first, consider hoverLayer,
// where current state is copied to elMirror, and support // where current state is copied to elMirror, and support
// emphasis opacity here. // emphasis opacity here.
el.traverse(function (child) { el.traverse(function (child) {
...@@ -221,17 +221,25 @@ export default echarts.extendChartView({ ...@@ -221,17 +221,25 @@ export default echarts.extendChartView({
rad = rad - Math.PI; rad = rad - Math.PI;
} }
var textPosition = isLeft ? 'left' : 'right'; var textPosition = isLeft ? 'left' : 'right';
symbolPath.setStyle({ graphic.modifyLabelStyle(
textRotation: -rad, symbolPath,
textPosition: textPosition, {
textOrigin: 'center' textRotation: -rad,
}); textPosition: textPosition,
symbolPath.hoverStyle && (symbolPath.hoverStyle.textPosition = textPosition); textOrigin: 'center'
},
{
textPosition: textPosition
}
);
} }
else { else {
symbolPath.setStyle({ graphic.modifyLabelStyle(
textRotation: labelRotate *= Math.PI / 180 symbolPath,
}); {
textRotation: labelRotate *= Math.PI / 180
}
);
} }
}); });
......
...@@ -657,6 +657,29 @@ export function setLabelStyle( ...@@ -657,6 +657,29 @@ export function setLabelStyle(
emphasisStyle.text = emphasisStyleText; emphasisStyle.text = emphasisStyleText;
} }
/**
* Modify label style manually.
* Only works after `setLabelStyle` and `setElementHoverStyle` called.
*
* @param {module:zrender/src/Element} el
* @param {Object} [normalStyleProps] optional
* @param {Object} [emphasisStyleProps] optional
*/
export function modifyLabelStyle(el, normalStyleProps, emphasisStyleProps) {
var elStyle = el.style;
if (normalStyleProps) {
rollbackDefaultTextStyle(elStyle);
el.setStyle(normalStyleProps);
applyDefaultTextStyle(elStyle);
}
elStyle = el.__hoverStl;
if (emphasisStyleProps && elStyle) {
rollbackDefaultTextStyle(elStyle);
zrUtil.extend(elStyle, emphasisStyleProps);
applyDefaultTextStyle(elStyle);
}
}
/** /**
* Set basic textStyle properties. * Set basic textStyle properties.
* See more info in `setTextStyleCommon`. * See more info in `setTextStyleCommon`.
...@@ -842,10 +865,6 @@ function setTokenTextStyle(textStyle, textStyleModel, globalTextStyle, opt, isEm ...@@ -842,10 +865,6 @@ function setTokenTextStyle(textStyle, textStyleModel, globalTextStyle, opt, isEm
globalTextStyle.textBorderWidth globalTextStyle.textBorderWidth
); );
// Save original textPosition, because style.textPosition will be repalced by
// real location (like [10, 30]) in zrender.
textStyle.insideRawTextPosition = textStyle.textPosition;
if (!isEmphasis) { if (!isEmphasis) {
if (isBlock) { if (isBlock) {
textStyle.insideRollbackOpt = opt; textStyle.insideRollbackOpt = opt;
...@@ -936,7 +955,7 @@ function applyDefaultTextStyle(textStyle) { ...@@ -936,7 +955,7 @@ function applyDefaultTextStyle(textStyle) {
} }
var useInsideStyle = opt.useInsideStyle; var useInsideStyle = opt.useInsideStyle;
var textPosition = textStyle.insideRawTextPosition; var textPosition = textStyle.textPosition;
var insideRollback; var insideRollback;
var autoColor = opt.autoColor; var autoColor = opt.autoColor;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册