Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc(tooltip): add support for rich text styles in tooltip.textStyle #432

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions en/option/component/tooltip.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,53 @@ Whether mouse is allowed to enter the floating layer of tooltip, whose default v

Render mode for tooltip. By default, it is set to be `'html'` so that extra DOM element is used for tooltip. It can also set to be `'richText'` so that the tooltip will be rendered inside Canvas. This is very useful for environments that don't have DOM, such as Wechat applications.

## renderMode(string) = 'richText'
Render mode for tooltip. By default, it is set to be `'html'` so that extra DOM element is used for tooltip. It can also set to be `'richText'` so that the tooltip will be rendered inside Canvas. This is very useful for environments that don't have DOM, such as Wechat applications.
```ts
{
title: {
text: 'ECharts 入门示例'
},
tooltip: {
trigger: 'axis',
formatter: (e) => {
return `{d|● }{a|富文本测试}\n{b|富文本测试2}\n{c|富文本测试3\n富文本测试3\n富文本测试3}`;
},
renderMode: 'richText',
backgroundColor: "#fff",
textStyle: {
rich: {
a: {
fill: 'red',
},
b: {
fill: 'orange',
width: 300,
}, c: {
fill: 'yellow',
backgroundColor: 'green'
},
d: {
fill: 'orange',
fontSize:30
},
},
}
},
xAxis: {
data: ['衬衫', '羊毛衫', '雪纺衫', '裤子', '高跟鞋', '袜子']
},
yAxis: {},
series: [
{
name: '销量',
type: 'line',
data: [5, 20, 36, 10, 10, 20]
}
],
}
```

## confine(boolean) = false

<ExampleUIControlBoolean default="false" />
Expand Down
67 changes: 67 additions & 0 deletions zh/option/component/tooltip.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,73 @@ const option = {

浮层的渲染模式,默认以 `'html` 即额外的 DOM 节点展示 tooltip;此外还可以设置为 `'richText'` 表示以富文本的形式渲染,渲染的结果在图表对应的 Canvas 中,这对于一些没有 DOM 的环境(如微信小程序)有更好的支持。

## renderMode(string) = 'richText'

<ExampleUIControlEnum options="html,richText" default="html" />

浮层的渲染模式,默认以 `'html` 即额外的 DOM 节点展示 tooltip;此外还可以设置为 `'richText'` 表示以富文本的形式渲染,渲染的结果在图表对应的 Canvas 中,这对于一些没有 DOM 的环境(如微信小程序)有更好的支持。

<ExampleBaseOption name="tooltip" title="提示框 richText" title-en="Tooltip">
const option = {
backgroundColor: '#eee',
tooltip: {
show: true,
renderMode: 'richText',
enterable: true,
// position: [100, 100],
trigger: 'axis',
z: 100,
formatter: (e) => {
return e.map((v, i) => {
return `{label|${v.axisValueLabel}} = {c${i}|${v.value}}`
}).join('\n')
},
textStyle: {
rich: {
label: {
color: 'red',
},
c0: {
color: 'orange',
},
c1: {
color: 'yellow',
backgroundColor: 'green',
padding: 5,
borderColor: 'red',
borderWidth: 1,
},
c2: {
color: 'orange',
fontSize: 30,
height: 50
},
},
}
},
yAxis: {
type: 'value'
},
xAxis: {
type: 'category',
data: ['A', 'B', 'C']
},
series: [{
name: 'bar0',
type: 'bar',
data: [2, 3, 6]
}, {
name: 'bar1',
type: 'bar',
data: [1, 0, 9]
}, {
name: 'bar2',
type: 'bar',
data: ['-', 2, 1]
}]
};
</ExampleBaseOption>

## confine(boolean) = false

<ExampleUIControlBoolean default="false" />
Expand Down