效果图:

一:安装
版本号建议安装"echarts": "^4.8.0”,其它版本init会报错
1、 首先需要安装echarts依赖包
npm install --save echarts@4.8.0
2、 或者使用国内的淘宝镜像:
npm install -g cnpm --registry=https://registry.npm.taobao.org

<template><div class="echarts_con"><divclass="echarts_main"ref="dialog_root"title="节点指标"@close="hideData()"><!--负载情况--><divref="bar_dv":style="{width: '100%',minHeight: '300px',}"></div></div></div>
</template><script>
import echarts from 'echarts'
// import myIcon from './image/hot_icon.png' //自定义图标
// import averageIcon from './image/hot_icon.png'
export default {name: "Echarts",data () {return {maxStr: 400,yInterval: 80,myData: [122, 45, 67, 78, 46],averageData: [32, 34, 6, 73, 84, 40]}},//外部传入数据的话要监听数据start// props: {//   myData: {//     type: Array,//     default: []//   },//   averageData: {//     type: Array,//     default: []//   }// },// computed: {//   address () {//     const { myData, averageData } = this//     return {//       myData,//       averageData//     }//   }// },// watch: {//   address: {//     handler: function (val) {//       this.compare(val.myData, val.averageData)//       let newArr = val.myData.concat(val.averageData)//       let maxNum = Math.max(...newArr)//       this.maxStr = maxNum//       if (maxNum >= 500) {//         this.yInterval = 200//       } else {//         this.yInterval = 50//       }//       this.drawLine(val.myData, val.averageData)//     },//     deep: true//   }// },// mounted () {// this.$nextTick(function () {//   this.drawLine();// });// },//外部传入数据的话要监听数据endmounted () {this.drawLine(this.myData, this.averageData)},methods: {//判断一一对应数据低于平均就提示compare (arr1, arr2) {if (arr1[0] < arr2[0]) {this.isCompare = true} else if (arr1[1] < arr2[1]) {this.isCompare = true} else if (arr1[2] < arr2[2]) {this.isCompare = true} else if (arr1[3] < arr2[3]) {this.isCompare = true} else {this.isCompare = false}},clickClose () {this.isCompare = false},/*负载情况图标*/drawLine (a, b) {var myData = a;var averageData = b;let bar_dv = this.$refs.bar_dv;let myChart = echarts.init(bar_dv);var autoHeight = parseInt(this.maxStr / 100) * 10 + 100;myChart.getDom().style.height = autoHeight + "px";myChart.resize(); //自适应高度// 绘制图表myChart.setOption({title: { text: '报表展示' },grid: {// left: 40,containLable: true},tooltip: {},xAxis: {data: ["看过我的", "沟通过的", "收到简历", "曝光人数"],axisLine: {lineStyle: {type: 'solid',color: '#eeeeee', //x左边线的颜色fontSize: 13,width: '0.5' //坐标线的宽度}},axisLabel: { //x轴字体textStyle: {color: '#333333',fontSize: 13}},},yAxis: {type: 'value',min: 0,max: this.maxStr,interval: this.yInterval,axisLine: {lineStyle: {type: 'solid',color: '#fff', //左边线的颜色width: '0.5' //坐标线的宽度}},axisLabel: {textStyle: {color: '#333333',fontSize: 13}},splitLine: {show: true,lineStyle: {color: ['#eeeeee'],width: 1,type: 'solid'}}},legend: {itemWidth: 11,itemHeight: 12,symbolKeepAspect: true,textStyle: {fontSize: 11,lineHeight: 0,backgroundColor: "rgba(11, 164, 19, 1)"},// icon: `image://${averageIcon}`,data: [{name: '我的',// icon: `image://${myIcon}`//自定义小图标},{name: '行业平均',// icon: `image://${averageIcon}`}],align: 'left',right: 40,top: '0',textStyle: {fontSize: 12,textAlign: 'center',color: '#333333',magrinRight: 3},},series: [{name: '我的',type: 'bar',data: myData,barWidth: 16, //柱子宽度barGap: '50%',//间距label: {show: true,position: 'top',textStyle: {color: '#4695F3'},formatter: function (params) {return params.value}},itemStyle: {normal: {color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{offset: 0,color: '#A5CCF6'}, {offset: 1,color: '#4695F3'}]),barBorderRadius: [4, 4, 0, 0],}}},{name: '行业平均',type: 'bar',data: averageData,barWidth: 16,barGap: '50%',label: {show: true,position: 'top',textStyle: {color: '#FE8401'},formatter: function (params) {return params.value}},itemStyle: {normal: {color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{offset: 0,color: '#FFB235'}, {offset: 1,color: '#FE8401'}]),barBorderRadius: [4, 4, 0, 0],},emphasis: {barBorderRadius: 30},}}]}, true);},hideData () {this.$emit("hideDialog")},confirm () {this.hideData();},}
}
</script><style scoped>
.echarts_con {width: 100%;margin: 0 auto;margin-top: 8px;border-radius: 20px;background: #fff;padding-bottom: 35px;
}
.echarts_main {width: 100%;margin: 0 auto;padding-top: 20px;margin-bottom: -32px;margin-right: 20px;margin-left: 20px;
}
.bottom {width: 90%;margin: 0 auto;background: #fef8e1;border-radius: 6px;height: 100%;margin-top: 16px;
}
.bottom_con {width: 90%;margin: 0 auto;display: flex;justify-content: space-between;align-items: center;height: 34px;line-height: 34px;
}
.bottom_text {height: 34px;line-height: 34px;font-size: 13px;font-family: PingFang, PingFang-SC;font-weight: SC;text-align: left;color: #fa5d1d;
}
.right_close {width: 13px;height: 13px;
}
</style>

vue+echart实现双柱状图相关推荐

  1. Vue:echarts的柱状图怎样按照比例缩小?

    Vue:echarts的柱状图怎样按照比例缩小? 资源: vue制作echart图表随着画面等比例放大缩小 第二种方法:在div中使用echarts,利用div的参数来限制echarts生成的图表的大 ...

  2. vue使用Echarts画柱状图

    目录 1 引入Echarts 1.1 安装 1.2 引入 2 基本柱状图 3 多列柱状图 4 柱状图样式设置 4.1 柱条样式 4.2 柱条间距 5 动态排序柱状图 6 总结 1 引入Echarts ...

  3. vue页面参数传递(VUE+echart+map联动实例)

    我们在使用vue的时候经常会遇到页面参数传递,相比之前JavaScript操作,js入参传参,js之间方法调用只要我们引入js就可以相互调用,但是vue里面的不太一样,主要涉及有三种方式,父子传参,子 ...

  4. Vue:echarts的柱状图为什么X轴上的文字不显示?

    Vue:echarts的柱状图为什么X轴上的文字不显示? 资源: echarts x轴文字显示不全(解决方案) echarts柱状图X轴底部文字有的不显示出来?

  5. python绘制直方图显示数字_Python实现绘制双柱状图并显示数值功能示例

    本文实例讲述了Python实现绘制双柱状图并显示数值功能.分享给大家供大家参考,具体如下: # -*- coding:utf-8 -*- #! python3 import matplotlib.py ...

  6. python画并列柱状图-Python实现绘制双柱状图并显示数值功能示例

    本文实例讲述了Python实现绘制双柱状图并显示数值功能.分享给大家供大家参考,具体如下: # -*- coding:utf-8 -*- #! python3 import matplotlib.py ...

  7. echarts legend颜色_echarts数据可视化图表(二):双柱状图

    echarts数据可视化图表(二):双柱状图 效果图: html js var loadEcharts09 = function () { var myChartss = echarts.init(d ...

  8. Vue + echart 实现中国地图 和 省市地图(可切换省份

    vue + echart 实现中国地图 和 省市地图(可切换省份) - 伏沙金 - 博客园

  9. 双柱状图与双折线图混合

    问题: 双柱状图的时候,折线图不能从柱状图的中心点开始 解决方法:使用双x轴来控制折线的起始位置 代码 var option = {backgroundColor:'#4a4a4a',tooltip: ...

最新文章

  1. python queue 多线程_Python如何实现并行的多线程?
  2. 模糊数学笔记:五、模糊聚类
  3. CTF-Python打包成的exe文件Re逆向
  4. LINUX 三剑客之awk
  5. 教你用java统计目录下所有文档的词频
  6. linux cp和rm命令
  7. hibernate by example 排除某些列
  8. ZZULIOJ 1061:顺序输出各位数字
  9. Struts向JSP中传值
  10. 跟屌丝大哥学DB2-第四课 数据类型 ,表 ,视图,索引,模式,约束(一)
  11. Ubuntu安装GitKraken
  12. 公交系统如何利用智能调度降低运营费用
  13. 计算机ps特效教程,制作木质电脑桌的PS滤镜教程
  14. linux shell中各种分号和括号,Linux Shell中各种分号和括号#的用法总结
  15. matlab中加载数据方式,【转帖】Matlab数据导入方法
  16. 北漂4年,我选择了回到家乡,我选择了父母在,不远行。
  17. 最难学的七大编程语言,VB 第一,Python垫底,看你学的排第几
  18. maya 中的 cmds.scriptJob 命令
  19. 标定学习笔记(二)-- 张正友论文学习笔记
  20. 罗马数字包含以下七种字符: I, V, X, L,C,D 和 M。 字符 数值 I 1 V 5 X 10 L

热门文章

  1. 6种方式创建多层索引MultiIndex
  2. java计时器_Java实现的计时器【秒表】功能示例
  3. SonarQube8.6 使用说明
  4. 乡村振兴涉农区域全景综合安防监控解决方案
  5. finally的一个妙用
  6. 随机变量不相关却不一定独立
  7. 【rustdesk】windows安装vcpkg及配置, rustdesk 客户端依赖库安装
  8. 刀柄锥度气动量仪检测
  9. 粒子背景php,html5+canvas圆形粒子移动背景动画特效
  10. 小程序中如何正确使用换行符‘\n‘