diff --git a/src/views/digitalMarketingAlgorithms/components/clusterAnalysis.vue b/src/views/digitalMarketingAlgorithms/components/clusterAnalysis.vue
index dfa7fc4..c6880a9 100644
--- a/src/views/digitalMarketingAlgorithms/components/clusterAnalysis.vue
+++ b/src/views/digitalMarketingAlgorithms/components/clusterAnalysis.vue
@@ -395,7 +395,6 @@ onMounted(() => {
var chartDom = document.getElementById("main");
var chartDom2 = document.getElementById("main2");
myChart = echarts.init(chartDom);
- 472;
myChart2 = echarts.init(chartDom2);
// 初始化图表配置
var option = {
diff --git a/src/views/digitalMarketingAlgorithms/components/regressionAnalysis.vue b/src/views/digitalMarketingAlgorithms/components/regressionAnalysis.vue
index e9ed0be..62f75fa 100644
--- a/src/views/digitalMarketingAlgorithms/components/regressionAnalysis.vue
+++ b/src/views/digitalMarketingAlgorithms/components/regressionAnalysis.vue
@@ -82,7 +82,7 @@
-
+
分析数据:
@@ -103,6 +103,11 @@
+
@@ -398,10 +403,83 @@ const handleChange = (info) => {
fileList.value.push(info);
};
const flag = ref(false);
+let myChart;
+const getRandomColorHex = () => {
+ const randomValue = (min, max) => {
+ // 生成 min 到 max 之间的随机整数
+ const value = Math.floor(Math.random() * (max - min + 1)) + min;
+ // 将整数转换为两位十六进制形式
+ return value.toString(16).padStart(2, "0");
+ };
+
+ // 限制红色通道较低,绿色和蓝色通道较高
+ const r = randomValue(0, 128); // 红色通道较低 (0-128)
+ const g = randomValue(128, 255); // 绿色通道较高 (128-255)
+ const b = randomValue(128, 255); // 蓝色通道较高 (128-255)
+
+ return `#${r}${g}${b}`;
+};
+//图标添加数据
+const addData = (myChart, newData, color) => {
+ // 获取当前的数据
+ let currentData = myChart.getOption().series[0].data || [];
+ // 添加新数据集,并为每个数据点单独设置颜色
+ if(input5.value[0]==="sales_forehead"){
+ newData.forEach((dataPoint) => {
+ currentData.push({
+ value: [dataPoint.sales_forehead, dataPoint.sales_volume],
+ itemStyle: { color: color },
+ });
+ });
+ }else{
+ newData.forEach((dataPoint) => {
+ currentData.push({
+ value: [dataPoint.sales_volume, dataPoint.sales_forehead],
+ itemStyle: { color: color },
+ });
+ });
+ }
+
+
+ // 更新图表
+ myChart.setOption({
+ series: [
+ {
+ data: currentData,
+ },
+ ],
+ });
+};
onMounted(() => {
getList();
optionData();
+ var chartDom = document.getElementById("main");
+ myChart = echarts.init(chartDom);
+ var option = {
+ dataset: [
+ {
+ source: [], // 初始时数据为空
+ },
+ ],
+ tooltip: {
+ position: "top",
+ },
+ xAxis: {},
+ yAxis: {},
+ series: [
+ {
+ type: "scatter",
+ encode: { tooltip: [0, 1] },
+ symbolSize: 8,
+ itemStyle: {
+ borderColor: "#555",
+ },
+ },
+ ],
+ };
+ // 设置初始的配置
+ myChart.setOption(option);
});
const optionData = () => {
@@ -532,35 +610,6 @@ const computation = () => {
userId: JSON.parse(getUserInfo()).userId,
};
loading1.value = true;
- if (input4.value === "线性回归") {
- if (input5.value.length > 1) {
- proxy.$modal.msgError("y变量数量有误!");
- return;
- }
- if (input6.value.length != 2 || input6.value.length > 2) {
- proxy.$modal.msgError("x变量数量有误!");
- return;
- }
- flagColumn.value = true;
- tableData2.value.forEach((item) => {
- sendData.y.push(item[input5.value[0]]);
- sendData.x.push([item[input6.value[0]], item[input6.value[1]]]);
- });
- API.linearRegression(sendData).then((res) => {
- tableLabel2.length = 0;
- for (const key in res.data) {
- tableLabel2.push({
- label: key,
- prop: key,
- });
- }
- let data = res.data;
- data.slopes = data.slopes.join(",");
- tableData3.value = [data];
- predictionResults.value = "";
- loading1.value = false;
- });
- } else {
if (input5.value.length > 1) {
proxy.$modal.msgError("y变量数量有误!");
return;
@@ -591,7 +640,16 @@ const computation = () => {
predictionResults.value = "";
loading1.value = true;
});
- }
+ //表格
+ myChart.setOption({
+ series: [
+ {
+ data: [], // 清空数据
+ },
+ ],
+ });
+ const bgColor = getRandomColorHex();
+ addData(myChart,tableData2.value,bgColor)
} else {
proxy.$modal.msgWarning("请模型参数进行设置!");
}