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.esm.js
CHANGED
|
@@ -8362,6 +8362,16 @@ const EChartsUtilsAll = {
|
|
|
8362
8362
|
// 原始数据
|
|
8363
8363
|
const xData = xDataArr[0];
|
|
8364
8364
|
const yData = yDataArr[0];
|
|
8365
|
+
let yValIsAllNull = false;
|
|
8366
|
+
if (xData.length == 0 ||
|
|
8367
|
+
yData.length == 0 ||
|
|
8368
|
+
(!xData.some((x) => x != '' && x != '/' && x != null && x != undefined) &&
|
|
8369
|
+
!yData.some((x) => x != '' && x != '/' && x != null && x != undefined))) {
|
|
8370
|
+
yValIsAllNull = true;
|
|
8371
|
+
}
|
|
8372
|
+
if (xData.filter((x) => x == 0).length == xData.length || yData.filter((x) => x == 0).length == yData.length) {
|
|
8373
|
+
yValIsAllNull = true;
|
|
8374
|
+
}
|
|
8365
8375
|
// 手动计算多项式回归系数(与Excel一致)
|
|
8366
8376
|
function polynomialRegression(x, y, degree) {
|
|
8367
8377
|
const n = x.length;
|
|
@@ -8428,20 +8438,23 @@ const EChartsUtilsAll = {
|
|
|
8428
8438
|
}
|
|
8429
8439
|
return coefficients;
|
|
8430
8440
|
}
|
|
8431
|
-
// 计算多项式回归系数(阶数为2)
|
|
8432
|
-
const coefficients = polynomialRegression(xData, yData, 2);
|
|
8433
8441
|
// 提取系数(与Excel一致)
|
|
8434
|
-
|
|
8435
|
-
const b = coefficients[1].toFixed(2);
|
|
8436
|
-
const c = coefficients[0].toFixed(2);
|
|
8442
|
+
let a = '/', b = '/', c = '/';
|
|
8437
8443
|
// 生成回归线的数据点
|
|
8438
|
-
|
|
8439
|
-
const minX = Math.min(...xData);
|
|
8444
|
+
let regressionPoints = [];
|
|
8440
8445
|
const maxX = Math.max(...xData);
|
|
8441
|
-
|
|
8442
|
-
|
|
8443
|
-
const
|
|
8444
|
-
|
|
8446
|
+
if (!yValIsAllNull) {
|
|
8447
|
+
// 计算多项式回归系数(阶数为2)
|
|
8448
|
+
const coefficients = polynomialRegression(xData, yData, 2);
|
|
8449
|
+
a = coefficients[2].toFixed(2);
|
|
8450
|
+
b = coefficients[1].toFixed(2);
|
|
8451
|
+
c = coefficients[0].toFixed(2);
|
|
8452
|
+
const minX = Math.min(...xData);
|
|
8453
|
+
const step = (maxX - minX) / 100;
|
|
8454
|
+
for (let x = minX; x <= maxX; x += step) {
|
|
8455
|
+
const y = parseFloat(a) * x * x + parseFloat(b) * x + parseFloat(c);
|
|
8456
|
+
regressionPoints.push([x, y]);
|
|
8457
|
+
}
|
|
8445
8458
|
}
|
|
8446
8459
|
// 输出方程
|
|
8447
8460
|
if (chartExtJson != null) {
|
|
@@ -8458,13 +8471,6 @@ const EChartsUtilsAll = {
|
|
|
8458
8471
|
sheet.setValue(chartExtJson.dwylHtbxC.row, chartExtJson.dwylHtbxC.col, c != 'NaN' ? c : '/');
|
|
8459
8472
|
}
|
|
8460
8473
|
}
|
|
8461
|
-
let yValIsAllNull = false;
|
|
8462
|
-
if (xData.length == 0 ||
|
|
8463
|
-
yData.length == 0 ||
|
|
8464
|
-
(!xData.some((x) => x != '' && x != '/' && x != null && x != undefined) &&
|
|
8465
|
-
!yData.some((x) => x != '' && x != '/' && x != null && x != undefined))) {
|
|
8466
|
-
yValIsAllNull = true;
|
|
8467
|
-
}
|
|
8468
8474
|
// 配置图表选项
|
|
8469
8475
|
let option = {
|
|
8470
8476
|
title: [
|
|
@@ -19975,7 +19981,7 @@ const FormulaUtils = {
|
|
|
19975
19981
|
isAcceptArea: true,
|
|
19976
19982
|
funParams: [
|
|
19977
19983
|
{
|
|
19978
|
-
name: '
|
|
19984
|
+
name: '需要用作判断的数字数组、字符串数组或单值',
|
|
19979
19985
|
repeatable: false,
|
|
19980
19986
|
optional: false,
|
|
19981
19987
|
},
|
|
@@ -20011,7 +20017,7 @@ const FormulaUtils = {
|
|
|
20011
20017
|
if (retData.allCellValsEw.length < 5) {
|
|
20012
20018
|
return '/';
|
|
20013
20019
|
}
|
|
20014
|
-
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
|
|
20020
|
+
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];
|
|
20015
20021
|
try {
|
|
20016
20022
|
// 处理array1和array2的默认值
|
|
20017
20023
|
if (array1 == null || array1 == undefined || (typeof array1 == 'string' && array1.trim().length == 0)) {
|
|
@@ -20080,7 +20086,7 @@ const FormulaUtils = {
|
|
|
20080
20086
|
case '>':
|
|
20081
20087
|
case '>':
|
|
20082
20088
|
if (isSingleValue1) {
|
|
20083
|
-
conditionMet =
|
|
20089
|
+
conditionMet = num2 > num1;
|
|
20084
20090
|
}
|
|
20085
20091
|
else {
|
|
20086
20092
|
conditionMet = num1 > numValue;
|
|
@@ -20089,7 +20095,7 @@ const FormulaUtils = {
|
|
|
20089
20095
|
case '<':
|
|
20090
20096
|
case '<':
|
|
20091
20097
|
if (isSingleValue1) {
|
|
20092
|
-
conditionMet =
|
|
20098
|
+
conditionMet = num2 < num1;
|
|
20093
20099
|
}
|
|
20094
20100
|
else {
|
|
20095
20101
|
conditionMet = num1 < numValue;
|
|
@@ -20099,7 +20105,7 @@ const FormulaUtils = {
|
|
|
20099
20105
|
case '≥':
|
|
20100
20106
|
case '≧':
|
|
20101
20107
|
if (isSingleValue1) {
|
|
20102
|
-
conditionMet =
|
|
20108
|
+
conditionMet = num2 >= num1;
|
|
20103
20109
|
}
|
|
20104
20110
|
else {
|
|
20105
20111
|
conditionMet = num1 >= numValue;
|
|
@@ -20109,7 +20115,7 @@ const FormulaUtils = {
|
|
|
20109
20115
|
case '≤':
|
|
20110
20116
|
case '≦':
|
|
20111
20117
|
if (isSingleValue1) {
|
|
20112
|
-
conditionMet =
|
|
20118
|
+
conditionMet = num2 <= num1;
|
|
20113
20119
|
}
|
|
20114
20120
|
else {
|
|
20115
20121
|
conditionMet = num1 <= numValue;
|
|
@@ -20118,7 +20124,7 @@ const FormulaUtils = {
|
|
|
20118
20124
|
case '=':
|
|
20119
20125
|
case '=':
|
|
20120
20126
|
if (isSingleValue1) {
|
|
20121
|
-
conditionMet =
|
|
20127
|
+
conditionMet = num2 === num1;
|
|
20122
20128
|
}
|
|
20123
20129
|
else {
|
|
20124
20130
|
conditionMet = num1 === numValue;
|