Echarts 的Formatter的回调函数
Posted mxyr
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Echarts 的Formatter的回调函数相关的知识,希望对你有一定的参考价值。
1 option = { 2 tooltip: { 3 trigger: ‘axis‘, 4 formatter: function (params,ticket,callback) { 5 let res = params[0].name; 6 for (let i = 0, l = params.length; i < l; i++) { 7 res += ‘<br/>‘ + params[i].marker + params[i].seriesName + ‘ : ‘ + params[i].value + ‘KB/s‘; 8 } 9 return res 10 }, 11 axisPointer: { 12 type: ‘shadow‘ 13 } 14 }, 15 legend: { 16 itemGap: 15, 17 top: 20, 18 data: [‘流出‘, ‘流入‘] 19 }, 20 color: [‘#5170ac‘, ‘#77acff‘], 21 grid: { 22 left: ‘3%‘, 23 right: ‘4%‘, 24 bottom: ‘0%‘, 25 containLabel: true 26 }, 27 xAxis: { 28 type: ‘value‘, 29 position: ‘top‘, 30 show : false, 31 }, 32 yAxis: { 33 triggerEvent: true, 34 type: ‘category‘, 35 inverse:true, 36 axisLabel: { 37 formatter: function (value) { 38 let res = value; 39 if (res.length > 5) { 40 res = res.substring(0, 4) + ".."; 41 } 42 return res; 43 } 44 }, 45 data: [] 46 }, 47 }; 48 option = { 49 tooltip: { 50 trigger: ‘axis‘, 51 formatter: function (params,ticket,callback) { 52 let res = params[0].name; 53 for (let i = 0, l = params.length; i < l; i++) { 54 res += ‘<br/>‘ + params[i].marker + params[i].seriesName + ‘ : ‘ + params[i].value + ‘KB/s‘; 55 } 56 return res 57 }, 58 axisPointer: { 59 type: ‘shadow‘ 60 } 61 }, 62 legend: { 63 itemGap: 15, 64 top: 20, 65 data: [‘流出‘, ‘流入‘] 66 }, 67 color: [‘#5170ac‘, ‘#77acff‘], 68 grid: { 69 left: ‘3%‘, 70 right: ‘4%‘, 71 bottom: ‘0%‘, 72 containLabel: true 73 }, 74 xAxis: { 75 type: ‘value‘, 76 position: ‘top‘, 77 show : false, 78 }, 79 yAxis: { 80 triggerEvent: true, 81 type: ‘category‘, 82 inverse:true, 83 axisLabel: { 84 formatter: function (value) { 85 let res = value; 86 if (res.length > 5) { 87 res = res.substring(0, 4) + ".."; 88 } 89 return res; 90 } 91 }, 92 data: [] 93 }, 94 };
以上是关于Echarts 的Formatter的回调函数的主要内容,如果未能解决你的问题,请参考以下文章