Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
new-api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
171315e6
authored
Jan 07, 2024
by
CaIon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 修复数据看板饼图显示错误
parent
b45f3b18
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
8 deletions
+10
-8
web/src/pages/Detail/index.js
+10
-8
No files found.
web/src/pages/Detail/index.js
View file @
171315e6
...
...
@@ -68,6 +68,7 @@ const Detail = (props) => {
id
:
'id0'
,
values
:
[
{
type
:
'null'
,
value
:
'0'
},
{
type
:
'null'
,
value
:
'0'
},
]
}
],
...
...
@@ -181,14 +182,14 @@ const Detail = (props) => {
// 合并created_at和model_name 为 lineData, created_at 数据类型是小时的时间戳
// 转换日期格式
let
createTime
=
timestamp2string1
(
item
.
created_at
);
let
lineItem
=
lineData
.
find
(
item
=>
item
.
Time
===
item
.
createTime
&&
item
.
Model
===
model_name
);
let
lineItem
=
lineData
.
find
(
item
=>
item
.
Time
===
createTime
&&
item
.
Model
===
model_name
);
if
(
lineItem
)
{
lineItem
.
Usage
+=
getQuotaWithUnit
(
quota
);
lineItem
.
Usage
+=
parseFloat
(
getQuotaWithUnit
(
quota
)
);
}
else
{
lineData
.
push
({
"Time"
:
createTime
,
"Model"
:
model_name
,
"Usage"
:
getQuotaWithUnit
(
quota
)
"Usage"
:
parseFloat
(
getQuotaWithUnit
(
quota
)
)
});
}
...
...
@@ -197,15 +198,16 @@ const Detail = (props) => {
pieData
.
sort
((
a
,
b
)
=>
b
.
value
-
a
.
value
);
pieChart
.
updateData
(
'id0'
,
pieData
);
lineChart
.
updateData
(
'barData'
,
lineData
);
pieChart
.
reLayout
();
lineChart
.
reLayout
();
}
useEffect
Once
(()
=>
{
useEffect
(()
=>
{
if
(
!
initialized
.
current
)
{
initialized
.
current
=
true
;
initChart
();
}
});
}
,
[]
);
return
(
<>
...
...
@@ -240,10 +242,10 @@ const Detail = (props) => {
<
/
>
<
/Form
>
<
div
style
=
{{
height
:
500
}}
>
<
div
id
=
"model_pie"
style
=
{{
width
:
'100%'
}}
><
/div
>
<
div
id
=
"model_pie"
style
=
{{
width
:
'100%'
,
minWidth
:
100
}}
><
/div
>
<
/div
>
<
div
style
=
{{
height
:
500
}}
>
<
div
id
=
"model_data"
style
=
{{
width
:
'100%'
}}
><
/div
>
<
div
id
=
"model_data"
style
=
{{
width
:
'100%'
,
minWidth
:
100
}}
><
/div
>
<
/div
>
<
/Layout.Content
>
<
/Layout
>
...
...
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