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
cf2e70dc
Commit
cf2e70dc
authored
Jan 30, 2023
by
isstuev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
x axis format
parent
d2368c18
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
37 additions
and
12 deletions
+37
-12
AddressCoinBalance.pw.tsx_mobile_base-view-dark-mode-mobile-1.png
...oinBalance.pw.tsx_mobile_base-view-dark-mode-mobile-1.png
+0
-0
EthereumChart.tsx
ui/charts/EthereumChart.tsx
+1
-1
ChartAxis.tsx
ui/shared/chart/ChartAxis.tsx
+10
-6
ChartWidgetGraph.tsx
ui/shared/chart/ChartWidgetGraph.tsx
+3
-2
useTimeChartController.tsx
ui/shared/chart/useTimeChartController.tsx
+23
-3
No files found.
ui/address/__screenshots__/AddressCoinBalance.pw.tsx_mobile_base-view-dark-mode-mobile-1.png
View replaced file @
d2368c18
View file @
cf2e70dc
38 KB
|
W:
|
H:
38.1 KB
|
W:
|
H:
2-up
Swipe
Onion skin
ui/charts/EthereumChart.tsx
View file @
cf2e70dc
...
...
@@ -130,7 +130,7 @@ const EthereumChart = () => {
type=
"left"
scale=
{
yScale
}
ticks=
{
5
}
tickFormat=
{
yTickFormat
}
tickFormat
Generator
=
{
yTickFormat
}
disableAnimation
/>
<
ChartOverlay
ref=
{
overlayRef
}
width=
{
innerWidth
}
height=
{
innerHeight
}
>
...
...
ui/shared/chart/ChartAxis.tsx
View file @
cf2e70dc
...
...
@@ -7,11 +7,11 @@ interface Props extends Omit<React.SVGProps<SVGGElement>, 'scale'> {
scale
:
d3
.
ScaleTime
<
number
,
number
>
|
d3
.
ScaleLinear
<
number
,
number
>
;
disableAnimation
?:
boolean
;
ticks
:
number
;
tickFormat
?:
(
domainValue
:
d3
.
AxisDomain
,
index
:
number
)
=>
string
;
tickFormat
Generator
?:
(
axis
:
d3
.
Axis
<
d3
.
NumberValue
>
)
=>
(
domainValue
:
d3
.
AxisDomain
,
index
:
number
)
=>
string
;
anchorEl
?:
SVGRectElement
|
null
;
}
const
ChartAxis
=
({
type
,
scale
,
ticks
,
tickFormat
,
disableAnimation
,
anchorEl
,
...
props
}:
Props
)
=>
{
const
ChartAxis
=
({
type
,
scale
,
ticks
,
tickFormat
Generator
,
disableAnimation
,
anchorEl
,
...
props
}:
Props
)
=>
{
const
ref
=
React
.
useRef
<
SVGGElement
>
(
null
);
const
textColorToken
=
useColorModeValue
(
'
blackAlpha.600
'
,
'
whiteAlpha.500
'
);
...
...
@@ -23,10 +23,14 @@ const ChartAxis = ({ type, scale, ticks, tickFormat, disableAnimation, anchorEl,
}
const
axisGenerator
=
type
===
'
left
'
?
d3
.
axisLeft
:
d3
.
axisBottom
;
const
axis
=
tickFormat
?
axisGenerator
(
scale
).
ticks
(
ticks
).
tickFormat
(
tickFormat
)
:
axisGenerator
(
scale
).
ticks
(
ticks
);
const
axis
=
axisGenerator
(
scale
).
ticks
(
ticks
);
if
(
tickFormatGenerator
)
{
axis
.
tickFormat
(
tickFormatGenerator
(
axis
));
}
const
axisGroup
=
d3
.
select
(
ref
.
current
);
if
(
disableAnimation
)
{
axisGroup
.
call
(
axis
);
}
else
{
...
...
@@ -38,7 +42,7 @@ const ChartAxis = ({ type, scale, ticks, tickFormat, disableAnimation, anchorEl,
.
attr
(
'
opacity
'
,
1
)
.
attr
(
'
color
'
,
textColor
)
.
attr
(
'
font-size
'
,
'
0.75rem
'
);
},
[
scale
,
ticks
,
tickFormat
,
disableAnimation
,
type
,
textColor
]);
},
[
scale
,
ticks
,
tickFormat
Generator
,
disableAnimation
,
type
,
textColor
]);
React
.
useEffect
(()
=>
{
if
(
!
anchorEl
)
{
...
...
ui/shared/chart/ChartWidgetGraph.tsx
View file @
cf2e70dc
...
...
@@ -55,7 +55,7 @@ const ChartWidgetGraph = ({ isEnlarged, items, onZoom, isZoomResetInitial, title
},
[
isGroupedValues
,
rangedItems
]);
const
chartData
=
[
{
items
:
displayedData
,
name
:
'
Value
'
,
color
}
];
const
{
yTickFormat
,
xScale
,
yScale
}
=
useTimeChartController
({
const
{
xTickFormat
,
yTickFormat
,
xScale
,
yScale
}
=
useTimeChartController
({
data
:
[
{
items
:
displayedData
,
name
:
title
,
color
}
],
width
:
innerWidth
,
height
:
innerHeight
,
...
...
@@ -105,7 +105,7 @@ const ChartWidgetGraph = ({ isEnlarged, items, onZoom, isZoomResetInitial, title
type=
"left"
scale=
{
yScale
}
ticks=
{
isEnlarged
?
6
:
3
}
tickFormat=
{
yTickFormat
}
tickFormat
Generator
=
{
yTickFormat
}
disableAnimation
/>
...
...
@@ -115,6 +115,7 @@ const ChartWidgetGraph = ({ isEnlarged, items, onZoom, isZoomResetInitial, title
transform=
{
`translate(0, ${ innerHeight })`
}
ticks=
{
isMobile
?
1
:
4
}
anchorEl=
{
overlayRef
.
current
}
tickFormatGenerator=
{
xTickFormat
}
disableAnimation
/>
...
...
ui/shared/chart/useTimeChartController.tsx
View file @
cf2e70dc
...
...
@@ -29,7 +29,8 @@ export default function useTimeChartController({ data, width, height }: Props) {
);
const
yMin
=
useMemo
(
()
=>
d3
.
min
(
data
,
({
items
})
=>
d3
.
min
(
items
,
({
value
})
=>
value
))
||
0
,
// use -1 instead of 0 to correctly display the curve between two zero points.
()
=>
d3
.
min
(
data
,
({
items
})
=>
d3
.
min
(
items
,
({
value
})
=>
value
))
||
-
1
,
[
data
],
);
...
...
@@ -51,8 +52,27 @@ export default function useTimeChartController({ data, width, height }: Props) {
[
height
,
yMin
,
yMax
],
);
const
xTickFormat
=
(
d
:
d3
.
AxisDomain
)
=>
d
.
toLocaleString
();
const
yTickFormat
=
(
d
:
d3
.
AxisDomain
)
=>
formatNumberToMetricPrefix
(
Number
(
d
));
const
xTickFormat
=
(
axis
:
d3
.
Axis
<
d3
.
NumberValue
>
)
=>
(
d
:
d3
.
AxisDomain
)
=>
{
let
format
:
(
date
:
Date
)
=>
string
;
const
scale
=
axis
.
scale
();
const
extent
=
scale
.
domain
();
const
span
=
Number
(
extent
[
1
])
-
Number
(
extent
[
0
]);
if
(
span
>
365
*
24
*
60
*
60
*
1000
)
{
format
=
d3
.
timeFormat
(
'
%Y
'
);
}
else
if
(
span
>
30
*
24
*
60
*
60
*
1000
)
{
format
=
d3
.
timeFormat
(
'
%b
'
);
}
else
if
(
span
>
7
*
24
*
60
*
60
*
1000
)
{
format
=
d3
.
timeFormat
(
'
%b %d
'
);
}
else
{
format
=
d3
.
timeFormat
(
'
%a %d
'
);
}
return
format
(
d
as
Date
);
};
const
yTickFormat
=
()
=>
(
d
:
d3
.
AxisDomain
)
=>
formatNumberToMetricPrefix
(
Number
(
d
));
return
{
xTickFormat
,
...
...
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