echarts 加单位 加数字单位


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>

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM