From 5aa68fdbf0250e8d014c3b96153c0b2d0c34894d Mon Sep 17 00:00:00 2001 From: zsmj Date: Tue, 28 Jun 2022 14:48:46 +0800 Subject: [PATCH] =?UTF-8?q?DESIGN-110=20feat:=20=E5=8F=8D=E9=A6=88-tooltip?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/base/single/tip/tip.tooltip.js | 39 ++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 10 deletions(-) diff --git a/src/base/single/tip/tip.tooltip.js b/src/base/single/tip/tip.tooltip.js index dc147492b..5499f05ac 100644 --- a/src/base/single/tip/tip.tooltip.js +++ b/src/base/single/tip/tip.tooltip.js @@ -39,16 +39,35 @@ BI.Tooltip = BI.inherit(BI.Tip, { mousemove: fn }); - this.text = BI.createWidget({ - type: "bi.label", - element: this, - textAlign: o.textAlign, - whiteSpace: "normal", - text: o.text, - textHeight: 20, - hgap: this._const.hgap, - vgap: this._const.vgap, - }); + var texts = (o.text + "").split("\n"); + if (texts.length > 1) { + BI.createWidget({ + type: "bi.vertical", + element: this, + hgap: this._const.hgap, + innerVgap: this._const.vgap, + items: BI.map(texts, function (i, text) { + return { + type: "bi.label", + textAlign: o.textAlign, + whiteSpace: "normal", + text: text, + textHeight: 18 + }; + }) + }); + } else { + this.text = BI.createWidget({ + type: "bi.label", + element: this, + textAlign: o.textAlign, + whiteSpace: "normal", + text: o.text, + textHeight: 18, + hgap: this._const.hgap, + vgap: this._const.vgap, + }); + } }, setWidth: function (width) {