rapid-spreadjs 1.0.91 → 1.0.93

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
@@ -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 isFormulaCells 是否获取公式单元格,默认为:false
631
+ * @param getType 获取类型(1:纯值、2:无值、3:公式),默认为:1
632
632
  */
633
- getCellsRangeStr: (sheet, isFormulaCells = false) => {
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,9 +640,15 @@ 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 ((!isFormulaCells && !formula && value !== null && value !== undefined && value !== '') || (isFormulaCells && formula)) {
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);
648
+ // 如果为无值类型,则设置单元格格式为文本格式
649
+ if (getType == 2 && (value == null || value == undefined || value == '')) {
650
+ sheet.setFormatter(0, 0, '@');
651
+ }
646
652
  }
647
653
  });
648
654
  // 辅助函数:将列索引转为大写字母(如 0->A, 1->B, 26->AA)
@@ -8104,19 +8110,23 @@ const EChartsUtilsAll = {
8104
8110
  let title = config.chartTitle, xName = config.chartXName, yName = config.chartYName;
8105
8111
  let legendData = [], seriesData = [];
8106
8112
  lineData.forEach((item, index) => {
8107
- legendData.push(item.legend);
8108
- seriesData.push({
8109
- name: item.legend,
8110
- type: 'line',
8111
- data: xDataArr[0].filter((x) => x != 0 && x != null && x != undefined && x != '/').map((x, idx) => [x, yDataArr[index][idx]]),
8112
- symbol: index == 0 ? 'triangle' : index == 1 ? 'circle' : 'rect',
8113
- lineStyle: {
8114
- color: item.lineColor,
8115
- // width: 2,
8116
- type: index == 2 ? 'solid' : 'dotted', // 虚线或实线
8117
- },
8118
- smooth: true, // 平滑曲线
8119
- });
8113
+ // 排除x轴和y轴所有数据都为0的
8114
+ if (xDataArr[index].some((x) => x != 0 && x != null && x != undefined && x != '/') &&
8115
+ yDataArr[index].some((x) => x != 0 && x != null && x != undefined && x != '/')) {
8116
+ legendData.push(item.legend);
8117
+ seriesData.push({
8118
+ name: item.legend,
8119
+ type: 'line',
8120
+ data: xDataArr[0].filter((x) => x != 0 && x != null && x != undefined && x != '/').map((x, idx) => [x, yDataArr[index][idx]]),
8121
+ symbol: index == 0 ? 'triangle' : index == 1 ? 'circle' : 'rect',
8122
+ lineStyle: {
8123
+ color: item.lineColor,
8124
+ // width: 2,
8125
+ type: index == 2 ? 'solid' : 'dotted', // 虚线或实线
8126
+ },
8127
+ smooth: true, // 平滑曲线
8128
+ });
8129
+ }
8120
8130
  });
8121
8131
  // 判断y轴数据是否为/、‘’、null、undefined或者没有数据
8122
8132
  let yValIsAllNull = false;
@@ -8180,7 +8190,7 @@ const EChartsUtilsAll = {
8180
8190
  name: 'X轴',
8181
8191
  min: 0, // 从 x=0 开始
8182
8192
  //max: xEnd, // 扩展到后推位置
8183
- interval: 30, // 设置刻度间隔为10
8193
+ //interval: 30, // 设置刻度间隔为10
8184
8194
  axisLine: { show: true },
8185
8195
  },
8186
8196
  yAxis: {
@@ -8490,9 +8500,9 @@ const EChartsUtilsAll = {
8490
8500
  if (!yValIsAllNull) {
8491
8501
  // 计算多项式回归系数(阶数为2)
8492
8502
  const coefficients = polynomialRegression(xData, yData, 2);
8493
- a = coefficients[2].toFixed(2);
8494
- b = coefficients[1].toFixed(2);
8495
- c = coefficients[0].toFixed(2);
8503
+ a = coefficients[2].toFixed(4);
8504
+ b = coefficients[1].toFixed(4);
8505
+ c = coefficients[0].toFixed(4);
8496
8506
  const minX = Math.min(...xData);
8497
8507
  const step = (maxX - minX) / 100;
8498
8508
  for (let x = minX; x <= maxX; x += step) {
@@ -8553,7 +8563,7 @@ const EChartsUtilsAll = {
8553
8563
  fontSize: 14,
8554
8564
  padding: [10, 0, 0, 0],
8555
8565
  },
8556
- interval: 0.05, // 设置刻度间隔为0.05
8566
+ //interval: 0.05, // 设置刻度间隔为0.05
8557
8567
  min: 0,
8558
8568
  max: maxX + 0.05,
8559
8569
  },