rapid-spreadjs 1.0.87 → 1.0.89
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 +31 -25
- 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 +31 -25
- 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: [
|
|
@@ -19997,7 +20003,7 @@ const FormulaUtils = {
|
|
|
19997
20003
|
isAcceptArea: true,
|
|
19998
20004
|
funParams: [
|
|
19999
20005
|
{
|
|
20000
|
-
name: '
|
|
20006
|
+
name: '需要用作判断的数字数组、字符串数组或单值',
|
|
20001
20007
|
repeatable: false,
|
|
20002
20008
|
optional: false,
|
|
20003
20009
|
},
|
|
@@ -20033,7 +20039,7 @@ const FormulaUtils = {
|
|
|
20033
20039
|
if (retData.allCellValsEw.length < 5) {
|
|
20034
20040
|
return '/';
|
|
20035
20041
|
}
|
|
20036
|
-
let array1 = retData.allCellValsEw[0], array2 = retData.allCellValsEw[1], operator = retData.allCellValsEw[2], value = retData.allCellValsEw[3], delimiter = retData.allCellValsEw[4], isOpposite = retData.allCellValsEw.length
|
|
20042
|
+
let array1 = retData.allCellValsEw[0], array2 = retData.allCellValsEw[1], operator = retData.allCellValsEw[2], value = retData.allCellValsEw[3], delimiter = retData.allCellValsEw[4], isOpposite = retData.allCellValsEw.length < 6 ? 0 : retData.allCellValsEw[5];
|
|
20037
20043
|
try {
|
|
20038
20044
|
// 处理array1和array2的默认值
|
|
20039
20045
|
if (array1 == null || array1 == undefined || (typeof array1 == 'string' && array1.trim().length == 0)) {
|
|
@@ -20102,7 +20108,7 @@ const FormulaUtils = {
|
|
|
20102
20108
|
case '>':
|
|
20103
20109
|
case '>':
|
|
20104
20110
|
if (isSingleValue1) {
|
|
20105
|
-
conditionMet =
|
|
20111
|
+
conditionMet = num2 > num1;
|
|
20106
20112
|
}
|
|
20107
20113
|
else {
|
|
20108
20114
|
conditionMet = num1 > numValue;
|
|
@@ -20111,7 +20117,7 @@ const FormulaUtils = {
|
|
|
20111
20117
|
case '<':
|
|
20112
20118
|
case '<':
|
|
20113
20119
|
if (isSingleValue1) {
|
|
20114
|
-
conditionMet =
|
|
20120
|
+
conditionMet = num2 < num1;
|
|
20115
20121
|
}
|
|
20116
20122
|
else {
|
|
20117
20123
|
conditionMet = num1 < numValue;
|
|
@@ -20121,7 +20127,7 @@ const FormulaUtils = {
|
|
|
20121
20127
|
case '≥':
|
|
20122
20128
|
case '≧':
|
|
20123
20129
|
if (isSingleValue1) {
|
|
20124
|
-
conditionMet =
|
|
20130
|
+
conditionMet = num2 >= num1;
|
|
20125
20131
|
}
|
|
20126
20132
|
else {
|
|
20127
20133
|
conditionMet = num1 >= numValue;
|
|
@@ -20131,7 +20137,7 @@ const FormulaUtils = {
|
|
|
20131
20137
|
case '≤':
|
|
20132
20138
|
case '≦':
|
|
20133
20139
|
if (isSingleValue1) {
|
|
20134
|
-
conditionMet =
|
|
20140
|
+
conditionMet = num2 <= num1;
|
|
20135
20141
|
}
|
|
20136
20142
|
else {
|
|
20137
20143
|
conditionMet = num1 <= numValue;
|
|
@@ -20140,7 +20146,7 @@ const FormulaUtils = {
|
|
|
20140
20146
|
case '=':
|
|
20141
20147
|
case '=':
|
|
20142
20148
|
if (isSingleValue1) {
|
|
20143
|
-
conditionMet =
|
|
20149
|
+
conditionMet = num2 === num1;
|
|
20144
20150
|
}
|
|
20145
20151
|
else {
|
|
20146
20152
|
conditionMet = num1 === numValue;
|