You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by ov...@apache.org on 2018/07/03 07:33:50 UTC

[incubator-echarts] branch master updated: refactor(tooltip): improve code

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

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


The following commit(s) were added to refs/heads/master by this push:
     new a764e18  refactor(tooltip): improve code
a764e18 is described below

commit a764e180a1b97f356df43d3f568a3b234453c7d7
Author: Ovilia <zw...@gmail.com>
AuthorDate: Tue Jul 3 15:33:39 2018 +0800

    refactor(tooltip): improve code
---
 src/component/tooltip/TooltipView.js | 20 ++++++++++----------
 src/model/mixin/dataFormat.js        |  4 ++--
 2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/src/component/tooltip/TooltipView.js b/src/component/tooltip/TooltipView.js
index 4ce0d30..4647cbe 100644
--- a/src/component/tooltip/TooltipView.js
+++ b/src/component/tooltip/TooltipView.js
@@ -48,17 +48,16 @@ export default echarts.extendComponentView({
         if (env.node) {
             return;
         }
-        var tooltip = ecModel.get('tooltip');
 
+        var tooltipModel = ecModel.getComponent('tooltip');
+        var renderMode = tooltipModel.get('renderMode');
         this._renderMode = 'html';
-        if (tooltip.length) {
-            if (tooltip[0].renderMode === 'auto') {
-                // using html when `document` exists, use richtext otherwise
-                this._renderMode = document ? 'html' : 'richtext';
-            }
-            else {
-                this._renderMode = tooltip[0].renderMode || this._renderMode;
-            }
+        if (renderMode === 'auto') {
+            // using html when `document` exists, use richtext otherwise
+            this._renderMode = document ? 'html' : 'richtext';
+        }
+        else {
+            this._renderMode = renderMode || this._renderMode;
         }
 
         var tooltipContent;
@@ -500,7 +499,8 @@ export default echarts.extendComponentView({
 
         var params = dataModel.getDataParams(dataIndex, dataType);
         var seriesTooltip = dataModel.formatTooltip(dataIndex, false, dataType, this._renderMode);
-        var defaultHtml, markers;
+        var defaultHtml;
+        var markers;
         if (zrUtil.isObject(seriesTooltip)) {
             defaultHtml = seriesTooltip.html;
             markers = seriesTooltip.markers;
diff --git a/src/model/mixin/dataFormat.js b/src/model/mixin/dataFormat.js
index 11fd5e1..29e68fd 100644
--- a/src/model/mixin/dataFormat.js
+++ b/src/model/mixin/dataFormat.js
@@ -37,8 +37,8 @@ export default {
         var name = data.getName(dataIndex);
         var itemOpt = data.getRawDataItem(dataIndex);
         var color = data.getItemVisual(dataIndex, 'color');
-        var tooltip = this.ecModel.get('tooltip');
-        var renderMode = tooltip && tooltip.length ? tooltip[0].renderMode : 'auto';
+        var tooltipModel = this.ecModel.getComponent('tooltip');
+        var renderMode = tooltipModel.get('renderMode') || 'html';
 
         return {
             componentType: this.mainType,


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