rapid-spreadjs 1.0.186 → 1.0.188

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
@@ -5350,8 +5350,32 @@ const EChartsUtilsAll = {
5350
5350
  chart50: (config, xDataArr, yDataArr) => {
5351
5351
  let lineData = JSON.parse(config.chartLinesJson);
5352
5352
  let title = '', xName = config.chartXName, yName = config.chartYName;
5353
- // 折线数量:以 chartLinesJson 中配置的折线条数为准
5354
- const lineCount = Array.isArray(lineData) ? lineData.length : 0;
5353
+ // 判断某个子数组的值是否全部为 "/" 或 null(即该条线无任何有效数据)
5354
+ const isAllEmpty = (arr) => {
5355
+ if (!Array.isArray(arr))
5356
+ return true;
5357
+ if (arr.length === 0)
5358
+ return true;
5359
+ return arr.every((v) => v == null || v === '/' || v === '');
5360
+ };
5361
+ // 同步过滤:将 yDataArr 中“值全为空”的子数组剔除,同时按索引对应剔除 lineData 中同一条线配置,
5362
+ // 保证剩余的线其图例名/颜色与 y 数据一一对应
5363
+ const validIndexes = [];
5364
+ for (let i = 0; i < yDataArr.length; i++) {
5365
+ if (!isAllEmpty(yDataArr[i])) {
5366
+ validIndexes.push(i);
5367
+ }
5368
+ }
5369
+ const filteredYDataArr = validIndexes.map((i) => yDataArr[i]);
5370
+ const filteredLineData = Array.isArray(lineData) ? validIndexes.map((i) => lineData[i]) : [];
5371
+ // 折线数量:以过滤后实际有数据的线条数为准
5372
+ const lineCount = filteredYDataArr.length;
5373
+ // 后续统一使用过滤后的数据
5374
+ lineData = filteredLineData;
5375
+ // 没有任何有效数据时,直接返回空配置,避免后续空数组访问报错
5376
+ if (lineCount === 0) {
5377
+ return {};
5378
+ }
5355
5379
  // x轴原始数据(共享一份)
5356
5380
  const xDataSourceOld = xDataArr[0];
5357
5381
  const allData = [];
@@ -5359,7 +5383,7 @@ const EChartsUtilsAll = {
5359
5383
  const point = { x: item };
5360
5384
  // 将每条线的 y 值都收进同一个点对象,key 为 y0/y1/y2...
5361
5385
  for (let i = 0; i < lineCount; i++) {
5362
- point['y' + i] = (yDataArr[i] || [])[index];
5386
+ point['y' + i] = (filteredYDataArr[i] || [])[index];
5363
5387
  }
5364
5388
  allData.push(point);
5365
5389
  });
@@ -5375,7 +5399,7 @@ const EChartsUtilsAll = {
5375
5399
  const nullCounts = [];
5376
5400
  for (let i = 0; i < lineCount; i++) {
5377
5401
  let cnt = 0;
5378
- (yDataArr[i] || []).forEach((item) => {
5402
+ (filteredYDataArr[i] || []).forEach((item) => {
5379
5403
  if (item == null || item == '/') {
5380
5404
  cnt++;
5381
5405
  }
@@ -5383,7 +5407,7 @@ const EChartsUtilsAll = {
5383
5407
  nullCounts.push(cnt);
5384
5408
  }
5385
5409
  // 若任意一条线存在非空值,则按“所有线均非空”过滤出有效点;否则保留全部点(与 chart50 上限/下限过滤逻辑保持语义一致)
5386
- const hasAnyValid = nullCounts.some((cnt, i) => cnt < (yDataArr[i] || []).length);
5410
+ const hasAnyValid = nullCounts.some((cnt, i) => cnt < (filteredYDataArr[i] || []).length);
5387
5411
  allData.forEach((item) => {
5388
5412
  if (!hasAnyValid) {
5389
5413
  for (let i = 0; i < lineCount; i++) {
@@ -24006,22 +24030,18 @@ const FormulaUtils = {
24006
24030
  optional: false,
24007
24031
  },
24008
24032
  {
24009
- name: '目标点x坐标',
24010
- repeatable: false,
24011
- optional: false,
24012
- },
24013
- {
24014
- name: '目标点y坐标',
24033
+ name: '目标点坐标,格式如 (3.5,6.5)',
24015
24034
  repeatable: false,
24016
24035
  optional: false,
24017
24036
  },
24018
24037
  ],
24019
24038
  funCallback: (spread, sheet, retData) => {
24020
- // 如果传递的参数小于3个,则返回/
24021
- if (retData.allCellVals.length < 3) {
24039
+ // 如果传递的参数小于2个,则返回/
24040
+ if (retData.allCellVals.length < 2) {
24022
24041
  return '/';
24023
24042
  }
24024
- let points = retData.allCellVals[0], xPoint = retData.allCellVals[1], yPoint = retData.allCellVals[2];
24043
+ const pointStrArr = retData.allCellVals[1].replace('(', '').replace(')', '').split(',');
24044
+ let points = retData.allCellVals[0], xPoint = pointStrArr[0], yPoint = pointStrArr[1];
24025
24045
  // 1. 格式校验
24026
24046
  if (typeof points !== 'string' || !points)
24027
24047
  return '/';