折线(区域)图、柱状(条形)图、K线图 : {a}(系列名称),{b}(类目值),{c}(数值), {d}(无)
详细可见官网:https://echarts.apache.org/zh/option.html#tooltip.formatter
配置项:
{
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'shadow'
},
textStyle: {
fontSize: 12
},
formatter: `
{b} <br/>
{a} {c}<br />
`
},
}
效果图:当存在多个系列数据时,使用{a}、{c}只会展示第一个系列!!!
配置项:
{
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'shadow'
},
textStyle: {
fontSize: 12
},
formatter: `
{b} <br/>
{a0} {c0}<br />
{a1} {c1}<br />
{a2} {c2}<br />
`
},
}
效果图:当存在多个系列数据时,可以使用{a0}表示第一个系列的数据,{a1}表示第二个系列的数据,以此类推!!!
配置项:
{
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'shadow'
},
textStyle: {
fontSize: 12
},
formatter: `{b} <br/>
<span style="background-color: red;display: inline-block; width: 8px;height: 8px; border-radius: 50%;margin-right: 4px;line-height: 12px"></span>
{a0} {c0}<br />
<span style="background-color: red;display: inline-block; width: 8px;height: 8px; border-radius: 50%;margin-right: 4px;line-height: 12px"></span>
{a1} {c1}<br />
<span style="background-color: red;display: inline-block; width: 8px;height: 8px; border-radius: 50%;margin-right: 4px;line-height: 12px"></span>
{a2} {c2}<br />
`
},
}
效果图:字符串模也可以直接使用字符串模板来书写自定义标签样式,例如没一项数据前的market标识!!!