rapid-spreadjs 1.0.173 → 1.0.175

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.esm.js CHANGED
@@ -1441,6 +1441,7 @@ const BusinessUtils = {
1441
1441
  cellValue !== undefined &&
1442
1442
  cellValue !== '' &&
1443
1443
  cellValue !== '/' &&
1444
+ cellValue !== '#VALUE!' &&
1444
1445
  !(cellValue instanceof GC.Spread.CalcEngine.CalcError)) {
1445
1446
  curRowHasValue = true;
1446
1447
  break;
@@ -9789,8 +9790,41 @@ const EChartsUtilsAll = {
9789
9790
  const chartExtJson = config.chartExtJson == null || config.chartExtJson == undefined ? null : JSON.parse(config.chartExtJson);
9790
9791
  let title = config.chartTitle, xName = config.chartXName, yName = config.chartYName, color = lineData[0].lineColor;
9791
9792
  // 原始数据
9792
- const xData = xDataArr[0];
9793
- const yData = yDataArr[0];
9793
+ let xData = xDataArr[0];
9794
+ let yData = yDataArr[0];
9795
+ /**
9796
+ * 判断值是否为无效占位符
9797
+ * 无效值包括: 0, '/', null, undefined, NaN, ''
9798
+ */
9799
+ function isValid(val) {
9800
+ if (val === 0 || val === '/' || val === null || val === undefined || val === '')
9801
+ return false;
9802
+ if (typeof val === 'number' && Number.isNaN(val))
9803
+ return false;
9804
+ return true;
9805
+ }
9806
+ /**
9807
+ * 根据两个数组对应位置的值进行联合过滤,去除任一为无效值的项
9808
+ * @param {Array} arr1 - 第一个数组
9809
+ * @param {Array} arr2 - 第二个数组
9810
+ * @returns {[Array, Array]} 返回过滤后的两个数组组成的元组
9811
+ */
9812
+ function filterArrData(arr1, arr2) {
9813
+ const filtered1 = [];
9814
+ const filtered2 = [];
9815
+ const len = Math.min(arr1.length, arr2.length);
9816
+ for (let i = 0; i < len; i++) {
9817
+ // 只有当两个数组在当前位置都是有效值时,才保留
9818
+ if (isValid(arr1[i]) && isValid(arr2[i])) {
9819
+ filtered1.push(arr1[i]);
9820
+ filtered2.push(arr2[i]);
9821
+ }
9822
+ }
9823
+ return [filtered1, filtered2];
9824
+ }
9825
+ const [xDataFiltered, yDataFiltered] = filterArrData(xData, yData);
9826
+ xData = xDataFiltered;
9827
+ yData = yDataFiltered;
9794
9828
  // 手动计算线性回归参数
9795
9829
  function linearRegression(x, y) {
9796
9830
  const n = x.length;