|
|
@ -1,6 +1,6 @@
|
|
|
|
<template>
|
|
|
|
<template>
|
|
|
|
<div>
|
|
|
|
<div>
|
|
|
|
<el-form label-width="80px" label-position="left">
|
|
|
|
<el-form label-width="100px" label-position="left">
|
|
|
|
<el-form-item label="数据集">
|
|
|
|
<el-form-item label="数据集">
|
|
|
|
<el-select
|
|
|
|
<el-select
|
|
|
|
size="mini"
|
|
|
|
size="mini"
|
|
|
@ -43,7 +43,7 @@
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
</template>
|
|
|
|
<script>
|
|
|
|
<script>
|
|
|
|
import { queryAllDataSet, detailBysetId, getData } from "@/api/bigscreen";
|
|
|
|
import { queryAllDataSet, detailBysetId } from "@/api/bigscreen";
|
|
|
|
import Dictionary from "@/components/Dictionary/index";
|
|
|
|
import Dictionary from "@/components/Dictionary/index";
|
|
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
export default {
|
|
|
@ -108,105 +108,11 @@ export default {
|
|
|
|
chartProperties: this.chartProperties,
|
|
|
|
chartProperties: this.chartProperties,
|
|
|
|
contextData
|
|
|
|
contextData
|
|
|
|
};
|
|
|
|
};
|
|
|
|
console.log(params);
|
|
|
|
this.$emit("input", params);
|
|
|
|
const { code, data } = await getData(params);
|
|
|
|
|
|
|
|
const analysisData = this.analysisChartsData(data);
|
|
|
|
|
|
|
|
console.log(analysisData);
|
|
|
|
|
|
|
|
this.$emit("input", analysisData);
|
|
|
|
|
|
|
|
this.$emit("change", params);
|
|
|
|
this.$emit("change", params);
|
|
|
|
if (code != "200") return;
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
selectParams(val, key) {
|
|
|
|
selectParams(val, key) {
|
|
|
|
this.chartProperties[key] = val;
|
|
|
|
this.chartProperties[key] = val;
|
|
|
|
},
|
|
|
|
|
|
|
|
// 解析不同图标的数据
|
|
|
|
|
|
|
|
analysisChartsData(data) {
|
|
|
|
|
|
|
|
// widget-barchart 柱线图、widget-linechart 折线图、 widget-barlinechart 柱线图、widget-piechart 饼图、widget-hollow-piechart 空心饼图
|
|
|
|
|
|
|
|
// widget-funnel 漏斗图 widget-gauge 仪表盘
|
|
|
|
|
|
|
|
const chartType = this.chartType;
|
|
|
|
|
|
|
|
if (
|
|
|
|
|
|
|
|
chartType == "widget-barchart" ||
|
|
|
|
|
|
|
|
chartType == "widget-linechart" ||
|
|
|
|
|
|
|
|
chartType == "widget-barlinechart"
|
|
|
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
return this.barOrLineChartFn(data);
|
|
|
|
|
|
|
|
} else if (
|
|
|
|
|
|
|
|
chartType == "widget-piechart" ||
|
|
|
|
|
|
|
|
chartType == "widget-hollow-piechart" ||
|
|
|
|
|
|
|
|
chartType == "widget-funnel"
|
|
|
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
return this.piechartFn(data);
|
|
|
|
|
|
|
|
} else if (chartType == "widget-gauge") {
|
|
|
|
|
|
|
|
return this.gaugeFn(data);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
// 柱状图、折线图、折柱图
|
|
|
|
|
|
|
|
barOrLineChartFn(data) {
|
|
|
|
|
|
|
|
const ananysicData = {};
|
|
|
|
|
|
|
|
const xAxisList = [];
|
|
|
|
|
|
|
|
const series = [];
|
|
|
|
|
|
|
|
for (const key in this.chartProperties) {
|
|
|
|
|
|
|
|
const obj = {};
|
|
|
|
|
|
|
|
const seriesData = [];
|
|
|
|
|
|
|
|
const value = this.chartProperties[key];
|
|
|
|
|
|
|
|
obj["type"] = value;
|
|
|
|
|
|
|
|
for (let i = 0; i < data.length; i++) {
|
|
|
|
|
|
|
|
if (value.startsWith("xAxis")) {
|
|
|
|
|
|
|
|
// 代表为x轴
|
|
|
|
|
|
|
|
xAxisList[i] = data[i][key];
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
// 其他的均为series展示数据
|
|
|
|
|
|
|
|
seriesData[i] = data[i][key];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
obj["data"] = seriesData;
|
|
|
|
|
|
|
|
if (!obj["type"].startsWith("xAxis")) {
|
|
|
|
|
|
|
|
series.push(obj);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
ananysicData["xAxis"] = xAxisList;
|
|
|
|
|
|
|
|
ananysicData["series"] = series;
|
|
|
|
|
|
|
|
// console.log(ananysicData, '结果数据')
|
|
|
|
|
|
|
|
return ananysicData;
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
// 饼图或者空心饼图或者漏斗图
|
|
|
|
|
|
|
|
piechartFn(data) {
|
|
|
|
|
|
|
|
const ananysicData = [];
|
|
|
|
|
|
|
|
for (let i = 0; i < data.length; i++) {
|
|
|
|
|
|
|
|
const obj = {};
|
|
|
|
|
|
|
|
for (const key in this.chartProperties) {
|
|
|
|
|
|
|
|
const value = this.chartProperties[key];
|
|
|
|
|
|
|
|
if (value === "name") {
|
|
|
|
|
|
|
|
obj["name"] = data[i][key];
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
obj["value"] = data[i][key];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
ananysicData.push(obj);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// console.log(ananysicData, '结果数据')
|
|
|
|
|
|
|
|
return ananysicData;
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
gaugeFn(data) {
|
|
|
|
|
|
|
|
const ananysicData = [];
|
|
|
|
|
|
|
|
for (let i = 0; i < data.length; i++) {
|
|
|
|
|
|
|
|
const obj = {};
|
|
|
|
|
|
|
|
for (const key in this.chartProperties) {
|
|
|
|
|
|
|
|
const value = this.chartProperties[key];
|
|
|
|
|
|
|
|
if (value === "name") {
|
|
|
|
|
|
|
|
obj["name"] = data[i][key];
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
obj["value"] = data[i][key];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!obj["unit"]) {
|
|
|
|
|
|
|
|
obj["unit"] = "%";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
ananysicData.push(obj);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// console.log(ananysicData, '结果数据')
|
|
|
|
|
|
|
|
return ananysicData[0];
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|