rapid-spreadjs 1.0.103 → 1.0.105
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 +335 -1
- 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 +335 -1
- 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/dist/utils/echarts-all.d.ts +150 -1
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -4093,6 +4093,40 @@ const EChartsUtilsAll = {
|
|
|
4093
4093
|
xDataSource2 = isTwoLine ? xDataArr[1] : [], // [1.5, 2.4, 3.6, 4.3, 5.4],
|
|
4094
4094
|
yDataSource1 = yDataArr[0], // [2.25, 2.29, 2.34, 2.29, 2.23],
|
|
4095
4095
|
yDataSource2 = isTwoLine ? yDataArr[1] : []; // [2.27, 2.32, 2.36, 2.33, 2.26];
|
|
4096
|
+
let xDataLs1 = [], yDataLs1 = [];
|
|
4097
|
+
xDataSource1.forEach((x, index) => {
|
|
4098
|
+
if (x != '/' &&
|
|
4099
|
+
x != 0 &&
|
|
4100
|
+
x != null &&
|
|
4101
|
+
x != undefined &&
|
|
4102
|
+
yDataSource1[index] != '/' &&
|
|
4103
|
+
yDataSource1[index] != 0 &&
|
|
4104
|
+
yDataSource1[index] != null &&
|
|
4105
|
+
yDataSource1[index] != undefined) {
|
|
4106
|
+
xDataLs1.push(x);
|
|
4107
|
+
yDataLs1.push(yDataSource1[index]);
|
|
4108
|
+
}
|
|
4109
|
+
});
|
|
4110
|
+
xDataSource1 = xDataLs1;
|
|
4111
|
+
yDataSource1 = yDataLs1;
|
|
4112
|
+
if (isTwoLine) {
|
|
4113
|
+
let xDataLs2 = [], yDataLs2 = [];
|
|
4114
|
+
xDataSource2.forEach((x, index) => {
|
|
4115
|
+
if (x != '/' &&
|
|
4116
|
+
x != 0 &&
|
|
4117
|
+
x != null &&
|
|
4118
|
+
x != undefined &&
|
|
4119
|
+
yDataSource2[index] != '/' &&
|
|
4120
|
+
yDataSource2[index] != 0 &&
|
|
4121
|
+
yDataSource2[index] != null &&
|
|
4122
|
+
yDataSource2[index] != undefined) {
|
|
4123
|
+
xDataLs2.push(x);
|
|
4124
|
+
yDataLs2.push(yDataSource2[index]);
|
|
4125
|
+
}
|
|
4126
|
+
});
|
|
4127
|
+
xDataSource2 = xDataLs2;
|
|
4128
|
+
yDataSource2 = yDataLs2;
|
|
4129
|
+
}
|
|
4096
4130
|
let title = config.chartTitle, xName = config.chartXName, yName = config.chartYName, legendName = '图例1';
|
|
4097
4131
|
const lineFunc = (xDataSource, yDataSource, isShowMarkPoint, isShowMarkLine, isTwoLineData) => {
|
|
4098
4132
|
//原始数据
|
|
@@ -8634,7 +8668,7 @@ const EChartsUtilsAll = {
|
|
|
8634
8668
|
return option;
|
|
8635
8669
|
},
|
|
8636
8670
|
/**
|
|
8637
|
-
*
|
|
8671
|
+
* 土工合成材料(拉拔摩擦特性)
|
|
8638
8672
|
* @param config 折线配置
|
|
8639
8673
|
* @param xDataArr x轴原始数据(二维数组)
|
|
8640
8674
|
* @param yDataArr y轴原始数据(二维数组)
|
|
@@ -8801,6 +8835,303 @@ const EChartsUtilsAll = {
|
|
|
8801
8835
|
};
|
|
8802
8836
|
return option;
|
|
8803
8837
|
},
|
|
8838
|
+
/**
|
|
8839
|
+
* 土工合成材料(有效孔径)
|
|
8840
|
+
* @param config 折线配置
|
|
8841
|
+
* @param xDataArr x轴原始数据(二维数组)
|
|
8842
|
+
* @param yDataArr y轴原始数据(二维数组)
|
|
8843
|
+
* @returns 返回ECharts配置项
|
|
8844
|
+
*/
|
|
8845
|
+
chart470: (config, xDataArr, yDataArr, sheet) => {
|
|
8846
|
+
let lineData = JSON.parse(config.chartLinesJson);
|
|
8847
|
+
const chartExtJson = config.chartExtJson == null || config.chartExtJson == undefined ? null : JSON.parse(config.chartExtJson);
|
|
8848
|
+
let title = config.chartTitle, xName = config.chartXName, yName = config.chartYName, color = lineData[0].lineColor;
|
|
8849
|
+
// 原始数据
|
|
8850
|
+
const xData = xDataArr[0];
|
|
8851
|
+
const yData = yDataArr[0];
|
|
8852
|
+
// 线性内插法函数:根据y值计算对应的x值
|
|
8853
|
+
function interpolateX(targetY, xData, yData) {
|
|
8854
|
+
// 查找目标y值所在区间
|
|
8855
|
+
for (let i = 0; i < yData.length - 1; i++) {
|
|
8856
|
+
if ((yData[i] >= targetY && yData[i + 1] <= targetY) || (yData[i] <= targetY && yData[i + 1] >= targetY)) {
|
|
8857
|
+
// 线性插值公式: x = x1 + (x2 - x1) * (targetY - y1) / (y2 - y1)
|
|
8858
|
+
const x1 = xData[i];
|
|
8859
|
+
const x2 = xData[i + 1];
|
|
8860
|
+
const y1 = yData[i];
|
|
8861
|
+
const y2 = yData[i + 1];
|
|
8862
|
+
return x1 + ((x2 - x1) * (targetY - y1)) / (y2 - y1);
|
|
8863
|
+
}
|
|
8864
|
+
}
|
|
8865
|
+
return null; // 如果目标y值不在数据范围内
|
|
8866
|
+
}
|
|
8867
|
+
// 计算y=5和y=10对应的x值
|
|
8868
|
+
const xAtY5 = interpolateX(5, xData, yData);
|
|
8869
|
+
const xAtY10 = interpolateX(10, xData, yData);
|
|
8870
|
+
// console.log('y=5时,x=' + (xAtY5 ? xAtY5 : ''));
|
|
8871
|
+
// console.log('y=10时,x=' + (xAtY10 ? xAtY10 : ''));
|
|
8872
|
+
let yValIsAllNull = false;
|
|
8873
|
+
if (xData.length == 0 ||
|
|
8874
|
+
yData.length == 0 ||
|
|
8875
|
+
(!xData.some((x) => x != '' && x != '/' && x != null && x != undefined) &&
|
|
8876
|
+
!yData.some((x) => x != '' && x != '/' && x != null && x != undefined))) {
|
|
8877
|
+
yValIsAllNull = true;
|
|
8878
|
+
}
|
|
8879
|
+
if (xData.filter((x) => x == 0).length == xData.length || yData.filter((x) => x == 0).length == yData.length) {
|
|
8880
|
+
yValIsAllNull = true;
|
|
8881
|
+
}
|
|
8882
|
+
// 输出x轴内插值
|
|
8883
|
+
if (chartExtJson != null) {
|
|
8884
|
+
if (chartExtJson.tghcclYxkj5 != null && chartExtJson.tghcclYxkj5 != undefined) {
|
|
8885
|
+
sheet.setValue(chartExtJson.tghcclYxkj5.row, chartExtJson.tghcclYxkj5.col, xAtY5 ? xAtY5 : '/');
|
|
8886
|
+
}
|
|
8887
|
+
if (chartExtJson.tghcclYxkj10 != null && chartExtJson.tghcclYxkj10 != undefined) {
|
|
8888
|
+
sheet.setValue(chartExtJson.tghcclYxkj10.row, chartExtJson.tghcclYxkj10.col, xAtY10 ? xAtY10 : '/');
|
|
8889
|
+
}
|
|
8890
|
+
}
|
|
8891
|
+
// 配置图表选项
|
|
8892
|
+
const option = {
|
|
8893
|
+
title: [
|
|
8894
|
+
{
|
|
8895
|
+
show: true,
|
|
8896
|
+
text: title,
|
|
8897
|
+
left: 'center',
|
|
8898
|
+
top: 2,
|
|
8899
|
+
textStyle: {
|
|
8900
|
+
fontSize: 14,
|
|
8901
|
+
fontWeight: 'normal',
|
|
8902
|
+
},
|
|
8903
|
+
},
|
|
8904
|
+
{
|
|
8905
|
+
show: true,
|
|
8906
|
+
text: xName,
|
|
8907
|
+
left: 'center',
|
|
8908
|
+
bottom: 0,
|
|
8909
|
+
textStyle: {
|
|
8910
|
+
fontSize: 12,
|
|
8911
|
+
fontWeight: 'normal',
|
|
8912
|
+
},
|
|
8913
|
+
},
|
|
8914
|
+
],
|
|
8915
|
+
tooltip: {
|
|
8916
|
+
trigger: 'axis',
|
|
8917
|
+
formatter: function (params) {
|
|
8918
|
+
return `标准颗粒直径: ${params[0].value[0].toFixed(3)} mm<br>过筛率: ${params[0].value[1].toFixed(2)} %`;
|
|
8919
|
+
},
|
|
8920
|
+
},
|
|
8921
|
+
grid: {
|
|
8922
|
+
top: 25,
|
|
8923
|
+
left: 25,
|
|
8924
|
+
right: 15,
|
|
8925
|
+
bottom: 20,
|
|
8926
|
+
containLabel: true,
|
|
8927
|
+
},
|
|
8928
|
+
xAxis: {
|
|
8929
|
+
name: xName,
|
|
8930
|
+
nameLocation: 'end',
|
|
8931
|
+
nameGap: 20,
|
|
8932
|
+
nameTextStyle: {
|
|
8933
|
+
fontSize: 12,
|
|
8934
|
+
},
|
|
8935
|
+
type: 'log', // 设置为对数坐标轴
|
|
8936
|
+
axisLine: {
|
|
8937
|
+
lineStyle: {
|
|
8938
|
+
color: '#333',
|
|
8939
|
+
},
|
|
8940
|
+
},
|
|
8941
|
+
min: 0.01, // 设置最小值为0.01
|
|
8942
|
+
max: 1, // 设置最大值为1
|
|
8943
|
+
axisLabel: {
|
|
8944
|
+
formatter: function (value) {
|
|
8945
|
+
return value.toFixed(2); // 格式化x轴标签显示
|
|
8946
|
+
},
|
|
8947
|
+
},
|
|
8948
|
+
// 增加纵向网格线
|
|
8949
|
+
splitLine: {
|
|
8950
|
+
show: true,
|
|
8951
|
+
lineStyle: {
|
|
8952
|
+
color: '#f0f0f0',
|
|
8953
|
+
width: 1,
|
|
8954
|
+
type: 'solid',
|
|
8955
|
+
},
|
|
8956
|
+
},
|
|
8957
|
+
// 设置更多的刻度点
|
|
8958
|
+
minorTick: {
|
|
8959
|
+
show: true,
|
|
8960
|
+
},
|
|
8961
|
+
minorSplitLine: {
|
|
8962
|
+
show: true,
|
|
8963
|
+
lineStyle: {
|
|
8964
|
+
color: '#f0f0f0',
|
|
8965
|
+
width: 1,
|
|
8966
|
+
type: 'solid',
|
|
8967
|
+
},
|
|
8968
|
+
},
|
|
8969
|
+
},
|
|
8970
|
+
yAxis: {
|
|
8971
|
+
type: 'value', // 普通坐标轴
|
|
8972
|
+
name: yName,
|
|
8973
|
+
nameLocation: 'middle', // 名称居中显示
|
|
8974
|
+
nameGap: 25, // 名称与轴线的距离
|
|
8975
|
+
nameTextStyle: {
|
|
8976
|
+
fontSize: 12,
|
|
8977
|
+
},
|
|
8978
|
+
axisLine: {
|
|
8979
|
+
lineStyle: {
|
|
8980
|
+
color: '#333',
|
|
8981
|
+
},
|
|
8982
|
+
},
|
|
8983
|
+
min: 0,
|
|
8984
|
+
max: 25,
|
|
8985
|
+
// 保持横向网格线
|
|
8986
|
+
splitLine: {
|
|
8987
|
+
show: true,
|
|
8988
|
+
lineStyle: {
|
|
8989
|
+
color: '#f0f0f0',
|
|
8990
|
+
width: 1,
|
|
8991
|
+
},
|
|
8992
|
+
},
|
|
8993
|
+
},
|
|
8994
|
+
series: yValIsAllNull
|
|
8995
|
+
? []
|
|
8996
|
+
: [
|
|
8997
|
+
{
|
|
8998
|
+
name: '孔径分布',
|
|
8999
|
+
type: 'line',
|
|
9000
|
+
data: xData.map((x, i) => [x, yData[i]]), // 组合x和y数据
|
|
9001
|
+
smooth: true, // 平滑曲线
|
|
9002
|
+
lineStyle: {
|
|
9003
|
+
width: 2,
|
|
9004
|
+
type: 'solid', // 实线
|
|
9005
|
+
},
|
|
9006
|
+
// 设置数据点样式为实心点
|
|
9007
|
+
showSymbol: true, // 确保显示数据点
|
|
9008
|
+
symbol: 'circle', // 实心圆点
|
|
9009
|
+
symbolSize: 8, // 点的大小
|
|
9010
|
+
itemStyle: {
|
|
9011
|
+
color: color, // 数据点颜色
|
|
9012
|
+
borderColor: '#fff', // 数据点边框颜色
|
|
9013
|
+
borderWidth: 1, // 数据点边框宽度
|
|
9014
|
+
},
|
|
9015
|
+
markPoint: {
|
|
9016
|
+
symbol: 'circle', // 使用简单的圆点作为标记
|
|
9017
|
+
symbolSize: 8, // 标记点大小
|
|
9018
|
+
data: [
|
|
9019
|
+
{
|
|
9020
|
+
name: 'y=5',
|
|
9021
|
+
coord: [xAtY5, 5], // 标记点坐标
|
|
9022
|
+
value: 5,
|
|
9023
|
+
itemStyle: {
|
|
9024
|
+
color: 'red', // 红色标记点
|
|
9025
|
+
},
|
|
9026
|
+
label: {
|
|
9027
|
+
show: true,
|
|
9028
|
+
formatter: `(${xAtY5.toFixed(3)},5)`, // 显示(x值,y值)
|
|
9029
|
+
position: 'right',
|
|
9030
|
+
fontSize: 12,
|
|
9031
|
+
},
|
|
9032
|
+
},
|
|
9033
|
+
{
|
|
9034
|
+
name: 'y=10',
|
|
9035
|
+
coord: [xAtY10, 10],
|
|
9036
|
+
value: 10,
|
|
9037
|
+
itemStyle: {
|
|
9038
|
+
color: 'red', // 红色标记点
|
|
9039
|
+
},
|
|
9040
|
+
label: {
|
|
9041
|
+
show: true,
|
|
9042
|
+
formatter: `(${xAtY10.toFixed(3)},10)`, // 显示(x值,y值)
|
|
9043
|
+
position: 'right',
|
|
9044
|
+
fontSize: 12,
|
|
9045
|
+
},
|
|
9046
|
+
},
|
|
9047
|
+
],
|
|
9048
|
+
},
|
|
9049
|
+
markLine: {
|
|
9050
|
+
symbol: 'none', // 去掉连线箭头
|
|
9051
|
+
data: [
|
|
9052
|
+
// y=5的水平虚线(从y轴到点)
|
|
9053
|
+
[
|
|
9054
|
+
{
|
|
9055
|
+
coord: [0.01, 5], // 起点:x轴最小值,y=5
|
|
9056
|
+
lineStyle: {
|
|
9057
|
+
type: 'dashed',
|
|
9058
|
+
color: 'red',
|
|
9059
|
+
width: 1,
|
|
9060
|
+
},
|
|
9061
|
+
},
|
|
9062
|
+
{
|
|
9063
|
+
coord: [xAtY5, 5], // 终点:标记点的x坐标,y=5
|
|
9064
|
+
lineStyle: {
|
|
9065
|
+
type: 'dashed',
|
|
9066
|
+
color: 'red',
|
|
9067
|
+
width: 1,
|
|
9068
|
+
},
|
|
9069
|
+
},
|
|
9070
|
+
],
|
|
9071
|
+
// y=5的垂直虚线(从x轴到点)
|
|
9072
|
+
[
|
|
9073
|
+
{
|
|
9074
|
+
coord: [xAtY5, 0], // 起点:标记点的x坐标,y轴最小值
|
|
9075
|
+
lineStyle: {
|
|
9076
|
+
type: 'dashed',
|
|
9077
|
+
color: 'red',
|
|
9078
|
+
width: 1,
|
|
9079
|
+
},
|
|
9080
|
+
},
|
|
9081
|
+
{
|
|
9082
|
+
coord: [xAtY5, 5], // 终点:标记点的坐标
|
|
9083
|
+
lineStyle: {
|
|
9084
|
+
type: 'dashed',
|
|
9085
|
+
color: 'red',
|
|
9086
|
+
width: 1,
|
|
9087
|
+
},
|
|
9088
|
+
},
|
|
9089
|
+
],
|
|
9090
|
+
// y=10的水平虚线(从y轴到点)
|
|
9091
|
+
[
|
|
9092
|
+
{
|
|
9093
|
+
coord: [0.01, 10], // 起点:x轴最小值,y=10
|
|
9094
|
+
lineStyle: {
|
|
9095
|
+
type: 'dashed',
|
|
9096
|
+
color: 'red',
|
|
9097
|
+
width: 1,
|
|
9098
|
+
},
|
|
9099
|
+
},
|
|
9100
|
+
{
|
|
9101
|
+
coord: [xAtY10, 10], // 终点:标记点的x坐标,y=10
|
|
9102
|
+
lineStyle: {
|
|
9103
|
+
type: 'dashed',
|
|
9104
|
+
color: 'red',
|
|
9105
|
+
width: 1,
|
|
9106
|
+
},
|
|
9107
|
+
},
|
|
9108
|
+
],
|
|
9109
|
+
// y=10的垂直虚线(从x轴到点)
|
|
9110
|
+
[
|
|
9111
|
+
{
|
|
9112
|
+
coord: [xAtY10, 0], // 起点:标记点的x坐标,y轴最小值
|
|
9113
|
+
lineStyle: {
|
|
9114
|
+
type: 'dashed',
|
|
9115
|
+
color: 'red',
|
|
9116
|
+
width: 1,
|
|
9117
|
+
},
|
|
9118
|
+
},
|
|
9119
|
+
{
|
|
9120
|
+
coord: [xAtY10, 10], // 终点:标记点的坐标
|
|
9121
|
+
lineStyle: {
|
|
9122
|
+
type: 'dashed',
|
|
9123
|
+
color: 'red',
|
|
9124
|
+
width: 1,
|
|
9125
|
+
},
|
|
9126
|
+
},
|
|
9127
|
+
],
|
|
9128
|
+
],
|
|
9129
|
+
},
|
|
9130
|
+
},
|
|
9131
|
+
],
|
|
9132
|
+
};
|
|
9133
|
+
return option;
|
|
9134
|
+
},
|
|
8804
9135
|
};
|
|
8805
9136
|
|
|
8806
9137
|
/**
|
|
@@ -9070,6 +9401,9 @@ const EChartsUtils = {
|
|
|
9070
9401
|
else if (config.chartType == 450) {
|
|
9071
9402
|
option = EChartsUtilsAll.chart450(config, xDataArr, yDataArr);
|
|
9072
9403
|
}
|
|
9404
|
+
else if (config.chartType == 470) {
|
|
9405
|
+
option = EChartsUtilsAll.chart470(config, xDataArr, yDataArr, sheet);
|
|
9406
|
+
}
|
|
9073
9407
|
if (option && typeof option === 'object') {
|
|
9074
9408
|
//如果是隐藏的图表,则需要禁用ECharts的动画效果
|
|
9075
9409
|
//原因是:如果ECharts使用了动画效果,图表渲染完成可能需要0.5秒,但是在导出ECharts统计图为图片的场景下时,可能在图表还没有渲染完成(动画效果还没结束)前就要获取图像了,此时可能就会造成获取到的图像内容丢失的情况
|