chartDialog1() { this.chartVisiable1 = !this.chartVisiable1; this.$nextTick(()=>{ var zongjineChart1 = echarts.init(document.getElementById("zongjineChart1"),'macarons'); this.$http({ url: `jingdiangoupiao/value/jingdianmingcheng/zongjine`, method: "get", }).then(({ data }) => { if (data && data.code === 0) { let res = data.data; let xAxis = []; let yAxis = []; let pArray = [] for(let i=0;i<res.length;i++){ xAxis.push(res[i].jingdianmingcheng); yAxis.push(parseFloat((res[i].total))); pArray.push({ value: parseFloat((res[i].total)), name: res[i].jingdianmingcheng }) } var option = {};
时间: 2023-12-03 15:02:12 浏览: 58
这是一个使用 Echarts 库进行图表绘制的函数,当调用该函数时,会根据传入的参数显示或隐藏图表。函数内部使用了 Vue.js 中的 $http 方法向后端发送请求获取数据,然后将数据处理成适合 Echarts 绘制的格式,并根据数据绘制出对应的图表。具体的图表类型和样式可以参考函数中的 option 对象。
相关问题
this.chartVisiable1 = !this.chartVisiable1; this.$nextTick(()=>{ var zongjineChart1 = echarts.init(document.getElementById("zongjineChart1"),'macarons');
这是一段 JavaScript 代码,它的作用是切换图表的可见性,并使用 ECharts 库初始化一个名为 zongjineChart1 的图表。其中,`this.chartVisiable1` 是一个变量,用于记录图表的可见性状态,`!this.chartVisiable1` 则表示将其状态取反。`this.$nextTick()` 是 Vue.js 框架提供的方法,用于在 DOM 更新后执行回调函数,这里的回调函数用于初始化图表。具体实现可以参考 ECharts 文档和 Vue.js 文档。
data() { return { flag: false, flag1: false, flag2: false, flag3: false, flag4: false, flag5: false, }; }, components: { hot, seller, trend, Map, rank, stock, }, methods: { changetheme() { this.$store.commit("tabtheme"); }, full() { this.flag = true; this.$nextTick(() => { this.$refs.seller2.changesize(); }); }, full1() { this.flag1 = true; this.$nextTick(() => { this.$refs.trend2.screenAdapter(); }); }, full2() { this.flag2 = true; this.$nextTick(() => { this.$refs.rank2.screenAdapter(); }); }, full3() { this.flag3 = true; this.$nextTick(() => { this.$refs.hot2.screenAdapter(); }); }, full4() { this.flag4 = true; this.$nextTick(() => { this.$refs.stock2.screenAdapter(); }); }, full5() { this.flag5 = true; this.$nextTick(() => { this.$refs.map2.screenAdapter(); }); },优化后代码
data() {
return {
flags: [false, false, false, false, false, false],
};
},
components: {
hot,
seller,
trend,
Map,
rank,
stock,
},
methods: {
changetheme() {
this.$store.commit("tabtheme");
},
full(index) {
this.flags[index] = true;
this.$nextTick(() => {
switch (index) {
case 0:
this.$refs.seller2.changesize();
break;
case 1:
this.$refs.trend2.screenAdapter();
break;
case 2:
this.$refs.rank2.screenAdapter();
break;
case 3:
this.$refs.hot2.screenAdapter();
break;
case 4:
this.$refs.stock2.screenAdapter();
break;
case 5:
this.$refs.map2.screenAdapter();
break;
default:
break;
}
});
},
},
阅读全文