1、echarts配置化

This commit is contained in:
cuiyouliang 2025-06-30 17:36:41 +08:00
parent fc3e7a9c23
commit 3671ce3c0c
2 changed files with 33 additions and 34 deletions

View File

@ -28,36 +28,38 @@ export default {
required: true
}
},
defaultOption: {
title: {
text: null,
left: 'center'
},
tooltip: {
show: true,
trigger: 'axis'
},
legend: {
data: []
},
grid: {
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true
},
xAxis: {
type: 'category',
boundaryGap: false,
data: []
},
yAxis: {
type: 'value'
},
series: []
},
data() {
return {};
return {
defaultOption: {
title: {
text: null,
left: 'center'
},
tooltip: {
show: true,
trigger: 'axis'
},
legend: {
data: []
},
grid: {
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true
},
xAxis: {
type: 'category',
boundaryGap: false,
data: []
},
yAxis: {
type: 'value'
},
series: []
}
};
},
mounted() {
this.initChart();
@ -65,12 +67,10 @@ export default {
methods: {
initChart() {
console.log(this.chartData);
Object.keys(this.chartData).forEach((key) => {
this.defaultOption[key] = this.chartData[key];
});
this.defaultOption = { ...this.defaultOption, ...this.chartData };
const chartDom = document.getElementById('LineChartnew');
const myChart = echarts.init(chartDom);
myChart(this.defaultOption);
myChart.setOption(this.defaultOption);
}
/* setOptions(chartData) {

View File

@ -92,7 +92,6 @@ const LinechartData = ref({
boundaryGap: false,
data: []
},
legend: {},
series: [
{ name: '用户量', data: [] },
{ name: '在线用户', data: [] },