Vue2怎么用echarts绘制折线图,饼图和大图
chartPan.vue
{{ title }}
使用 chartPan.vue 之饼图
console.log('arr', arr); // [ {"name": "master节点","value": "1" },{ "name": "worker节点", "value": "1"}] console.log('sum', sum); // sum 2 this.$refs.pieNode ? this.$refs.pieNode.pieInit(arr, `${this.tab === 'node' ? '节点' : ''}总数`, sum, 'node) : '';
效果

使用 chartPan.vue 之折线图
console.log('chartDate', chartDate); // ['2023-04-25 17:57:01', '2023-04-25 17:58:01', '2023-04-25 17:59:01',] console.log('chartData', chartData); // [4.92, 4.84, 5.07, 4.96, 5.06,] this.$refs.cpu ? this.$refs.cpu.lineInit(chartDate, chartData, this.tab === 'node' ? '(%)' : '(核)', this.tab) : '';
效果

展开大图
handlePreViewChart 事件
// 展示大dialog 图形 handlePreViewChart(type, title) { console.log('maxCpuChartData', this.maxCpuChartData); // { subtext: "(%)", maxChartDate : [ "2023-04-25 17:57:10", "2023-04-25 17:58:10","2023-04-25 17:59:10","2023-04-25 18:00:10",], maxChartData : [4.92,4.84,5.07] } this.chartPublicData = type === 'cpu' ? { ...this.maxCpuChartData } : { ...this.maxMemChartData }; this.$refs.maxChart.title = title; this.$refs.maxChart.dialogVisible = true; },
大图组件 maxChart.vue
大图效果
