|
@@ -26,7 +26,7 @@ echarts.use([
|
|
|
DataZoomComponent,
|
|
|
VisualMapComponent,
|
|
|
]);
|
|
|
-
|
|
|
+let lineTypeTwoCharts = undefined;
|
|
|
export default {
|
|
|
name: "countryLineChart",
|
|
|
props: ["list", "keys", "xName", "subsection"],
|
|
@@ -34,7 +34,6 @@ export default {
|
|
|
return {
|
|
|
leftList: [],
|
|
|
rightList: [],
|
|
|
- chart: undefined,
|
|
|
xText: {},
|
|
|
};
|
|
|
},
|
|
@@ -73,20 +72,22 @@ export default {
|
|
|
let values = [],
|
|
|
keys = [];
|
|
|
for (let o = 0; o < list.length; o++) {
|
|
|
- const v = list[o], key = v[this.xName];
|
|
|
+ const v = list[o],
|
|
|
+ key = v[this.xName];
|
|
|
keys.push(key);
|
|
|
- let k = 0, b = 0;
|
|
|
+ let k = 0,
|
|
|
+ b = 0;
|
|
|
for (let i = 0; i < this.subsection.length; i++) {
|
|
|
- const put = this.subsection[i];
|
|
|
- if(put.start_x - 0 <= key && put.end_x - 0 >= key){
|
|
|
- k = put.k;
|
|
|
- b = put.b;
|
|
|
- break
|
|
|
- }
|
|
|
+ const put = this.subsection[i];
|
|
|
+ if (put.start_x - 0 <= key && put.end_x - 0 >= key) {
|
|
|
+ k = put.k;
|
|
|
+ b = put.b;
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
for (let i = 0; i < this.keys.length; i++) {
|
|
|
if (!values[i]) values[i] = [];
|
|
|
- values[i][o] = (k * key + b)*100;
|
|
|
+ values[i][o] = (k * key + b) * 100;
|
|
|
}
|
|
|
}
|
|
|
return {
|
|
@@ -107,9 +108,9 @@ export default {
|
|
|
},
|
|
|
createChart() {
|
|
|
if (!this.$refs.countryLineChart) return;
|
|
|
- this.chart = echarts.init(this.$refs.countryLineChart);
|
|
|
+ lineTypeTwoCharts = echarts.init(this.$refs.countryLineChart);
|
|
|
let chartData = this.formatte(this.list);
|
|
|
- this.chart.resize({
|
|
|
+ lineTypeTwoCharts.resize({
|
|
|
height: (this.$refs.countryLineChart.offsetWidth * 6) / 16,
|
|
|
});
|
|
|
var option = {
|
|
@@ -137,14 +138,20 @@ export default {
|
|
|
let t = "<table class='tool'>",
|
|
|
inli = o.input || [],
|
|
|
outli = o.output || [];
|
|
|
- t += "<tr><td>流入</td><td></td><td>" + (o.in * 100).toFixed(2) + "% </td></tr>";
|
|
|
+ t +=
|
|
|
+ "<tr><td>流入</td><td></td><td>" +
|
|
|
+ (o.in * 100).toFixed(2) +
|
|
|
+ "% </td></tr>";
|
|
|
for (let i = 0; i < inli.length; i++) {
|
|
|
const v = inli[i];
|
|
|
t += `<tr><td>${v.channel}</td><td>${v.epg_name || ""}</td><td>${(
|
|
|
v.value * 100
|
|
|
).toFixed(2)}%</td> </tr>`;
|
|
|
}
|
|
|
- t += "<tr><td>流出</td><td></td><td>" + (o.out * 100).toFixed(2) + "% </td></tr>";
|
|
|
+ t +=
|
|
|
+ "<tr><td>流出</td><td></td><td>" +
|
|
|
+ (o.out * 100).toFixed(2) +
|
|
|
+ "% </td></tr>";
|
|
|
for (let i = 0; i < outli.length; i++) {
|
|
|
const v = outli[i];
|
|
|
t += `<tr><td>${v.channel}</td> <td>${v.epg_name ||
|
|
@@ -187,20 +194,20 @@ export default {
|
|
|
}),
|
|
|
};
|
|
|
|
|
|
- option && this.chart.setOption(option);
|
|
|
+ option && lineTypeTwoCharts.setOption(option);
|
|
|
},
|
|
|
|
|
|
formatsubsection() {
|
|
|
- let bei = 100;
|
|
|
+ let bei = 100;
|
|
|
for (let i = 0; i < this.subsection.length; i++) {
|
|
|
const v = this.subsection[i];
|
|
|
let sx = v.start_x,
|
|
|
sy = v.start_y,
|
|
|
ex = v.end_x,
|
|
|
ey = v.end_y;
|
|
|
- let k = ((ey*bei - sy*bei) / bei / (ex - sx)).toFixed(8) - 0;
|
|
|
+ let k = ((ey * bei - sy * bei) / bei / (ex - sx)).toFixed(8) - 0;
|
|
|
let b = sy - k * sx;
|
|
|
- if(k === 0) k = 0;
|
|
|
+ if (k === 0) k = 0;
|
|
|
v.k = k;
|
|
|
v.b = b;
|
|
|
}
|
|
@@ -209,17 +216,18 @@ export default {
|
|
|
|
|
|
watch: {
|
|
|
list() {
|
|
|
- if (this.chart) this.chart.dispose();
|
|
|
- this.formatsubsection();
|
|
|
- this.createChart();
|
|
|
+ if (lineTypeTwoCharts) lineTypeTwoCharts.dispose();
|
|
|
+ this.formatsubsection();
|
|
|
+ this.createChart();
|
|
|
},
|
|
|
},
|
|
|
mounted() {
|
|
|
+ if (lineTypeTwoCharts) lineTypeTwoCharts.dispose();
|
|
|
this.formatsubsection();
|
|
|
this.createChart();
|
|
|
},
|
|
|
beforeUnmount: function() {
|
|
|
- this.chart.dispose();
|
|
|
+ if (lineTypeTwoCharts) lineTypeTwoCharts.dispose();
|
|
|
},
|
|
|
components: {},
|
|
|
};
|