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.cjs.js CHANGED
@@ -1463,6 +1463,7 @@ const BusinessUtils = {
1463
1463
  cellValue !== undefined &&
1464
1464
  cellValue !== '' &&
1465
1465
  cellValue !== '/' &&
1466
+ cellValue !== '#VALUE!' &&
1466
1467
  !(cellValue instanceof GC.Spread.CalcEngine.CalcError)) {
1467
1468
  curRowHasValue = true;
1468
1469
  break;
@@ -9811,8 +9812,41 @@ const EChartsUtilsAll = {
9811
9812
  const chartExtJson = config.chartExtJson == null || config.chartExtJson == undefined ? null : JSON.parse(config.chartExtJson);
9812
9813
  let title = config.chartTitle, xName = config.chartXName, yName = config.chartYName, color = lineData[0].lineColor;
9813
9814
  // 原始数据
9814
- const xData = xDataArr[0];
9815
- const yData = yDataArr[0];
9815
+ let xData = xDataArr[0];
9816
+ let yData = yDataArr[0];
9817
+ /**
9818
+ * 判断值是否为无效占位符
9819
+ * 无效值包括: 0, '/', null, undefined, NaN, ''
9820
+ */
9821
+ function isValid(val) {
9822
+ if (val === 0 || val === '/' || val === null || val === undefined || val === '')
9823
+ return false;
9824
+ if (typeof val === 'number' && Number.isNaN(val))
9825
+ return false;
9826
+ return true;
9827
+ }
9828
+ /**
9829
+ * 根据两个数组对应位置的值进行联合过滤,去除任一为无效值的项
9830
+ * @param {Array} arr1 - 第一个数组
9831
+ * @param {Array} arr2 - 第二个数组
9832
+ * @returns {[Array, Array]} 返回过滤后的两个数组组成的元组
9833
+ */
9834
+ function filterArrData(arr1, arr2) {
9835
+ const filtered1 = [];
9836
+ const filtered2 = [];
9837
+ const len = Math.min(arr1.length, arr2.length);
9838
+ for (let i = 0; i < len; i++) {
9839
+ // 只有当两个数组在当前位置都是有效值时,才保留
9840
+ if (isValid(arr1[i]) && isValid(arr2[i])) {
9841
+ filtered1.push(arr1[i]);
9842
+ filtered2.push(arr2[i]);
9843
+ }
9844
+ }
9845
+ return [filtered1, filtered2];
9846
+ }
9847
+ const [xDataFiltered, yDataFiltered] = filterArrData(xData, yData);
9848
+ xData = xDataFiltered;
9849
+ yData = yDataFiltered;
9816
9850
  // 手动计算线性回归参数
9817
9851
  function linearRegression(x, y) {
9818
9852
  const n = x.length;