rapid-spreadjs 1.0.172 → 1.0.174
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 +97 -2
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.cjs.min.js +1 -1
- package/dist/index.cjs.min.js.map +1 -1
- package/dist/index.esm.js +97 -2
- package/dist/index.esm.js.map +1 -1
- package/dist/index.esm.min.js +1 -1
- package/dist/index.esm.min.js.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -9789,8 +9789,31 @@ const EChartsUtilsAll = {
|
|
|
9789
9789
|
const chartExtJson = config.chartExtJson == null || config.chartExtJson == undefined ? null : JSON.parse(config.chartExtJson);
|
|
9790
9790
|
let title = config.chartTitle, xName = config.chartXName, yName = config.chartYName, color = lineData[0].lineColor;
|
|
9791
9791
|
// 原始数据
|
|
9792
|
-
|
|
9793
|
-
|
|
9792
|
+
let xData = xDataArr[0];
|
|
9793
|
+
let yData = yDataArr[0];
|
|
9794
|
+
/**
|
|
9795
|
+
* 根据两个数组对应位置的值进行联合过滤,去除任一为0的项
|
|
9796
|
+
* @param {number[]} arr1 - 第一个数字数组
|
|
9797
|
+
* @param {number[]} arr2 - 第二个数字数组
|
|
9798
|
+
* @returns {[number[], number[]]} 返回过滤后的两个数组组成的元组
|
|
9799
|
+
*/
|
|
9800
|
+
function filterArrData(arr1, arr2) {
|
|
9801
|
+
const filtered1 = [];
|
|
9802
|
+
const filtered2 = [];
|
|
9803
|
+
// 以较短的数组长度为基准,防止越界
|
|
9804
|
+
const len = Math.min(arr1.length, arr2.length);
|
|
9805
|
+
for (let i = 0; i < len; i++) {
|
|
9806
|
+
// 只有当两个数组在当前位置都非0时,才保留该数据
|
|
9807
|
+
if (arr1[i] !== 0 && arr2[i] !== 0) {
|
|
9808
|
+
filtered1.push(arr1[i]);
|
|
9809
|
+
filtered2.push(arr2[i]);
|
|
9810
|
+
}
|
|
9811
|
+
}
|
|
9812
|
+
return [filtered1, filtered2];
|
|
9813
|
+
}
|
|
9814
|
+
const [xDataFiltered, yDataFiltered] = filterArrData(xData, yData);
|
|
9815
|
+
xData = xDataFiltered;
|
|
9816
|
+
yData = yDataFiltered;
|
|
9794
9817
|
// 手动计算线性回归参数
|
|
9795
9818
|
function linearRegression(x, y) {
|
|
9796
9819
|
const n = x.length;
|
|
@@ -23780,6 +23803,78 @@ const FormulaUtils = {
|
|
|
23780
23803
|
return qdhsz;
|
|
23781
23804
|
},
|
|
23782
23805
|
},
|
|
23806
|
+
{
|
|
23807
|
+
funName: 'YJZBPD',
|
|
23808
|
+
funDesc: '报告上根据技术要求进行坐标判定',
|
|
23809
|
+
funDefaultVal: null,
|
|
23810
|
+
funParams: [
|
|
23811
|
+
{
|
|
23812
|
+
name: '四边形坐标,格式如 (0,0):(3,7):(15,8):(9.5,3.3)',
|
|
23813
|
+
repeatable: false,
|
|
23814
|
+
optional: false,
|
|
23815
|
+
},
|
|
23816
|
+
{
|
|
23817
|
+
name: '目标点x坐标',
|
|
23818
|
+
repeatable: false,
|
|
23819
|
+
optional: false,
|
|
23820
|
+
},
|
|
23821
|
+
{
|
|
23822
|
+
name: '目标点y坐标',
|
|
23823
|
+
repeatable: false,
|
|
23824
|
+
optional: false,
|
|
23825
|
+
},
|
|
23826
|
+
],
|
|
23827
|
+
funCallback: (spread, sheet, retData) => {
|
|
23828
|
+
// 如果传递的参数小于3个,则返回/
|
|
23829
|
+
if (retData.allCellVals.length < 3) {
|
|
23830
|
+
return '/';
|
|
23831
|
+
}
|
|
23832
|
+
let points = retData.allCellVals[0], xPoint = retData.allCellVals[1], yPoint = retData.allCellVals[2];
|
|
23833
|
+
// 1. 格式校验
|
|
23834
|
+
if (typeof points !== 'string' || !points)
|
|
23835
|
+
return '/';
|
|
23836
|
+
const regex = /^\s*\(\s*(-?\d+(?:\.\d+)?)\s*,\s*(-?\d+(?:\.\d+)?)\s*\)\s*:\s*\(\s*(-?\d+(?:\.\d+)?)\s*,\s*(-?\d+(?:\.\d+)?)\s*\)\s*:\s*\(\s*(-?\d+(?:\.\d+)?)\s*,\s*(-?\d+(?:\.\d+)?)\s*\)\s*:\s*\(\s*(-?\d+(?:\.\d+)?)\s*,\s*(-?\d+(?:\.\d+)?)\s*\)\s*$/;
|
|
23837
|
+
const match = points.match(regex);
|
|
23838
|
+
if (!match)
|
|
23839
|
+
return '/';
|
|
23840
|
+
// 2. 解析坐标
|
|
23841
|
+
const coords = [];
|
|
23842
|
+
for (let i = 1; i < match.length; i += 2) {
|
|
23843
|
+
coords.push({ x: parseFloat(match[i]), y: parseFloat(match[i + 1]) });
|
|
23844
|
+
}
|
|
23845
|
+
const tx = Number(xPoint), ty = Number(yPoint);
|
|
23846
|
+
if (isNaN(tx) || isNaN(ty))
|
|
23847
|
+
return '/';
|
|
23848
|
+
// 3. 【新增】边界判定:点到线段距离 ≤ 容差 → 直接合格
|
|
23849
|
+
const EPSILON = 1e-9;
|
|
23850
|
+
function pointToSegmentDistSq(px, py, ax, ay, bx, by) {
|
|
23851
|
+
const dx = bx - ax, dy = by - ay;
|
|
23852
|
+
const lenSq = dx * dx + dy * dy;
|
|
23853
|
+
if (lenSq === 0)
|
|
23854
|
+
return (px - ax) ** 2 + (py - ay) ** 2; // 退化为点
|
|
23855
|
+
let t = ((px - ax) * dx + (py - ay) * dy) / lenSq;
|
|
23856
|
+
t = Math.max(0, Math.min(1, t)); // 钳制到 [0,1]
|
|
23857
|
+
const projX = ax + t * dx, projY = ay + t * dy;
|
|
23858
|
+
return (px - projX) ** 2 + (py - projY) ** 2;
|
|
23859
|
+
}
|
|
23860
|
+
const n = coords.length;
|
|
23861
|
+
for (let i = 0, j = n - 1; i < n; j = i++) {
|
|
23862
|
+
const distSq = pointToSegmentDistSq(tx, ty, coords[j].x, coords[j].y, coords[i].x, coords[i].y);
|
|
23863
|
+
if (distSq <= EPSILON * EPSILON)
|
|
23864
|
+
return '合格';
|
|
23865
|
+
}
|
|
23866
|
+
// 4. 射线法判定内部
|
|
23867
|
+
let inside = false;
|
|
23868
|
+
for (let i = 0, j = n - 1; i < n; j = i++) {
|
|
23869
|
+
const xi = coords[i].x, yi = coords[i].y;
|
|
23870
|
+
const xj = coords[j].x, yj = coords[j].y;
|
|
23871
|
+
const intersect = yi > ty !== yj > ty && tx < ((xj - xi) * (ty - yi)) / (yj - yi) + xi;
|
|
23872
|
+
if (intersect)
|
|
23873
|
+
inside = !inside;
|
|
23874
|
+
}
|
|
23875
|
+
return inside ? '合格' : '不合格';
|
|
23876
|
+
},
|
|
23877
|
+
},
|
|
23783
23878
|
{
|
|
23784
23879
|
funName: 'YJTEST',
|
|
23785
23880
|
funDesc: '云检测试函数',
|