rapid-spreadjs 1.0.87 → 1.0.88
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +24 -18
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.cjs.min.js +1 -1
- package/dist/index.cjs.min.js.map +1 -1
- package/dist/index.esm.js +24 -18
- package/dist/index.esm.js.map +1 -1
- package/dist/index.esm.min.js +1 -1
- package/dist/index.esm.min.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -8384,6 +8384,16 @@ const EChartsUtilsAll = {
|
|
|
8384
8384
|
// 原始数据
|
|
8385
8385
|
const xData = xDataArr[0];
|
|
8386
8386
|
const yData = yDataArr[0];
|
|
8387
|
+
let yValIsAllNull = false;
|
|
8388
|
+
if (xData.length == 0 ||
|
|
8389
|
+
yData.length == 0 ||
|
|
8390
|
+
(!xData.some((x) => x != '' && x != '/' && x != null && x != undefined) &&
|
|
8391
|
+
!yData.some((x) => x != '' && x != '/' && x != null && x != undefined))) {
|
|
8392
|
+
yValIsAllNull = true;
|
|
8393
|
+
}
|
|
8394
|
+
if (xData.filter((x) => x == 0).length == xData.length || yData.filter((x) => x == 0).length == yData.length) {
|
|
8395
|
+
yValIsAllNull = true;
|
|
8396
|
+
}
|
|
8387
8397
|
// 手动计算多项式回归系数(与Excel一致)
|
|
8388
8398
|
function polynomialRegression(x, y, degree) {
|
|
8389
8399
|
const n = x.length;
|
|
@@ -8450,20 +8460,23 @@ const EChartsUtilsAll = {
|
|
|
8450
8460
|
}
|
|
8451
8461
|
return coefficients;
|
|
8452
8462
|
}
|
|
8453
|
-
// 计算多项式回归系数(阶数为2)
|
|
8454
|
-
const coefficients = polynomialRegression(xData, yData, 2);
|
|
8455
8463
|
// 提取系数(与Excel一致)
|
|
8456
|
-
|
|
8457
|
-
const b = coefficients[1].toFixed(2);
|
|
8458
|
-
const c = coefficients[0].toFixed(2);
|
|
8464
|
+
let a = '/', b = '/', c = '/';
|
|
8459
8465
|
// 生成回归线的数据点
|
|
8460
|
-
|
|
8461
|
-
const minX = Math.min(...xData);
|
|
8466
|
+
let regressionPoints = [];
|
|
8462
8467
|
const maxX = Math.max(...xData);
|
|
8463
|
-
|
|
8464
|
-
|
|
8465
|
-
const
|
|
8466
|
-
|
|
8468
|
+
if (!yValIsAllNull) {
|
|
8469
|
+
// 计算多项式回归系数(阶数为2)
|
|
8470
|
+
const coefficients = polynomialRegression(xData, yData, 2);
|
|
8471
|
+
a = coefficients[2].toFixed(2);
|
|
8472
|
+
b = coefficients[1].toFixed(2);
|
|
8473
|
+
c = coefficients[0].toFixed(2);
|
|
8474
|
+
const minX = Math.min(...xData);
|
|
8475
|
+
const step = (maxX - minX) / 100;
|
|
8476
|
+
for (let x = minX; x <= maxX; x += step) {
|
|
8477
|
+
const y = parseFloat(a) * x * x + parseFloat(b) * x + parseFloat(c);
|
|
8478
|
+
regressionPoints.push([x, y]);
|
|
8479
|
+
}
|
|
8467
8480
|
}
|
|
8468
8481
|
// 输出方程
|
|
8469
8482
|
if (chartExtJson != null) {
|
|
@@ -8480,13 +8493,6 @@ const EChartsUtilsAll = {
|
|
|
8480
8493
|
sheet.setValue(chartExtJson.dwylHtbxC.row, chartExtJson.dwylHtbxC.col, c != 'NaN' ? c : '/');
|
|
8481
8494
|
}
|
|
8482
8495
|
}
|
|
8483
|
-
let yValIsAllNull = false;
|
|
8484
|
-
if (xData.length == 0 ||
|
|
8485
|
-
yData.length == 0 ||
|
|
8486
|
-
(!xData.some((x) => x != '' && x != '/' && x != null && x != undefined) &&
|
|
8487
|
-
!yData.some((x) => x != '' && x != '/' && x != null && x != undefined))) {
|
|
8488
|
-
yValIsAllNull = true;
|
|
8489
|
-
}
|
|
8490
8496
|
// 配置图表选项
|
|
8491
8497
|
let option = {
|
|
8492
8498
|
title: [
|