假设我的折线图需要在数据后面添加MB的单位,而且折线图上有两条折线
则在tootip中添加formatter格式化数据:
var option = {
title: {
text: ''
},
tooltip : {
trigger: 'axis',
formatter: "{b} <br/>{a0} : {c0} MB<br/>{a1} : {c1} MB"
},
legend: {
data:['使用流量','套餐流量']
},
................................................
series : [
{
name:'使用流量',
type:'line',
stack: '总量',
areaStyle: {normal: {}},
data:chartdata2
},
{
name:'套餐流量',
type:'line',
stack: ' ',
areaStyle: {normal: {}},
data:chartMdata2
}
]
};.
若只有一条直线,则改为formatter: "{b} <br/>{a0} : {c0} MB"
其中a代表legend中的数据,b代表类别,c代表series中的数据