一。components文件下引入 barCharts.vue文件

<template>
<div :class="className" :style="{height:height,width:width}" />
</template> <script>
import * as echarts from 'echarts'
require('echarts/theme/macarons') // echarts theme
//import resize from './mixins/resize' const animationDuration = 6000 export default {
//mixins: [resize],
props: {
className: {
type: String,
default: 'chart'
},
width: {
type: String,
default: '100%'
},
height: {
type: String,
default: '200px'
}
},
data() {
return {
chart: null
}
},
mounted() {
this.$nextTick(() => {
this.initChart()
})
},
beforeDestroy() {
if (!this.chart) {
return
}
this.chart.dispose()
this.chart = null
},
methods: {
initChart() {
this.chart = echarts.init(this.$el, 'macarons') this.chart.setOption({
tooltip: {
trigger: 'axis',
axisPointer: { // 坐标轴指示器,坐标轴触发有效
type: 'shadow' // 默认为直线,可选为:'line' | 'shadow'
}
},
grid: {
top: 30,
left: '2%',
right: '1%',
bottom: 10,
containLabel: true
},
dataset: {
source: [
['product', '2015','2016'],
['AC06H', 143.3,60],
['AC06L', 83.1,21.4],
['AC12N', 386.4 ,35.3],
['AC125', 72.4 ,10],
['AC13E', 192.4 ,72],
['AC13W', 572.4 ,10],
['AC18H', 142.4 ,47],
]
},
xAxis: { type: 'category' },
yAxis: {},
series: [{
type: 'bar',
itemStyle: {
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
{ offset: 0, color: '#09c9c5' },
{ offset: 1, color: '#003791' }
])
}
},{
type: 'bar',
itemStyle: {
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
{ offset: 0, color: '#5eff4d' },
{ offset: 1, color: '#245119' }
])
},
}]
})
}
}
}
</script>

二。需要的页面引入组件:

效果图如下:

最新文章

  1. CompletionService/ExecutorCompletionService/线程池/concurrent包
  2. jdk+myeclipse配置安装相关步骤
  3. LinqToSQL实例参见
  4. ANDROID L——Material Design详细解释(UI控制)
  5. Swift语言指南(七)--语言基础之布尔值和类型别名
  6. spring boot + vue + element-ui全栈开发入门——基于Electron桌面应用开发
  7. ios开发数据库版本迁移手动更新迭代和自动更新迭代艺术(二)
  8. 关于项目里server清楚缓存的代码
  9. 解决关于 ionic3 启动白屏 控制台错误提示:Uncaught SyntaxError Use of const in strict mode.
  10. [20180408]那些函数索引适合字段的查询.txt
  11. linux 查看cpu的使用百分比
  12. CF 954H Path Counting
  13. 【转】netstat 的10个基本用法
  14. sql server不要插入大数据,开销太大
  15. EXCEL 单元格引用问题
  16. PECL: configuration option &quot;php_ini&quot; is not set to php.ini location
  17. Howto run google-chrome as root
  18. linux使用rsync、inotify-tools实现多台服务器文件实时同步
  19. uber shader
  20. nyoj-1016-德莱联盟(向量叉乘判断线段相交)

热门文章

  1. 8Hello world
  2. PHP全栈开发(八):CSS Ⅹ 导航栏制作
  3. Python处理刚刚,分钟,小时,天前等时间
  4. Maven 聚合工程的创建
  5. C#自定义控件开发(1)
  6. 超精准!AI 结合邮件内容与附件的意图理解与分类!⛵
  7. 原来用 MySQL 也可以做全文检索
  8. RabbitMQ个人实践
  9. 06#Web 实战:实现可滑动的标签页
  10. linux mint 归档管理器报错Extraction not performd