|
@@ -197,17 +197,14 @@ export default {
|
|
|
hd() {
|
|
|
this.init();
|
|
|
},
|
|
|
- topic() {
|
|
|
- this.init();
|
|
|
- },
|
|
|
},
|
|
|
mounted() {
|
|
|
this.height = (this.$refs.main.offsetWidth / 24) * 6.9;
|
|
|
- this.init();
|
|
|
},
|
|
|
computed: {},
|
|
|
methods: {
|
|
|
init() {
|
|
|
+ console.log("--");
|
|
|
linechart && linechart.destroy();
|
|
|
barchart && barchart.destroy();
|
|
|
piechart && piechart.destroy();
|
|
@@ -232,10 +229,26 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
this.plays = pli;
|
|
|
- this.pie1(pli);
|
|
|
+
|
|
|
+ if (!pli || !pli.length) {
|
|
|
+ document.getElementById("piechart").style.display = "none";
|
|
|
+ } else {
|
|
|
+ document.getElementById("piechart").style.display = "block";
|
|
|
+ }
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.pie1(pli);
|
|
|
+ });
|
|
|
});
|
|
|
qushiData(this.topic).then(r => {
|
|
|
- this.line1(r);
|
|
|
+ let li = r || [];
|
|
|
+ if (!li || !li.length) {
|
|
|
+ document.getElementById("container").style.display = "none";
|
|
|
+ } else {
|
|
|
+ document.getElementById("container").style.display = "block";
|
|
|
+ }
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.line1(li);
|
|
|
+ });
|
|
|
});
|
|
|
this.bmGet();
|
|
|
pingtaiData({
|
|
@@ -307,7 +320,15 @@ export default {
|
|
|
depRange: this.type,
|
|
|
title: this.topic,
|
|
|
}).then(r => {
|
|
|
- this.bar1((r || []).reverse());
|
|
|
+ let li = (r || []).reverse();
|
|
|
+ if (!li || !li.length) {
|
|
|
+ document.getElementById("barChart").style.display = "none";
|
|
|
+ } else {
|
|
|
+ document.getElementById("barChart").style.display = "block";
|
|
|
+ }
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.bar1(li);
|
|
|
+ });
|
|
|
});
|
|
|
},
|
|
|
numform(text) {
|
|
@@ -319,7 +340,10 @@ export default {
|
|
|
return num;
|
|
|
},
|
|
|
line1(li) {
|
|
|
- if (linechart) linechart.destroy();
|
|
|
+ if (linechart) {
|
|
|
+ linechart.destroy();
|
|
|
+ linechart = null;
|
|
|
+ }
|
|
|
const that = this;
|
|
|
// 传播量趋势
|
|
|
linechart = new F2.Chart({
|
|
@@ -355,7 +379,7 @@ export default {
|
|
|
},
|
|
|
});
|
|
|
linechart.tooltip({
|
|
|
- triggerOn: ["touchstart", "touchmove"],
|
|
|
+ triggerOn: ["click"],
|
|
|
onShow: function onShow(ev) {
|
|
|
const items = ev.items;
|
|
|
items[0].name = items[0].title;
|
|
@@ -381,7 +405,10 @@ export default {
|
|
|
linechart.render();
|
|
|
},
|
|
|
bar1(li) {
|
|
|
- if (barchart) barchart.destroy();
|
|
|
+ if (barchart) {
|
|
|
+ barchart.destroy();
|
|
|
+ barchart = null;
|
|
|
+ }
|
|
|
const that = this;
|
|
|
barchart = new F2.Chart({
|
|
|
id: "barChart",
|
|
@@ -435,7 +462,10 @@ export default {
|
|
|
});
|
|
|
},
|
|
|
pie1(li) {
|
|
|
- if (piechart) piechart.destroy();
|
|
|
+ if (piechart) {
|
|
|
+ piechart.destroy();
|
|
|
+ piechart = null;
|
|
|
+ }
|
|
|
const that = this;
|
|
|
piechart = new F2.Chart({
|
|
|
id: "piechart",
|
|
@@ -457,7 +487,7 @@ export default {
|
|
|
});
|
|
|
// 添加饼图文本
|
|
|
piechart.pieLabel({
|
|
|
- anchorOffset: 0,
|
|
|
+ anchorOffset: -10,
|
|
|
label1: function label1(data, color) {
|
|
|
return {
|
|
|
text: data.p,
|