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/02/27 18:10:34 UTC

[incubator-echarts] branch release updated: Fix: calculate label bounding rect error when rich used (e.g., containLabel: true while axisLabel has rich)

This is an automated email from the ASF dual-hosted git repository.

sushuang pushed a commit to branch release
in repository https://gitbox.apache.org/repos/asf/incubator-echarts.git


The following commit(s) were added to refs/heads/release by this push:
     new 76fabfa  Fix: calculate label bounding rect error when rich used (e.g., containLabel: true while axisLabel has rich)
76fabfa is described below

commit 76fabfa256e19e982cff803f81b797a16327840f
Author: sushuang <su...@gmail.com>
AuthorDate: Tue Feb 26 22:03:41 2019 +0800

    Fix: calculate label bounding rect error when rich used (e.g., containLabel: true while axisLabel has rich)
---
 src/model/mixin/textStyle.js |  1 +
 src/util/format.js           | 40 +++++++++++++++++++++++++++++++++++++++-
 2 files changed, 40 insertions(+), 1 deletion(-)

diff --git a/src/model/mixin/textStyle.js b/src/model/mixin/textStyle.js
index dbfea6b..67ddb45 100644
--- a/src/model/mixin/textStyle.js
+++ b/src/model/mixin/textStyle.js
@@ -56,6 +56,7 @@ export default {
             this.getShallow('align'),
             this.getShallow('verticalAlign') || this.getShallow('baseline'),
             this.getShallow('padding'),
+            this.getShallow('lineHeight'),
             this.getShallow('rich'),
             this.getShallow('truncateText')
         );
diff --git a/src/util/format.js b/src/util/format.js
index d00cce0..d499d52 100644
--- a/src/util/format.js
+++ b/src/util/format.js
@@ -236,4 +236,42 @@ export function capitalFirst(str) {
 
 export var truncateText = textContain.truncateText;
 
-export var getTextRect = textContain.getBoundingRect;
+/**
+ * @public
+ * @param {Object} opt
+ * @param {string} opt.text
+ * @param {string} opt.font
+ * @param {string} [opt.textAlign='left']
+ * @param {string} [opt.textVerticalAlign='top']
+ * @param {Array.<number>} [opt.textPadding]
+ * @param {number} [opt.textLineHeight]
+ * @param {Object} [opt.rich]
+ * @param {Object} [opt.truncate]
+ * @return {Object} {x, y, width, height, lineHeight}
+ */
+export function getTextBoundingRect(opt) {
+    return textContain.getBoundingRect(
+        opt.text,
+        opt.font,
+        opt.textAlign,
+        opt.textVerticalAlign,
+        opt.textPadding,
+        opt.textLineHeight,
+        opt.rich,
+        opt.truncate
+    );
+}
+
+/**
+ * @deprecated
+ * the `textLineHeight` was added later.
+ * For backward compatiblility, put it as the last parameter.
+ * But deprecated this interface. Please use `getTextBoundingRect` instead.
+ */
+export function getTextRect(
+    text, font, textAlign, textVerticalAlign, textPadding, rich, truncate, textLineHeight
+) {
+    return textContain.getBoundingRect(
+        text, font, textAlign, textVerticalAlign, textPadding, textLineHeight, rich, truncate
+    );
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org