欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

echarts实例

程序员文章站 2022-06-14 14:57:20
...

echarts 官网:

https://www.echartsjs.com/index.html

 

echarts官方示例:

https://www.echartsjs.com/examples/

 

实例:

<!-- 引入文件 -->
<script src="/echars/echarts.common.min.js"></script>
<!-- div设置id -->
<div id="XXX"></div>

//初始化echarts
 var myChart = echarts.init(document.getElementById(XXX));

 var option = {
    tooltip: {
        trigger: 'item',
        formatter: "{a} <br/>{b}: {c} ({d}%)"
    },
    legend: {
        orient: 'vertical',
        x: 'left',
        data:['直接访问','邮件营销','联盟广告','视频广告','搜索引擎']
    },
    series: [
        {
            name:'访问来源',
            type:'pie',
            radius: ['50%', '70%'],
            avoidLabelOverlap: false,
            label: {
                normal: {
                    show: false,
                    position: 'center'
                },
                emphasis: {
                    show: true,
                    textStyle: {
                        fontSize: '30',
                        fontWeight: 'bold'
                    }
                }
            },
            labelLine: {
                normal: {
                    show: false
                }
            },
            data:[
                {value:335, name:'直接访问'},
                {value:310, name:'邮件营销'},
                {value:234, name:'联盟广告'},
                {value:135, name:'视频广告'},
                {value:1548, name:'搜索引擎'}
            ]
        }
    ]
};

 myChart.setOption(option);

 

相关标签: echarts