一。components文件下新建 lineCharts.vue

<template>
<div :class="className" :style="{ height: height, width: width }" />
</template> <script>
import * as echarts from 'echarts'
require('echarts/theme/macarons') // echarts theme export default { props: {
className: {
type: String,
default: 'chart'
},
width: {
type: String,
default: '100%'
},
height: {
type: String,
default: '400px'
},
autoResize: {
type: Boolean,
default: true
},
chartData: {
type: Object,
required: true
}
},
data() {
return {
chart: null
}
},
watch: {
chartData: {
deep: true,
handler(val) {
this.setOptions(val)
}
}
},
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.setOptions(this.chartData)
},
setOptions({ expectedData, actualData } = {}) {
this.chart.setOption({
legend: {
data: ['AC06H', 'AC06L', 'AC12N', 'AC12S', 'AC13E'],
textStyle: {
color: '#fff'
}
},
grid: {
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true
},
toolbox: {
feature: {
saveAsImage: {}
}
},
xAxis: {
type: 'category',
boundaryGap: false,
data: ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10','11', '12', '13', '14', '15','16','17','18','19','20']
},
yAxis: {
type: 'value'
},
series: [
{
name: 'AC06H',
type: 'line',
stack: 'Total',
smooth: false,
data: [691,301, 134, 590, 634, 420, 132, 530, 310,301,254, 320, 590, 134, 530, 310, 590,90, 230, 210],
itemStyle: {
normal: {
//areaStyle: {type: 'default',color:'#d5f0fd'}, //阴影颜色
lineStyle:{color:'#00ffff'}
}
},
},
{
name: 'AC06L',
type: 'line',
stack: 'Total',
smooth: false,
data: [220, 382, 691,301, 134, 590, 634,520,34,123,90,691,301, 400,254, 320, 590,120, 530, 310],
itemStyle: {
normal: {
lineStyle:{color:'#ff00ff'}
}
},
},
{
name: 'AC12N',
type: 'line',
stack: 'Total',
smooth: false,
data: [150, 432, 101,254, 720, 590,120, 530, 382, 101, 682,390, 30, 520,691,301, 254, 320, 130, 410],
itemStyle: {
normal: {
lineStyle:{color:'#fff'}
}
},
},
{
name: 'AC12S',
type: 'line',
stack: 'Total',
smooth: false,
data: [320, 832, 101,600, 382,434, 210, 330, 50, 90, 501, 834,100, 432, 101, 382,590, 130, 400,520],
itemStyle: {
normal: {
lineStyle:{color:'#00a0e9'}
}
},
},
{
name: 'AC13E',
type: 'line',
stack: 'Total',
smooth: false,
data: [600, 382,434, 210, 330, 120, 232, 201, 501, 834, 432, 101, 382,434, 10, 330, 120 ,832, 501, 834,],
itemStyle: {
normal: {
lineStyle:{color:'#ffff00'}
}
},
}
]
})
}
}
}
</script>

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

效果图如下:

最新文章

  1. Windows cmd 长时间不输出新内容 直到按下ctrl + c 取消或者回车的解决办法
  2. jsp页面取得一对多中的set集合的size
  3. DT时代即将到来
  4. 【CodeForces 604B】F - 一般水的题1-More Cowbe
  5. Aspose 数字和日期 设置
  6. linux 历史命令用法(转)
  7. Android之Socket通信(一)
  8. IntelliJ IDEA对开发者的三大诱惑
  9. [DP之计数DP]
  10. JavaSE教程-03Java中分支语句与四种进制转换-思维导图
  11. css中那些容易被我们程序猿所忽略的选择器
  12. 归并排序Merge Sort
  13. JDBC中execute、executeQuery和executeUpdate的区别
  14. expect学习笔记及实例详解
  15. Mysql 数据库安装与配置详解
  16. Solr复杂条件查询
  17. CefGlue中js与C#交互(实现mp3播放)
  18. js 迭代 方法
  19. Web应用三种部署方式的优缺点
  20. VMware 增加硬盘ubuntu

热门文章

  1. Wine 安装迅雷5.8.14.176
  2. Linux命令系列之top——里面藏着很多鲜为人知的宝藏知识
  3. ArrayList LinkedList Vector之间的区别
  4. 8.RabbitMQ系列之RPC
  5. HTML躬行记(2)——WebRTC基础实践
  6. windows和虚拟机上的Ubuntu互传文件
  7. Dropout原理分析
  8. 纯css爱心代码-最近超级火的打火机与公主裙中的爱心代码(简易版)
  9. Bitmap和byte[]的相互转换
  10. 2022春每日一题:Day 23