rapid-spreadjs 1.0.182 → 1.0.184

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
@@ -5205,6 +5205,17 @@ const EChartsUtilsAll = {
5205
5205
  yAxisMax = null;
5206
5206
  seriesData = [];
5207
5207
  }
5208
+ let yMinVal = 0, yMaxVal = 0;
5209
+ let allYVal = [];
5210
+ if (seriesData.length > 0) {
5211
+ seriesData.forEach((item) => {
5212
+ item.data.forEach((itemData) => {
5213
+ allYVal.push(itemData.value[1]);
5214
+ });
5215
+ });
5216
+ yMinVal = Number(EChartsUtilsComm.getRound(Math.min(...allYVal) - 0.02, 0.01));
5217
+ yMaxVal = Number(EChartsUtilsComm.getRound(Math.max(...allYVal) + 0.02, 0.01));
5218
+ }
5208
5219
  let option = {
5209
5220
  grid: {
5210
5221
  // show: true,//是否显示外边框线
@@ -5271,8 +5282,8 @@ const EChartsUtilsAll = {
5271
5282
  yAxis: [
5272
5283
  {
5273
5284
  type: 'value',
5274
- max: !yValIsAllNull ? yAxisMax : 0,
5275
- min: !yValIsAllNull ? yAxisMin : 0,
5285
+ max: !yValIsAllNull ? yMaxVal : 0,
5286
+ min: !yValIsAllNull ? yMinVal : 0,
5276
5287
  name: yName,
5277
5288
  nameGap: !yValIsAllNull ? 40 : 25,
5278
5289
  nameRotate: 90,
@@ -16747,6 +16758,79 @@ const FormulaUtils = {
16747
16758
  // return calcVal(retArrVals[0], accuracy);
16748
16759
  },
16749
16760
  },
16761
+ {
16762
+ funName: 'YJROUNDKX',
16763
+ funDesc: '计算科学计数修约',
16764
+ funDefaultVal: null,
16765
+ funParams: [
16766
+ {
16767
+ name: '数值',
16768
+ repeatable: false,
16769
+ optional: false,
16770
+ },
16771
+ {
16772
+ name: '修约位数',
16773
+ repeatable: false,
16774
+ optional: false,
16775
+ },
16776
+ ],
16777
+ funCallback: (spread, sheet, retData) => {
16778
+ let symbol = '/';
16779
+ //如果传递的参数小于2个(第一个参数为修约的数值,第二个参数为修约位数),则返回符号
16780
+ if (retData.allCellVals.length < 2) {
16781
+ return symbol;
16782
+ }
16783
+ //判断要修约的值和精度是否为数字,不是则返回符号
16784
+ if (!FormulaUtils.commFun.isNumber(retData.allCellVals[0]) || !FormulaUtils.commFun.isNumber(retData.allCellVals[1])) {
16785
+ return symbol;
16786
+ }
16787
+ let retArrVals = FormulaUtils.commFun.convertToInt(retData.allCellVals);
16788
+ //修约位数(正式以配置中为优先级获取,如业务系统中就要根据配置来判断)
16789
+ let accuracy = Math.floor(retArrVals[1]);
16790
+ //小于等于0时,返回原始数据
16791
+ if (accuracy <= 0 || retArrVals[0] == 0) {
16792
+ return retArrVals[0];
16793
+ }
16794
+ /**
16795
+ * 将数字转换为统一的标准科学计数法表达字符串
16796
+ * @param {number} num - 需要转换的数字
16797
+ * @param {number} [digits] - 有效数字位数(默认自动推断)
16798
+ * @returns {string} 如 "1.34*10^-2"、"1.34"、"1.34*10³"
16799
+ */
16800
+ const toScientificNotation = (num, digits) => {
16801
+ if (num === 0)
16802
+ return '0';
16803
+ if (!isFinite(num))
16804
+ return String(num);
16805
+ // 1. 确定有效数字位数:未指定时从原数推断
16806
+ if (digits === undefined) {
16807
+ const str = String(Math.abs(num));
16808
+ // 去除小数点和前导零,剩余即为有效数字
16809
+ digits = str.replace(/^0*\.?0*/, '').replace('.', '').length || 1;
16810
+ }
16811
+ // 2. 利用 toExponential 获取标准化系数和指数
16812
+ // 例如: (134).toExponential(2) => "1.34e+2"
16813
+ const expStr = num.toExponential(digits - 1);
16814
+ const [coefStr, expPart] = expStr.split('e');
16815
+ const exponent = parseInt(expPart, 10);
16816
+ // 3. 清理系数尾部多余的零(如 1.340 → 1.34)
16817
+ const coefficient = parseFloat(coefStr).toString();
16818
+ // 4. 根据指数值格式化输出
16819
+ if (exponent === 0) {
16820
+ // 指数为0:直接返回系数,如 "1.34"
16821
+ return coefficient;
16822
+ }
16823
+ // 上标映射表
16824
+ const superscripts = { '-': '⁻', '0': '⁰', '1': '¹', '2': '²', '3': '³', '4': '⁴', '5': '⁵', '6': '⁶', '7': '⁷', '8': '⁸', '9': '⁹' };
16825
+ const expDisplay = String(exponent)
16826
+ .split('')
16827
+ .map((ch) => superscripts[ch] || ch)
16828
+ .join('');
16829
+ return `${coefficient}*10${expDisplay}`;
16830
+ };
16831
+ return toScientificNotation(retArrVals[0], accuracy);
16832
+ },
16833
+ },
16750
16834
  {
16751
16835
  funName: 'YJDZ',
16752
16836
  funDesc: '按照单元格点选顺序,优先提取最后一个有数据的单元格值',
@@ -19606,10 +19690,18 @@ const FormulaUtils = {
19606
19690
  getddn.y2 = array_x[_index];
19607
19691
  getddn.x = dn;
19608
19692
  if (_index == array_y.length) {
19609
- getddn.x1 = array_y[_index - 2];
19610
- getddn.x2 = array_y[_index - 1];
19611
- getddn.y1 = array_x[_index - 2];
19612
- getddn.y2 = array_x[_index - 1];
19693
+ if (dn < array_y[0]) {
19694
+ getddn.x1 = array_y[_index - _index];
19695
+ getddn.x2 = array_y[_index - _index + 1];
19696
+ getddn.y1 = array_x[_index - _index];
19697
+ getddn.y2 = array_x[_index - _index + 1];
19698
+ }
19699
+ else {
19700
+ getddn.x1 = array_y[_index - 2];
19701
+ getddn.x2 = array_y[_index - 1];
19702
+ getddn.y1 = array_x[_index - 2];
19703
+ getddn.y2 = array_x[_index - 1];
19704
+ }
19613
19705
  getddn.x = dn;
19614
19706
  }
19615
19707
  else if (_index == 0) {