<template>
<!-- 饼状图
1. 调用页面引入
import EcharsPie from '@/components/echarsPie.vue';
注:自定义的组件名称 不要使用关键字
components: {EcharsPie}
2. 调用页面入参:
<EcharsPie :dataList = "valObj"></EcharsPie>
valObj: {
title: "图表的标题名称",
tooltip: " 这是提示信息",
width: 400,
height: 300,
color: ["#1EAB8F", "#22D2FD", "#FFC000", "#828DA2", "#FF6023", "#0576FE"], //颜色 数组
seriesName: "设备状态",
yData: [
{ value: 20, name: "未知", dic_code: "0" },
{ value: 10, name: "工作", dic_code: "1" },
{ value: 90, name: "待机", dic_code: "2" },
{ value: 0, name: "停机", dic_code: "3" },
{ value: 0, name: "故障", dic_code: "4" },
{ value: 0, name: "调试", dic_code: "5" }
],
legendList:{
itemGap: 16, // 设置legend的间距
itemWidth: 30,// 设置宽度
itemHeight: 14, // 设置高度
orient: "vertical", //垂直显示还是水平显示
right: 0, //legend相对位置
bottom: 30,//legend相对位置
textStyle: { fontSize: "14" },//legend字体大小
data: ["未知", "工作", "待机", "停机", "故障", "调试"], // 数据
},
seriesStyle:{
lableShow:true,//是否出现提示文字
lableFontSize:14,//提示文字大小
lableLineShow:true,//是否出现提示线
lableLineLength:35,//提示线的长度
radius: "60%", //饼图的半径 若为数组,第一项是内半径,第二项是外半径。例['50%', '70%']
center: ["50%", "60%"], //中心(圆心)坐标,数组的第一项是横坐标,第二项是纵坐标。饼图相对中心的位置
}
}
-->
<div class="echart_box_pie">
<div class="echart_tit" v-show="dataList.title">{{dataList.title}}
<el-tooltip placement="bottom-start" effect="light" v-show="dataList.tooltip">
<div slot="content" v-html="dataList.tooltip">
</div>
<i class="el-icon-question"></i>
</el-tooltip>
</div>
<div class="echart_pie" :style="{width:dataList.width+'px',height:dataList.height+'px'}" id="echart_pie"></div>
</div>
</template> <script>
export default {
props: {
dataList: {
type: Object,
default: function() {
return {
width: 1400, //地图宽
height: 800 //地图高
};
}
}
},
data() {
return {};
},
mounted() {
this.initEcharsPie();
},
methods: {
//初始化echars柱状图,
initEcharsPie() {
var _this = this;
let myChart = this.$echarts.init(document.getElementById("echart_pie"));
myChart.clear();
// 绘制图表样式
let option = {
title: {
text: ""
},
color: this.dataList.color, //饼状图颜色数组
tooltip: {
trigger: "item",
formatter: "{a} <br/>{b} : {c} ({d}%)"
},
legend: this.dataList.legendList,
series: [
{
name: this.dataList.seriesName,
type: "pie",
radius: this.dataList.seriesStyle.radius,
center: this.dataList.seriesStyle.center,
data: this.dataList.yData,
itemStyle: {
emphasis: {
shadowBlur: 10,
shadowOffsetX: 0,
shadowColor: "rgba(0, 0, 0, 0.5)"
},
normal: {
label: {
//此处为指示线文字设置
show: this.dataList.seriesStyle.labelShow,
formatter: "{d}%\n{b}",
fontWeight: "normal",
fontSize: this.dataList.seriesStyle.lableFontSize
},
labelLine: {
//指示线状态
show: this.dataList.seriesStyle.lableLineShow,
length: this.dataList.seriesStyle.lableLineLength
}
}
}
}
]
};
myChart.setOption(option);
}
}
};
</script> <style lang="scss" scoped>
.echart_box_pie {
margin: 4px;
position: relative;
z-index: 1;
}
.echart_tit {
position: absolute;
top: 0;
left: 0;
z-index: 2;
width: 100%;
height: 40px;
line-height: 40px;
text-align: left;
padding-left: 14px;
box-sizing: border-box;
}
</style>

最新文章

  1. 免费制作gif图片工具
  2. 一步一步打造自己的Android图片浏览器(原创)
  3. 关于C#垃圾回收
  4. 学习笔记-- android动画简述
  5. object references an unsaved transient instance - save the transient instance before flushing错误
  6. &gt;&gt;&gt; FilterDispatcher &lt;&lt;&lt; is deprecated! Please use the new filters!
  7. 脱离rails 使用Active Record
  8. PetaPoco 笔记
  9. URL和DNS解析
  10. treeview右键添加新节点
  11. 【Android开发经验】使用反射,得到的类的字段、方法、并实现了简单的调用
  12. iOS开发系列-UI基础-KVC
  13. uploadify上传图片的类型错误的解决办法
  14. Nginx 1.10.1 版本nginx.conf优化配置及详细注释
  15. Python 科学计算-介绍
  16. C#Json转DataTable
  17. &ldquo;.Net 社区大会&rdquo;(dotnetConf) 2018 Day 1 主题演讲
  18. Java中的常用集合类型总结
  19. 20172306 2018-2019-2 《Java程序设计与数据结构》第八周学习总结
  20. 第45节:Java当中的变量,面向对象

热门文章

  1. 502 bad gateway nginx 的错误的解决方案
  2. WinEdit编辑器中中文乱码
  3. 解决 i18n properties文件中文必须是unicode的问题
  4. 在Rails中最方便集成使用Bootstrap的方式
  5. SQL 使用分区方法
  6. pluginManagement的坑
  7. BZOJ1491 Red is good
  8. PCL智能指针疑云 &lt;三&gt; 智能指针作为函数的传值参数和传引用参数
  9. go语言系列--输出正弦函数
  10. 解析获得的网页数据(XML文件或JSON文件)