-
Notifications
You must be signed in to change notification settings - Fork 358
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
upcoming: [M3-7302] - Replace NodeBalancer detail charts with Recharts #9983
Merged
hana-akamai
merged 7 commits into
linode:develop
from
hana-akamai:M3-7302-replace-nodebalancer-detail-charts
Dec 14, 2023
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
a9d2613
replace nodebalancer detail connection chart with recharts
hana-akamai cb1d79f
replace nodebalancer detail traffic chart with recharts
hana-akamai ebde6c7
clean up
hana-akamai 4ba70aa
Added changeset: Replace NodeBalancer detail charts with Recharts
hana-akamai 0866fc6
fix graph display
hana-akamai 2bb4439
Merge branch 'develop' into M3-7302-replace-nodebalancer-detail-charts
hana-akamai e7956f2
fix console error
hana-akamai File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
packages/manager/.changeset/pr-9983-upcoming-features-1702070124570.md
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,5 @@ | ||
--- | ||
"@linode/manager": Upcoming Features | ||
--- | ||
|
||
Replace NodeBalancer detail charts with Recharts ([#9983](https://github.com/linode/manager/pull/9983)) |
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,138 @@ | ||
import { Typography, useTheme } from '@mui/material'; | ||
import { styled } from '@mui/material/styles'; | ||
import { DateTime } from 'luxon'; | ||
import React from 'react'; | ||
import { | ||
AreaChart as _AreaChart, | ||
Area, | ||
CartesianGrid, | ||
ResponsiveContainer, | ||
Tooltip, | ||
TooltipProps, | ||
XAxis, | ||
YAxis, | ||
} from 'recharts'; | ||
|
||
import { Paper } from 'src/components/Paper'; | ||
import { roundTo } from 'src/utilities/roundTo'; | ||
|
||
interface AreaProps { | ||
color: string; | ||
dataKey: string; | ||
} | ||
|
||
interface XAxisProps { | ||
tickFormat: string; | ||
tickGap: number; | ||
} | ||
|
||
interface AreaChartProps { | ||
areas: AreaProps[]; | ||
data: any; | ||
height: number; | ||
timezone: string; | ||
unit: string; | ||
xAxis: XAxisProps; | ||
} | ||
|
||
const humanizeLargeData = (value: number) => { | ||
if (value >= 1000000) { | ||
return value / 1000000 + 'M'; | ||
} | ||
if (value >= 1000) { | ||
return value / 1000 + 'K'; | ||
} | ||
return `${value}`; | ||
}; | ||
|
||
export const AreaChart = (props: AreaChartProps) => { | ||
const { areas, data, height, timezone, unit, xAxis } = props; | ||
|
||
const theme = useTheme(); | ||
|
||
const xAxisTickFormatter = (t: number) => { | ||
return DateTime.fromMillis(t, { zone: timezone }).toFormat( | ||
xAxis.tickFormat | ||
); | ||
}; | ||
|
||
const tooltipLabelFormatter = (t: number) => { | ||
return DateTime.fromMillis(t, { zone: timezone }).toFormat( | ||
'LLL dd, yyyy, h:mm a' | ||
); | ||
}; | ||
|
||
const tooltipValueFormatter = (value: number) => | ||
`${roundTo(value)} ${unit}/s`; | ||
|
||
const CustomTooltip = ({ | ||
active, | ||
label, | ||
payload, | ||
}: TooltipProps<any, any>) => { | ||
if (active && payload && payload.length) { | ||
return ( | ||
<StyledPaper> | ||
<Typography>{tooltipLabelFormatter(label)}</Typography> | ||
{payload.map((item) => ( | ||
<Typography fontFamily={theme.font.bold} key={item.dataKey}> | ||
{item.dataKey}: {tooltipValueFormatter(item.value)} | ||
</Typography> | ||
))} | ||
</StyledPaper> | ||
); | ||
} | ||
|
||
return null; | ||
}; | ||
|
||
return ( | ||
<ResponsiveContainer height={height} width="100%"> | ||
<_AreaChart data={data}> | ||
<CartesianGrid | ||
stroke={theme.color.grey7} | ||
strokeDasharray="3 3" | ||
vertical={false} | ||
/> | ||
<XAxis | ||
dataKey="t" | ||
domain={['dataMin', 'dataMax']} | ||
interval="preserveEnd" | ||
minTickGap={xAxis.tickGap} | ||
scale="time" | ||
stroke={theme.color.label} | ||
tickFormatter={xAxisTickFormatter} | ||
type="number" | ||
/> | ||
<YAxis stroke={theme.color.label} tickFormatter={humanizeLargeData} /> | ||
<Tooltip | ||
contentStyle={{ | ||
color: '#606469', | ||
}} | ||
itemStyle={{ | ||
color: '#606469', | ||
fontFamily: theme.font.bold, | ||
}} | ||
content={<CustomTooltip />} | ||
/> | ||
{areas.map(({ color, dataKey }) => ( | ||
<Area | ||
dataKey={dataKey} | ||
fill={color} | ||
isAnimationActive={false} | ||
key={dataKey} | ||
stroke={color} | ||
type="monotone" | ||
/> | ||
))} | ||
</_AreaChart> | ||
</ResponsiveContainer> | ||
); | ||
}; | ||
|
||
const StyledPaper = styled(Paper, { | ||
label: 'StyledPaper', | ||
})(({ theme }) => ({ | ||
border: `1px solid ${theme.color.border2}`, | ||
padding: theme.spacing(1), | ||
})); |
114 changes: 0 additions & 114 deletions
114
...des/LinodesDetail/LinodeNetworking/NetworkingSummaryPanel/NetworkTransferHistoryChart.tsx
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Handle displaying multiple values (e.g. traffic in and traffic out values for the nodebalancer traffic chart)