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

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

上级 41b21425
......@@ -62,7 +62,7 @@ function fadeOutItem(item, opacityPath, opacityRatio) {
function fadeInItem(item, opacityPath) {
var opacity = getItemOpacity(item, opacityPath);
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
// emphasis opacity here.
el.traverse(function (child) {
......@@ -221,17 +221,25 @@ export default echarts.extendChartView({
rad = rad - Math.PI;
}
var textPosition = isLeft ? 'left' : 'right';
symbolPath.setStyle({
textRotation: -rad,
textPosition: textPosition,
textOrigin: 'center'
});
symbolPath.hoverStyle && (symbolPath.hoverStyle.textPosition = textPosition);
graphic.modifyLabelStyle(
symbolPath,
{
textRotation: -rad,
textPosition: textPosition,
textOrigin: 'center'
},
{
textPosition: textPosition
}
);
}
else {
symbolPath.setStyle({
textRotation: labelRotate *= Math.PI / 180
});
graphic.modifyLabelStyle(
symbolPath,
{
textRotation: labelRotate *= Math.PI / 180
}
);
}
});
......
......@@ -657,6 +657,29 @@ export function setLabelStyle(
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.
* See more info in `setTextStyleCommon`.
......@@ -842,10 +865,6 @@ function setTokenTextStyle(textStyle, textStyleModel, globalTextStyle, opt, isEm
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 (isBlock) {
textStyle.insideRollbackOpt = opt;
......@@ -936,7 +955,7 @@ function applyDefaultTextStyle(textStyle) {
}
var useInsideStyle = opt.useInsideStyle;
var textPosition = textStyle.insideRawTextPosition;
var textPosition = textStyle.textPosition;
var insideRollback;
var autoColor = opt.autoColor;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册