echarts realizes 3D pie chart

echarts is a powerful data visualization tool that can help us create various charts quickly and easily.

To implement a 3D pie chart in echarts, you need to use the components seriesin the series of echarts pie3D.

Here is a simple example showing how to create a 3D pie chart using echarts:

var myChart = echarts.init(document.getElementById('main'));

var option = {
    title: {
        text: '3D饼图',
        left: 'center'
    },
    series: [
        {
            type: 'pie3D',
            radius: ['50%', '80%'],
            data: [
                {
     
     value: 335, name: '直接访问'},
                {
     
     value: 310, name: '邮件营销'},
                {
     
     value: 274, name: '联盟广告'},
                {
     
     value: 235, name: '视频广告'},
                {
     
     value: 400, name: '搜索引擎'}
            ]
        }
    ]
};

myChart.setOption(option);

In the above code, we use pie3Dthe component, and set the radius to ['50%', '80%'], and then give the data [{value: 335, name: '直接访问'}, ...]. This will create a 3D pie chart.

Note that this is just a simple example, you can adjust the appearance and behavior of the chart by configuring more options, such as title, legend, label, animation, etc. For details, please refer to the official documentation of echarts.

Guess you like

Origin blog.csdn.net/weixin_35749440/article/details/128870357