-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(circle-packing): add support for mouse handlers to SVG and HTML …
…implementations
- Loading branch information
Showing
10 changed files
with
296 additions
and
67 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
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
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
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,11 @@ | ||
import React from 'react' | ||
import { BasicTooltip } from '@nivo/tooltip' | ||
import { ComputedDatum } from './types' | ||
|
||
export const CirclePackingTooltip = <RawDatum,>({ | ||
id, | ||
formattedValue, | ||
color, | ||
}: ComputedDatum<RawDatum>) => ( | ||
<BasicTooltip id={id} value={formattedValue} enableChip={true} color={color} /> | ||
) |
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,35 @@ | ||
import React from 'react' | ||
import { animated } from 'react-spring' | ||
import { CircleProps } from './types' | ||
import { useBoundMouseHandlers } from './hooks' | ||
|
||
export const CircleSvg = <RawDatum,>({ | ||
node, | ||
style, | ||
onMouseEnter, | ||
onMouseMove, | ||
onMouseLeave, | ||
onClick, | ||
}: CircleProps<RawDatum>) => { | ||
const handlers = useBoundMouseHandlers<RawDatum>(node, { | ||
onMouseEnter, | ||
onMouseMove, | ||
onMouseLeave, | ||
onClick, | ||
}) | ||
|
||
return ( | ||
<animated.circle | ||
key={node.id} | ||
cx={style.x} | ||
cy={style.y} | ||
r={style.radius} | ||
fill={style.color} | ||
opacity={style.opacity} | ||
onMouseEnter={handlers.onMouseEnter} | ||
onMouseMove={handlers.onMouseMove} | ||
onMouseLeave={handlers.onMouseLeave} | ||
onClick={handlers.onClick} | ||
/> | ||
) | ||
} |
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.