formatter: function (array) { return array.seriesName + "<br/>" + array.marker + array.name + "平均体重" + array.value + "KG" }
完整代码:
<div id="ChartB" style="height: 300px"></div> <script type="text/javascript"> var chartDom = document.getElementById(‘ChartB‘); var myChart = echarts.init(chartDom); var option = { tooltip: { trigger: ‘item‘, formatter: function (array) { return array.seriesName + "<br/>" + array.marker + array.name + "平均体重" + array.value + "KG" } }, xAxis: { type: ‘category‘, data: [‘2020-10‘, ‘2020-11‘, ‘2020-12‘, ‘2021-01‘, ‘2021-02‘, ‘2021-03‘], axisLine: { show: true } }, yAxis: { type: ‘value‘, name: ‘KG‘, axisLine: { show: true } }, legend: { bottom: ‘0px‘ }, grid: { top: ‘30px‘, left: ‘40px‘, right: ‘10px‘, bottom: ‘50px‘ }, series: [ { name: ‘肉牛‘, data: [40, 45, 45, 50, 55, 60], type: ‘line‘, smooth: true }, { name: ‘牛犊‘, data: [55, 60, 65, 70, 75, 80], type: ‘line‘, smooth: true }, { name: ‘公牛‘, data: [60, 65, 65, 63, 62, 60], type: ‘line‘, smooth: true }, { name: ‘母牛‘, data: [70, 70, 72, 65, 68, 69], type: ‘line‘, smooth: true } ] }; option && myChart.setOption(option); </script>
原文:https://www.cnblogs.com/blts/p/14848536.html