Skip to content

Commit

Permalink
feat(bubble): rename 'root' property to 'data'
Browse files Browse the repository at this point in the history
  • Loading branch information
Raphael Benitte committed May 7, 2016
1 parent 6e2f25e commit 49bffcd
Show file tree
Hide file tree
Showing 9 changed files with 77 additions and 77 deletions.
30 changes: 13 additions & 17 deletions specs/bubble/Bubble.spec.js
Original file line number Diff line number Diff line change
@@ -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('<Bubble />', function () {
Expand All @@ -17,26 +28,11 @@ describe('<Bubble />', 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((
<Bubble
width={400} height={400}
root={root}
data={bubbleData}
value="loc"
colors="nivo"
transitionDuration={0}
Expand All @@ -45,7 +41,7 @@ describe('<Bubble />', 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);
Expand Down
30 changes: 13 additions & 17 deletions specs/bubble/BubbleD3.spec.js
Original file line number Diff line number Diff line change
@@ -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('<BubbleD3 />', function () {
Expand All @@ -17,26 +28,11 @@ describe('<BubbleD3 />', 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((
<BubbleD3
width={400} height={400}
root={root}
data={bubbleData}
value="loc"
colors="d310"
transitionDuration={0}
Expand All @@ -45,7 +41,7 @@ describe('<BubbleD3 />', 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);
Expand Down
41 changes: 41 additions & 0 deletions specs/bubble/bubbleData.js
Original file line number Diff line number Diff line change
@@ -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 }
]
}
]
};
1 change: 1 addition & 0 deletions src/components/charts/bubble/Bubble.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const createNodes = ({ borderWidth, borderColor, label, labelFormat, labelSkipRa
renderedNodes.push(
<text
key={`${node.key}.text`}
className="nivo_bubble_legend"
transform={`translate(${node.style.x},${node.style.y})`}
textAnchor={'middle'}
style={{
Expand Down
34 changes: 0 additions & 34 deletions src/components/charts/bubble/BubbleNode.js

This file was deleted.

4 changes: 2 additions & 2 deletions src/components/charts/bubble/BubblePlaceholders.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class BubblePlaceholders extends Component {

render() {
const {
root,
data,
namespace,
identityProperty, value,
padding,
Expand All @@ -53,7 +53,7 @@ class BubblePlaceholders extends Component {
const nodes = this.bubble.compute({
width: useWidth,
height: useHeight,
root,
data,
identityProperty, valueAccessor,
padding,
color
Expand Down
2 changes: 1 addition & 1 deletion src/components/charts/bubble/BubbleProps.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions src/lib/charts/bubble/BubbleD3.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ const BubbleD3 = () => {
*
* @param {number} width
* @param {number} height
* @param {object} root
* @param {object} data
* @param {string} identityProperty
* @param {function} valueAccessor
* @param {number} padding
* @param {function} color
*/
compute({
width, height,
root,
data,
identityProperty, valueAccessor,
padding,
color
Expand All @@ -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 => {
Expand Down
6 changes: 3 additions & 3 deletions src/lib/charts/bubble/BubbleD3Svg.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const BubbleD3Svg = domRoot => {
return {
draw(props) {
const {
root,
data,
identityProperty, value,
width, height, margin,
padding,
Expand Down Expand Up @@ -58,7 +58,7 @@ const BubbleD3Svg = domRoot => {
const bubbled = bubble.compute({
width: useWidth,
height: useHeight,
root,
data,
identityProperty, valueAccessor,
padding,
color
Expand Down Expand Up @@ -163,7 +163,7 @@ const BubbleD3Svg = domRoot => {
element: wrapper,
width: useWidth,
height: useHeight,
rawData: root,
rawData: data,
identity,
valueAccessor,
data: bubbled,
Expand Down

0 comments on commit 49bffcd

Please sign in to comment.