Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add data page redesign #2464

Open
wants to merge 3 commits into
base: redesign_reports
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions centrifuge-app/src/components/Charts/PoolPerformanceChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { AnchorButton, Box, IconDownload, Select, Shelf, Stack, Tabs, TabsItem,
import * as React from 'react'
import { useParams } from 'react-router'
import { Bar, CartesianGrid, ComposedChart, Line, ResponsiveContainer, Tooltip, XAxis, YAxis } from 'recharts'
import { ValueType } from 'recharts/types/component/DefaultTooltipContent'
import { useTheme } from 'styled-components'
import { getCSVDownloadUrl } from '../../../src/utils/getCSVDownloadUrl'
import { daysBetween, formatDate } from '../../utils/date'
Expand Down Expand Up @@ -46,6 +47,14 @@ type GraphDataItemWithoutType = {

type GraphDataItem = GraphDataItemWithType | GraphDataItemWithoutType

type CustomTickProps = {
x: number
y: number
payload: {
value: ValueType
}
}

const rangeFilters = [
{ value: 'all', label: 'All' },
{ value: '30d', label: '30 days' },
Expand Down Expand Up @@ -500,9 +509,17 @@ function CustomLegend({
)
}

export const CustomTick = ({ x, y, payload }: any) => {
export const CustomTick = ({ x, y, payload }: CustomTickProps) => {
const theme = useTheme()

let dateValue: Date | null = null

if (payload.value instanceof Date) {
dateValue = payload.value
} else if (typeof payload.value === 'string' || typeof payload.value === 'number') {
dateValue = new Date(payload.value)
}

return (
<g transform={`translate(${x},${y})`}>
<text
Expand All @@ -512,7 +529,7 @@ export const CustomTick = ({ x, y, payload }: any) => {
dy={16}
textAnchor="middle"
>
{new Date(payload.value).toLocaleString('en-US', { month: 'short' })}
{dateValue ? dateValue.toLocaleString('en-US', { month: 'short' }) : ''}
</text>
</g>
)
Expand Down
Loading