|
@@ -81,9 +81,10 @@ export default {
|
|
data() {
|
|
data() {
|
|
return {
|
|
return {
|
|
color1: [], // 默认颜色
|
|
color1: [], // 默认颜色
|
|
|
|
+ // 配色方案列表(每个方案是一个颜色数组)
|
|
|
|
+ colorSchemes: colorSchemes,
|
|
chartData: {},
|
|
chartData: {},
|
|
chartType: "scatter", // 当前图表类型(默认是散点图)
|
|
chartType: "scatter", // 当前图表类型(默认是散点图)
|
|
- colorSchemes: [...colorSchemes],
|
|
|
|
pointSize: 1, // 默认点大小
|
|
pointSize: 1, // 默认点大小
|
|
};
|
|
};
|
|
},
|
|
},
|
|
@@ -97,7 +98,7 @@ export default {
|
|
themeColor: {
|
|
themeColor: {
|
|
handler(newval) {
|
|
handler(newval) {
|
|
if (newval.length === 0) {
|
|
if (newval.length === 0) {
|
|
- this.color1 = colorSchemes[0].colors;
|
|
|
|
|
|
+ this.color1 = this.colorSchemes[0].colors;
|
|
} else {
|
|
} else {
|
|
this.color1 = newval;
|
|
this.color1 = newval;
|
|
}
|
|
}
|
|
@@ -113,12 +114,10 @@ export default {
|
|
},
|
|
},
|
|
},
|
|
},
|
|
async mounted() {
|
|
async mounted() {
|
|
- this.getData();
|
|
|
|
- if (this.themeColor.length === 0) {
|
|
|
|
- this.color1 = colorSchemes[0].colors;
|
|
|
|
- } else {
|
|
|
|
- this.color1 = this.themeColor;
|
|
|
|
- }
|
|
|
|
|
|
+ this.$nextTick(() => {
|
|
|
|
+ this.color1 = this.colorSchemes[0].colors;
|
|
|
|
+ this.getData();
|
|
|
|
+ });
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
async getData() {
|
|
async getData() {
|
|
@@ -152,12 +151,10 @@ export default {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
},
|
|
-
|
|
|
|
// 更新配色方案
|
|
// 更新配色方案
|
|
updateChartColor() {
|
|
updateChartColor() {
|
|
this.renderChart(); // 当配色方案或点大小发生变化时重新渲染图表
|
|
this.renderChart(); // 当配色方案或点大小发生变化时重新渲染图表
|
|
},
|
|
},
|
|
-
|
|
|
|
// 切换图表类型
|
|
// 切换图表类型
|
|
setChartType(type) {
|
|
setChartType(type) {
|
|
this.chartType = type;
|
|
this.chartType = type;
|
|
@@ -180,7 +177,7 @@ export default {
|
|
renderChart() {
|
|
renderChart() {
|
|
const uniqueColors = [...new Set(this.chartData.data[0].color)];
|
|
const uniqueColors = [...new Set(this.chartData.data[0].color)];
|
|
if (!this.color1) {
|
|
if (!this.color1) {
|
|
- this.color1 = colorSchemes[0].colors;
|
|
|
|
|
|
+ this.color1 = this.colorSchemes[0].colors;
|
|
}
|
|
}
|
|
const traces = uniqueColors.map((color, idx) => {
|
|
const traces = uniqueColors.map((color, idx) => {
|
|
const colorData = this.chartData.data[0].color.map((c) =>
|
|
const colorData = this.chartData.data[0].color.map((c) =>
|