Skip to content

Commit

Permalink
feat(bubble): add onBubbleClick property to BubbleD3 component
Browse files Browse the repository at this point in the history
  • Loading branch information
Raphael Benitte committed May 13, 2016
1 parent ca94708 commit 3b61508
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/components/charts/bubble/BubbleProps.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export const bubblePropTypes = {
height: number.isRequired,
margin,
data: object.isRequired,
onBubbleClick: func.isRequired,
identityProperty: string,
value: string.isRequired,
padding: number.isRequired,
Expand Down Expand Up @@ -57,6 +58,7 @@ export const bubblePropTypes = {
*/
export const bubbleDefaultProps = {
margin: Nivo.defaults.margin,
onBubbleClick: () => {},
identityProperty: 'name',
value: 'value',
padding: 1,
Expand Down
4 changes: 4 additions & 0 deletions src/lib/charts/bubble/BubbleD3Svg.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const BubbleD3Svg = domRoot => {
draw(props) {
const {
data,
onBubbleClick,
identityProperty, value,
width, height, margin,
padding,
Expand Down Expand Up @@ -81,6 +82,7 @@ const BubbleD3Svg = domRoot => {
.style('stroke', borderColorFn)
.style('stroke-width', borderWidth)
.attr('transform', d => `translate(${d.x},${d.y})`)
.on('click', onBubbleClick)
;

// —————————————————————————————————————————————————————————————————————————————————————————————————————————
Expand All @@ -105,6 +107,7 @@ const BubbleD3Svg = domRoot => {
.duration(transitionDuration)
.ease(transitionEasing)
.attr('transform', `translate(${width / 2},${height / 2})`)
.attr('r', 0)
.remove()
;

Expand Down Expand Up @@ -134,6 +137,7 @@ const BubbleD3Svg = domRoot => {
.text(labelFn)
.attr('transform', d => `translate(${d.x},${d.y})`)
.attr('dy', labelTextDY)
.on('click', onBubbleClick)
;

// —————————————————————————————————————————————————————————————————————————————————————————————————————————
Expand Down

0 comments on commit 3b61508

Please sign in to comment.