rapid-spreadjs 1.0.132 → 1.0.133

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
@@ -987,11 +987,12 @@ const BusinessUtils = {
987
987
  * @param cellRange 单元格范围JSON对象,格式为:{row:0, col:0, rowCount:2, colCount:5}
988
988
  * @param curDefaultPointCount 本次默认点数
989
989
  * @param lastDefaultPointCount 上次默认点数,默认为:0(0代表首次创建)
990
- * @param isAutoFillFirstCellNumber 是否自动填充第一个单元格为序号数字,默认为:false
990
+ * @param isClearCreateCellsValue 是否清空创建的行单元格值,默认为:false
991
+ * @param isAutoFillFirstCellNumber 是否自动填充第一个单元格为序号数字,默认为:false(当isClearCreateCellsValue=false时,该参数才有效)
991
992
  * @param created 创建完成后的回调函数,第一个参数为循环后的所有单元格范围对象(格式为:{row:0, col:0, rowCount:10, colCount:5}),第二个参数为所有循环行的单元格二维数组对象
992
993
  * @param rowHeight 创建的行高度,默认为:undefined(如果传了该参数,则新复制的行高为该参数指定的高度,否则为原始循环的行高)
993
994
  */
994
- dynamicCreateCyclicRows: (GC, spread, cellRange, curDefaultPointCount, lastDefaultPointCount = 0, isAutoFillFirstCellNumber = false, created = null, rowHeight) => {
995
+ dynamicCreateCyclicRows: (GC, spread, cellRange, curDefaultPointCount, lastDefaultPointCount = 0, isClearCreateCellsValue = false, isAutoFillFirstCellNumber = false, created = null, rowHeight) => {
995
996
  // 不进行动态创建行
996
997
  if ((curDefaultPointCount <= 1 && lastDefaultPointCount == 0) || (curDefaultPointCount == lastDefaultPointCount && lastDefaultPointCount > 0)) {
997
998
  return;
@@ -1055,6 +1056,14 @@ const BusinessUtils = {
1055
1056
  // pasteOption: GC.Spread.Sheets.ClipboardPasteOptions.all // 粘贴全部内容(数据、样式、公式等)
1056
1057
  // });
1057
1058
  }
1059
+ // 清空创建的行单元格值
1060
+ if (isClearCreateCellsValue) {
1061
+ // 获取添加行范围的所有单元格
1062
+ const addCells = SheetUtils.getAllCellObjsByRange(sheet, { row: addRowIndex, col: 1, rowCount: addRowCount, colCount: 77 });
1063
+ addCells.forEach((cell) => {
1064
+ sheet.setValue(cell.row, cell.col, '');
1065
+ });
1066
+ }
1058
1067
  };
1059
1068
  // 暂停绘制、计算、事件
1060
1069
  sheet.suspendPaint();
@@ -1094,23 +1103,25 @@ const BusinessUtils = {
1094
1103
  rowCount: cyclicCellsRangeObj.rowCount,
1095
1104
  colCount: cyclicCellsRangeObj.colCount,
1096
1105
  };
1097
- // 自动填充第一个单元格为序号数字
1098
1106
  const allCells = SheetUtils.getAllCellObjsByRanges(sheet, [cyclicCellsRange]);
1099
1107
  const allCellsByRowObj = rapidUtils.groupByJson(allCells, 'row');
1100
1108
  let allCellsByRow = [];
1101
- if (isAutoFillFirstCellNumber) {
1102
- rapidUtils.forEachJson(allCellsByRowObj, (value, key, source) => {
1103
- allCellsByRow.push(value);
1104
- });
1105
- let number = 0;
1106
- allCellsByRow.forEach((rowCells, rowIndex) => {
1107
- rowCells.forEach((rowCell, cellIndex) => {
1108
- if (cellIndex == 0) {
1109
- number++;
1110
- sheet.setValue(rowCell.row, rowCell.col, number);
1111
- }
1109
+ // 自动填充第一个单元格为序号数字
1110
+ if (!isClearCreateCellsValue) {
1111
+ if (isAutoFillFirstCellNumber) {
1112
+ rapidUtils.forEachJson(allCellsByRowObj, (value, key, source) => {
1113
+ allCellsByRow.push(value);
1112
1114
  });
1113
- });
1115
+ let number = 0;
1116
+ allCellsByRow.forEach((rowCells, rowIndex) => {
1117
+ rowCells.forEach((rowCell, cellIndex) => {
1118
+ if (cellIndex == 0) {
1119
+ number++;
1120
+ sheet.setValue(rowCell.row, rowCell.col, number);
1121
+ }
1122
+ });
1123
+ });
1124
+ }
1114
1125
  }
1115
1126
  // 恢复事件、计算、绘制
1116
1127
  sheet.resumeDirty();
@@ -1500,14 +1511,6 @@ const BusinessUtils = {
1500
1511
  createBlackRowCell();
1501
1512
  // 恢复绘制
1502
1513
  sheet.resumePaint();
1503
- let allRowHeight = 0;
1504
- for (let i = 0; i < sheet.getRowCount(); i++) {
1505
- const curRowVisible = sheet.getRowVisible(i);
1506
- if (curRowVisible) {
1507
- allRowHeight += sheet.getRowHeight(i);
1508
- }
1509
- }
1510
- console.log('创建空白行单元格后的总高度:', allRowHeight);
1511
1514
  return { hasValueIndex: hasValueRows, noValueIndex: noValueRows };
1512
1515
  },
1513
1516
  };
@@ -9910,6 +9913,171 @@ const EChartsUtilsAll = {
9910
9913
  };
9911
9914
  return option;
9912
9915
  },
9916
+ /**
9917
+ * 沥青含量与磨耗值及粘附砂量关系曲线图
9918
+ * @param config 折线配置
9919
+ * @param xDataArr x轴原始数据(二维数组)
9920
+ * @param yDataArr y轴原始数据(二维数组)
9921
+ * @returns 返回ECharts配置项
9922
+ */
9923
+ chart510: (config, xDataArr, yDataArr, sheet) => {
9924
+ let lineData = JSON.parse(config.chartLinesJson);
9925
+ // const chartExtJson = config.chartExtJson == null || config.chartExtJson == undefined ? null : JSON.parse(config.chartExtJson);
9926
+ let title = config.chartTitle, xName = config.chartXName, yName1 = '磨耗值(g/㎡)', yName2 = '粘附砂量(g/㎡)', color1 = lineData[0].lineColor, color2 = lineData[1].lineColor;
9927
+ // 原始数据
9928
+ const xData = xDataArr[0];
9929
+ const yData1 = yDataArr[0], yData2 = yDataArr[1];
9930
+ let yValIsAllNull1 = false, yValIsAllNull2 = false;
9931
+ if (xData.length == 0 ||
9932
+ yData1.length == 0 ||
9933
+ (!xData.some((x) => x != '' && x != '/' && x != null && x != undefined) &&
9934
+ !yData1.some((x) => x != '' && x != '/' && x != null && x != undefined))) {
9935
+ yValIsAllNull1 = true;
9936
+ }
9937
+ if (xData.filter((x) => x == 0).length == xData.length || yData1.filter((x) => x == 0).length == yData1.length) {
9938
+ yValIsAllNull1 = true;
9939
+ }
9940
+ if (xData.length == 0 ||
9941
+ yData2.length == 0 ||
9942
+ (!xData.some((x) => x != '' && x != '/' && x != null && x != undefined) &&
9943
+ !yData2.some((x) => x != '' && x != '/' && x != null && x != undefined))) {
9944
+ yValIsAllNull2 = true;
9945
+ }
9946
+ if (xData.filter((x) => x == 0).length == xData.length || yData2.filter((x) => x == 0).length == yData2.length) {
9947
+ yValIsAllNull2 = true;
9948
+ }
9949
+ // 配置项
9950
+ const option = {
9951
+ // 标题配置
9952
+ title: [
9953
+ {
9954
+ show: true,
9955
+ text: title,
9956
+ left: 'center',
9957
+ top: 2,
9958
+ textStyle: {
9959
+ fontSize: 14,
9960
+ fontWeight: 'normal',
9961
+ },
9962
+ },
9963
+ {
9964
+ show: true,
9965
+ text: xName,
9966
+ left: 'center',
9967
+ bottom: 0,
9968
+ textStyle: {
9969
+ fontSize: 12,
9970
+ fontWeight: 'normal',
9971
+ },
9972
+ },
9973
+ ],
9974
+ // 不显示图例
9975
+ legend: {
9976
+ show: false,
9977
+ },
9978
+ // 网格配置
9979
+ grid: {
9980
+ top: 25,
9981
+ left: 25,
9982
+ right: 25,
9983
+ bottom: yValIsAllNull1 && yValIsAllNull2 ? 25 : 20,
9984
+ containLabel: true,
9985
+ },
9986
+ // 提示框配置
9987
+ tooltip: {
9988
+ trigger: 'axis',
9989
+ axisPointer: {
9990
+ type: 'cross',
9991
+ },
9992
+ },
9993
+ // X轴配置
9994
+ xAxis: {
9995
+ type: 'category',
9996
+ data: xData,
9997
+ splitLine: {
9998
+ show: true,
9999
+ },
10000
+ },
10001
+ // Y轴配置(双Y轴)
10002
+ yAxis: [
10003
+ {
10004
+ // 左侧Y轴 - 磨耗值
10005
+ type: 'value',
10006
+ name: yName1,
10007
+ nameLocation: 'middle', // 名称居中显示
10008
+ nameGap: !yValIsAllNull1 ? 35 : 5, // 名称与轴线的距离
10009
+ max: Math.max(...yData1) + 100,
10010
+ // 显示横向网格线
10011
+ splitLine: {
10012
+ show: true,
10013
+ },
10014
+ axisLine: {
10015
+ show: true,
10016
+ },
10017
+ axisLabel: {
10018
+ formatter: '{value}',
10019
+ },
10020
+ axisTick: {
10021
+ show: true,
10022
+ },
10023
+ },
10024
+ {
10025
+ // 右侧Y轴 - 粘附砂量
10026
+ type: 'value',
10027
+ name: yName2,
10028
+ nameLocation: 'middle', // 名称居中显示
10029
+ nameGap: !yValIsAllNull2 ? 35 : 5, // 名称与轴线的距离
10030
+ max: Math.max(...yData2) + 100,
10031
+ splitLine: {
10032
+ show: false,
10033
+ },
10034
+ axisLine: {
10035
+ show: true,
10036
+ },
10037
+ axisLabel: {
10038
+ formatter: '{value}',
10039
+ },
10040
+ axisTick: {
10041
+ show: true,
10042
+ },
10043
+ },
10044
+ ],
10045
+ // 数据系列配置
10046
+ series: [
10047
+ {
10048
+ name: '磨耗值',
10049
+ type: 'line',
10050
+ smooth: true, // 平滑曲线
10051
+ data: yValIsAllNull1 ? [] : yData1.filter((x) => x != 0),
10052
+ yAxisIndex: 0, // 使用第一个Y轴(左侧)
10053
+ symbol: 'circle',
10054
+ symbolSize: 5,
10055
+ lineStyle: {
10056
+ color: color1,
10057
+ },
10058
+ itemStyle: {
10059
+ color: color1,
10060
+ },
10061
+ },
10062
+ {
10063
+ name: '粘附砂量',
10064
+ type: 'line',
10065
+ smooth: true, // 平滑曲线
10066
+ data: yValIsAllNull2 ? [] : yData2.filter((x) => x != 0),
10067
+ yAxisIndex: 1, // 使用第二个Y轴(右侧)
10068
+ symbol: 'circle',
10069
+ symbolSize: 5,
10070
+ lineStyle: {
10071
+ color: color2,
10072
+ },
10073
+ itemStyle: {
10074
+ color: color2,
10075
+ },
10076
+ },
10077
+ ],
10078
+ };
10079
+ return option;
10080
+ },
9913
10081
  };
9914
10082
 
9915
10083
  /**
@@ -10185,6 +10353,9 @@ const EChartsUtils = {
10185
10353
  else if (config.chartType == 490) {
10186
10354
  option = EChartsUtilsAll.chart490(config, xDataArr, yDataArr, sheet);
10187
10355
  }
10356
+ else if (config.chartType == 510) {
10357
+ option = EChartsUtilsAll.chart510(config, xDataArr, yDataArr, sheet);
10358
+ }
10188
10359
  if (option && typeof option === 'object') {
10189
10360
  //如果是隐藏的图表,则需要禁用ECharts的动画效果
10190
10361
  //原因是:如果ECharts使用了动画效果,图表渲染完成可能需要0.5秒,但是在导出ECharts统计图为图片的场景下时,可能在图表还没有渲染完成(动画效果还没结束)前就要获取图像了,此时可能就会造成获取到的图像内容丢失的情况