Skip to content

Commit

Permalink
updated website with onClick props : onClick added as property and cl…
Browse files Browse the repository at this point in the history
…icking on the chart display an action log
  • Loading branch information
Nino3103 committed Jul 4, 2024
1 parent bf04ea2 commit 0c3767a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
8 changes: 8 additions & 0 deletions website/src/data/components/radar/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,14 @@ const props: ChartProperty[] = [
help: 'Override default slice tooltip.',
flavors: ['svg'],
},
{
key: 'onClick',
flavors: ['svg', 'canvas'],
group: 'Interactivity',
help: 'onClick handler, it receives target node data and mouse event.',
type: '(node, event) => void',
required: false,
},
...motionProperties(['svg'], svgDefaultProps),
]

Expand Down
12 changes: 11 additions & 1 deletion website/src/pages/radar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,23 @@ const Radar = () => {
getTabData={data => data.data}
image={image}
>
{(properties, data, theme) => {
{(properties, data, theme, logAction) => {
return (
<ResponsiveRadar
data={data.data}
keys={data.keys}
{...properties}
theme={theme}
onClick={slice =>
logAction({
type: 'click',
label: `[slice] {${Object.entries(slice)
.map(([key, value]) => `${key}: ${value}`)
.join(', ')}}`,
color: slice.color,
data: slice,
})
}
/>
)
}}
Expand Down

0 comments on commit 0c3767a

Please sign in to comment.