Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
JINRUN-DP
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
xinzhedeai
JINRUN-DP
Commits
70b02751
Commit
70b02751
authored
Dec 22, 2025
by
xinzhedeai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
左侧降雨量没有默认值
parent
cae519e6
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
5 deletions
+37
-5
LeftRainfallTrend.vue
src/components/MineMonitor/LeftRainfallTrend.vue
+37
-5
No files found.
src/components/MineMonitor/LeftRainfallTrend.vue
View file @
70b02751
...
...
@@ -38,17 +38,49 @@ const showNoData = ref(false);
// const DEFAULT_Y_AXIS_MAX = 250; // Y轴最大值
// const DEFAULT_Y_AXIS_MIN = 0; // Y轴最小值
// 新增:计算y轴最大值(包含数据和警戒线,并预留空间)
const
getYAxisMax
=
()
=>
{
// 处理空数据情况
if
(
yAxisData
.
value
.
length
===
0
&&
warningLines
.
value
.
length
===
0
)
{
return
10
;
// 无数据时默认最大值
}
// 获取实际数据的最大值
const
dataMax
=
yAxisData
.
value
.
length
>
0
?
Math
.
max
(...
yAxisData
.
value
)
:
0
;
// 获取警戒线的最大值
const
warningMax
=
warningLines
.
value
.
length
>
0
?
Math
.
max
(...
warningLines
.
value
.
map
(
line
=>
line
.
value
))
:
0
;
// 取两者中的较大值作为基准
const
baseMax
=
Math
.
max
(
dataMax
,
warningMax
);
// 增加20%的冗余空间(可根据需求调整比例)
const
redundant
=
baseMax
*
0.2
;
// 确保最小值至少为10,避免数值过小导致图表显示异常
return
Math
.
max
(
baseMax
+
redundant
,
0.5
);
};
// 模拟接口请求函数
const
fetchRainCurve
=
async
()
=>
{
const
response
=
await
getRainCurve
();
console
.
log
(
'
降雨量
'
,
response
.
data
)
const
result
=
response
.
data
if
(
result
.
code
==
200
)
{
// result.data.ydata= []
// 处理空数据情况
if
(
!
result
.
data
||
!
result
.
data
.
ydata
||
result
.
data
.
ydata
.
length
===
0
)
{
// 显示"暂无数据"提示
showNoData
.
value
=
true
;
yAxisData
.
value
=
[
0
]
xAxisData
.
value
=
[
0
]
}
else
{
// 隐藏"暂无数据"提示
showNoData
.
value
=
false
;
...
...
@@ -93,10 +125,9 @@ const updateChartData = () => {
xAxis
:
{
data
:
xAxisData
.
value
},
// yAxis: {
// min: DEFAULT_Y_AXIS_MIN,
// max: DEFAULT_Y_AXIS_MAX
// },
yAxis
:
{
max
:
getYAxisMax
()
// 应用动态计算的最大值
},
series
:
[{
data
:
yAxisData
.
value
,
markLine
:
{
...
...
@@ -146,6 +177,7 @@ const initChart = () => {
padding
:
[
0
,
38
,
0
,
0
],
},
type
:
"
value
"
,
max
:
getYAxisMax
(),
// max: 300,
// min: DEFAULT_Y_AXIS_MIN, // 设置Y轴最小值
// max: DEFAULT_Y_AXIS_MAX, // 设置Y轴最大值
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment