|
|
|
@ -318,9 +318,11 @@ import useAlgorithmStore from "@/store/modules/algorithm.js";
|
|
|
|
const algorithmStore = useAlgorithmStore();
|
|
|
|
const algorithmStore = useAlgorithmStore();
|
|
|
|
import popModel from "@/views/components/popModal.vue";
|
|
|
|
import popModel from "@/views/components/popModal.vue";
|
|
|
|
import * as echarts from "echarts";
|
|
|
|
import * as echarts from "echarts";
|
|
|
|
|
|
|
|
import { htmlPdf } from "@/utils/pdf.js";
|
|
|
|
import * as API from "@/api/AI.js";
|
|
|
|
import * as API from "@/api/AI.js";
|
|
|
|
import { getUserInfo } from "@/utils/auth";
|
|
|
|
import { getUserInfo } from "@/utils/auth";
|
|
|
|
import * as XLSX from "XLSX";
|
|
|
|
import * as XLSX from "XLSX";
|
|
|
|
|
|
|
|
import JSZip from "jszip";
|
|
|
|
import { onMounted, reactive } from "vue";
|
|
|
|
import { onMounted, reactive } from "vue";
|
|
|
|
const { proxy } = getCurrentInstance();
|
|
|
|
const { proxy } = getCurrentInstance();
|
|
|
|
const dialogVisible = ref(false);
|
|
|
|
const dialogVisible = ref(false);
|
|
|
|
@ -424,23 +426,12 @@ const addData = (myChart, newData, color) => {
|
|
|
|
// 获取当前的数据
|
|
|
|
// 获取当前的数据
|
|
|
|
let currentData = myChart.getOption().series[0].data || [];
|
|
|
|
let currentData = myChart.getOption().series[0].data || [];
|
|
|
|
// 添加新数据集,并为每个数据点单独设置颜色
|
|
|
|
// 添加新数据集,并为每个数据点单独设置颜色
|
|
|
|
if(input5.value[0]==="sales_forehead"){
|
|
|
|
|
|
|
|
newData.forEach((dataPoint) => {
|
|
|
|
newData.forEach((dataPoint) => {
|
|
|
|
currentData.push({
|
|
|
|
currentData.push({
|
|
|
|
value: [dataPoint.sales_forehead, dataPoint.sales_volume],
|
|
|
|
value: [dataPoint[0], dataPoint[1]],
|
|
|
|
itemStyle: { color: color },
|
|
|
|
itemStyle: { color: color },
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}else{
|
|
|
|
|
|
|
|
newData.forEach((dataPoint) => {
|
|
|
|
|
|
|
|
currentData.push({
|
|
|
|
|
|
|
|
value: [dataPoint.sales_volume, dataPoint.sales_forehead],
|
|
|
|
|
|
|
|
itemStyle: { color: color },
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 更新图表
|
|
|
|
// 更新图表
|
|
|
|
myChart.setOption({
|
|
|
|
myChart.setOption({
|
|
|
|
series: [
|
|
|
|
series: [
|
|
|
|
@ -469,7 +460,7 @@ onMounted(() => {
|
|
|
|
yAxis: {},
|
|
|
|
yAxis: {},
|
|
|
|
series: [
|
|
|
|
series: [
|
|
|
|
{
|
|
|
|
{
|
|
|
|
type: "scatter",
|
|
|
|
type: "line",
|
|
|
|
encode: { tooltip: [0, 1] },
|
|
|
|
encode: { tooltip: [0, 1] },
|
|
|
|
symbolSize: 8,
|
|
|
|
symbolSize: 8,
|
|
|
|
itemStyle: {
|
|
|
|
itemStyle: {
|
|
|
|
@ -641,15 +632,32 @@ const computation = () => {
|
|
|
|
loading1.value = true;
|
|
|
|
loading1.value = true;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
//表格
|
|
|
|
//表格
|
|
|
|
myChart.setOption({
|
|
|
|
let sendData2={}
|
|
|
|
series: [
|
|
|
|
if(input5.value[0]==="sales_volume"){
|
|
|
|
{
|
|
|
|
sendData2={
|
|
|
|
data: [], // 清空数据
|
|
|
|
userId:JSON.parse(getUserInfo()).userId,
|
|
|
|
},
|
|
|
|
y:tableData2.value.map(item=>item.sales_volume),
|
|
|
|
],
|
|
|
|
x:tableData2.value.map(item=>item.sales_forehead)
|
|
|
|
});
|
|
|
|
}
|
|
|
|
const bgColor = getRandomColorHex();
|
|
|
|
}else{
|
|
|
|
addData(myChart,tableData2.value,bgColor)
|
|
|
|
sendData2={
|
|
|
|
|
|
|
|
userId:JSON.parse(getUserInfo()).userId,
|
|
|
|
|
|
|
|
y:tableData2.value.map(item=>item.sales_forehead),
|
|
|
|
|
|
|
|
x:tableData2.value.map(item=>item.sales_volume)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
API.regressionAnalysisTrendChart(sendData2).then((res)=>{
|
|
|
|
|
|
|
|
myChart.setOption({
|
|
|
|
|
|
|
|
series: [
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
data: [], // 清空数据
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
const bgColor = getRandomColorHex();
|
|
|
|
|
|
|
|
addData(myChart,res.data,bgColor)
|
|
|
|
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
proxy.$modal.msgWarning("请模型参数进行设置!");
|
|
|
|
proxy.$modal.msgWarning("请模型参数进行设置!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -674,19 +682,6 @@ const handleClick = (item) => {
|
|
|
|
};
|
|
|
|
};
|
|
|
|
const predictionResults = ref("");
|
|
|
|
const predictionResults = ref("");
|
|
|
|
const Forecasting = () => {
|
|
|
|
const Forecasting = () => {
|
|
|
|
// if (nowData.value.type === "线性回归") {
|
|
|
|
|
|
|
|
// const sendData = {
|
|
|
|
|
|
|
|
// intercept: nowData.value.intercept,
|
|
|
|
|
|
|
|
// type: nowData.value.type,
|
|
|
|
|
|
|
|
// slopes: nowData.value.slopes.split(",").map(Number),
|
|
|
|
|
|
|
|
// raX: formInline2.user.split(",").map(Number),
|
|
|
|
|
|
|
|
// };
|
|
|
|
|
|
|
|
// API.logisticRegressionPrediction(sendData).then((res) => {
|
|
|
|
|
|
|
|
// dialogVisible2.value = false;
|
|
|
|
|
|
|
|
// predictionResults.value = res.data;
|
|
|
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// if (nowData.value.type === "逻辑回归") {
|
|
|
|
|
|
|
|
const sendData = {
|
|
|
|
const sendData = {
|
|
|
|
intercept: nowData.value.intercept,
|
|
|
|
intercept: nowData.value.intercept,
|
|
|
|
slope: nowData.value.slope,
|
|
|
|
slope: nowData.value.slope,
|
|
|
|
@ -703,9 +698,22 @@ const upLoad = () => {
|
|
|
|
if (!tableDom) {
|
|
|
|
if (!tableDom) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const wb = XLSX.utils.table_to_book(tableDom);
|
|
|
|
const wb = XLSX.utils.table_to_book(tableDom);
|
|
|
|
XLSX.writeFile(wb, "回归分析.xlsx");
|
|
|
|
// XLSX.writeFile(wb, '聚类分析.xlsx');
|
|
|
|
|
|
|
|
const zip = new JSZip();
|
|
|
|
|
|
|
|
const excelBlob = XLSX.write(wb, { bookType: "xlsx", type: "array" });
|
|
|
|
|
|
|
|
zip.file("回归分析.xlsx", new Blob([excelBlob], { type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" }));
|
|
|
|
|
|
|
|
zip.file("回归分析图.pdf", handleExport());
|
|
|
|
|
|
|
|
zip.generateAsync({ type: "blob" }).then((content) => {
|
|
|
|
|
|
|
|
saveAs(content, "回归分析.zip");
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
//图表导出pdf
|
|
|
|
|
|
|
|
const handleExport = async (name) => {
|
|
|
|
|
|
|
|
var fileName = "回归分析图";
|
|
|
|
|
|
|
|
const fileList = document.getElementsByClassName("pdfRef"); // 很重要
|
|
|
|
|
|
|
|
const pdfBlob = await htmlPdf(fileName, document.querySelector("#pdfRef"), fileList, true);
|
|
|
|
|
|
|
|
return pdfBlob;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
const startOver = () => {
|
|
|
|
const startOver = () => {
|
|
|
|
input.value = "";
|
|
|
|
input.value = "";
|
|
|
|
|