|
@@ -2,12 +2,11 @@
|
|
|
<div id="lineChart" ref="line"></div>
|
|
|
</template>
|
|
|
<script>
|
|
|
-import * as echarts from "echarts";
|
|
|
export default {
|
|
|
name: "LineChart",
|
|
|
data() {
|
|
|
return {
|
|
|
- lineChart: null,
|
|
|
+ lineChart: null
|
|
|
};
|
|
|
},
|
|
|
props: {
|
|
@@ -15,21 +14,21 @@ export default {
|
|
|
type: Array,
|
|
|
default() {
|
|
|
return [];
|
|
|
- },
|
|
|
+ }
|
|
|
},
|
|
|
valueData: {
|
|
|
type: Array,
|
|
|
default() {
|
|
|
return [];
|
|
|
- },
|
|
|
- },
|
|
|
+ }
|
|
|
+ }
|
|
|
},
|
|
|
watch: {
|
|
|
valueData: {
|
|
|
handler(val) {
|
|
|
this.initEchart(this.categoryData, this.valueData);
|
|
|
},
|
|
|
- immediate: false,
|
|
|
+ immediate: false
|
|
|
}
|
|
|
},
|
|
|
mounted() {
|
|
@@ -40,43 +39,39 @@ export default {
|
|
|
methods: {
|
|
|
initEchart(xData, seriesData) {
|
|
|
if (!this.lineChart) {
|
|
|
- this.lineChart = echarts.init(this.$refs.line);
|
|
|
+ this.lineChart = this.$Echarts.init(this.$refs.line);
|
|
|
}
|
|
|
let option = {
|
|
|
tooltip: {
|
|
|
show: true,
|
|
|
- trigger: "axis",
|
|
|
+ trigger: "axis"
|
|
|
},
|
|
|
grid: {
|
|
|
left: "3%",
|
|
|
right: "4%",
|
|
|
bottom: "3%",
|
|
|
top: "20px",
|
|
|
- containLabel: true,
|
|
|
+ containLabel: true
|
|
|
},
|
|
|
xAxis: {
|
|
|
type: "category",
|
|
|
data: xData,
|
|
|
axisTick: {
|
|
|
- show: false, // 不显示坐标轴刻度线
|
|
|
+ show: false // 不显示坐标轴刻度线
|
|
|
},
|
|
|
axisLine: {
|
|
|
show: true,
|
|
|
lineStyle: {
|
|
|
color: "rgba(219,225,255,1)",
|
|
|
width: 1,
|
|
|
- type: "solid",
|
|
|
- },
|
|
|
+ type: "solid"
|
|
|
+ }
|
|
|
},
|
|
|
axisLabel: {
|
|
|
//x轴文字的配置
|
|
|
show: true,
|
|
|
- color: "rgba(219,225,255,1)",
|
|
|
- // 旧版textStyle写法
|
|
|
- // textStyle: {
|
|
|
- // color: "rgba(219,225,255,1)"
|
|
|
- // }
|
|
|
- },
|
|
|
+ color: "rgba(219,225,255,1)"
|
|
|
+ }
|
|
|
},
|
|
|
yAxis: {
|
|
|
// min: 1000,
|
|
@@ -90,54 +85,47 @@ export default {
|
|
|
type: "value",
|
|
|
scale: true,
|
|
|
splitLine: {
|
|
|
- show: false, // 不显示网格线
|
|
|
+ show: false // 不显示网格线
|
|
|
},
|
|
|
axisLine: {
|
|
|
- show: false, // 不显示坐标轴线
|
|
|
+ show: false // 不显示坐标轴线
|
|
|
},
|
|
|
axisLabel: {
|
|
|
//y轴文字的配置
|
|
|
color: "rgba(219,225,255,1)",
|
|
|
- margin: 15,
|
|
|
- // 旧版textStyle写法
|
|
|
- // textStyle: {
|
|
|
- // color: "rgba(219,225,255,1)",
|
|
|
- // margin: 15
|
|
|
- // }
|
|
|
- // formatter: '{value} %'//y轴的每一个刻度值后面加上‘%’号
|
|
|
- },
|
|
|
+ margin: 15
|
|
|
+ }
|
|
|
},
|
|
|
series: [
|
|
|
{
|
|
|
data: seriesData,
|
|
|
- // data: this.seriesData,
|
|
|
type: "line",
|
|
|
smooth: true,
|
|
|
itemStyle: {
|
|
|
- color: "#00aaff",
|
|
|
+ color: "#00aaff"
|
|
|
},
|
|
|
areaStyle: {
|
|
|
- color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
|
|
|
+ color: new this.$Echarts.graphic.LinearGradient(0, 0, 0, 1, [
|
|
|
{
|
|
|
offset: 0,
|
|
|
- color: "#00aaff",
|
|
|
+ color: "#00aaff"
|
|
|
},
|
|
|
{
|
|
|
offset: 1,
|
|
|
- color: "#00aaff00",
|
|
|
- },
|
|
|
- ]),
|
|
|
- },
|
|
|
- },
|
|
|
- ],
|
|
|
+ color: "#00aaff00"
|
|
|
+ }
|
|
|
+ ])
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ]
|
|
|
};
|
|
|
this.lineChart.setOption(option);
|
|
|
- },
|
|
|
- },
|
|
|
+ }
|
|
|
+ }
|
|
|
};
|
|
|
</script>
|
|
|
<style>
|
|
|
-#lineChart {
|
|
|
+#lineChart {
|
|
|
width: 100%;
|
|
|
height: 100%;
|
|
|
}
|