echarts让折线图的每个折点都显示数值

在 series中添加

itemStyle : { normal: {label : {show: true}}}
  • 1

在django中使用echarts折线图的完整代码

<script type="text/javascript">
var dom = document.getElementById("container");
var myChart = echarts.init(dom);
var app = {};
option = null;

result = eval({{ chart_data | safe }});

option = {
    title: {
        text: result.title,
        x: 'center',
        show : true
    },
    tooltip: {
        formatter: '{b}\n{c}'
     },
    xAxis: {
        type: 'category',
        data: result.feature
    },
    yAxis: {
        type: 'value'
    },
    series: [{
        data: result.data,
        type: 'line',
        // 显示数值
        itemStyle : { normal: {label : {show: true}}}
    }]

};


if (option && typeof option === "object") {
    myChart.setOption(option, true);
}
</script>

猜你喜欢

转载自blog.csdn.net/hzp666/article/details/80843366