|
|
@@ -1,7 +1,7 @@
|
|
|
<!--
|
|
|
* @Author: your name
|
|
|
* @Date: 2025-08-14 11:28:28
|
|
|
- * @LastEditTime: 2025-08-27 15:32:46
|
|
|
+ * @LastEditTime: 2025-08-28 16:02:25
|
|
|
* @LastEditors: bogon
|
|
|
* @Description: In User Settings Edit
|
|
|
* @FilePath: /performance-test/src/views/performance/components/custonAsCom/dragChart/components/chartConfig/form/toolbox.vue
|
|
|
@@ -78,41 +78,12 @@
|
|
|
>
|
|
|
<span>标题颜色</span>
|
|
|
<el-color-picker
|
|
|
+ show-alpha
|
|
|
v-model="formLabelAlign.titleColor"
|
|
|
></el-color-picker>
|
|
|
</div>
|
|
|
</el-form-item>
|
|
|
- <el-form-item label="背景">
|
|
|
- <div
|
|
|
- slot="label"
|
|
|
- style="
|
|
|
- display: flex;
|
|
|
- align-items: center;
|
|
|
- justify-content: space-between;
|
|
|
- "
|
|
|
- >
|
|
|
- <span>背景</span>
|
|
|
- <el-switch v-model="formLabelAlign.enableBackground"></el-switch>
|
|
|
- </div>
|
|
|
- </el-form-item>
|
|
|
- <el-form-item label="透明度">
|
|
|
- <div
|
|
|
- slot="label"
|
|
|
- style="
|
|
|
- display: flex;
|
|
|
- align-items: center;
|
|
|
- justify-content: space-between;
|
|
|
- "
|
|
|
- >
|
|
|
- <span>透明度</span>
|
|
|
- <el-slider
|
|
|
- style="width: 90px"
|
|
|
- :min="14"
|
|
|
- :max="40"
|
|
|
- v-model="formLabelAlign.transparency"
|
|
|
- ></el-slider>
|
|
|
- </div>
|
|
|
- </el-form-item>
|
|
|
+
|
|
|
<el-form-item label="背景颜色">
|
|
|
<div
|
|
|
slot="label"
|
|
|
@@ -124,6 +95,7 @@
|
|
|
>
|
|
|
<span>背景颜色</span>
|
|
|
<el-color-picker
|
|
|
+ show-alpha
|
|
|
v-model="formLabelAlign.background"
|
|
|
></el-color-picker>
|
|
|
</div>
|
|
|
@@ -135,10 +107,11 @@
|
|
|
>
|
|
|
<span>数据颜色</span>
|
|
|
</div>
|
|
|
- <template v-for="(item, ind) in formLabelAlign.Ydata">
|
|
|
+ <template v-for="(item, ind) in filteredYData">
|
|
|
<div class="attributeItemData">
|
|
|
- <span></span>
|
|
|
+ <span>{{ item.label }}</span>
|
|
|
<el-color-picker
|
|
|
+ show-alpha
|
|
|
v-model="formLabelAlign.dataColor[ind]"
|
|
|
></el-color-picker>
|
|
|
</div>
|
|
|
@@ -186,15 +159,13 @@ export default {
|
|
|
formLabelAlign: {
|
|
|
enableLegend: null,
|
|
|
legendPosition: "",
|
|
|
- size: 14,
|
|
|
- titleColor: "#000",
|
|
|
- enableBackground: null,
|
|
|
- background: "",
|
|
|
- transparency: null, //透明度
|
|
|
+ size: 18,
|
|
|
+ titleColor: "#464646",
|
|
|
+ background: null,
|
|
|
dataColor: [],
|
|
|
},
|
|
|
disabled: true,
|
|
|
- selectData: [], //可选择的数据
|
|
|
+ selectColorData: [], //可选择的数据
|
|
|
};
|
|
|
},
|
|
|
computed: {
|
|
|
@@ -202,6 +173,36 @@ export default {
|
|
|
currentChartList: "currentChartList",
|
|
|
dataBaseCheckList: "dataBaseCheckList",
|
|
|
}),
|
|
|
+ filteredYData() {
|
|
|
+ const { type } = this.curEdit;
|
|
|
+ const { BarYdata, LineYdata, ScatterYdata, Ydata } = this.curEdit;
|
|
|
+ if (type === "pareto") {
|
|
|
+ return [...LineYdata, ...BarYdata];
|
|
|
+ } else if (type === "Cp") {
|
|
|
+ return [...LineYdata, ...ScatterYdata];
|
|
|
+ } else if (
|
|
|
+ [
|
|
|
+ "bar",
|
|
|
+ "line",
|
|
|
+ "radar",
|
|
|
+ "scatter",
|
|
|
+ "pie",
|
|
|
+ // "doughnut",
|
|
|
+ // "lineHighlight",
|
|
|
+ "horizontalStackedBar1",
|
|
|
+ "funnelPlot2",
|
|
|
+ "roseChart",
|
|
|
+ "stackedBar",
|
|
|
+ "boxPlot",
|
|
|
+ "sankeyDiagram",
|
|
|
+ "Heatmap",
|
|
|
+ ].includes(type)
|
|
|
+ ) {
|
|
|
+ console.log(Ydata, "filteredYData");
|
|
|
+ return Ydata;
|
|
|
+ }
|
|
|
+ return []; // 默认返回空数组
|
|
|
+ },
|
|
|
},
|
|
|
watch: {
|
|
|
curEdit() {
|
|
|
@@ -209,18 +210,17 @@ export default {
|
|
|
},
|
|
|
formLabelAlign: {
|
|
|
handler(nval) {
|
|
|
- this.changeChart("filter");
|
|
|
+ this.changeChart("");
|
|
|
},
|
|
|
deep: true,
|
|
|
},
|
|
|
},
|
|
|
+ mounted() {
|
|
|
+ console.log("toolbox页面");
|
|
|
+ this.changeData();
|
|
|
+ },
|
|
|
methods: {
|
|
|
- ...mapMutations("dragChart", [
|
|
|
- "updateChart",
|
|
|
- "setCurEdit",
|
|
|
- "setFormFilterAlignData",
|
|
|
- ]),
|
|
|
-
|
|
|
+ ...mapMutations("dragChart", ["updateChart"]),
|
|
|
changeData() {
|
|
|
if (this.$refs.form) {
|
|
|
this.$refs.form.resetFields();
|
|
|
@@ -229,22 +229,17 @@ export default {
|
|
|
if (this.curEdit && this.curEdit.option) {
|
|
|
// 使用 this.$set 替代直接赋值
|
|
|
this.$set(this, "formLabelAlign", {
|
|
|
- text: this.curEdit.option.title?.text || "",
|
|
|
- Xlable: this.curEdit.option.xAxis?.name || "",
|
|
|
- Ylable: this.curEdit.option.yAxis?.name || "",
|
|
|
- YRightLable:
|
|
|
- this.curEdit.type === "pareto"
|
|
|
- ? this.curEdit.option.yAxis[1].name
|
|
|
- : "",
|
|
|
- YLeftLable:
|
|
|
- this.curEdit.type === "pareto"
|
|
|
- ? this.curEdit.option.yAxis[0].name
|
|
|
- : "",
|
|
|
+ enableLegend: this.curEdit.option.legend?.show,
|
|
|
+ legendPosition: this.curEdit.option.legend?.top || "top",
|
|
|
+ size: this.curEdit.option.title?.textStyle?.fontSize || 18,
|
|
|
+ titleColor: this.curEdit.option.title?.textStyle?.color || "#000",
|
|
|
+ background: this.curEdit.option.backgroundColor
|
|
|
+ ? this.curEdit.option.backgroundColor
|
|
|
+ : "transparent",
|
|
|
+ dataColor: [],
|
|
|
});
|
|
|
// 查找是否存在数据
|
|
|
- const index = this.currentChartList.findIndex(
|
|
|
- (item) => item.id === this.curEdit.id
|
|
|
- );
|
|
|
+ console.log(this.curEdit, "this.curEdit.option");
|
|
|
} else {
|
|
|
this.$message.warning("请选择一个图表进行编辑");
|
|
|
}
|
|
|
@@ -253,150 +248,249 @@ export default {
|
|
|
changeChart(isFilter) {
|
|
|
if (!this.curEdit?.option) return; // 确保 curEdit 和 option 存在
|
|
|
const item = JSON.parse(JSON.stringify(this.curEdit));
|
|
|
- if (this.curEdit.type === "scatter" || this.curEdit.type === "radar") {
|
|
|
- //判断散点选择的是否为number 或可转为number
|
|
|
- const isAllNumbers = (data) =>
|
|
|
- data.every((val) =>
|
|
|
- val.data.every((vals) => {
|
|
|
- return !isNaN(
|
|
|
- Number(vals[val.label] == undefined ? 0 : vals[val.label])
|
|
|
- );
|
|
|
- })
|
|
|
- );
|
|
|
- const isAllNumbersXdata = isAllNumbers(this.formLabelAlign.Xdata);
|
|
|
- const isAllNumbersYdata = isAllNumbers(this.formLabelAlign.Ydata);
|
|
|
- if (
|
|
|
- this.curEdit.type === "scatter" &&
|
|
|
- (!isAllNumbersXdata || !isAllNumbersYdata)
|
|
|
- ) {
|
|
|
- this.$message.warning("请选择数值项进行散点图绘制");
|
|
|
- return;
|
|
|
- }
|
|
|
- if (this.curEdit.type === "radar" && !isAllNumbersYdata) {
|
|
|
- this.$message.warning("指标值请选择数值项进行散点图绘制");
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
// 确保标题和坐标轴对象存在
|
|
|
item.option.title = item.option.title || {};
|
|
|
Object.assign(item.option.title, { text: this.formLabelAlign.text });
|
|
|
+ const defalueFormLabelAlign = {
|
|
|
+ text: this.curEdit.option.title?.text || "",
|
|
|
+ Xlable: this.curEdit.option.xAxis?.name || "",
|
|
|
+ Ylable: this.curEdit.option.yAxis?.name || "",
|
|
|
+ YRightLable:
|
|
|
+ this.curEdit.type === "pareto"
|
|
|
+ ? this.curEdit.option.yAxis[1].name
|
|
|
+ : "",
|
|
|
+ YLeftLable:
|
|
|
+ this.curEdit.type === "pareto"
|
|
|
+ ? this.curEdit.option.yAxis[0].name
|
|
|
+ : "",
|
|
|
+ Xdata:
|
|
|
+ this.curEdit.Xdata.length > 0
|
|
|
+ ? this.curEdit.Xdata
|
|
|
+ : [
|
|
|
+ {
|
|
|
+ label: "",
|
|
|
+ data: [],
|
|
|
+ id: "",
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ Ydata:
|
|
|
+ this.curEdit.Ydata.length > 0
|
|
|
+ ? this.curEdit.Ydata
|
|
|
+ : [
|
|
|
+ {
|
|
|
+ label: "",
|
|
|
+ data: [],
|
|
|
+ id: "",
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ BarXdata:
|
|
|
+ this.curEdit.BarXdata.length > 0
|
|
|
+ ? this.curEdit.BarXdata
|
|
|
+ : [
|
|
|
+ {
|
|
|
+ label: "",
|
|
|
+ data: [],
|
|
|
+ id: "",
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ BarYdata:
|
|
|
+ this.curEdit.BarYdata.length > 0
|
|
|
+ ? this.curEdit.BarYdata
|
|
|
+ : [
|
|
|
+ {
|
|
|
+ label: "",
|
|
|
+ data: [],
|
|
|
+ id: "",
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ LineXdata:
|
|
|
+ this.curEdit.LineXdata.length > 0
|
|
|
+ ? this.curEdit.LineXdata
|
|
|
+ : [
|
|
|
+ {
|
|
|
+ label: "",
|
|
|
+ data: [],
|
|
|
+ id: "",
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ LineYdata:
|
|
|
+ this.curEdit.LineYdata.length > 0
|
|
|
+ ? this.curEdit.LineYdata
|
|
|
+ : [
|
|
|
+ {
|
|
|
+ label: "",
|
|
|
+ data: [],
|
|
|
+ id: "",
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ ScatterXdata:
|
|
|
+ this.curEdit.ScatterXdata.length > 0
|
|
|
+ ? this.curEdit.ScatterXdata
|
|
|
+ : [
|
|
|
+ {
|
|
|
+ label: "",
|
|
|
+ data: [],
|
|
|
+ id: "",
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ ScatterYdata:
|
|
|
+ this.curEdit.ScatterYdata.length > 0
|
|
|
+ ? this.curEdit.ScatterYdata
|
|
|
+ : [
|
|
|
+ {
|
|
|
+ label: "",
|
|
|
+ data: [],
|
|
|
+ id: "",
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ };
|
|
|
if (this.curEdit.type === "bar" || this.curEdit.type === "line") {
|
|
|
handleBarChartLogic(
|
|
|
item,
|
|
|
- this.formLabelAlign,
|
|
|
- this.formFilterAlign,
|
|
|
+ {
|
|
|
+ ...defalueFormLabelAlign,
|
|
|
+ ...this.formLabelAlign,
|
|
|
+ },
|
|
|
+ item.formFilterAlignData,
|
|
|
isFilter,
|
|
|
this.curEdit.type
|
|
|
);
|
|
|
} else if (this.curEdit.type === "scatter") {
|
|
|
handleScatterChartLogic(
|
|
|
item,
|
|
|
- this.formLabelAlign,
|
|
|
- this.formFilterAlign,
|
|
|
+ {
|
|
|
+ ...defalueFormLabelAlign,
|
|
|
+ ...this.formLabelAlign,
|
|
|
+ },
|
|
|
+ item.formFilterAlignData,
|
|
|
isFilter,
|
|
|
this.curEdit.type
|
|
|
);
|
|
|
} else if (this.curEdit.type === "radar") {
|
|
|
handleRadarChartLogic(
|
|
|
item,
|
|
|
- this.formLabelAlign,
|
|
|
- this.formFilterAlign,
|
|
|
+ {
|
|
|
+ ...defalueFormLabelAlign,
|
|
|
+ ...this.formLabelAlign,
|
|
|
+ },
|
|
|
+ item.formFilterAlignData,
|
|
|
isFilter,
|
|
|
this.curEdit.type
|
|
|
);
|
|
|
} else if (this.curEdit.type === "Cp") {
|
|
|
handleCpChartLogic(
|
|
|
item,
|
|
|
- this.formLabelAlign,
|
|
|
- this.formFilterAlign,
|
|
|
+ {
|
|
|
+ ...defalueFormLabelAlign,
|
|
|
+ ...this.formLabelAlign,
|
|
|
+ },
|
|
|
+ item.formFilterAlignData,
|
|
|
isFilter,
|
|
|
this.curEdit.type
|
|
|
);
|
|
|
} else if (this.curEdit.type === "roseChart") {
|
|
|
handleRoseChartChartLogic(
|
|
|
item,
|
|
|
- this.formLabelAlign,
|
|
|
- this.formFilterAlign,
|
|
|
+ {
|
|
|
+ ...defalueFormLabelAlign,
|
|
|
+ ...this.formLabelAlign,
|
|
|
+ },
|
|
|
+ item.formFilterAlignData,
|
|
|
isFilter,
|
|
|
this.curEdit.type
|
|
|
);
|
|
|
} else if (this.curEdit.type === "pie") {
|
|
|
handlePieChartLogic(
|
|
|
item,
|
|
|
- this.formLabelAlign,
|
|
|
- this.formFilterAlign,
|
|
|
+ {
|
|
|
+ ...defalueFormLabelAlign,
|
|
|
+ ...this.formLabelAlign,
|
|
|
+ },
|
|
|
+ item.formFilterAlignData,
|
|
|
isFilter,
|
|
|
this.curEdit.type
|
|
|
);
|
|
|
} else if (this.curEdit.type === "stackedBar") {
|
|
|
handlestackedBarChartLogic(
|
|
|
item,
|
|
|
- this.formLabelAlign,
|
|
|
- this.formFilterAlign,
|
|
|
+ {
|
|
|
+ ...defalueFormLabelAlign,
|
|
|
+ ...this.formLabelAlign,
|
|
|
+ },
|
|
|
+ item.formFilterAlignData,
|
|
|
isFilter,
|
|
|
this.curEdit.type
|
|
|
);
|
|
|
} else if (this.curEdit.type === "pareto") {
|
|
|
handleParetoChartLogic(
|
|
|
item,
|
|
|
- this.formLabelAlign,
|
|
|
- this.formFilterAlign,
|
|
|
+ {
|
|
|
+ ...defalueFormLabelAlign,
|
|
|
+ ...this.formLabelAlign,
|
|
|
+ },
|
|
|
+ item.formFilterAlignData,
|
|
|
isFilter,
|
|
|
this.curEdit.type
|
|
|
);
|
|
|
} else if (this.curEdit.type === "boxPlot") {
|
|
|
handleBoxPlotChartLogic(
|
|
|
item,
|
|
|
- this.formLabelAlign,
|
|
|
- this.formFilterAlign,
|
|
|
+ {
|
|
|
+ ...defalueFormLabelAlign,
|
|
|
+ ...this.formLabelAlign,
|
|
|
+ },
|
|
|
+ item.formFilterAlignData,
|
|
|
isFilter,
|
|
|
this.curEdit.type
|
|
|
);
|
|
|
} else if (this.curEdit.type === "sankeyDiagram") {
|
|
|
handleSankeyDiagramPlotChartLogic(
|
|
|
item,
|
|
|
- this.formLabelAlign,
|
|
|
- this.formFilterAlign,
|
|
|
+ {
|
|
|
+ ...defalueFormLabelAlign,
|
|
|
+ ...this.formLabelAlign,
|
|
|
+ },
|
|
|
+ item.formFilterAlignData,
|
|
|
isFilter,
|
|
|
this.curEdit.type
|
|
|
);
|
|
|
} else if (this.curEdit.type === "Heatmap") {
|
|
|
handleHeatmapPlotChartLogic(
|
|
|
item,
|
|
|
- this.formLabelAlign,
|
|
|
- this.formFilterAlign,
|
|
|
+ {
|
|
|
+ ...defalueFormLabelAlign,
|
|
|
+ ...this.formLabelAlign,
|
|
|
+ },
|
|
|
+ item.formFilterAlignData,
|
|
|
isFilter,
|
|
|
this.curEdit.type
|
|
|
);
|
|
|
} else if (this.curEdit.type === "horizontalStackedBar1") {
|
|
|
handlHorizontalStackedBar1ChartLogic(
|
|
|
item,
|
|
|
- this.formLabelAlign,
|
|
|
- this.formFilterAlign,
|
|
|
+ {
|
|
|
+ ...defalueFormLabelAlign,
|
|
|
+ ...this.formLabelAlign,
|
|
|
+ },
|
|
|
+ item.formFilterAlignData,
|
|
|
isFilter,
|
|
|
this.curEdit.type
|
|
|
);
|
|
|
} else if (this.curEdit.type === "funnelPlot2") {
|
|
|
handleFunnelPlot2Chart(
|
|
|
item,
|
|
|
- this.formLabelAlign,
|
|
|
- this.formFilterAlign,
|
|
|
+ {
|
|
|
+ ...defalueFormLabelAlign,
|
|
|
+ ...this.formLabelAlign,
|
|
|
+ },
|
|
|
+ item.formFilterAlignData,
|
|
|
isFilter,
|
|
|
this.curEdit.type
|
|
|
);
|
|
|
}
|
|
|
- //设置仓库
|
|
|
- this.setFormFilterAlignData({
|
|
|
- id: this.curEdit.id,
|
|
|
- data: JSON.parse(JSON.stringify(this.formFilterAlign)),
|
|
|
- });
|
|
|
+
|
|
|
this.updateChart({
|
|
|
...item,
|
|
|
- LineYdata: this.formLabelAlign.LineYdata,
|
|
|
- ScatterYdata: this.formLabelAlign.ScatterYdata,
|
|
|
- BarYdata: this.formLabelAlign.BarYdata,
|
|
|
- Ydata: this.formLabelAlign.Ydata, //还是给所有的数据保存起来了,并不是过滤后的数据
|
|
|
- formFilterAlignData: this.formFilterAlign,
|
|
|
}); // 更新图表
|
|
|
},
|
|
|
},
|