码迷,mamicode.com
首页 > 其他好文 > 详细

echarts饼状图

时间:2018-02-26 13:35:09      阅读:213      评论:0      收藏:0      [点我收藏+]

标签:组件   let   ems   log   char   min   formatter   饼状图   blur   

1.vue

//引入Echarts主模块
import echarts from ‘echarts/lib/echarts‘
//引入线状图
import ‘echarts/lib/chart/pie‘
//引入所需组件
import ‘echarts/lib/component/tooltip‘
import ‘echarts/lib/component/title‘
import ‘echarts/lib/component/legend‘
<div class="pic_cont" ref="chartOne">
<div class="no-data-tip">
<div v-html="loading"></div>
</div>
</div>
methods: {
//性别比例
createChartOne(){
let chartOne = echarts.init( this.$refs.chartOne );
let option = {
tooltip: {
trigger: ‘item‘,
formatter: "{a} <br/>{b} : {c} ({d}%)"
},
legend: {
orient: ‘vertical‘,
right: ‘0‘,
bottom: ‘20‘,
data: [‘男‘, ‘女‘, ‘未知‘]
},
series: [
{
name: ‘性别比例‘,
type: ‘pie‘,
radius: [‘50%‘, ‘70%‘],
data: [
{ value: 335, name: ‘男‘ },
{ value: 310, name: ‘女‘ },
{ value: 234, name: ‘未知‘ }
],
itemStyle: {
emphasis: {
shadowBlur: 10,
shadowOffsetX: 0,
shadowColor: ‘rgba(0, 0, 0, 0.5)‘
}
}
}
]
};
chartOne.setOption( option, true );
}
}
效果:

技术分享图片

2.jq

<script src="<php>mc_autoVer(‘__SHOPS__/Js/echarts.min.js‘)</php>"></script>

<div class="pie-simple" id="pie-simple" style="position: relative;">
<div class="no-data-tip" style="display: block;color: #666;position: absolute;top: 50%;left: 0;width: 100%;text-align: center;font-size: 14px;">
<i class="fa fa-circle-o-notch fa-spin"></i> 互动粉丝比例,正在计算中...
</div>
</div>

//圆饼图1
var myChart1 = echarts.init(document.getElementById("pie-simple"));
option1 = {
title : {
text: ‘互动粉丝比例‘,
x:‘left‘
},
tooltip : {
trigger: ‘item‘,
formatter: "{a} <br/>{b} : {c} ({d}%)"
},
legend: {
orient: ‘vertical‘,
right: ‘0‘,
data:defualt_1
},
series : [
{
name: ‘访问来源‘,
type: ‘pie‘,
radius : ‘55%‘,
center: [‘40%‘, ‘60%‘],
data:interactionNum,
itemStyle: {
emphasis: {
shadowBlur: 10,
shadowOffsetX: 0,
shadowColor: ‘rgba(0, 0, 0, 0.5)‘
}
}
}
]
};
myChart1.setOption(option1,true);

效果:

技术分享图片

 

 

echarts饼状图

标签:组件   let   ems   log   char   min   formatter   饼状图   blur   

原文地址:https://www.cnblogs.com/miaSlady/p/8472444.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!