You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
158 lines
3.5 KiB
158 lines
3.5 KiB
3 years ago
|
<template>
|
||
|
<div :class="className" :style="{height:height,width:width}" />
|
||
|
</template>
|
||
|
|
||
|
<script>
|
||
|
import echarts from 'echarts'
|
||
|
require('echarts/theme/macarons'); // echarts theme
|
||
|
import resize from './mixins/resize'
|
||
|
|
||
|
export default {
|
||
|
mixins: [resize],
|
||
|
props: {
|
||
|
className: {
|
||
|
type: String,
|
||
|
default: 'chart'
|
||
|
},
|
||
|
width: {
|
||
|
type: String,
|
||
|
default: '100%'
|
||
|
},
|
||
|
height: {
|
||
|
type: String,
|
||
|
default: '300px'
|
||
|
},
|
||
|
autoResize: {
|
||
|
type: Boolean,
|
||
|
default: true
|
||
|
},
|
||
|
lineSerData: {
|
||
|
type: Array,
|
||
|
default: []
|
||
|
},
|
||
|
lineLgData: {
|
||
|
type: Array,
|
||
|
default: []
|
||
|
},
|
||
|
lineXData: {
|
||
|
type: Array,
|
||
|
default: []
|
||
|
},
|
||
|
},
|
||
|
data() {
|
||
|
return {
|
||
|
chart: null
|
||
|
}
|
||
|
},
|
||
|
watch: {
|
||
|
},
|
||
|
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');
|
||
|
if(!this.lineXData.length){
|
||
|
var html =
|
||
|
'<div style="text-align:center;"><div style="line-height:260px;color:#868686; font-size: 26px;">暂无数据</div>' +
|
||
|
'<h3 style="color: #74bcff; font-size: 18px;">历年项目走势</h3></div>';
|
||
|
this.$el.innerHTML = html;
|
||
|
this.$el.removeAttribute('_echarts_instance_')
|
||
|
}
|
||
|
this.setOptions()
|
||
|
},
|
||
|
setOptions() {
|
||
|
this.chart.setOption({
|
||
|
title: {
|
||
|
text: "历年项目走势",
|
||
|
x:'center',
|
||
|
y: 'bottom',
|
||
|
},
|
||
|
|
||
|
xAxis: {
|
||
|
// data: [ '2014', '2015', '2016', '2017', '2018', '2019','2020'],
|
||
|
data:this.lineXData,
|
||
|
boundaryGap: false,
|
||
|
axisTick: {
|
||
|
show: false
|
||
|
}
|
||
|
},
|
||
|
grid: {
|
||
|
left: 10,
|
||
|
right: 10,
|
||
|
bottom: 30,
|
||
|
top: 30,
|
||
|
containLabel: true
|
||
|
},
|
||
|
tooltip: {
|
||
|
trigger: 'axis',
|
||
|
axisPointer: {
|
||
|
type: 'cross'
|
||
|
},
|
||
|
padding: [5, 10]
|
||
|
},
|
||
|
yAxis: {
|
||
|
axisTick: {
|
||
|
show: false
|
||
|
},
|
||
|
axisLabel: {
|
||
|
formatter:'{value}个'
|
||
|
}
|
||
|
},
|
||
|
legend: {
|
||
|
// data: ['立项数', '结项数']
|
||
|
data:this.lineLgData
|
||
|
},
|
||
|
series: this.lineSerData
|
||
|
// [{
|
||
|
// name: '立项数',
|
||
|
// // itemStyle: {
|
||
|
// // normal: {
|
||
|
// // color: '#FF005A',
|
||
|
// // lineStyle: {
|
||
|
// // color: '#FF005A',
|
||
|
// // width: 2
|
||
|
// // }
|
||
|
// // }
|
||
|
// // },
|
||
|
// // smooth: true,
|
||
|
// type: 'line',
|
||
|
// data: expectedData,
|
||
|
// // animationDuration: 2800,
|
||
|
// // animationEasing: 'cubicInOut'
|
||
|
// },
|
||
|
// {
|
||
|
// name: '结项数',
|
||
|
// // smooth: true,
|
||
|
// type: 'line',
|
||
|
// // itemStyle: {
|
||
|
// // normal: {
|
||
|
// // color: '#3888fa',
|
||
|
// // lineStyle: {
|
||
|
// // color: '#3888fa',
|
||
|
// // width: 2
|
||
|
// // },
|
||
|
// // areaStyle: {
|
||
|
// // color: '#f3f8ff'
|
||
|
// // }
|
||
|
// // }
|
||
|
// // },
|
||
|
// data: actualData,
|
||
|
// // animationDuration: 2800,
|
||
|
// // animationEasing: 'quadraticOut'
|
||
|
// }]
|
||
|
})
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
</script>
|