Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
Block Explorer UI
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
hive
Block Explorer UI
Commits
cef6fb91
Commit
cef6fb91
authored
4 weeks ago
by
Lukas
Committed by
mcfarhat
4 weeks ago
Browse files
Options
Downloads
Patches
Plain Diff
Use theme locally to set stroke color in chart component
parent
624b462e
No related branches found
No related tags found
1 merge request
!599
Lbudginas/#493 hive price chart
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
components/home/MarketHistoryChart.tsx
+32
-38
32 additions, 38 deletions
components/home/MarketHistoryChart.tsx
with
32 additions
and
38 deletions
components/home/MarketHistoryChart.tsx
+
32
−
38
View file @
cef6fb91
...
@@ -13,6 +13,7 @@ import { useHiveChainContext } from "@/contexts/HiveChainContext";
...
@@ -13,6 +13,7 @@ import { useHiveChainContext } from "@/contexts/HiveChainContext";
import
{
Card
,
CardContent
,
CardHeader
}
from
"
../ui/card
"
;
import
{
Card
,
CardContent
,
CardHeader
}
from
"
../ui/card
"
;
import
{
Loader2
}
from
"
lucide-react
"
;
import
{
Loader2
}
from
"
lucide-react
"
;
import
{
colorMap
}
from
"
../balanceHistory/BalanceHistoryChart
"
;
import
{
colorMap
}
from
"
../balanceHistory/BalanceHistoryChart
"
;
import
{
useTheme
}
from
"
@/contexts/ThemeContext
"
;
const
CustomTooltip
=
({
const
CustomTooltip
=
({
active
,
active
,
...
@@ -54,7 +55,6 @@ const calculateAvgHivePrice = (
...
@@ -54,7 +55,6 @@ const calculateAvgHivePrice = (
interface
MarketChartProps
{
interface
MarketChartProps
{
data
:
Hive
.
MarketHistory
|
undefined
;
data
:
Hive
.
MarketHistory
|
undefined
;
isLoading
:
boolean
;
isLoading
:
boolean
;
strokeColor
:
string
;
}
}
interface
ChartData
{
interface
ChartData
{
date
:
string
;
date
:
string
;
...
@@ -65,9 +65,9 @@ interface ChartData {
...
@@ -65,9 +65,9 @@ interface ChartData {
const
MarketHistoryChart
:
React
.
FC
<
MarketChartProps
>
=
({
const
MarketHistoryChart
:
React
.
FC
<
MarketChartProps
>
=
({
data
,
data
,
isLoading
,
isLoading
,
strokeColor
,
})
=>
{
})
=>
{
const
{
hiveChain
}
=
useHiveChainContext
();
const
{
hiveChain
}
=
useHiveChainContext
();
const
{
theme
}
=
useTheme
();
if
(
!
data
||
!
hiveChain
)
return
;
if
(
!
data
||
!
hiveChain
)
return
;
...
@@ -99,44 +99,38 @@ const MarketHistoryChart: React.FC<MarketChartProps> = ({
...
@@ -99,44 +99,38 @@ const MarketHistoryChart: React.FC<MarketChartProps> = ({
const
maxValue
=
Math
.
max
(
const
maxValue
=
Math
.
max
(
...
chartData
.
map
((
d
:
ChartData
)
=>
parseFloat
(
d
.
avgPrice
))
...
chartData
.
map
((
d
:
ChartData
)
=>
parseFloat
(
d
.
avgPrice
))
);
);
const
strokeColor
=
theme
===
"
dark
"
?
"
#FFF
"
:
"
#000
"
;
return
(
return
(
<
Card
className
=
"mb-3"
>
<
ResponsiveContainer
<
CardHeader
className
=
"flex justify-between items-center px-1 py-3"
>
width
=
"100%"
<
h2
className
=
"text-lg font-semibold"
>
Hive Price Chart
</
h2
>
height
=
{
250
}
</
CardHeader
>
>
<
CardContent
>
<
LineChart
data
=
{
chartData
}
>
<
ResponsiveContainer
<
XAxis
width
=
"100%"
dataKey
=
"date"
height
=
{
300
}
stroke
=
{
strokeColor
}
>
/>
<
LineChart
data
=
{
chartData
}
>
<
YAxis
<
XAxis
dataKey
=
"avgPrice"
dataKey
=
"date"
domain
=
{
[
minValue
,
maxValue
]
}
stroke
=
{
strokeColor
}
stroke
=
{
strokeColor
}
/>
/>
<
YAxis
<
Tooltip
content
=
{
<
CustomTooltip
/>
}
/>
dataKey
=
"avgPrice"
<
Legend
domain
=
{
[
minValue
,
maxValue
]
}
verticalAlign
=
"top"
stroke
=
{
strokeColor
}
height
=
{
36
}
/>
/>
<
Tooltip
content
=
{
<
CustomTooltip
/>
}
/>
<
Line
<
Legend
name
=
{
`Hive Price: $
${
lastHivePrice
}
`
}
verticalAlign
=
"top"
type
=
"monotone"
height
=
{
36
}
dataKey
=
"avgPrice"
/>
stroke
=
{
colorMap
.
HIVE
}
<
Line
dot
=
{
false
}
name
=
{
`Hive Price: $
${
lastHivePrice
}
`
}
strokeWidth
=
{
2
}
type
=
"monotone"
/>
dataKey
=
"avgPrice"
</
LineChart
>
stroke
=
{
colorMap
.
HIVE
}
</
ResponsiveContainer
>
dot
=
{
false
}
strokeWidth
=
{
2
}
/>
</
LineChart
>
</
ResponsiveContainer
>
</
CardContent
>
</
Card
>
);
);
};
};
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment