Skip to content
Closed
4 changes: 2 additions & 2 deletions src/chart/treemap/TreemapSeries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ interface BreadcrumbItemStyleOption extends ItemStyleOption {
}

interface TreemapSeriesLabelOption extends SeriesLabelOption {
ellipsis?: boolean
ellipsis?: string,
formatter?: string | ((params: CallbackDataParams) => string)
}

Expand Down Expand Up @@ -306,7 +306,7 @@ class TreemapSeriesModel extends SeriesModel<TreemapSeriesOption> {
upperLabel: {
show: true,
position: [0, '50%'],
ellipsis: true,
ellipsis: '...',
verticalAlign: 'middle'
}
},
Expand Down
26 changes: 25 additions & 1 deletion src/component/tooltip/TooltipHTMLContent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { isString, indexOf, each, bind, isArray, isDom } from 'zrender/src/core/util';
import { isString, indexOf, map, each, bind, isArray, isDom, retrieve } from 'zrender/src/core/util';
import { toHex } from 'zrender/src/tool/color';
import { normalizeEvent } from 'zrender/src/core/event';
import { transformLocalCoord } from 'zrender/src/core/dom';
Expand Down Expand Up @@ -400,6 +400,30 @@ class TooltipHTMLContent {
// it. Although it is not supported by IE8~IE10, fortunately it is a rare
// scenario.
+ `;pointer-events:${this._enterable ? 'auto' : 'none'}`;

const textStyleModel = tooltipModel.getModel('textStyle');
const userWidth = textStyleModel.get('width');
if (userWidth != null) {
style.cssText += `;width:${userWidth}px;`;
// `text-overflow_string` has very humble compatibility
// shttps://caniuse.com/mdn-css_properties_text-overflow_string
const ellipsis = retrieve(textStyleModel.get('ellipsis'), 'ellipsis');
const userOverflow = textStyleModel.get('overflow');
if (userOverflow) {
let overflowStyle;
if (userOverflow === 'truncate') {
overflowStyle = `overflow:hidden;text-overflow:${ellipsis};white-space:nowrap;`;
}
else {
const breakMode = userOverflow === 'break'
? 'break-word'
: userOverflow === 'breakAll'
? 'break-all' : '';
breakMode && (overflowStyle = `word-break:${breakMode};white-space:normal;`);
}
style.cssText += overflowStyle;
}
}
}

this._show = true;
Expand Down
11 changes: 8 additions & 3 deletions src/component/tooltip/TooltipRichContent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class TooltipRichContent {
style: {
rich: markupStyleCreator.richTextStyles,
text: content as string,
lineHeight: 22,
lineHeight: +textStyleModel.get('lineHeight') || 22,
backgroundColor: tooltipModel.get('backgroundColor'),
borderRadius: tooltipModel.get('borderRadius'),
borderWidth: 1,
Expand All @@ -103,10 +103,15 @@ class TooltipRichContent {
textShadowBlur: textStyleModel.get('textShadowBlur') || 0,
textShadowOffsetX: textStyleModel.get('textShadowOffsetX') || 0,
textShadowOffsetY: textStyleModel.get('textShadowOffsetY') || 0,
fill: tooltipModel.get(['textStyle', 'color']),
fill: textStyleModel.get('color'),
padding: getPaddingFromTooltipModel(tooltipModel, 'richText'),
verticalAlign: 'top',
align: 'left'
align: 'left',
width: +textStyleModel.get('width') || null,
height: +textStyleModel.get('height') || null,
overflow: textStyleModel.get('overflow'),
ellipsis: textStyleModel.get('ellipsis'),
lineOverflow: textStyleModel.get('lineOverflow')
},
z: tooltipModel.get('z')
});
Expand Down
5 changes: 5 additions & 0 deletions src/label/labelStyle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,11 @@ function setTextStyleCommon(
if (margin != null) {
textStyle.margin = margin;
}
const ellipsis = textStyleModel.get('ellipsis');
if (ellipsis) {
textStyle.ellipsis = ellipsis;
}
textStyle.lineOverflow = textStyleModel.get('lineOverflow');
setTokenTextStyle(textStyle, textStyleModel, globalTextStyle, opt, isNotNormal, isAttached, true, false);
}
// Consider case:
Expand Down
4 changes: 3 additions & 1 deletion src/util/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1358,10 +1358,12 @@ export interface CommonTooltipOption<FormatterParams> {
'color' | 'fontStyle' | 'fontWeight' | 'fontFamily' | 'fontSize' |
'lineHeight' | 'width' | 'height' | 'textBorderColor' | 'textBorderWidth' |
'textShadowColor' | 'textShadowBlur' | 'textShadowOffsetX' | 'textShadowOffsetY'
| 'align'> & {
| 'align' | 'overflow'> & {

// Available when renderMode is html
decoration?: string
ellipsis?: TextStyleProps['ellipsis']
lineOverflow?: TextStyleProps['lineOverflow']
}
}

Expand Down
21 changes: 17 additions & 4 deletions test/new-tooltip.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.