├── .babelrc ├── .gitignore ├── .npmignore ├── README.md ├── __tests__ ├── axis │ ├── xaxis-test.js │ └── yaxis-test.js ├── container │ ├── svg-test.js │ ├── svg_change.js │ ├── title-test.js │ └── title_change.js ├── data │ ├── garbage.csv │ ├── state_age.json │ └── user_sample.json ├── label │ └── label-test.js └── legend │ └── legend-test.js ├── devServer.js ├── docs ├── axis.md ├── container.md ├── label.md ├── legend.md ├── svg.md ├── title.md ├── xaxis.md ├── xgrid.md ├── yaxis.md └── ygrid.md ├── example ├── container.js ├── index.html ├── index.js └── src │ ├── animate_container.jsx │ ├── animate_xaxis.jsx │ ├── blank_chart.jsx │ ├── components.jsx │ ├── container.jsx │ ├── css │ └── container_update.css │ ├── data │ ├── garbage.csv │ ├── state_age.json │ └── user_sample.json │ ├── grid.jsx │ ├── label.jsx │ ├── legend.jsx │ ├── xaxis.jsx │ ├── xaxis_click.jsx │ └── yaxis.jsx ├── karma.conf.js ├── package.json ├── react-d3-core.js ├── react-d3-core.min.js ├── src ├── axis │ ├── axis.jsx │ ├── label.jsx │ ├── xaxis.jsx │ └── yaxis.jsx ├── chartContainer.jsx ├── commonProps.jsx ├── container │ ├── svg.jsx │ └── title.jsx ├── grid │ ├── grid.jsx │ ├── xgrid.jsx │ └── ygrid.jsx ├── index.jsx ├── legend.jsx └── utils │ ├── scale.jsx │ ├── xDomain.jsx │ └── yDomain.jsx ├── tests.webpack.js ├── webpack.config.js └── webpack.prod.config.js /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["react", "es2015", "stage-0"], 3 | "env": { 4 | "development": { 5 | "presets": ["react-hmre"], 6 | "plugins": [ 7 | "add-module-exports" 8 | ] 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | dist/ 4 | example/dist 5 | example/dist_es5 6 | npm-debug.log 7 | lib 8 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | example 2 | __tests__ 3 | src 4 | docs 5 | react-d3-core* 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # react-d3-core 2 | 3 | [![Dependency Status](https://gemnasium.com/react-d3/react-d3-core.svg)](https://gemnasium.com/react-d3/react-d3-core) 4 | 5 | react d3 core components for reusability. 6 | 7 | `react-d3-core` is includes the core components of the `react-d3` projects. The reason we extract the main component here, is because of reusability. For instance, we use grid, axes over and over again in line chart, area chart, bar chart ... etc. If we move these system a little bit forward to a react component we can declare it more easily in the future. 8 | 9 | Such as we need xaxis, yaxis, grid in a new chart. We can install `react-d3-core` and import them. 10 | 11 | 12 | ## Install 13 | 14 | ``` 15 | npm install react-d3-core 16 | ``` 17 | 18 | ## LIVE DEMO 19 | 20 | http://reactd3.org/docs/core 21 | 22 | 23 | ## Quick example 24 | 25 | #### With webpack 26 | 27 | - Legend 28 | 29 | ```js 30 | "use strict"; 31 | 32 | var React = require('react'); 33 | var ReactDOM = require('react-dom'); 34 | var Legend = require('../../lib/index').Legend; 35 | 36 | (function() { 37 | var chartSeries = [ 38 | { 39 | field: 'Under 5 Years' 40 | }, 41 | { 42 | field: '5 to 13 Years' 43 | } 44 | ] 45 | 46 | ReactDOM.render( 47 |
48 | 49 | 50 | 51 | 55 |
56 | , document.getElementById('blank-legend') 57 | ) 58 | })() 59 | ``` 60 | 61 | 62 | #### In HTML (without build tools) 63 | 64 | Clone code `react-d3-core.js` or minify js `react-d3-core.min.js` and include the script in your HTML. 65 | 66 | You'll also need `react`, `react-dom`, `d3` 67 | 68 | - Legend 69 | 70 | ```html 71 | 72 | 73 | 74 | 75 | Line Chart example 76 | 77 | 78 | 79 |
80 | 81 | 82 | 83 | 84 | 85 | 109 | 110 | 111 | ``` 112 | 113 | ## Supported Components 114 | 115 | #### Container 116 | 117 | - [Chart](./docs/container.md) 118 | - [Svg](./docs/svg.md) 119 | - [Title](./docs/title.md) 120 | 121 | #### Axis 122 | 123 | - [Axis](./docs/axis.md) 124 | - [Xaxis](./docs/xaxis.md) 125 | - [Yaxis](./docs/yaxis.md) 126 | 127 | #### Grid 128 | 129 | - [xGrid](./docs/xgrid.md) 130 | - [yGrid](./docs/ygrid.md) 131 | 132 | #### Label 133 | 134 | - [Label](./docs/label.md) 135 | 136 | #### Legend 137 | 138 | - [Legend](./docs/legend.md) 139 | 140 | 141 | ## Develop 142 | 143 | ``` 144 | $ npm install 145 | $ node devServer.js 146 | ``` 147 | 148 | Open `localhost:5000/example` 149 | 150 | ## History 151 | 152 | #### Before v1.1.x ... 153 | 154 | - Initial release 155 | - Babel 5 156 | - D3 3.0 157 | 158 | #### 2016 / 3 / 3, v1.2.0 159 | 160 | - Move to Babel 6. 161 | - D3 4.0. 162 | - improve example folder. 163 | 164 | 165 | ## License 166 | 167 | Apache 2.0 168 | -------------------------------------------------------------------------------- /__tests__/axis/xaxis-test.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import TestUtils from 'react-addons-test-utils'; 4 | 5 | const d3 = require('d3'); 6 | const expect = require('expect'); 7 | const Xaxis = require('../../lib/axis/xaxis'); 8 | const data = require('json!../data/user_sample.json'); 9 | const common = require('../../lib/commonProps'); 10 | 11 | describe('Axes, set x accessor', () => { 12 | 13 | it('Create xaxis, default orient is bottom, and with default height and margins', () => { 14 | var x = function(d) { return d.index; } 15 | 16 | var newGroup = TestUtils.renderIntoDocument( 17 | 20 | ); 21 | 22 | var height = common.height; 23 | var margins = common.margins; 24 | 25 | var dom = ReactDOM.findDOMNode(newGroup) 26 | expect(dom.getAttribute('transform')).toEqual(`translate(0, ${height - margins.top - margins.bottom})`) 27 | }) 28 | 29 | it('Create xaxis, orient in bottom', () => { 30 | var x = function(d) { return d.index; } 31 | 32 | var newGroup = TestUtils.renderIntoDocument( 33 | 37 | ); 38 | 39 | var height = common.height; 40 | var margins = common.margins; 41 | 42 | var dom = ReactDOM.findDOMNode(newGroup) 43 | expect(dom.getAttribute('transform')).toEqual(`translate(0, ${height - margins.top - margins.bottom})`) 44 | }) 45 | 46 | it('Create xaxis, orient in top', () => { 47 | var x = function(d) { return d.index; } 48 | 49 | var newGroup = TestUtils.renderIntoDocument( 50 | 54 | ); 55 | 56 | var dom = ReactDOM.findDOMNode(newGroup) 57 | expect(dom.getAttribute('transform')).toEqual('translate(0, 0)') 58 | }) 59 | }) 60 | -------------------------------------------------------------------------------- /__tests__/axis/yaxis-test.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import TestUtils from 'react-addons-test-utils'; 4 | 5 | const d3 = require('d3'); 6 | const expect = require('expect'); 7 | const Yaxis = require('../../lib/axis/yaxis'); 8 | const data = require('json!../data/user_sample.json'); 9 | const common = require('../../lib/commonProps'); 10 | 11 | describe('Axes, set y accessor', () => { 12 | 13 | it('Create yaxis, default orient is left, and with default height and margins', () => { 14 | var y = function(d) { return d.index; } 15 | 16 | var newGroup = TestUtils.renderIntoDocument( 17 | 20 | ); 21 | 22 | var dom = ReactDOM.findDOMNode(newGroup) 23 | expect(dom.getAttribute('transform')).toEqual('translate(0, 0)') 24 | }) 25 | 26 | it('Create yaxis, orient in left', () => { 27 | var y = function(d) { return d.index; } 28 | 29 | var newGroup = TestUtils.renderIntoDocument( 30 | 34 | ); 35 | 36 | var dom = ReactDOM.findDOMNode(newGroup) 37 | expect(dom.getAttribute('transform')).toEqual('translate(0, 0)') 38 | }) 39 | 40 | it('Create yaxis, orient in right', () => { 41 | var y = function(d) { return d.index; } 42 | 43 | var newGroup = TestUtils.renderIntoDocument( 44 | 48 | ); 49 | 50 | var width = common.width; 51 | var margins = common.margins; 52 | 53 | var dom = ReactDOM.findDOMNode(newGroup) 54 | expect(dom.getAttribute('transform')).toEqual(`translate(${width - margins.right - margins.left}, 0)`) 55 | }) 56 | 57 | 58 | }) 59 | -------------------------------------------------------------------------------- /__tests__/container/svg-test.js: -------------------------------------------------------------------------------- 1 | import { 2 | default as React 3 | } from 'react'; 4 | 5 | import { 6 | default as TestUtils 7 | } from 'react-addons-test-utils'; 8 | 9 | const d3 = require('d3'); 10 | const expect = require('expect'); 11 | const Svg = require('../../lib/container/svg'); 12 | const SvgClick = require('./svg_change'); 13 | 14 | var width = 960, 15 | height = 500, 16 | margins = {top: 20, right: 50, bottom: 20, left: 50}, 17 | id = "test-chart", 18 | svgClassName = "test-chart-class"; 19 | 20 | describe('SVG', () => { 21 | 22 | it('create a new svg tag, with a group tag', () => { 23 | var newSvg = TestUtils.renderIntoDocument( 24 | 31 | 32 | ); 33 | 34 | var svgDom = TestUtils.findRenderedDOMComponentWithClass( 35 | newSvg, 36 | "test-chart-class" 37 | ); 38 | 39 | var gDom = TestUtils.findRenderedDOMComponentWithTag( 40 | newSvg, 41 | "g" 42 | ); 43 | expect(svgDom.id).toEqual(id); 44 | expect(+svgDom.getAttribute('width')).toEqual(width); 45 | expect(+svgDom.getAttribute('height')).toEqual(height); 46 | expect(gDom.getAttribute('transform')).toEqual('translate(' + margins.left + ', ' + margins.top + ')'); 47 | 48 | }) 49 | 50 | it('change attributes (width, height, transform, class, id) when click', () => { 51 | 52 | var clickSvg = TestUtils.renderIntoDocument( 53 | 60 | 61 | ); 62 | 63 | var svgDom = TestUtils.findRenderedDOMComponentWithClass( 64 | clickSvg, 65 | "test-chart-class" 66 | ); 67 | 68 | var gDom = TestUtils.findRenderedDOMComponentWithTag( 69 | clickSvg, 70 | "g" 71 | ); 72 | 73 | clickSvg._onClick(); 74 | 75 | expect(svgDom.id).toEqual(id + '1'); 76 | expect(+svgDom.getAttribute('width')).toEqual(width + 100); 77 | expect(+svgDom.getAttribute('height')).toEqual(height + 100); 78 | expect(gDom.getAttribute('transform')).toEqual('translate(' + margins.left + ', ' + (+margins.top + 10) + ')'); 79 | }) 80 | 81 | it('svg with children', () => { 82 | 83 | var childrenSvg = TestUtils.renderIntoDocument( 84 | 91 | 92 | 93 | ); 94 | 95 | var rectDom = TestUtils.findRenderedDOMComponentWithClass( 96 | childrenSvg, 97 | "test-rect" 98 | ); 99 | 100 | expect(+rectDom.getAttribute('width')).toEqual(100); 101 | expect(+rectDom.getAttribute('height')).toEqual(100); 102 | }) 103 | }) 104 | -------------------------------------------------------------------------------- /__tests__/container/svg_change.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | var React = require('react'); 4 | var Svg = require('../../lib/container/svg.js'); 5 | 6 | var ClickSvg = React.createClass({ 7 | getInitialState: function() { 8 | return { 9 | expend: false 10 | } 11 | }, 12 | _onClick: function() { 13 | this.setState({ 14 | expend: !this.state.expend 15 | }) 16 | }, 17 | render: function() { 18 | var width = this.props.width; 19 | var height = this.props.height; 20 | var className = this.props.svgClassName; 21 | var margins = this.props.margins; 22 | var id = this.props.id; 23 | 24 | var expend = this.state.expend; 25 | var top = margins.top; 26 | 27 | width = expend? (width + 100): width; 28 | height = expend? (height + 100): height; 29 | className = expend? (className + '1'): className; 30 | id = expend? (id + '1'): id; 31 | 32 | var newMargins= expend? ({top: 30, right: 50, bottom: 20, left: 50}): margins; 33 | 34 | return ( 35 | 42 | 43 | ) 44 | } 45 | }) 46 | 47 | module.exports = ClickSvg; 48 | -------------------------------------------------------------------------------- /__tests__/container/title-test.js: -------------------------------------------------------------------------------- 1 | import { 2 | default as React 3 | } from 'react'; 4 | 5 | import { 6 | default as TestUtils 7 | } from 'react-addons-test-utils'; 8 | 9 | const d3 = require('d3'); 10 | const expect = require('expect'); 11 | const Title = require('../../lib/container/title'); 12 | const TitleChange = require('./title_change'); 13 | 14 | var title = "test-chart", 15 | titleClassName = "test-chart-class"; 16 | 17 | 18 | describe('Title', () => { 19 | 20 | it('create a new title', () => { 21 | var newTitle = TestUtils.renderIntoDocument( 22 | 26 | ); 27 | 28 | var titleDom = TestUtils.findRenderedDOMComponentWithClass( 29 | newTitle, 30 | "test-chart-class" 31 | ); 32 | 33 | expect(titleDom.textContent).toEqual('test-chart'); 34 | 35 | }) 36 | 37 | it('Change title', () => { 38 | 39 | var newTitle = TestUtils.renderIntoDocument( 40 | <TitleChange 41 | title= {title} 42 | titleClassName= {titleClassName} 43 | /> 44 | ); 45 | 46 | var titleDom = TestUtils.findRenderedDOMComponentWithClass( 47 | newTitle, 48 | "test-chart-class" 49 | ); 50 | 51 | newTitle._onClick(); 52 | 53 | expect(titleDom.textContent).toEqual('test-chart1'); 54 | 55 | }) 56 | }) 57 | -------------------------------------------------------------------------------- /__tests__/container/title_change.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | var React = require('react'); 4 | var Title = require('../../lib/container/title.js'); 5 | 6 | var ChangeTitle = React.createClass({ 7 | getInitialState: function() { 8 | return { 9 | expend: false 10 | } 11 | }, 12 | _onClick: function() { 13 | this.setState({ 14 | expend: !this.state.expend 15 | }) 16 | }, 17 | render: function() { 18 | var title = this.props.title; 19 | var titleClassName = this.props.titleClassName; 20 | 21 | var expend = this.state.expend; 22 | 23 | title = expend? (title + '1'): title; 24 | titleClassName = expend? (titleClassName + '1'): titleClassName; 25 | 26 | return ( 27 | <Title 28 | title= {title} 29 | titleClassName= {titleClassName} 30 | onClick={this._onClick}> 31 | 32 | ) 33 | } 34 | }) 35 | 36 | module.exports = ChangeTitle; 37 | -------------------------------------------------------------------------------- /__tests__/data/garbage.csv: -------------------------------------------------------------------------------- 1 | month,total,incineration,garbageBury,largeGarbageRecycle,foodWaste,recycle,other,average 2 | 2001M01,770095,295355,339023,0,0,75630,60087,1.124 3 | 2001M02,629350,248283,256351,0,0,74732,49983,1.016 4 | 2001M03,663170,271344,264674,0,0,77137,50015,0.966 5 | 2001M04,650177,279304,250420,0,0,72205,48249,0.976 6 | 2001M05,713649,326336,246014,0,0,96295,45004,1.034 7 | 2001M06,695624,326309,236874,0,0,91924,40516,1.041 8 | 2001M07,704734,356180,206992,0,0,96427,45136,1.020 9 | 2001M08,693821,345400,211975,0,0,98186,38261,1.005 10 | 2001M09,795625,362212,304039,0,0,88582,40793,1.192 11 | 2001M10,726018,315929,270775,0,0,101538,37775,1.052 12 | 2001M11,650861,285575,236909,0,0,94331,34046,0.973 13 | 2001M12,640683,324674,191039,0,0,89766,35205,0.926 14 | 2002M01,683665,345433,198188,0,0,108206,31838,0.988 15 | 2002M02,672584,353367,198474,0,0,95222,25522,1.075 16 | 2002M03,652716,341320,182254,0,0,102716,26426,0.942 17 | 2002M04,662728,363258,181085,0,0,93790,24595,0.987 18 | 2002M05,694568,380675,189499,0,0,102992,21401,1.001 19 | 2002M06,671190,373771,176130,0,0,92674,28614,1.003 20 | 2002M07,691517,390530,170942,0,0,103016,27029,1.003 21 | 2002M08,681693,382657,163702,0,0,108936,26397,0.989 22 | 2002M09,649518,359573,165399,0,0,102177,22369,0.975 23 | 2002M10,668299,343228,185622,0,0,110382,29066,0.970 24 | 2002M11,612179,328975,156378,0,0,107199,19628,0.917 25 | 2002M12,644181,353381,162517,0,0,114527,13756,0.933 26 | 2003M01,710215,397710,174292,0,8948,113909,15356,1.023 27 | 2003M02,550699,316471,123177,0,10139,90116,10796,0.876 28 | 2003M03,610571,353792,128981,0,11510,103688,12600,0.878 29 | 2003M04,627469,363105,133639,0,12352,100401,17973,0.930 30 | 2003M05,668782,360933,164640,0,13815,116191,13203,0.959 31 | 2003M06,654195,371453,147821,0,13498,110205,11219,0.969 32 | 2003M07,675156,377136,146773,0,14882,126174,10192,0.969 33 | 2003M08,656865,376204,135333,0,14614,121063,9651,0.942 34 | 2003M09,668895,384371,136603,0,15800,123077,9045,0.990 35 | 2003M10,639074,351194,135405,0,16410,127017,9048,0.915 36 | 2003M11,602510,313748,145138,0,17277,114353,11994,0.890 37 | 2003M12,643587,339933,141087,0,19356,132965,10246,0.920 38 | 2004M01,696099,395233,151548,0,21789,117914,9614,0.995 39 | 2004M02,591716,326367,117994,0,21379,117710,8266,0.904 40 | 2004M03,627731,349888,116664,0,22963,131049,7166,0.896 41 | 2004M04,619103,339664,124011,0,23390,121882,10156,0.913 42 | 2004M05,651088,361769,137501,0,25916,118645,7257,0.929 43 | 2004M06,669185,387857,117681,0,26548,131773,5327,0.987 44 | 2004M07,667594,394328,116719,0,25424,126374,4748,0.953 45 | 2004M08,656224,382116,114372,0,24301,130745,4691,0.936 46 | 2004M09,640068,366284,111339,0,24823,132611,5012,0.943 47 | 2004M10,619278,330194,124193,0,25208,134844,4839,0.882 48 | 2004M11,626843,332284,123097,0,27554,136315,7594,0.922 49 | 2004M12,650031,341754,119047,0,29970,152944,6317,0.925 50 | 2005M01,656035,380660,104940,2574,35827,126559,5475,0.933 51 | 2005M02,640793,370156,104681,2200,36133,123289,4334,1.009 52 | 2005M03,650863,359579,98553,1347,37432,150645,3307,0.926 53 | 2005M04,633506,332646,104069,1512,42990,147234,5054,0.931 54 | 2005M05,666509,359270,106375,1561,43718,150256,5328,0.947 55 | 2005M06,670038,380450,90663,2163,41526,151669,3566,0.984 56 | 2005M07,683512,385660,96356,4873,37372,156553,2697,0.971 57 | 2005M08,679191,382372,93080,2675,37483,162856,725,0.965 58 | 2005M09,660542,364280,89777,3153,37439,163373,2521,0.969 59 | 2005M10,629688,335791,97689,2773,37973,153757,1705,0.894 60 | 2005M11,622630,318023,99670,2573,37572,162304,2488,0.913 61 | 2005M12,635378,331511,98745,2171,38736,161159,3055,0.901 62 | 2006M01,687321,367784,103616,3578,41125,167722,3496,0.975 63 | 2006M02,596097,324825,84760,1464,42845,140125,2079,0.935 64 | 2006M03,635158,326259,82062,2267,44991,178157,1421,0.899 65 | 2006M04,612048,320099,73868,1566,48058,166801,1658,0.895 66 | 2006M05,665768,344364,84207,2364,50420,183442,972,0.942 67 | 2006M06,668101,359602,70987,2698,48985,185276,554,0.977 68 | 2006M07,670102,367193,65409,1660,46399,188806,636,0.948 69 | 2006M08,671907,361360,63265,2053,48268,196416,544,0.950 70 | 2006M09,637838,344741,57317,2529,48448,183949,853,0.931 71 | 2006M10,655268,352267,58321,2832,50159,190016,1673,0.926 72 | 2006M11,646579,350407,50525,2949,50462,190084,2152,0.943 73 | 2006M12,645418,345067,56679,2687,50017,189318,1652,0.911 74 | 2007M01,669649,371663,48035,3038,50076,195990,848,0.944 75 | 2007M02,658237,386836,48880,3037,50669,167897,918,1.028 76 | 2007M03,671883,368444,44152,1988,55526,200943,831,0.948 77 | 2007M04,641209,353137,45477,2178,53678,185143,1597,0.934 78 | 2007M05,674137,365524,50618,2829,56691,196456,2019,0.950 79 | 2007M06,680109,381399,37541,2341,57053,198560,3215,0.990 80 | 2007M07,680124,375015,38329,2724,58048,204876,1132,0.958 81 | 2007M08,695753,385436,37044,3091,58798,211228,157,0.980 82 | 2007M09,639221,348446,30804,2508,55275,202044,145,0.930 83 | 2007M10,676374,355058,45373,2738,54999,210818,7387,0.952 84 | 2007M11,620035,310086,43163,2570,54493,202630,7094,0.901 85 | 2007M12,642717,334726,35531,2188,57485,205608,7179,0.904 86 | 2008M01,682388,382802,27405,2676,58545,210784,176,0.959 87 | 2008M02,629922,365300,23174,2292,57652,181373,133,0.946 88 | 2008M03,606304,337292,18753,2161,57681,190267,151,0.851 89 | 2008M04,611410,337406,17960,2301,57321,196263,158,0.887 90 | 2008M05,647752,354148,21247,2399,61232,208717,8,0.909 91 | 2008M06,644275,353399,17489,2955,60109,210316,8,0.934 92 | 2008M07,646515,360850,19080,4325,58798,203454,7,0.907 93 | 2008M08,622844,333976,17645,4321,56479,210417,7,0.874 94 | 2008M09,642632,348806,18396,5525,57677,212179,49,0.931 95 | 2008M10,621165,331001,19926,6097,55602,208531,7,0.871 96 | 2008M11,573100,299502,18319,4644,53494,197134,7,0.830 97 | 2008M12,609066,332802,16728,4770,56603,198125,37,0.853 98 | 2009M01,666916,387876,19520,5776,57250,196486,8,0.934 99 | 2009M02,603384,321171,16055,4367,58098,203687,7,0.935 100 | 2009M03,618851,329950,15827,4397,58772,209899,7,0.866 101 | 2009M04,620060,328230,14598,4227,59782,213217,7,0.896 102 | 2009M05,635779,334901,14086,4430,60543,221473,346,0.889 103 | 2009M06,674564,357906,14520,5072,63185,232980,900,0.975 104 | 2009M07,664885,344645,14165,5678,62929,237461,7,0.930 105 | 2009M08,685801,363353,21476,8009,58633,234323,7,0.959 106 | 2009M09,642615,311225,14501,6346,58567,251969,7,0.928 107 | 2009M10,655304,328883,13837,6016,61217,245343,7,0.915 108 | 2009M11,634043,314302,13897,5590,61198,239049,7,0.915 109 | 2009M12,643817,313962,13282,5565,61296,249704,7,0.899 110 | 2010M01,670991,338901,13836,7365,60115,250768,7,0.936 111 | 2010M02,671571,359297,15164,6993,59564,230547,6,1.037 112 | 2010M03,674038,329915,14762,5636,62408,261310,7,0.940 113 | 2010M04,642960,314467,13777,5729,60830,246841,1316,0.927 114 | 2010M05,672954,334249,17138,6135,64227,251199,7,0.938 115 | 2010M06,686566,344352,14371,6625,63947,257265,7,0.989 116 | 2010M07,674449,331610,14506,7257,65827,255243,7,0.940 117 | 2010M08,669168,323818,14150,6657,66142,258394,7,0.933 118 | 2010M09,689302,335753,17222,8548,66129,260843,807,0.993 119 | 2010M10,638173,300518,15645,7447,65678,248879,7,0.889 120 | 2010M11,634052,288684,17198,6278,66135,255750,7,0.913 121 | 2010M12,633376,287077,14001,5550,68162,258579,7,0.882 122 | 2011M01,669127,322138,17760,9852,66990,252380,7,0.932 123 | 2011M02,579427,282685,14229,4601,63782,214123,6,0.893 124 | 2011M03,630674,284573,18352,6012,65822,255909,6,0.878 125 | 2011M04,621122,276972,12358,5094,66971,259720,6,0.894 126 | 2011M05,645598,294537,11292,5501,70548,263714,6,0.899 127 | 2011M06,644114,296265,11173,6317,70774,259579,6,0.926 128 | 2011M07,640912,299283,10312,7062,70499,253750,6,0.892 129 | 2011M08,645523,296319,9600,6981,70300,262317,6,0.898 130 | 2011M09,627089,289489,8694,7061,66350,255489,6,0.901 131 | 2011M10,621275,279523,8765,7167,67568,258246,6,0.864 132 | 2011M11,596078,259332,10777,7116,66306,252540,6,0.856 133 | 2011M12,633650,287505,8843,7563,65288,264447,6,0.880 134 | 2012M01,663145,318630,10593,7588,67470,258847,17,0.921 135 | 2012M02,581227,254533,8053,6046,65086,247502,7,0.863 136 | 2012M03,625485,278802,8637,7025,68433,262582,7,0.868 137 | 2012M04,595741,267364,7935,6751,67688,245997,6,0.854 138 | 2012M05,624899,274088,8742,7039,71326,263698,6,0.867 139 | 2012M06,640348,289514,8872,6907,72368,262682,6,0.918 140 | 2012M07,620990,277878,7728,7953,71502,255924,6,0.861 141 | 2012M08,626361,279670,8819,9360,70211,258296,6,0.868 142 | 2012M09,595516,253637,8060,7927,68466,257419,6,0.853 143 | 2012M10,613300,259450,8860,7079,71640,266265,6,0.850 144 | 2012M11,605045,256114,7869,8203,70894,261958,6,0.866 145 | 2012M12,611852,267574,7885,7104,69456,259827,6,0.847 146 | 2013M01,634231,285083,8605,8120,66933,265484,6,0.877 147 | 2013M02,597573,278109,9499,6196,65033,238730,6,0.915 148 | 2013M03,615770,266933,7803,5800,68278,266950,6,0.851 149 | 2013M04,613496,273477,6841,6414,68389,258369,6,0.876 150 | 2013M05,613277,264877,7849,7006,70454,263084,6,0.848 151 | 2013M06,610220,268879,7478,6562,68135,259159,6,0.871 152 | 2013M07,643080,285548,8092,8651,68956,271828,6,0.889 153 | 2013M08,624524,273663,7052,6940,67517,269347,6,0.863 154 | 2013M09,592806,257769,6928,7476,61939,258687,6,0.846 155 | 2013M10,606793,254716,7054,7407,63403,274207,6,0.838 156 | 2013M11,583401,241141,6827,6786,63101,265540,6,0.832 157 | 2013M12,599406,258519,7328,6653,63075,263825,6,0.827 158 | 2014M01,661470,298125,8774,7347,64992,282226,6,0.913 159 | 2014M02,582868,253420,7097,3780,60760,257804,6,0.890 160 | 2014M03,606147,264120,6772,5218,60993,269039,6,0.836 161 | 2014M04,598134,255984,6626,5271,59764,270484,6,0.853 162 | 2014M05,619557,266883,6217,4990,61535,279926,6,0.855 163 | 2014M06,620332,277195,6300,5903,60625,270303,6,0.884 164 | 2014M07,641095,281291,6523,5765,60970,286538,8,0.884 165 | 2014M08,621297,273004,5994,5379,59319,277595,6,0.856 166 | 2014M09,621172,265693,8995,6071,59416,280991,6,0.885 167 | 2014M10,607449,255810,6869,6034,57933,280796,6,0.837 168 | 2014M11,569058,232157,6476,4845,56412,269162,6,0.810 169 | 2014M12,620859,265775,6492,5235,57654,285696,6,0.855 170 | 2015M01,608176,266883,7578,5478,50964,277237,36,0.837 171 | 2015M02,588467,274532,7385,5472,47830,253243,6,0.897 172 | 2015M03,617597,270293,6915,5030,52152,283193,15,0.850 173 | -------------------------------------------------------------------------------- /__tests__/data/state_age.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "State": "CA", 4 | "Under 5 Years": "2704659", 5 | "5 to 13 Years": "4499890", 6 | "14 to 17 Years": "2159981", 7 | "18 to 24 Years": "3853788", 8 | "25 to 44 Years": "10604510", 9 | "45 to 64 Years": "8819342", 10 | "65 Years and Over": "4114496" 11 | }, 12 | { 13 | "State": "TX", 14 | "Under 5 Years": "2027307", 15 | "5 to 13 Years": "3277946", 16 | "14 to 17 Years": "1420518", 17 | "18 to 24 Years": "2454721", 18 | "25 to 44 Years": "7017731", 19 | "45 to 64 Years": "5656528", 20 | "65 Years and Over": "2472223" 21 | }, 22 | { 23 | "State": "NY", 24 | "Under 5 Years": "1208495", 25 | "5 to 13 Years": "2141490", 26 | "14 to 17 Years": "1058031", 27 | "18 to 24 Years": "1999120", 28 | "25 to 44 Years": "5355235", 29 | "45 to 64 Years": "5120254", 30 | "65 Years and Over": "2607672" 31 | }, 32 | { 33 | "State": "FL", 34 | "Under 5 Years": "1140516", 35 | "5 to 13 Years": "1938695", 36 | "14 to 17 Years": "925060", 37 | "18 to 24 Years": "1607297", 38 | "25 to 44 Years": "4782119", 39 | "45 to 64 Years": "4746856", 40 | "65 Years and Over": "3187797" 41 | }, 42 | { 43 | "State": "IL", 44 | "Under 5 Years": "894368", 45 | "5 to 13 Years": "1558919", 46 | "14 to 17 Years": "725973", 47 | "18 to 24 Years": "1311479", 48 | "25 to 44 Years": "3596343", 49 | "45 to 64 Years": "3239173", 50 | "65 Years and Over": "1575308" 51 | }, 52 | { 53 | "State": "PA", 54 | "Under 5 Years": "737462", 55 | "5 to 13 Years": "1345341", 56 | "14 to 17 Years": "679201", 57 | "18 to 24 Years": "1203944", 58 | "25 to 44 Years": "3157759", 59 | "45 to 64 Years": "3414001", 60 | "65 Years and Over": "1910571" 61 | } 62 | ] 63 | -------------------------------------------------------------------------------- /__tests__/data/user_sample.json: -------------------------------------------------------------------------------- 1 | 2 | [ 3 | {"name":"Darron Weissnat IV","BMI":20.72,"age":39,"birthday":"2005-01-03T00:00:00.000Z","city":"East Russel","married":false,"index":0} 4 | , 5 | {"name":"Pablo Ondricka","BMI":19.32,"age":38,"birthday":"1974-05-13T00:00:00.000Z","city":"Lake Edytheville","married":false,"index":1} 6 | , 7 | {"name":"Mr. Stella Kiehn Jr.","BMI":16.8,"age":34,"birthday":"2003-07-25T00:00:00.000Z","city":"Lake Veronicaburgh","married":false,"index":2} 8 | , 9 | {"name":"Lavon Hilll I","BMI":20.57,"age":12,"birthday":"1994-10-26T00:00:00.000Z","city":"Annatown","married":true,"index":3} 10 | , 11 | {"name":"Clovis Pagac","BMI":24.28,"age":26,"birthday":"1995-11-10T00:00:00.000Z","city":"South Eldredtown","married":false,"index":4} 12 | , 13 | {"name":"Gaylord Paucek","BMI":24.41,"age":30,"birthday":"1975-06-12T00:00:00.000Z","city":"Koeppchester","married":true,"index":5} 14 | , 15 | {"name":"Ashlynn Kuhn MD","BMI":23.77,"age":32,"birthday":"1985-08-09T00:00:00.000Z","city":"West Josiemouth","married":false,"index":6} 16 | , 17 | {"name":"Fern Schmeler IV","BMI":27.33,"age":26,"birthday":"2005-02-10T00:00:00.000Z","city":"West Abigaleside","married":true,"index":7} 18 | , 19 | {"name":"Enid Weber","BMI":18.72,"age":17,"birthday":"1998-11-30T00:00:00.000Z","city":"Zackton","married":true,"index":8} 20 | , 21 | {"name":"Leatha O'Hara","BMI":17.68,"age":42,"birthday":"2010-10-17T00:00:00.000Z","city":"Lake Matilda","married":false,"index":9} 22 | , 23 | {"name":"Korbin Steuber","BMI":16.35,"age":39,"birthday":"1975-06-30T00:00:00.000Z","city":"East Armandofort","married":true,"index":10} 24 | , 25 | {"name":"Brennon Torphy","BMI":27.37,"age":24,"birthday":"2003-10-21T00:00:00.000Z","city":"Croninfort","married":true,"index":11} 26 | , 27 | {"name":"Ms. Genoveva Bradtke","BMI":28.63,"age":19,"birthday":"1983-01-10T00:00:00.000Z","city":"Port Emanuel","married":true,"index":12} 28 | , 29 | {"name":"Gregg Halvorson","BMI":15.45,"age":15,"birthday":"2004-06-15T00:00:00.000Z","city":"Lake Angelinastad","married":false,"index":13} 30 | , 31 | {"name":"Mr. Sabina Schroeder III","BMI":24.27,"age":26,"birthday":"1980-11-22T00:00:00.000Z","city":"Toyview","married":true,"index":14} 32 | , 33 | {"name":"Alanna Mitchell","BMI":29.25,"age":37,"birthday":"1971-08-04T00:00:00.000Z","city":"Lake Monserratmouth","married":false,"index":15} 34 | , 35 | {"name":"Ronny Sanford","BMI":29.16,"age":24,"birthday":"1994-11-24T00:00:00.000Z","city":"New Claudhaven","married":false,"index":16} 36 | , 37 | {"name":"Emmitt Pouros","BMI":27.95,"age":14,"birthday":"1989-04-04T00:00:00.000Z","city":"Moorefurt","married":true,"index":17} 38 | , 39 | {"name":"Earl Purdy","BMI":18.34,"age":38,"birthday":"2013-04-03T00:00:00.000Z","city":"Lake Rowanberg","married":true,"index":18} 40 | , 41 | {"name":"Cordelia Klocko","BMI":25.85,"age":36,"birthday":"2011-01-17T00:00:00.000Z","city":"Lakinchester","married":true,"index":19} 42 | , 43 | {"name":"Guido Conroy","BMI":25.17,"age":39,"birthday":"1977-04-20T00:00:00.000Z","city":"Scarlettland","married":true,"index":20} 44 | , 45 | {"name":"Miss Demond Weissnat V","BMI":21.44,"age":19,"birthday":"2007-06-09T00:00:00.000Z","city":"Savionberg","married":false,"index":21} 46 | , 47 | {"name":"Easton Mante","BMI":20.61,"age":43,"birthday":"2007-01-29T00:00:00.000Z","city":"Kutchberg","married":false,"index":22} 48 | , 49 | {"name":"Dayton Ebert","BMI":29.88,"age":20,"birthday":"1978-04-27T00:00:00.000Z","city":"West Wiley","married":true,"index":23} 50 | ] 51 | -------------------------------------------------------------------------------- /__tests__/label/label-test.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import TestUtils from 'react-addons-test-utils'; 4 | 5 | const d3 = require('d3'); 6 | const expect = require('expect'); 7 | const Label = require('../../lib/axis/label'); 8 | const data = require('json!../data/user_sample.json'); 9 | const common = require('../../lib/commonProps'); 10 | 11 | const defaultProps = Object.assign(common, { 12 | hTransform: 'rotate(0)', 13 | vTransform: 'rotate(270)', 14 | labelTitle: 'label title', 15 | labelPosition: 'bottom', 16 | labelOffset: 40, 17 | textAnchor: 'middle', 18 | labelClassName: 'react-d3-core__label' 19 | }) 20 | 21 | describe('Label', () => { 22 | 23 | it('Create label with default values, in bottom position', () => { 24 | 25 | var newGroup = TestUtils.renderIntoDocument( 26 |