|
@@ -3,6 +3,7 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
+import { cloneDeep } from "lodash";
|
|
|
let option = {
|
|
|
backgroundColor: "rgba(0,0,0,0)",
|
|
|
tooltip: {
|
|
@@ -95,39 +96,39 @@ let option = {
|
|
|
},
|
|
|
},
|
|
|
],
|
|
|
- series: [
|
|
|
- {
|
|
|
- name: "", //收储面积
|
|
|
- type: "bar",
|
|
|
- barWidth: "12px",
|
|
|
- itemStyle: {
|
|
|
- normal: {
|
|
|
- color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
|
|
|
- {
|
|
|
- offset: 0,
|
|
|
- color: "#409EFF",
|
|
|
- },
|
|
|
- {
|
|
|
- offset: 1,
|
|
|
- color: "rgba(24, 253, 255, 0)",
|
|
|
- },
|
|
|
- ]),
|
|
|
+ series: [],
|
|
|
+};
|
|
|
+// 柱体
|
|
|
+let seriesItem = {
|
|
|
+ name: "", //收储面积
|
|
|
+ type: "bar",
|
|
|
+ barWidth: "12px",
|
|
|
+ itemStyle: {
|
|
|
+ normal: {
|
|
|
+ color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
|
|
|
+ {
|
|
|
+ offset: 0,
|
|
|
+ color: "#409EFF",
|
|
|
},
|
|
|
- },
|
|
|
- data: [],
|
|
|
- },
|
|
|
- {
|
|
|
- name: "", //收储个数
|
|
|
- type: "line",
|
|
|
- smooth: true,
|
|
|
- itemStyle: {
|
|
|
- normal: {
|
|
|
- color: "#FFCC64", // 折线的颜色
|
|
|
+ {
|
|
|
+ offset: 1,
|
|
|
+ color: "rgba(24, 253, 255, 0)",
|
|
|
},
|
|
|
- },
|
|
|
- data: [],
|
|
|
+ ]),
|
|
|
},
|
|
|
- ],
|
|
|
+ },
|
|
|
+ data: [],
|
|
|
+};
|
|
|
+let lineItem = {
|
|
|
+ name: "", //收储个数
|
|
|
+ type: "line",
|
|
|
+ smooth: true,
|
|
|
+ itemStyle: {
|
|
|
+ normal: {
|
|
|
+ color: "#FFCC64", // 折线的颜色
|
|
|
+ },
|
|
|
+ },
|
|
|
+ data: [],
|
|
|
};
|
|
|
export default {
|
|
|
name: "bar_echart",
|
|
@@ -144,17 +145,25 @@ export default {
|
|
|
};
|
|
|
},
|
|
|
methods: {
|
|
|
- setOptions(cartData) {
|
|
|
+ setOptions(v) {
|
|
|
let _this = this;
|
|
|
if (!this.myChart) {
|
|
|
// var dom = document.getElementById("bar_echart");
|
|
|
this.myChart = echarts.init(this.$refs.echart);
|
|
|
}
|
|
|
- option.legend.data = cartData.legend;
|
|
|
- option.xAxis.data = cartData.xdata;
|
|
|
-
|
|
|
- option.series[0].data = cartData.data;
|
|
|
-
|
|
|
+ option.legend.data = v.legend;
|
|
|
+ option.xAxis.data = v.xData;
|
|
|
+ v.yData.forEach((item, k) => {
|
|
|
+ let o = cloneDeep(seriesItem); // JSON.parse(JSON.stringify(seriesItem));
|
|
|
+ o.name = v.xData[k];
|
|
|
+ o.data = item;
|
|
|
+ // alldata = [...alldata, ...o.data];
|
|
|
+ // if (v.interval) {
|
|
|
+ // option.xAxis.axisLabel.interval = 0;
|
|
|
+ // option.xAxis.axisLabel.rotate = 0;
|
|
|
+ // }
|
|
|
+ option.series.push(o);
|
|
|
+ });
|
|
|
this.myChart.resize();
|
|
|
this.myChart.setOption(option);
|
|
|
|