diff --git a/specs/bubble/Bubble.spec.js b/specs/bubble/Bubble.spec.js index 7bcac2f4a..03c5fea72 100644 --- a/specs/bubble/Bubble.spec.js +++ b/specs/bubble/Bubble.spec.js @@ -1,7 +1,18 @@ +/* + * This file is part of the nivo library. + * + * (c) Raphaël Benitte + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +'use strict'; + import expect, { spyOn } from 'expect'; import React, { Component } from 'react'; import { render } from 'react-dom'; import { Bubble } from '../../src/'; +import bubbleData from './bubbleData'; describe('', function () { @@ -17,26 +28,11 @@ describe('', function () { document.body.removeChild(node); }); - const root = { name: 'nivo', children: [ - { name: 'charts', children: [ - { name: 'Pie', loc: 74467 }, - { name: 'Stack', loc: 74467 }, - { name: 'Tree', loc: 74467 }, - { name: 'Bubble', loc: 74467 } - ]}, - { name: 'utils', children: [ - { name: 'Colors', loc: 74467 }, - { name: 'Arcs', loc: 74467 }, - { name: 'Data', loc: 74467 }, - { name: 'Animation', loc: 74467 } - ]} - ]}; - it('should render a circle for each leaf', done => { render(( ', function () { setTimeout(() => { const circles = node.getElementsByClassName('nivo_bubble_node'); expect(circles).toNotBe(null); - expect(circles.length).toBe(8); + expect(circles.length).toBe(11); done(); }, 4000); diff --git a/specs/bubble/BubbleD3.spec.js b/specs/bubble/BubbleD3.spec.js index 43c6e65c2..56391b940 100644 --- a/specs/bubble/BubbleD3.spec.js +++ b/specs/bubble/BubbleD3.spec.js @@ -1,7 +1,18 @@ +/* + * This file is part of the nivo library. + * + * (c) Raphaël Benitte + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +'use strict'; + import expect, { spyOn } from 'expect'; import React, { Component } from 'react'; import { render } from 'react-dom'; import { BubbleD3 } from '../../src/'; +import bubbleData from './bubbleData'; describe('', function () { @@ -17,26 +28,11 @@ describe('', function () { document.body.removeChild(node); }); - const root = { name: 'nivo', children: [ - { name: 'charts', children: [ - { name: 'Pie', loc: 74467 }, - { name: 'Stack', loc: 74467 }, - { name: 'Tree', loc: 74467 }, - { name: 'Bubble', loc: 74467 } - ]}, - { name: 'utils', children: [ - { name: 'Colors', loc: 74467 }, - { name: 'Arcs', loc: 74467 }, - { name: 'Data', loc: 74467 }, - { name: 'Animation', loc: 74467 } - ]} - ]}; - it('should render a circle for each leaf', done => { render(( ', function () { setTimeout(() => { const circles = node.getElementsByClassName('nivo_bubble_node'); expect(circles).toNotBe(null); - expect(circles.length).toBe(8); + expect(circles.length).toBe(11); done(); }, 4000); diff --git a/specs/bubble/bubbleData.js b/specs/bubble/bubbleData.js new file mode 100644 index 000000000..bc325c24d --- /dev/null +++ b/specs/bubble/bubbleData.js @@ -0,0 +1,41 @@ +/* + * This file is part of the nivo library. + * + * (c) Raphaël Benitte + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +'use strict'; + +export default { + name: 'nivo', + children: [ + { + name: 'charts', + children: [ + { name: 'Pie', loc: 1000 }, + { name: 'Stack', loc: 1000 }, + { name: 'Tree', loc: 6000 }, + { name: 'Bubble', loc: 1000 } + ] + }, + { + name: 'utils', + children: [ + { name: 'Colors', loc: 1000 }, + { name: 'Arcs', loc: 4000 }, + { name: 'Data', loc: 1000 }, + { name: 'Animation', loc: 7000 } + ] + }, + { + name: 'generator', + children: [ + { name: 'tree', loc: 3000 }, + { name: 'serie', loc: 2000 }, + { name: 'geo', loc: 1000 } + ] + } + ] +}; \ No newline at end of file diff --git a/src/components/charts/bubble/Bubble.js b/src/components/charts/bubble/Bubble.js index c0e4d7e9f..54ca7fd7b 100644 --- a/src/components/charts/bubble/Bubble.js +++ b/src/components/charts/bubble/Bubble.js @@ -48,6 +48,7 @@ const createNodes = ({ borderWidth, borderColor, label, labelFormat, labelSkipRa renderedNodes.push( ( - -); - -const { number } = PropTypes; - -BubbleNode.propTypes = { - r: number.isRequired, - x: number.isRequired, - y: number.isRequired, - colorR: number.isRequired, - colorG: number.isRequired, - colorB: number.isRequired -}; - - -export default BubbleNode; diff --git a/src/components/charts/bubble/BubblePlaceholders.js b/src/components/charts/bubble/BubblePlaceholders.js index fdaf06c56..904402b03 100644 --- a/src/components/charts/bubble/BubblePlaceholders.js +++ b/src/components/charts/bubble/BubblePlaceholders.js @@ -33,7 +33,7 @@ class BubblePlaceholders extends Component { render() { const { - root, + data, namespace, identityProperty, value, padding, @@ -53,7 +53,7 @@ class BubblePlaceholders extends Component { const nodes = this.bubble.compute({ width: useWidth, height: useHeight, - root, + data, identityProperty, valueAccessor, padding, color diff --git a/src/components/charts/bubble/BubbleProps.js b/src/components/charts/bubble/BubbleProps.js index 12a4d38f1..e79c39458 100644 --- a/src/components/charts/bubble/BubbleProps.js +++ b/src/components/charts/bubble/BubbleProps.js @@ -25,7 +25,7 @@ export const bubblePropTypes = { width: number.isRequired, height: number.isRequired, margin, - root: object.isRequired, // data + data: object.isRequired, identityProperty: string, value: string.isRequired, padding: number.isRequired, diff --git a/src/lib/charts/bubble/BubbleD3.js b/src/lib/charts/bubble/BubbleD3.js index feb9e6e1e..f6a813db3 100644 --- a/src/lib/charts/bubble/BubbleD3.js +++ b/src/lib/charts/bubble/BubbleD3.js @@ -26,7 +26,7 @@ const BubbleD3 = () => { * * @param {number} width * @param {number} height - * @param {object} root + * @param {object} data * @param {string} identityProperty * @param {function} valueAccessor * @param {number} padding @@ -34,7 +34,7 @@ const BubbleD3 = () => { */ compute({ width, height, - root, + data, identityProperty, valueAccessor, padding, color @@ -46,7 +46,7 @@ const BubbleD3 = () => { .padding(padding) ; - const flattened = flatten(root, identityProperty); + const flattened = flatten(data, identityProperty); const nodes = layout.nodes(flattened) .filter(d => !d.children) .map(d => { diff --git a/src/lib/charts/bubble/BubbleD3Svg.js b/src/lib/charts/bubble/BubbleD3Svg.js index ab334a1e2..1797fbf5d 100644 --- a/src/lib/charts/bubble/BubbleD3Svg.js +++ b/src/lib/charts/bubble/BubbleD3Svg.js @@ -28,7 +28,7 @@ const BubbleD3Svg = domRoot => { return { draw(props) { const { - root, + data, identityProperty, value, width, height, margin, padding, @@ -58,7 +58,7 @@ const BubbleD3Svg = domRoot => { const bubbled = bubble.compute({ width: useWidth, height: useHeight, - root, + data, identityProperty, valueAccessor, padding, color @@ -163,7 +163,7 @@ const BubbleD3Svg = domRoot => { element: wrapper, width: useWidth, height: useHeight, - rawData: root, + rawData: data, identity, valueAccessor, data: bubbled,