// 曲线图 ==》 (首页,数据分析) <template lang='pug'> div(:id="id", :style="{ width: '100%', height: '90%' }") </template> <script> export default { props: ['id', 'data', 'title', 'color', 'yAxisName'], watch: { data: { immediate: true, deep: true, handler(newValue, oldValue) { this.initChart() } } }, mounted() { this.initChart() }, methods: { initChart() { let dom = document.getElementById(this.id) if (!dom) return let myCharts = this.$echarts.init(dom) let option = { // color:['#D0F0FF'], title: { text: this.title }, tooltip: { trigger: 'axis' }, grid: { left: '3%', bottom: '3%', containLabel: true }, xAxis: [ { // type: 'category', type: 'time', boundaryGap: false } ], yAxis: [ { type: 'value', name: this.yAxisName } ], series: [ { name: '', type: 'line', stack: '总量', smooth: true, // label: { // show: true, // position: 'top' // }, areaStyle: { normal: { color: new this.$echarts.graphic.LinearGradient(0, 0, 0, 1, [ { offset: 0, color: this.color // 0% 处的颜色 }, { offset: 1, color: '#fff' // 100% 处的颜色 } ]) } }, lineStyle: { color: this.color }, itemStyle: { normal: { color: '#13B0FF' } }, emphasis: { focus: 'series' }, data: this.data } ] } myCharts.setOption(option, true) } } } </script> <style lang="scss" scoped> </style>