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.cjs.js
CHANGED
|
@@ -9811,8 +9811,31 @@ const EChartsUtilsAll = {
|
|
|
9811
9811
|
const chartExtJson = config.chartExtJson == null || config.chartExtJson == undefined ? null : JSON.parse(config.chartExtJson);
|
|
9812
9812
|
let title = config.chartTitle, xName = config.chartXName, yName = config.chartYName, color = lineData[0].lineColor;
|
|
9813
9813
|
// 原始数据
|
|
9814
|
-
|
|
9815
|
-
|
|
9814
|
+
let xData = xDataArr[0];
|
|
9815
|
+
let yData = yDataArr[0];
|
|
9816
|
+
/**
|
|
9817
|
+
* 根据两个数组对应位置的值进行联合过滤,去除任一为0的项
|
|
9818
|
+
* @param {number[]} arr1 - 第一个数字数组
|
|
9819
|
+
* @param {number[]} arr2 - 第二个数字数组
|
|
9820
|
+
* @returns {[number[], number[]]} 返回过滤后的两个数组组成的元组
|
|
9821
|
+
*/
|
|
9822
|
+
function filterArrData(arr1, arr2) {
|
|
9823
|
+
const filtered1 = [];
|
|
9824
|
+
const filtered2 = [];
|
|
9825
|
+
// 以较短的数组长度为基准,防止越界
|
|
9826
|
+
const len = Math.min(arr1.length, arr2.length);
|
|
9827
|
+
for (let i = 0; i < len; i++) {
|
|
9828
|
+
// 只有当两个数组在当前位置都非0时,才保留该数据
|
|
9829
|
+
if (arr1[i] !== 0 && arr2[i] !== 0) {
|
|
9830
|
+
filtered1.push(arr1[i]);
|
|
9831
|
+
filtered2.push(arr2[i]);
|
|
9832
|
+
}
|
|
9833
|
+
}
|
|
9834
|
+
return [filtered1, filtered2];
|
|
9835
|
+
}
|
|
9836
|
+
const [xDataFiltered, yDataFiltered] = filterArrData(xData, yData);
|
|
9837
|
+
xData = xDataFiltered;
|
|
9838
|
+
yData = yDataFiltered;
|
|
9816
9839
|
// 手动计算线性回归参数
|
|
9817
9840
|
function linearRegression(x, y) {
|
|
9818
9841
|
const n = x.length;
|
|
@@ -23802,6 +23825,78 @@ const FormulaUtils = {
|
|
|
23802
23825
|
return qdhsz;
|
|
23803
23826
|
},
|
|
23804
23827
|
},
|
|
23828
|
+
{
|
|
23829
|
+
funName: 'YJZBPD',
|
|
23830
|
+
funDesc: '报告上根据技术要求进行坐标判定',
|
|
23831
|
+
funDefaultVal: null,
|
|
23832
|
+
funParams: [
|
|
23833
|
+
{
|
|
23834
|
+
name: '四边形坐标,格式如 (0,0):(3,7):(15,8):(9.5,3.3)',
|
|
23835
|
+
repeatable: false,
|
|
23836
|
+
optional: false,
|
|
23837
|
+
},
|
|
23838
|
+
{
|
|
23839
|
+
name: '目标点x坐标',
|
|
23840
|
+
repeatable: false,
|
|
23841
|
+
optional: false,
|
|
23842
|
+
},
|
|
23843
|
+
{
|
|
23844
|
+
name: '目标点y坐标',
|
|
23845
|
+
repeatable: false,
|
|
23846
|
+
optional: false,
|
|
23847
|
+
},
|
|
23848
|
+
],
|
|
23849
|
+
funCallback: (spread, sheet, retData) => {
|
|
23850
|
+
// 如果传递的参数小于3个,则返回/
|
|
23851
|
+
if (retData.allCellVals.length < 3) {
|
|
23852
|
+
return '/';
|
|
23853
|
+
}
|
|
23854
|
+
let points = retData.allCellVals[0], xPoint = retData.allCellVals[1], yPoint = retData.allCellVals[2];
|
|
23855
|
+
// 1. 格式校验
|
|
23856
|
+
if (typeof points !== 'string' || !points)
|
|
23857
|
+
return '/';
|
|
23858
|
+
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*$/;
|
|
23859
|
+
const match = points.match(regex);
|
|
23860
|
+
if (!match)
|
|
23861
|
+
return '/';
|
|
23862
|
+
// 2. 解析坐标
|
|
23863
|
+
const coords = [];
|
|
23864
|
+
for (let i = 1; i < match.length; i += 2) {
|
|
23865
|
+
coords.push({ x: parseFloat(match[i]), y: parseFloat(match[i + 1]) });
|
|
23866
|
+
}
|
|
23867
|
+
const tx = Number(xPoint), ty = Number(yPoint);
|
|
23868
|
+
if (isNaN(tx) || isNaN(ty))
|
|
23869
|
+
return '/';
|
|
23870
|
+
// 3. 【新增】边界判定:点到线段距离 ≤ 容差 → 直接合格
|
|
23871
|
+
const EPSILON = 1e-9;
|
|
23872
|
+
function pointToSegmentDistSq(px, py, ax, ay, bx, by) {
|
|
23873
|
+
const dx = bx - ax, dy = by - ay;
|
|
23874
|
+
const lenSq = dx * dx + dy * dy;
|
|
23875
|
+
if (lenSq === 0)
|
|
23876
|
+
return (px - ax) ** 2 + (py - ay) ** 2; // 退化为点
|
|
23877
|
+
let t = ((px - ax) * dx + (py - ay) * dy) / lenSq;
|
|
23878
|
+
t = Math.max(0, Math.min(1, t)); // 钳制到 [0,1]
|
|
23879
|
+
const projX = ax + t * dx, projY = ay + t * dy;
|
|
23880
|
+
return (px - projX) ** 2 + (py - projY) ** 2;
|
|
23881
|
+
}
|
|
23882
|
+
const n = coords.length;
|
|
23883
|
+
for (let i = 0, j = n - 1; i < n; j = i++) {
|
|
23884
|
+
const distSq = pointToSegmentDistSq(tx, ty, coords[j].x, coords[j].y, coords[i].x, coords[i].y);
|
|
23885
|
+
if (distSq <= EPSILON * EPSILON)
|
|
23886
|
+
return '合格';
|
|
23887
|
+
}
|
|
23888
|
+
// 4. 射线法判定内部
|
|
23889
|
+
let inside = false;
|
|
23890
|
+
for (let i = 0, j = n - 1; i < n; j = i++) {
|
|
23891
|
+
const xi = coords[i].x, yi = coords[i].y;
|
|
23892
|
+
const xj = coords[j].x, yj = coords[j].y;
|
|
23893
|
+
const intersect = yi > ty !== yj > ty && tx < ((xj - xi) * (ty - yi)) / (yj - yi) + xi;
|
|
23894
|
+
if (intersect)
|
|
23895
|
+
inside = !inside;
|
|
23896
|
+
}
|
|
23897
|
+
return inside ? '合格' : '不合格';
|
|
23898
|
+
},
|
|
23899
|
+
},
|
|
23805
23900
|
{
|
|
23806
23901
|
funName: 'YJTEST',
|
|
23807
23902
|
funDesc: '云检测试函数',
|