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
4f5688f0
Commit
4f5688f0
authored
Nov 09, 2022
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
offset fix
parent
958286c8
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
9 deletions
+17
-9
EthereumChart.tsx
ui/charts/EthereumChart.tsx
+4
-1
Graph.tsx
ui/pages/Graph.tsx
+1
-1
types.tsx
ui/shared/chart/types.tsx
+5
-0
useChartSize.tsx
ui/shared/chart/useChartSize.tsx
+7
-7
No files found.
ui/charts/EthereumChart.tsx
View file @
4f5688f0
...
@@ -19,12 +19,15 @@ import useChartSize from 'ui/shared/chart/useChartSize';
...
@@ -19,12 +19,15 @@ import useChartSize from 'ui/shared/chart/useChartSize';
import
useTimeChartController
from
'
ui/shared/chart/useTimeChartController
'
;
import
useTimeChartController
from
'
ui/shared/chart/useTimeChartController
'
;
const
CHART_MARGIN
=
{
bottom
:
20
,
left
:
65
,
right
:
30
,
top
:
10
};
const
CHART_MARGIN
=
{
bottom
:
20
,
left
:
65
,
right
:
30
,
top
:
10
};
const
CHART_OFFSET
=
{
y
:
26
,
// legend height
};
const
EthereumChart
=
()
=>
{
const
EthereumChart
=
()
=>
{
const
ref
=
React
.
useRef
<
SVGSVGElement
>
(
null
);
const
ref
=
React
.
useRef
<
SVGSVGElement
>
(
null
);
const
overlayRef
=
React
.
useRef
<
SVGRectElement
>
(
null
);
const
overlayRef
=
React
.
useRef
<
SVGRectElement
>
(
null
);
const
{
width
,
height
,
innerWidth
,
innerHeight
}
=
useChartSize
(
ref
.
current
,
CHART_MARGIN
);
const
{
width
,
height
,
innerWidth
,
innerHeight
}
=
useChartSize
(
ref
.
current
,
CHART_MARGIN
,
CHART_OFFSET
);
const
[
range
,
setRange
]
=
React
.
useState
<
[
number
,
number
]
>
([
0
,
Infinity
]);
const
[
range
,
setRange
]
=
React
.
useState
<
[
number
,
number
]
>
([
0
,
Infinity
]);
const
data
:
TimeChartData
=
[
const
data
:
TimeChartData
=
[
...
...
ui/pages/Graph.tsx
View file @
4f5688f0
...
@@ -14,7 +14,7 @@ const Graph = () => {
...
@@ -14,7 +14,7 @@ const Graph = () => {
<
Box
w=
"100%"
h=
"400px"
>
<
Box
w=
"100%"
h=
"400px"
>
<
EthereumChart
/>
<
EthereumChart
/>
</
Box
>
</
Box
>
<
Heading
as=
"h2"
size=
"sm"
fontWeight=
"500"
mb=
{
3
}
mt=
"
10
0px"
>
Ethereum Daily Transactions For Last Month
</
Heading
>
<
Heading
as=
"h2"
size=
"sm"
fontWeight=
"500"
mb=
{
3
}
mt=
"
8
0px"
>
Ethereum Daily Transactions For Last Month
</
Heading
>
<
Box
w=
"240px"
h=
"150px"
>
<
Box
w=
"240px"
h=
"150px"
>
<
SplineChartExample
/>
<
SplineChartExample
/>
</
Box
>
</
Box
>
...
...
ui/shared/chart/types.tsx
View file @
4f5688f0
...
@@ -10,6 +10,11 @@ export interface ChartMargin {
...
@@ -10,6 +10,11 @@ export interface ChartMargin {
left
?:
number
;
left
?:
number
;
}
}
export
interface
ChartOffset
{
x
?:
number
;
y
?:
number
;
}
export
interface
TimeChartDataItem
{
export
interface
TimeChartDataItem
{
items
:
Array
<
TimeChartItem
>
;
items
:
Array
<
TimeChartItem
>
;
name
:
string
;
name
:
string
;
...
...
ui/shared/chart/useChartSize.tsx
View file @
4f5688f0
import
_debounce
from
'
lodash/debounce
'
;
import
_debounce
from
'
lodash/debounce
'
;
import
React
from
'
react
'
;
import
React
from
'
react
'
;
import
type
{
ChartMargin
}
from
'
ui/shared/chart/types
'
;
import
type
{
ChartMargin
,
ChartOffset
}
from
'
ui/shared/chart/types
'
;
export
default
function
useChartSize
(
svgEl
:
SVGSVGElement
|
null
,
margin
?:
ChartMargin
)
{
export
default
function
useChartSize
(
svgEl
:
SVGSVGElement
|
null
,
margin
?:
ChartMargin
,
offsets
?:
ChartOffset
)
{
const
[
rect
,
setRect
]
=
React
.
useState
<
{
width
:
number
;
height
:
number
}
>
({
width
:
0
,
height
:
0
});
const
[
rect
,
setRect
]
=
React
.
useState
<
{
width
:
number
;
height
:
number
}
>
({
width
:
0
,
height
:
0
});
const
calculateRect
=
React
.
useCallback
(()
=>
{
const
calculateRect
=
React
.
useCallback
(()
=>
{
...
@@ -34,10 +34,10 @@ export default function useChartSize(svgEl: SVGSVGElement | null, margin?: Chart
...
@@ -34,10 +34,10 @@ export default function useChartSize(svgEl: SVGSVGElement | null, margin?: Chart
return
React
.
useMemo
(()
=>
{
return
React
.
useMemo
(()
=>
{
return
{
return
{
width
:
rect
.
width
,
width
:
Math
.
max
(
rect
.
width
-
(
offsets
?.
x
||
0
),
0
)
,
height
:
rect
.
height
,
height
:
Math
.
max
(
rect
.
height
-
(
offsets
?.
y
||
0
),
0
)
,
innerWidth
:
Math
.
max
(
rect
.
width
-
(
margin
?.
left
||
0
)
-
(
margin
?.
right
||
0
),
0
),
innerWidth
:
Math
.
max
(
rect
.
width
-
(
offsets
?.
x
||
0
)
-
(
margin
?.
left
||
0
)
-
(
margin
?.
right
||
0
),
0
),
innerHeight
:
Math
.
max
(
rect
.
height
-
(
margin
?.
bottom
||
0
)
-
(
margin
?.
top
||
0
),
0
),
innerHeight
:
Math
.
max
(
rect
.
height
-
(
offsets
?.
y
||
0
)
-
(
margin
?.
bottom
||
0
)
-
(
margin
?.
top
||
0
),
0
),
};
};
},
[
margin
?.
bottom
,
margin
?.
left
,
margin
?.
right
,
margin
?.
top
,
rect
]);
},
[
margin
?.
bottom
,
margin
?.
left
,
margin
?.
right
,
margin
?.
top
,
offsets
?.
x
,
offsets
?.
y
,
rect
.
height
,
rect
.
width
]);
}
}
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