Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
frontend
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
vicotor
frontend
Commits
87716a55
Commit
87716a55
authored
Dec 21, 2022
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adjust chart height
parent
ea062c17
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
14 deletions
+19
-14
AddressCoinBalanceChart.tsx
ui/address/coinBalance/AddressCoinBalanceChart.tsx
+1
-0
ChartWidget.tsx
ui/shared/chart/ChartWidget.tsx
+12
-9
ChartWidgetGraph.tsx
ui/shared/chart/ChartWidgetGraph.tsx
+3
-3
ChartWidgetSkeleton.tsx
ui/shared/chart/ChartWidgetSkeleton.tsx
+3
-2
No files found.
ui/address/coinBalance/AddressCoinBalanceChart.tsx
View file @
87716a55
...
@@ -30,6 +30,7 @@ const AddressCoinBalanceChart = ({ addressQuery }: Props) => {
...
@@ -30,6 +30,7 @@ const AddressCoinBalanceChart = ({ addressQuery }: Props) => {
return
(
return
(
<
ChartWidget
<
ChartWidget
chartHeight=
"200px"
title=
"Balances"
title=
"Balances"
items=
{
items
}
items=
{
items
}
isLoading=
{
isLoading
||
isError
}
isLoading=
{
isLoading
||
isError
}
...
...
ui/shared/chart/ChartWidget.tsx
View file @
87716a55
...
@@ -18,11 +18,12 @@ type Props = {
...
@@ -18,11 +18,12 @@ type Props = {
title
:
string
;
title
:
string
;
description
?:
string
;
description
?:
string
;
isLoading
:
boolean
;
isLoading
:
boolean
;
chartHeight
?:
string
;
}
}
const
DOWNLOAD_IMAGE_SCALE
=
5
;
const
DOWNLOAD_IMAGE_SCALE
=
5
;
const
ChartWidget
=
({
items
,
title
,
description
,
isLoading
}:
Props
)
=>
{
const
ChartWidget
=
({
items
,
title
,
description
,
isLoading
,
chartHeight
}:
Props
)
=>
{
const
ref
=
useRef
<
HTMLDivElement
>
(
null
);
const
ref
=
useRef
<
HTMLDivElement
>
(
null
);
const
[
isFullscreen
,
setIsFullscreen
]
=
useState
(
false
);
const
[
isFullscreen
,
setIsFullscreen
]
=
useState
(
false
);
const
[
isZoomResetInitial
,
setIsZoomResetInitial
]
=
React
.
useState
(
true
);
const
[
isZoomResetInitial
,
setIsZoomResetInitial
]
=
React
.
useState
(
true
);
...
@@ -78,7 +79,7 @@ const ChartWidget = ({ items, title, description, isLoading }: Props) => {
...
@@ -78,7 +79,7 @@ const ChartWidget = ({ items, title, description, isLoading }: Props) => {
},
[
title
]);
},
[
title
]);
if
(
isLoading
)
{
if
(
isLoading
)
{
return
<
ChartWidgetSkeleton
hasDescription=
{
Boolean
(
description
)
}
/>;
return
<
ChartWidgetSkeleton
hasDescription=
{
Boolean
(
description
)
}
chartHeight=
{
chartHeight
}
/>;
}
}
if
(
items
)
{
if
(
items
)
{
...
@@ -172,12 +173,14 @@ const ChartWidget = ({ items, title, description, isLoading }: Props) => {
...
@@ -172,12 +173,14 @@ const ChartWidget = ({ items, title, description, isLoading }: Props) => {
</
Menu
>
</
Menu
>
</
Grid
>
</
Grid
>
<
ChartWidgetGraph
<
Box
h=
{
chartHeight
||
'
auto
'
}
>
items=
{
items
}
<
ChartWidgetGraph
onZoom=
{
handleZoom
}
items=
{
items
}
isZoomResetInitial=
{
isZoomResetInitial
}
onZoom=
{
handleZoom
}
title=
{
title
}
isZoomResetInitial=
{
isZoomResetInitial
}
/>
title=
{
title
}
/>
</
Box
>
</
Box
>
</
Box
>
<
FullscreenChartModal
<
FullscreenChartModal
...
@@ -194,4 +197,4 @@ const ChartWidget = ({ items, title, description, isLoading }: Props) => {
...
@@ -194,4 +197,4 @@ const ChartWidget = ({ items, title, description, isLoading }: Props) => {
return
null
;
return
null
;
};
};
export
default
ChartWidget
;
export
default
React
.
memo
(
ChartWidget
)
;
ui/shared/chart/ChartWidgetGraph.tsx
View file @
87716a55
...
@@ -31,7 +31,7 @@ const ChartWidgetGraph = ({ isEnlarged, items, onZoom, isZoomResetInitial, title
...
@@ -31,7 +31,7 @@ const ChartWidgetGraph = ({ isEnlarged, items, onZoom, isZoomResetInitial, title
const
overlayRef
=
React
.
useRef
<
SVGRectElement
>
(
null
);
const
overlayRef
=
React
.
useRef
<
SVGRectElement
>
(
null
);
const
chartId
=
useMemo
(()
=>
`chart-
${
title
.
split
(
'
'
).
join
(
''
)
}
`
,
[
title
]);
const
chartId
=
useMemo
(()
=>
`chart-
${
title
.
split
(
'
'
).
join
(
''
)
}
`
,
[
title
]);
const
[
range
,
setRange
]
=
React
.
useState
<
[
number
,
number
]
>
([
0
,
Infinity
]);
const
[
range
,
setRange
]
=
React
.
useState
<
[
number
,
number
]
>
([
0
,
Infinity
]);
const
{
innerWidth
,
innerHeight
}
=
useChartSize
(
ref
.
current
,
CHART_MARGIN
);
const
{
width
,
height
,
innerWidth
,
innerHeight
}
=
useChartSize
(
ref
.
current
,
CHART_MARGIN
);
const
displayedData
=
useMemo
(()
=>
items
.
slice
(
range
[
0
],
range
[
1
]),
[
items
,
range
]);
const
displayedData
=
useMemo
(()
=>
items
.
slice
(
range
[
0
],
range
[
1
]),
[
items
,
range
]);
const
chartData
=
[
{
items
:
items
,
name
:
'
Value
'
,
color
}
];
const
chartData
=
[
{
items
:
items
,
name
:
'
Value
'
,
color
}
];
...
@@ -54,9 +54,9 @@ const ChartWidgetGraph = ({ isEnlarged, items, onZoom, isZoomResetInitial, title
...
@@ -54,9 +54,9 @@ const ChartWidgetGraph = ({ isEnlarged, items, onZoom, isZoomResetInitial, title
},
[
isZoomResetInitial
]);
},
[
isZoomResetInitial
]);
return
(
return
(
<
svg
width=
"100%"
height=
"100%"
ref=
{
ref
}
cursor=
"pointer"
id=
{
chartId
}
>
<
svg
width=
{
width
||
'
100%
'
}
height=
{
height
||
'
auto
'
}
ref=
{
ref
}
cursor=
"pointer"
id=
{
chartId
}
opacity=
{
width
?
1
:
0
}
>
<
g
transform=
{
`translate(${ CHART_MARGIN?.left || 0 },${ CHART_MARGIN?.top || 0 })`
}
opacity=
{
innerWidth
?
1
:
0
}
>
<
g
transform=
{
`translate(${ CHART_MARGIN?.left || 0 },${ CHART_MARGIN?.top || 0 })`
}
>
<
ChartGridLine
<
ChartGridLine
type=
"horizontal"
type=
"horizontal"
scale=
{
yScale
}
scale=
{
yScale
}
...
...
ui/shared/chart/ChartWidgetSkeleton.tsx
View file @
87716a55
...
@@ -3,9 +3,10 @@ import React from 'react';
...
@@ -3,9 +3,10 @@ import React from 'react';
interface
Props
{
interface
Props
{
hasDescription
:
boolean
;
hasDescription
:
boolean
;
chartHeight
?:
string
;
}
}
const
ChartWidgetSkeleton
=
({
hasDescription
}:
Props
)
=>
{
const
ChartWidgetSkeleton
=
({
hasDescription
,
chartHeight
}:
Props
)
=>
{
return
(
return
(
<
Box
<
Box
height=
"235px"
height=
"235px"
...
@@ -14,7 +15,7 @@ const ChartWidgetSkeleton = ({ hasDescription }: Props) => {
...
@@ -14,7 +15,7 @@ const ChartWidgetSkeleton = ({ hasDescription }: Props) => {
<
Skeleton
w=
"75%"
h=
"24px"
/>
<
Skeleton
w=
"75%"
h=
"24px"
/>
{
hasDescription
&&
<
Skeleton
w=
"50%"
h=
"18px"
mt=
{
1
}
/>
}
{
hasDescription
&&
<
Skeleton
w=
"50%"
h=
"18px"
mt=
{
1
}
/>
}
<
Skeleton
w=
"100%"
h=
"150px"
mt=
{
5
}
/>
<
Skeleton
w=
"100%"
h=
{
chartHeight
||
'
150px
'
}
mt=
{
5
}
/>
</
Box
>
</
Box
>
);
);
};
};
...
...
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