Skip to content

Commit

Permalink
add treemap component
Browse files Browse the repository at this point in the history
  • Loading branch information
jsladerman committed Dec 19, 2024
1 parent 2732d59 commit 9f669fb
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 7 deletions.
13 changes: 7 additions & 6 deletions assets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,13 @@
"@graphql-codegen/named-operations-object": "3.0.0",
"@jumpn/utils-graphql": "0.6.0",
"@markdoc/markdoc": "0.4.0",
"@nivo/core": "0.87.0",
"@nivo/geo": "0.87.0",
"@nivo/line": "0.87.0",
"@nivo/pie": "0.87.0",
"@nivo/radial-bar": "0.87.0",
"@nivo/tooltip": "0.87.0",
"@nivo/core": "0.88.0",
"@nivo/geo": "0.88.0",
"@nivo/line": "0.88.0",
"@nivo/pie": "0.88.0",
"@nivo/radial-bar": "0.88.0",
"@nivo/tooltip": "0.88.0",
"@nivo/treemap": "0.88.0",
"@pluralsh/design-system": "4.3.0",
"@react-hooks-library/core": "0.6.0",
"@saas-ui/use-hotkeys": "1.1.3",
Expand Down
39 changes: 39 additions & 0 deletions assets/src/components/cost-management/CostManagementTreeMap.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { ResponsiveTreeMapHtml } from '@nivo/treemap'
import { useThemeColorMode } from '@pluralsh/design-system'

type TreeMapData = {
name: string
color: string
amount?: number
children?: TreeMapData[]
}

export function CostManagementTreeMap({ data }: { data: TreeMapData }) {
const colorMode = useThemeColorMode()
return (
<ResponsiveTreeMapHtml
data={data}
identity="name"
value="amount"
valueFormat=" >-$.3s"
innerPadding={2}
label={(e) => e.id + ' (' + e.formattedValue + ')'}
labelSkipSize={12}
labelTextColor={{
from: 'color',
modifiers: [[colorMode === 'dark' ? 'brighter' : 'darker', 2]],
}}
enableParentLabel={false}
parentLabelTextColor={{
from: 'color',
modifiers: [[colorMode === 'dark' ? 'brighter' : 'darker', 3]],
}}
colors={{ scheme: 'blues' }}
nodeOpacity={0.45}
borderColor={{
from: 'color',
modifiers: [[colorMode === 'dark' ? 'brighter' : 'darker', 0.1]],
}}
/>
)
}
7 changes: 6 additions & 1 deletion assets/src/routes/costManagementRoutes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@ export const costManagementRoutes = [
>
<Route
index
element={<Navigate to={CM_NAMESPACES_REL_PATH} />}
element={
<Navigate
replace
to={CM_NAMESPACES_REL_PATH}
/>
}
/>
<Route
path={CM_NAMESPACES_REL_PATH}
Expand Down

0 comments on commit 9f669fb

Please sign in to comment.