rapid-spreadjs 1.0.90 → 1.0.92
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 +50 -27
- 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 +50 -27
- 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/dist/utils/echarts-all.d.ts +0 -2
- package/dist/utils/sheet.d.ts +3 -3
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -626,11 +626,11 @@ const SheetUtils = {
|
|
|
626
626
|
// return GC.Spread.Sheets.CalcEngine.rangeToFormula(cellRange);
|
|
627
627
|
},
|
|
628
628
|
/**
|
|
629
|
-
*
|
|
629
|
+
* 获取工作表中所有纯值、无值或公式单元格的范围选择字符串
|
|
630
630
|
* @param sheet 工作表对象
|
|
631
|
-
* @param
|
|
631
|
+
* @param getType 获取类型(1:纯值、2:无值、3:公式),默认为:1
|
|
632
632
|
*/
|
|
633
|
-
getCellsRangeStr: (sheet,
|
|
633
|
+
getCellsRangeStr: (sheet, getType = 1) => {
|
|
634
634
|
const range = { row: 0, col: 1, rowCount: sheet.getRowCount(), colCount: 77 };
|
|
635
635
|
// 所有单元格对象集合
|
|
636
636
|
const allCells = SheetUtils.getAllCellObjsByRanges(sheet, [range]);
|
|
@@ -640,8 +640,10 @@ const SheetUtils = {
|
|
|
640
640
|
allCells.forEach((cell) => {
|
|
641
641
|
const value = sheet.getValue(cell.row, cell.col);
|
|
642
642
|
const formula = sheet.getFormula(cell.row, cell.col);
|
|
643
|
-
// 非公式+有值(非空) ||
|
|
644
|
-
if ((
|
|
643
|
+
// 非公式+有值(非空) || 无值 || 公式
|
|
644
|
+
if ((getType == 1 && !formula && value !== null && value !== undefined && value !== '') ||
|
|
645
|
+
(getType == 2 && (value == null || value == undefined || value == '')) ||
|
|
646
|
+
(getType == 3 && formula)) {
|
|
645
647
|
retCells.push(cell);
|
|
646
648
|
}
|
|
647
649
|
});
|
|
@@ -8104,19 +8106,23 @@ const EChartsUtilsAll = {
|
|
|
8104
8106
|
let title = config.chartTitle, xName = config.chartXName, yName = config.chartYName;
|
|
8105
8107
|
let legendData = [], seriesData = [];
|
|
8106
8108
|
lineData.forEach((item, index) => {
|
|
8107
|
-
|
|
8108
|
-
|
|
8109
|
-
|
|
8110
|
-
|
|
8111
|
-
|
|
8112
|
-
|
|
8113
|
-
|
|
8114
|
-
|
|
8115
|
-
|
|
8116
|
-
|
|
8117
|
-
|
|
8118
|
-
|
|
8119
|
-
|
|
8109
|
+
// 排除x轴和y轴所有数据都为0的
|
|
8110
|
+
if (xDataArr[index].some((x) => x != 0 && x != null && x != undefined && x != '/') &&
|
|
8111
|
+
yDataArr[index].some((x) => x != 0 && x != null && x != undefined && x != '/')) {
|
|
8112
|
+
legendData.push(item.legend);
|
|
8113
|
+
seriesData.push({
|
|
8114
|
+
name: item.legend,
|
|
8115
|
+
type: 'line',
|
|
8116
|
+
data: xDataArr[0].filter((x) => x != 0 && x != null && x != undefined && x != '/').map((x, idx) => [x, yDataArr[index][idx]]),
|
|
8117
|
+
symbol: index == 0 ? 'triangle' : index == 1 ? 'circle' : 'rect',
|
|
8118
|
+
lineStyle: {
|
|
8119
|
+
color: item.lineColor,
|
|
8120
|
+
// width: 2,
|
|
8121
|
+
type: index == 2 ? 'solid' : 'dotted', // 虚线或实线
|
|
8122
|
+
},
|
|
8123
|
+
smooth: true, // 平滑曲线
|
|
8124
|
+
});
|
|
8125
|
+
}
|
|
8120
8126
|
});
|
|
8121
8127
|
// 判断y轴数据是否为/、‘’、null、undefined或者没有数据
|
|
8122
8128
|
let yValIsAllNull = false;
|
|
@@ -8180,7 +8186,7 @@ const EChartsUtilsAll = {
|
|
|
8180
8186
|
name: 'X轴',
|
|
8181
8187
|
min: 0, // 从 x=0 开始
|
|
8182
8188
|
//max: xEnd, // 扩展到后推位置
|
|
8183
|
-
interval: 30, // 设置刻度间隔为10
|
|
8189
|
+
//interval: 30, // 设置刻度间隔为10
|
|
8184
8190
|
axisLine: { show: true },
|
|
8185
8191
|
},
|
|
8186
8192
|
yAxis: {
|
|
@@ -8490,9 +8496,9 @@ const EChartsUtilsAll = {
|
|
|
8490
8496
|
if (!yValIsAllNull) {
|
|
8491
8497
|
// 计算多项式回归系数(阶数为2)
|
|
8492
8498
|
const coefficients = polynomialRegression(xData, yData, 2);
|
|
8493
|
-
a = coefficients[2].toFixed(
|
|
8494
|
-
b = coefficients[1].toFixed(
|
|
8495
|
-
c = coefficients[0].toFixed(
|
|
8499
|
+
a = coefficients[2].toFixed(4);
|
|
8500
|
+
b = coefficients[1].toFixed(4);
|
|
8501
|
+
c = coefficients[0].toFixed(4);
|
|
8496
8502
|
const minX = Math.min(...xData);
|
|
8497
8503
|
const step = (maxX - minX) / 100;
|
|
8498
8504
|
for (let x = minX; x <= maxX; x += step) {
|
|
@@ -8553,7 +8559,7 @@ const EChartsUtilsAll = {
|
|
|
8553
8559
|
fontSize: 14,
|
|
8554
8560
|
padding: [10, 0, 0, 0],
|
|
8555
8561
|
},
|
|
8556
|
-
interval: 0.05, // 设置刻度间隔为0.05
|
|
8562
|
+
//interval: 0.05, // 设置刻度间隔为0.05
|
|
8557
8563
|
min: 0,
|
|
8558
8564
|
max: maxX + 0.05,
|
|
8559
8565
|
},
|
|
@@ -20055,6 +20061,11 @@ const FormulaUtils = {
|
|
|
20055
20061
|
repeatable: false,
|
|
20056
20062
|
optional: false,
|
|
20057
20063
|
},
|
|
20064
|
+
{
|
|
20065
|
+
name: '是否返回符合或不符合结果的数量(传数字的1或0,0:不返回数量、1:返回数量),默认为:0',
|
|
20066
|
+
repeatable: false,
|
|
20067
|
+
optional: false,
|
|
20068
|
+
},
|
|
20058
20069
|
],
|
|
20059
20070
|
funCallback: (spread, sheet, retData) => {
|
|
20060
20071
|
// 如果传递的参数小于5个,则返回空字符串
|
|
@@ -20062,7 +20073,9 @@ const FormulaUtils = {
|
|
|
20062
20073
|
if (retData.allCellValsEw.length < 5) {
|
|
20063
20074
|
return '/';
|
|
20064
20075
|
}
|
|
20065
|
-
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]
|
|
20076
|
+
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],
|
|
20077
|
+
// 是否返回符合或不符合结果的数量(如最终符合或不符合的结果为“5,6,7”,并且isReturnCount=1,则返回数字3,否则返回“5,6,7”),默认为:0
|
|
20078
|
+
isReturnCount = retData.allCellValsEw.length < 7 ? 0 : retData.allCellValsEw[6];
|
|
20066
20079
|
try {
|
|
20067
20080
|
// 处理array1和array2的默认值
|
|
20068
20081
|
if (array1 == null || array1 == undefined || (typeof array1 == 'string' && array1.trim().length == 0)) {
|
|
@@ -20077,7 +20090,7 @@ const FormulaUtils = {
|
|
|
20077
20090
|
if (typeof array2 == 'string' && array2.trim().length > 0) {
|
|
20078
20091
|
array2 = [array2];
|
|
20079
20092
|
}
|
|
20080
|
-
// 如果operator、value、delimiter、isOpposite为数组,则设置其取第一个值
|
|
20093
|
+
// 如果operator、value、delimiter、isOpposite、isReturnCount为数组,则设置其取第一个值
|
|
20081
20094
|
if (Array.isArray(operator) && operator.length > 0) {
|
|
20082
20095
|
operator = operator[0];
|
|
20083
20096
|
}
|
|
@@ -20090,6 +20103,9 @@ const FormulaUtils = {
|
|
|
20090
20103
|
if (Array.isArray(isOpposite) && isOpposite.length > 0) {
|
|
20091
20104
|
isOpposite = isOpposite[0];
|
|
20092
20105
|
}
|
|
20106
|
+
if (Array.isArray(isReturnCount) && isReturnCount.length > 0) {
|
|
20107
|
+
isReturnCount = isReturnCount[0];
|
|
20108
|
+
}
|
|
20093
20109
|
// 设置isOpposite的默认值
|
|
20094
20110
|
if (isOpposite == '1' || isOpposite == '0') {
|
|
20095
20111
|
isOpposite = parseInt(isOpposite);
|
|
@@ -20097,6 +20113,13 @@ const FormulaUtils = {
|
|
|
20097
20113
|
if (isOpposite != 0 && isOpposite != 1) {
|
|
20098
20114
|
isOpposite = 0;
|
|
20099
20115
|
}
|
|
20116
|
+
// 设置isReturnCount的默认值
|
|
20117
|
+
if (isReturnCount == '1' || isReturnCount == '0') {
|
|
20118
|
+
isReturnCount = parseInt(isReturnCount);
|
|
20119
|
+
}
|
|
20120
|
+
if (isReturnCount != 0 && isReturnCount != 1) {
|
|
20121
|
+
isReturnCount = 0;
|
|
20122
|
+
}
|
|
20100
20123
|
// TODO:暂定此情况
|
|
20101
20124
|
// 第一个参数是否为单值(array1为一个值的时候,此时array2的所有元素可能需要参与计算,满足要求的就返回array2中的值)
|
|
20102
20125
|
const isSingleValue1 = array2.length > array1.length && array1.length == 1;
|
|
@@ -20201,8 +20224,8 @@ const FormulaUtils = {
|
|
|
20201
20224
|
return '';
|
|
20202
20225
|
})
|
|
20203
20226
|
.filter((val) => val !== '' && val != '/' && val != 'null' && val != null && val != undefined); // 过滤空值
|
|
20204
|
-
// 使用指定的分隔符连接结果[2,3,5]
|
|
20205
|
-
return resultValues.join(delimiter);
|
|
20227
|
+
// 使用指定的分隔符连接结果[2,3,5]
|
|
20228
|
+
return isReturnCount == 1 ? resultValues.length : resultValues.join(delimiter);
|
|
20206
20229
|
}
|
|
20207
20230
|
catch (error) {
|
|
20208
20231
|
// 任何错误都返回"/"
|