From 3b615080c7ae1192c572b6b3b207307c0640379b Mon Sep 17 00:00:00 2001 From: Raphael Benitte Date: Sat, 14 May 2016 01:58:08 +0900 Subject: [PATCH] feat(bubble): add onBubbleClick property to BubbleD3 component --- src/components/charts/bubble/BubbleProps.js | 2 ++ src/lib/charts/bubble/BubbleD3Svg.js | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/src/components/charts/bubble/BubbleProps.js b/src/components/charts/bubble/BubbleProps.js index 89f8ae096..0bb833b0c 100644 --- a/src/components/charts/bubble/BubbleProps.js +++ b/src/components/charts/bubble/BubbleProps.js @@ -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, @@ -57,6 +58,7 @@ export const bubblePropTypes = { */ export const bubbleDefaultProps = { margin: Nivo.defaults.margin, + onBubbleClick: () => {}, identityProperty: 'name', value: 'value', padding: 1, diff --git a/src/lib/charts/bubble/BubbleD3Svg.js b/src/lib/charts/bubble/BubbleD3Svg.js index 52291784b..9d96c16a9 100644 --- a/src/lib/charts/bubble/BubbleD3Svg.js +++ b/src/lib/charts/bubble/BubbleD3Svg.js @@ -29,6 +29,7 @@ const BubbleD3Svg = domRoot => { draw(props) { const { data, + onBubbleClick, identityProperty, value, width, height, margin, padding, @@ -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) ; // ————————————————————————————————————————————————————————————————————————————————————————————————————————— @@ -105,6 +107,7 @@ const BubbleD3Svg = domRoot => { .duration(transitionDuration) .ease(transitionEasing) .attr('transform', `translate(${width / 2},${height / 2})`) + .attr('r', 0) .remove() ; @@ -134,6 +137,7 @@ const BubbleD3Svg = domRoot => { .text(labelFn) .attr('transform', d => `translate(${d.x},${d.y})`) .attr('dy', labelTextDY) + .on('click', onBubbleClick) ; // —————————————————————————————————————————————————————————————————————————————————————————————————————————