echarts环形图

echarts环形图,第1张

this.pieDatas = [
                            [{
                                name: '正餐',
                                value: tmpObj.canteenAmount
                            }, {
                                name: '超市',
                                value: tmpObj.supermarketAmount
                            }, {
                                name: '其他',
                                value: tmpObj.otherAmount
                            }]
 ];

piechart: function() {
                var myChart = echarts.init(document.getElementById('consumer-preferences-pie'));
                var option = {
                    tooltip: {
                        trigger: 'item'
                    },
                    series: this.pieDatas.map(function(data, idx) {
                        return {
                            type: 'pie',
                            radius: ['33', '58'],
                            data: data,
                            itemStyle: {
                                borderColor: '#fff',
                                borderWidth: 3,
                            },
                            label: {
                                formatter: function(e) {
                                    return e.name + "\n" + e.value + '元';
                                },
                                padding: [0, 2],
                                rich: {
                                    color: 'rgba(0, 0, 0, 0.85)',
                                    fontSize: 12,
                                    fontFamily: 'PingFangSC-Regular, PingFang SC',
                                    fontWeight: 400,
                                    lineHeight: 17
                                }
                            }
                        };
                    }),
                    color: ['#00C47C', '#F6C723', '#FF8646']
                };
                option && myChart.setOption(option);
                window.addEventListener('resize', function() {
                    myChart.resize();
                })
 }

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1322343.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-12
下一篇 2022-06-12

发表评论

登录后才能评论

评论列表(0条)

保存