You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by su...@apache.org on 2019/06/17 15:21:05 UTC
[incubator-echarts] 01/02: Fix default hover style of label in
circular layout of graph.
This is an automated email from the ASF dual-hosted git repository.
sushuang pushed a commit to branch fix/graph-circular-layout
in repository https://gitbox.apache.org/repos/asf/incubator-echarts.git
commit 166b9644aa506da2a44072e6430fbd852a971362
Author: sushuang <su...@gmail.com>
AuthorDate: Wed Jun 12 13:54:16 2019 +0800
Fix default hover style of label in circular layout of graph.
---
src/chart/graph/GraphView.js | 28 ++++++++++++++++++----------
src/util/graphic.js | 29 ++++++++++++++++++++++++-----
2 files changed, 42 insertions(+), 15 deletions(-)
diff --git a/src/chart/graph/GraphView.js b/src/chart/graph/GraphView.js
index 1b5477f..e9f5529 100644
--- a/src/chart/graph/GraphView.js
+++ b/src/chart/graph/GraphView.js
@@ -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
+ }
+ );
}
});
diff --git a/src/util/graphic.js b/src/util/graphic.js
index b8c2373..8795440 100644
--- a/src/util/graphic.js
+++ b/src/util/graphic.js
@@ -658,6 +658,29 @@ export function setLabelStyle(
}
/**
+ * 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`.
* @param {Object|module:zrender/graphic/Style} textStyle
@@ -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;
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org