
在vue项目开发中如何利用百度echarts做一个饼图数据分析图,下面web建站小编给大家简单介绍一下具体实现代码,如右图!
1、在需要的页面引入
import * as echarts from 'echarts' //如果没有安装,根据提示安装echarts
2、实现代码如下:
drawPie() {
var myindex = 0
var colorArr = [
{
c1: '#3266f6',
c2: '#661dcf'
},
{
c1: '#ec489e',
c2: '#fdae40'
},
{
c1: '#4b96e0',
c2: '#4fdac5'
},
{
c1: '#4fabda',
c2: '#1395d8'
}
]
let myPieChart = echarts.init(document.getElementById('pies'))
myPieChart.setOption({
title: {
text: ''
},
tooltip: {
trigger: 'item',
formatter: '{b}: {c}个 ({d}%)'
},
legend: {
top: '10%',
itemGap: 10 //图例之间间距
},
series: {
name: '近三十天访问统计',
type: 'pie',
silent: true,
radius: ['0', '75%'],
center: ['50%', '55%'],
avoidLabelOverlap: false,
minAngle: 15, //最小角度
zlevel: 1,
itemStyle: {
normal: {
color: function(params) {
let colorList = colorArr
return new echarts.graphic.LinearGradient(1, 0, 0, 0, [
{
//颜色渐变函数 前四个参数分别表示四个位置依次为左、下、右、上
offset: 0,
color: colorList[params.dataIndex].c1
},
{
offset: 1,
color: colorList[params.dataIndex].c2
}
])
}
}
},
label: {
normal: {
show: true,
position: 'inner',
formatter: '{b}:{d}%\n{c}',
lineHeight: 15,
color: '#fff'
}
},
labelLine: {
normal: {
show: false
}
},
data: [
{ name: '学习', value: 300 },
{ name: '资料', value: 500 },
{ name: '下载', value: 200 }
]
}
})
},
富婆图表:提供近30种不同类型的图表,包括折线图、柱状图、饼图等
百度echarts雷达图radar根据分数点显示每个不同颜色
上面是“vue+百度echarts做一个饼图”的全面内容,想了解更多关于 js 内容,请继续关注web建站教程。
当前网址:https://m.ipkd.cn/webs_3692.html
声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

wordpress如何优化wp_title实现满足网站SEO
推荐一款图片、视频和设计模板下载的素材网站——FOCA(免费可商用)
MakeBestMusic
百度搜索引擎喜欢收录什么样的网站?
一个来自俄罗斯的免费游戏下载网站——BYRUTOR