-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: resolve git to take account of the case in folders
- Loading branch information
1 parent
2c61089
commit 437c7e8
Showing
6 changed files
with
143 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { FC } from 'react'; | ||
import { | ||
ResponsiveContainer, | ||
AreaChart as AreaChartCmp, | ||
Area, | ||
Tooltip, | ||
XAxis, | ||
} from 'recharts'; | ||
import { AreaChartProps } from './types'; | ||
|
||
const AreaChart: FC<AreaChartProps> = ({ | ||
data, | ||
setDate, | ||
setValue, | ||
isDarkMode, | ||
width = '100%', | ||
height = 180, | ||
}) => { | ||
return ( | ||
<ResponsiveContainer width={width} height={height}> | ||
<AreaChartCmp | ||
data={data} | ||
onMouseLeave={() => { | ||
setDate && setDate(null); | ||
setValue && setValue(null); | ||
}} | ||
> | ||
<XAxis | ||
dataKey="date" | ||
tickFormatter={(date) => | ||
new Date(date).toLocaleDateString('en-US', { | ||
day: 'numeric', | ||
}) | ||
} | ||
strokeOpacity={0} | ||
tick={{ | ||
fontSize: '16px', | ||
fill: '#9CA0B0', | ||
fontWeight: 400, | ||
}} | ||
tickMargin={16} | ||
/> | ||
<Tooltip | ||
contentStyle={{ display: 'none' }} | ||
content={({ active, payload }) => { | ||
if (active && payload && payload.length) { | ||
setValue && setValue(payload[0].payload['value']); | ||
setDate && setDate(payload[0].payload['date']); | ||
} | ||
|
||
return null; | ||
}} | ||
/> | ||
<Area | ||
dataKey="value" | ||
stroke={isDarkMode ? '#C6BBFA' : '#624FBE'} | ||
fillOpacity={0} | ||
strokeWidth={2} | ||
/> | ||
</AreaChartCmp> | ||
</ResponsiveContainer> | ||
); | ||
}; | ||
|
||
export default AreaChart; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default as AreaChart } from './AreaChart'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export type AreaChartProps = { | ||
data: any; | ||
setValue: (value: number | null) => void; | ||
setDate: (date: Date | null) => void; | ||
isDarkMode: boolean; | ||
width?: number | string; | ||
height?: number | string; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { FC } from 'react'; | ||
import { | ||
ResponsiveContainer, | ||
BarChart as BarChartCmp, | ||
XAxis, | ||
Tooltip, | ||
Bar, | ||
} from 'recharts'; | ||
import { BarChartProps } from './types'; | ||
|
||
const BarChart: FC<BarChartProps> = ({ | ||
data, | ||
setValue, | ||
setDate, | ||
isDarkMode, | ||
width = '100%', | ||
height = 180, | ||
}) => { | ||
return ( | ||
<ResponsiveContainer width={width} height={height}> | ||
<BarChartCmp | ||
data={data} | ||
onMouseLeave={() => { | ||
setValue && setValue(null); | ||
setDate && setDate(null); | ||
}} | ||
> | ||
<XAxis | ||
dataKey="date" | ||
tickFormatter={(date) => | ||
new Date(date).toLocaleDateString('en-US', { | ||
day: 'numeric', | ||
}) | ||
} | ||
strokeOpacity={0} | ||
tick={{ | ||
fontSize: '16px', | ||
fill: '#9CA0B0', | ||
fontWeight: 400, | ||
}} | ||
tickMargin={16} | ||
/> | ||
<Tooltip | ||
contentStyle={{ display: 'none' }} | ||
content={({ active, payload }) => { | ||
if (active && payload && payload.length) { | ||
setValue && setValue(payload[0].payload['value']); | ||
setDate && setDate(payload[0].payload['date']); | ||
} | ||
|
||
return null; | ||
}} | ||
/> | ||
<Bar dataKey="value" fill={isDarkMode ? '#81B3F6' : '#3D7BCE'} /> | ||
</BarChartCmp> | ||
</ResponsiveContainer> | ||
); | ||
}; | ||
|
||
export default BarChart; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default as BarChart } from './BarChart'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export type BarChartProps = { | ||
data: any; | ||
setValue: (value: number | null) => void; | ||
setDate: (date: Date | null) => void; | ||
isDarkMode: boolean; | ||
width?: number | string; | ||
height?: number | string; | ||
}; |