11 |
12 | # TECHNOLOGY COLOPHON
13 |
14 | CSS3, HTML5, JavaScript
15 | React, Flux, SuperAgent
16 |
--------------------------------------------------------------------------------
/src/public/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/start-react/sb-admin-react/e5a9c58780dece135372075fd87ab8ac62c0e7c6/src/public/logo.png
--------------------------------------------------------------------------------
/src/public/robots.txt:
--------------------------------------------------------------------------------
1 | # www.robotstxt.org/
2 |
3 | # Allow crawling of all content
4 | User-agent: *
5 | Disallow:
6 |
--------------------------------------------------------------------------------
/src/public/tile-wide.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/start-react/sb-admin-react/e5a9c58780dece135372075fd87ab8ac62c0e7c6/src/public/tile-wide.png
--------------------------------------------------------------------------------
/src/public/tile.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/start-react/sb-admin-react/e5a9c58780dece135372075fd87ab8ac62c0e7c6/src/public/tile.png
--------------------------------------------------------------------------------
/src/routes/dashboardPages/blank/blank.js:
--------------------------------------------------------------------------------
1 | import React, { PropTypes } from 'react';
2 | import { PageHeader } from 'react-bootstrap';
3 |
4 | const title = 'Blank';
5 |
6 | function displayBlank(props, context) {
7 | context.setTitle(title);
8 | return (
9 |
16 | );
17 | }
18 |
19 |
20 | displayBlank.contextTypes = { setTitle: PropTypes.func.isRequired };
21 | export default displayBlank;
22 |
--------------------------------------------------------------------------------
/src/routes/dashboardPages/blank/index.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import Blank from './blank';
3 |
4 | export default {
5 | path: '/blank',
6 |
7 | action() {
8 | return ;
9 | },
10 |
11 | };
12 |
--------------------------------------------------------------------------------
/src/routes/dashboardPages/buttons/index.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import Button from './Button';
3 |
4 | export default {
5 |
6 | path: '/button',
7 |
8 | action() {
9 | return ;
10 | },
11 |
12 | };
13 |
--------------------------------------------------------------------------------
/src/routes/dashboardPages/flotCharts/index.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import FlotCharts from './FlotCharts';
3 |
4 | export default {
5 |
6 | path: '/flotcharts',
7 |
8 | action() {
9 | return ;
10 | },
11 |
12 | };
13 |
--------------------------------------------------------------------------------
/src/routes/dashboardPages/forms/index.js:
--------------------------------------------------------------------------------
1 |
2 | import React from 'react';
3 | import Forms from './forms';
4 |
5 | export default {
6 |
7 | path: '/forms',
8 |
9 | action() {
10 | return ;
11 | },
12 |
13 | };
14 |
--------------------------------------------------------------------------------
/src/routes/dashboardPages/grid/index.js:
--------------------------------------------------------------------------------
1 |
2 | import React from 'react';
3 | import Grid from './Grid';
4 |
5 | export default {
6 |
7 | path: '/grid',
8 |
9 | action() {
10 | return ;
11 | },
12 |
13 | };
14 |
--------------------------------------------------------------------------------
/src/routes/dashboardPages/icons/index.js:
--------------------------------------------------------------------------------
1 |
2 | import React from 'react';
3 | import Icons from './Icons';
4 |
5 | export default {
6 |
7 | path: '/icons',
8 |
9 | action() {
10 | return ;
11 | },
12 |
13 | };
14 |
--------------------------------------------------------------------------------
/src/routes/dashboardPages/morrisjsCharts/index.js:
--------------------------------------------------------------------------------
1 |
2 | import React from 'react';
3 | import MorrisjsCharts from './MorrisjsCharts';
4 |
5 | export default {
6 |
7 | path: '/morrisjscharts',
8 |
9 | action() {
10 | return ;
11 | },
12 |
13 | };
14 |
--------------------------------------------------------------------------------
/src/routes/dashboardPages/notification/index.js:
--------------------------------------------------------------------------------
1 |
2 | import React from 'react';
3 | import Notification from './Notification';
4 |
5 | export default {
6 |
7 | path: '/notification',
8 |
9 | action() {
10 | return ;
11 | },
12 |
13 | };
14 |
--------------------------------------------------------------------------------
/src/routes/dashboardPages/panelWells/index.js:
--------------------------------------------------------------------------------
1 |
2 | import React from 'react';
3 | import PanelWells from './PanelWells';
4 |
5 | export default {
6 |
7 | path: '/panelwells',
8 |
9 | action() {
10 | return ;
11 | },
12 |
13 | };
14 |
--------------------------------------------------------------------------------
/src/routes/dashboardPages/tables/index.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import Table from './Table';
3 |
4 | export default {
5 |
6 | path: '/table',
7 |
8 | action() {
9 | return ;
10 | },
11 |
12 | };
13 |
--------------------------------------------------------------------------------
/src/routes/dashboardPages/typography/index.js:
--------------------------------------------------------------------------------
1 |
2 | import React from 'react';
3 | import Typography from './Typography';
4 |
5 | export default {
6 |
7 | path: '/typography',
8 |
9 | action() {
10 | return ;
11 | },
12 |
13 | };
14 |
--------------------------------------------------------------------------------
/src/routes/error/ErrorPage.css:
--------------------------------------------------------------------------------
1 | /**
2 | * React Starter Kit (https://www.reactstarterkit.com/)
3 | *
4 | * Copyright © 2014-2016 Kriasoft, LLC. All rights reserved.
5 | *
6 | * This source code is licensed under the MIT license found in the
7 | * LICENSE.txt file in the root directory of this source tree.
8 | */
9 |
10 | * {
11 | line-height: 1.2;
12 | margin: 0;
13 | }
14 |
15 | html {
16 | color: #888;
17 | display: table;
18 | font-family: sans-serif;
19 | height: 100%;
20 | text-align: center;
21 | width: 100%;
22 | }
23 |
24 | body {
25 | display: table-cell;
26 | vertical-align: middle;
27 | /* stylelint-disable */
28 | margin: 2em auto;
29 | /* stylelint-enable */
30 | }
31 |
32 | h1 {
33 | color: #555;
34 | font-size: 2em;
35 | font-weight: 400;
36 | }
37 |
38 | p {
39 | margin: 0 auto;
40 | width: 280px;
41 | }
42 |
43 | pre {
44 | text-align: left;
45 | margin-top: 2rem;
46 | }
47 |
48 | @media only screen and (max-width: 280px) {
49 | body,
50 | p {
51 | width: 95%;
52 | }
53 |
54 | h1 {
55 | font-size: 1.5em;
56 | margin: 0 0 0.3em;
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/src/routes/error/ErrorPage.js:
--------------------------------------------------------------------------------
1 | /**
2 | * React Starter Kit (https://www.reactstarterkit.com/)
3 | *
4 | * Copyright © 2014-2016 Kriasoft, LLC. All rights reserved.
5 | *
6 | * This source code is licensed under the MIT license found in the
7 | * LICENSE.txt file in the root directory of this source tree.
8 | */
9 |
10 | import React, { PropTypes } from 'react';
11 | import withStyles from 'isomorphic-style-loader/lib/withStyles';
12 | import s from './ErrorPage.css';
13 |
14 | function ErrorPage({ error }, context) {
15 | let title = 'Error';
16 | let content = 'Sorry, a critical error occurred on this page.';
17 | let errorMessage = null;
18 |
19 | if (error.status === 404) {
20 | title = 'Page Not Found';
21 | content = 'Sorry, the page you were trying to view does not exist.';
22 | } else if (process.env.NODE_ENV !== 'production') {
23 | errorMessage = {error.stack}
;
24 | }
25 |
26 | if (context.setTitle) {
27 | context.setTitle(title);
28 | }
29 |
30 | return (
31 |
32 |
{title}
33 |
{content}
34 | {errorMessage}
35 |
36 | );
37 | }
38 |
39 | ErrorPage.propTypes = { error: PropTypes.object.isRequired };
40 | ErrorPage.contextTypes = { setTitle: PropTypes.func.isRequired };
41 |
42 | export { ErrorPage as ErrorPageWithoutStyle };
43 | export default withStyles(s)(ErrorPage);
44 |
--------------------------------------------------------------------------------
/src/routes/error/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * React Starter Kit (https://www.reactstarterkit.com/)
3 | *
4 | * Copyright © 2014-2016 Kriasoft, LLC. All rights reserved.
5 | *
6 | * This source code is licensed under the MIT license found in the
7 | * LICENSE.txt file in the root directory of this source tree.
8 | */
9 |
10 | import React from 'react';
11 | import App from '../../components/App';
12 | import ErrorPage from './ErrorPage';
13 |
14 | export default {
15 |
16 | path: '/error',
17 |
18 | action({ render, context, error }) {
19 | // console.log('error obj inside error index.js', error);
20 | return render(
21 |
22 |
23 | ,
24 | error.status || 500
25 | );
26 | },
27 |
28 | };
29 |
--------------------------------------------------------------------------------
/src/routes/home/Home.css:
--------------------------------------------------------------------------------
1 | /**
2 | * React Starter Kit (https://www.reactstarterkit.com/)
3 | *
4 | * Copyright © 2014-2016 Kriasoft, LLC. All rights reserved.
5 | *
6 | * This source code is licensed under the MIT license found in the
7 | * LICENSE.txt file in the root directory of this source tree.
8 | */
9 |
10 | @import '../../components/variables.css';
11 |
12 | .root {
13 | padding-left: 20px;
14 | padding-right: 20px;
15 | }
16 |
17 | .container {
18 | margin: 0 auto;
19 | padding: 0 0 40px;
20 | max-width: var(--max-content-width);
21 | }
22 |
23 | .news {
24 | padding: 0;
25 | }
26 |
27 | .newsItem {
28 | list-style-type: none;
29 | padding-bottom: 6px;
30 | }
31 |
32 | .newsTitle {
33 | font-size: 1.125em;
34 | }
35 |
36 | .newsTitle,
37 | .newsDesc {
38 | display: block;
39 | }
40 |
--------------------------------------------------------------------------------
/src/routes/home/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * React Starter Kit (https://www.reactstarterkit.com/)
3 | *
4 | * Copyright © 2014-2016 Kriasoft, LLC. All rights reserved.
5 | *
6 | * This source code is licensed under the MIT license found in the
7 | * LICENSE.txt file in the root directory of this source tree.
8 | */
9 |
10 | import React from 'react';
11 | import Home from './Home';
12 | // import fetch from '../../core/fetch';
13 |
14 | export default {
15 |
16 | path: '/',
17 |
18 | async action() {
19 | return ;
20 | // const resp = await fetch('/graphql', {
21 | // method: 'post',
22 | // headers: {
23 | // Accept: 'application/json',
24 | // 'Content-Type': 'application/json',
25 | // },
26 | // body: JSON.stringify({
27 | // query: '{news{title,link,contentSnippet}}',
28 | // }),
29 | // credentials: 'include',
30 | // });
31 | // const { data } = await resp.json();
32 | // if (!data || !data.news) throw new Error('Failed to load the news feed.');
33 | // return ;
34 | },
35 |
36 | };
37 |
--------------------------------------------------------------------------------
/src/routes/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * React Starter Kit (https://www.reactstarterkit.com/)
3 | *
4 | * Copyright © 2014-2016 Kriasoft, LLC. All rights reserved.
5 | *
6 | * This source code is licensed under the MIT license found in the
7 | * LICENSE.txt file in the root directory of this source tree.
8 | */
9 |
10 | import React from 'react';
11 | import App from '../components/App';
12 |
13 | // Child routes
14 | import home from './home';
15 | import login from './login';
16 | import table from './dashboardPages/tables';
17 | import button from './dashboardPages/buttons';
18 | import flotcharts from './dashboardPages/flotCharts';
19 | import forms from './dashboardPages/forms';
20 | import grid from './dashboardPages/grid';
21 | import icons from './dashboardPages/icons';
22 | import morrisjscharts from './dashboardPages/morrisjsCharts';
23 | import notification from './dashboardPages/notification';
24 | import panelwells from './dashboardPages/panelWells';
25 | import typography from './dashboardPages/typography';
26 | import blank from './dashboardPages/blank';
27 | import error from './error';
28 |
29 | import Header from '../components/Header';
30 |
31 | export default [
32 |
33 | {
34 | path: '/login',
35 | children: [
36 | login,
37 | ],
38 | async action({ next, render, context }) {
39 | const component = await next();
40 | if (component === undefined) return component;
41 | return render(
42 | {component}
43 | );
44 | },
45 | },
46 |
47 |
48 | {
49 | path: '/',
50 |
51 | // keep in mind, routes are evaluated in order
52 | children: [
53 | home,
54 | // contact,
55 | table,
56 | button,
57 | flotcharts,
58 | forms,
59 | grid,
60 | icons,
61 | morrisjscharts,
62 | notification,
63 | panelwells,
64 | typography,
65 | // register,
66 | blank,
67 |
68 | // place new routes before...
69 | // content,
70 | error,
71 | ],
72 |
73 | async action({ next, render, context }) {
74 | // console.log('inside dashboard');
75 | const component = await next();
76 | // console.log('inside dasdboard component', component);
77 | if (component === undefined) return component;
78 | return render(
79 |
85 | );
86 | },
87 | },
88 | {
89 | path: '/error',
90 | children: [
91 | error,
92 | ],
93 | async action({ next, render, context }) {
94 | // console.log('inside error');
95 | const component = await next();
96 | // console.log('inside error with component', component);
97 | if (component === undefined) return component;
98 | return render(
99 | {component}
100 | );
101 | },
102 | },
103 | ];
104 |
--------------------------------------------------------------------------------
/src/routes/login/Login.css:
--------------------------------------------------------------------------------
1 | /**
2 | * React Starter Kit (https://www.reactstarterkit.com/)
3 | *
4 | * Copyright © 2014-2016 Kriasoft, LLC. All rights reserved.
5 | *
6 | * This source code is licensed under the MIT license found in the
7 | * LICENSE.txt file in the root directory of this source tree.
8 | */
9 | @import '../../components/variables.css';
10 |
11 | .root {
12 | padding-left: 20px;
13 | padding-right: 20px;
14 | }
15 |
16 | .container {
17 | margin: 0 auto;
18 | padding: 0 0 40px;
19 | max-width: 380px;
20 | }
21 |
22 | .lead {
23 | font-size: 1.25em;
24 | }
25 |
26 | .formGroup {
27 | margin-bottom: 15px;
28 | }
29 |
30 | .label {
31 | display: inline-block;
32 | margin-bottom: 5px;
33 | max-width: 100%;
34 | font-weight: 700;
35 | }
36 |
37 | .input {
38 | display: block;
39 | box-sizing: border-box;
40 | padding: 10px 16px;
41 | width: 100%;
42 | height: 46px;
43 | outline: 0;
44 | border: 1px solid #ccc;
45 | border-radius: 0;
46 | background: #fff;
47 | box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
48 | color: #616161;
49 | font-size: 18px;
50 | line-height: 1.3333333;
51 | transition: border-color ease-in-out 0.15s, box-shadow ease-in-out 0.15s;
52 | }
53 |
54 | .input:focus {
55 | border-color: #0074c2;
56 | box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(0, 116, 194, 0.6);
57 | }
58 |
59 | .button {
60 | display: block;
61 | box-sizing: border-box;
62 | margin: 0;
63 | padding: 10px 16px;
64 | width: 100%;
65 | outline: 0;
66 | border: 1px solid #373277;
67 | border-radius: 0;
68 | background: #373277;
69 | color: #fff;
70 | text-align: center;
71 | text-decoration: none;
72 | font-size: 18px;
73 | line-height: 1.3333333;
74 | cursor: pointer;
75 | }
76 |
77 | .button:hover {
78 | background: rgba(54, 50, 119, 0.8);
79 | }
80 |
81 | .button:focus {
82 | border-color: #0074c2;
83 | box-shadow: 0 0 8px rgba(0, 116, 194, 0.6);
84 | }
85 |
86 | .facebook {
87 | border-color: #3b5998;
88 | background: #3b5998;
89 | composes: button;
90 | }
91 |
92 | .facebook:hover {
93 | background: #2d4373;
94 | }
95 |
96 | .google {
97 | border-color: #dd4b39;
98 | background: #dd4b39;
99 | composes: button;
100 | }
101 |
102 | .google:hover {
103 | background: #c23321;
104 | }
105 |
106 | .twitter {
107 | border-color: #55acee;
108 | background: #55acee;
109 | composes: button;
110 | }
111 |
112 | .twitter:hover {
113 | background: #2795e9;
114 | }
115 |
116 | .icon {
117 | display: inline-block;
118 | margin: -2px 12px -2px 0;
119 | width: 20px;
120 | height: 20px;
121 | vertical-align: middle;
122 | fill: currentColor;
123 | }
124 |
125 | .lineThrough {
126 | position: relative;
127 | z-index: 1;
128 | display: block;
129 | margin-bottom: 15px;
130 | width: 100%;
131 | color: #757575;
132 | text-align: center;
133 | font-size: 80%;
134 | }
135 |
136 | .lineThrough::before {
137 | position: absolute;
138 | top: 50%;
139 | left: 50%;
140 | z-index: -1;
141 | margin-top: -5px;
142 | margin-left: -20px;
143 | width: 40px;
144 | height: 10px;
145 | background-color: #fff;
146 | content: '';
147 | }
148 |
149 | .lineThrough::after {
150 | position: absolute;
151 | top: 49%;
152 | z-index: -2;
153 | display: block;
154 | width: 100%;
155 | border-bottom: 1px solid #ddd;
156 | content: '';
157 | }
158 |
--------------------------------------------------------------------------------
/src/routes/login/Login.js:
--------------------------------------------------------------------------------
1 | /**
2 | * React Starter Kit (https://www.reactstarterkit.com/)
3 | *
4 | * Copyright © 2014-2016 Kriasoft, LLC. All rights reserved.
5 | *
6 | * This source code is licensed under the MIT license found in the
7 | * LICENSE.txt file in the root directory of this source tree.
8 | */
9 |
10 | import React, { PropTypes } from 'react';
11 | // import { Panel, Input, Button } from 'react-bootstrap';
12 | import Button from 'react-bootstrap/lib/Button';
13 | import Panel from 'react-bootstrap/lib/Panel';
14 | import { FormControl, Checkbox } from 'react-bootstrap';
15 | import withStyles from 'isomorphic-style-loader/lib/withStyles';
16 | import s from './Login.css';
17 | import history from '../../core/history';
18 |
19 | const title = 'Log In';
20 |
21 |
22 | function submitHandler(e) {
23 | e.preventDefault();
24 | history.push('/');
25 | }
26 |
27 | function Login(props, context) {
28 | context.setTitle(title);
29 | return (
30 |
31 |
32 |
SB Admin React
33 |
34 |
35 |
36 |
Please Sign In} className="login-panel">
37 |
38 |
61 |
62 |
63 |
64 |
65 |
66 | );
67 | }
68 |
69 |
70 | Login.contextTypes = { setTitle: PropTypes.func.isRequired };
71 |
72 | export default withStyles(s)(Login);
73 |
--------------------------------------------------------------------------------
/src/routes/login/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * React Starter Kit (https://www.reactstarterkit.com/)
3 | *
4 | * Copyright © 2014-2016 Kriasoft, LLC. All rights reserved.
5 | *
6 | * This source code is licensed under the MIT license found in the
7 | * LICENSE.txt file in the root directory of this source tree.
8 | */
9 |
10 | import React from 'react';
11 | // import App from '../../components/App';
12 | import Login from './Login';
13 |
14 | export default {
15 |
16 | path: '/',
17 |
18 | action() {
19 | return ;
20 | },
21 |
22 | };
23 |
--------------------------------------------------------------------------------
/src/vendor/recharts/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing to Recharts
2 |
3 | We'd love for you to contribute to our source code and to make Recharts even better than it is today! Here are the guidelines we'd like you to follow:
4 |
5 | + [Issues and Bugs](#issues)
6 | + [Pull Requests](#pr)
7 | + [Code Guide](#code)
8 | + [License](#license)
9 |
10 | ## Issues and Bugs
11 |
12 | ### Where to Find Known Issues
13 |
14 | We will be using [GitHub Issues](https://github.com/recharts/recharts/issues) for our public bugs. We will keep a close eye on this and try to make it clear when we have an internal fix in progress. Before filing a new task, try to make sure your problem doesn't already exist.
15 |
16 | ### Reporting New Issues
17 |
18 | The best way to get your bug fixed is to provide a reduced test case. jsFiddle provide a way to give live examples. You can fork our example in [recharts.org](http://recharts.org/) to show your case.
19 |
20 |
21 | ## Pull Requests
22 |
23 | **Working on your first Pull Request?** You can learn how from this *free* series [How to Contribute to an Open Source Project on GitHub](https://egghead.io/series/how-to-contribute-to-an-open-source-project-on-github)
24 |
25 | *Before* submitting a pull request, please make sure the following is done…
26 |
27 | + Search [GitHub](https://github.com/recharts/recharts/pulls) for an open or closed Pull Request that relates to your submission. You don't want to duplicate effort.
28 |
29 | + Fork the repo and create your branch from `master`.
30 | + If you've added code that should be **tested**, add tests!
31 | + If you've changed APIs, update the [documentation](https://github.com/recharts/recharts.org) and demo.
32 | + Ensure the test suite passes (`npm run test`).
33 | + Make sure your code lints (`npm run lint`) - we've done our best to make sure these rules match our internal linting guidelines.
34 |
35 |
36 | ## code Guide
37 |
38 | Our linter will catch most styling issues that may exist in your code.
39 | You can check the status of your code styling by simply running: `npm run lint`
40 |
41 | However, there are still some styles that the linter cannot pick up. If you are unsure about something, looking at [Airbnb's Style Guide](https://github.com/airbnb/javascript) will guide you in the right direction.
42 |
43 | ### Code Conventions
44 |
45 | * Use semicolons `;`
46 | * Commas last `,`
47 | * 2 spaces for indentation (no tabs)
48 | * Prefer `'` over `"`
49 | * 100 character line length
50 | * Write "attractive" code
51 |
52 | ## License
53 |
54 | By contributing to Recharts, you agree that your contributions will be licensed under its MIT license.
55 |
--------------------------------------------------------------------------------
/src/vendor/recharts/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 recharts
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
23 |
--------------------------------------------------------------------------------
/src/vendor/recharts/README.md:
--------------------------------------------------------------------------------
1 | # Recharts
2 |
3 | [](https://travis-ci.org/recharts/recharts)
4 | [](https://coveralls.io/github/recharts/recharts?branch=master)
5 | [](http://badge.fury.io/js/recharts)
6 | [](https://www.npmjs.com/package/recharts)
7 | [](https://gitter.im/recharts/recharts?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
8 |
9 | ## Intro
10 |
11 | Recharts is a **Redefined** chart library built with [React](https://facebook.github.io/react/) and [D3](http://d3js.org).
12 |
13 | The main purpose of this library is to help you to write charts in React applications without any pain. Main principles of Recharts are:
14 |
15 | 1. **Simply** deploy with React components
16 | 1. **Native** SVG support, lightweight depending only on some D3 submodules
17 | 1. **Declarative** components, components of charts are purely presentational
18 |
19 | ## Examples
20 |
21 | ```jsx
22 |
28 |
29 |
30 |
31 |
32 |
33 |
34 | ```
35 |
36 | All the components of Recharts are clearly separated. The lineChart is composed of x axis, tooltip, grid, and line items, and each of them is an independent React Component. The clear separation and composition of components is one of the principle Recharts follows.
37 |
38 | ## Module Formats
39 |
40 | - [babel-plugin-recharts](https://github.com/recharts/babel-plugin-recharts) A simple transform to cherry-pick Recharts modules so you don’t have to.
41 |
42 | ## Contribution
43 |
44 | We'd love :heart: to hear what you think we should build. Please create an issue to write your usage or ideas.
45 |
46 | We are looking for like-minded people who share the same idea about Recharts. The goal of this project is create a more flexible charting library for the React community.
47 |
48 | ## License
49 |
50 | [MIT](http://opensource.org/licenses/MIT)
51 |
52 | Copyright (c) 2015-2016 Recharts Group
53 |
--------------------------------------------------------------------------------
/src/vendor/recharts/demo/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | plugins: [
3 | "transform-export-extensions",
4 | "transform-decorators-legacy",
5 | "transform-class-properties",
6 | "transform-object-rest-spread",
7 | "transform-function-bind",
8 | ],
9 | presets: ["es2015", "react"]
10 | }
11 |
--------------------------------------------------------------------------------
/src/vendor/recharts/demo/component/BrushDemo.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { Surface, Brush } from 'recharts';
3 |
4 | export default React.createClass({
5 | render () {
6 | let data = [
7 | '2015-10-01',
8 | '2015-10-02',
9 | '2015-10-03',
10 | '2015-10-04',
11 | '2015-10-05',
12 | '2015-10-06',
13 | '2015-10-07',
14 | '2015-10-08',
15 | '2015-10-09',
16 | '2015-10-10',
17 | '2015-10-11',
18 | '2015-10-12',
19 | '2015-10-13',
20 | '2015-10-14',
21 | '2015-10-15',
22 | '2015-10-16',
23 | '2015-10-17',
24 | '2015-10-18',
25 | '2015-10-19',
26 | '2015-10-20',
27 | '2015-10-21',
28 | '2015-10-22',
29 | '2015-10-23',
30 | '2015-10-24',
31 | '2015-10-25',
32 | '2015-10-26',
33 | '2015-10-27',
34 | '2015-10-28',
35 | '2015-10-29',
36 | '2015-10-30'
37 | ];
38 |
39 | return (
40 |
41 |
42 |
43 | );
44 | }
45 | });
46 |
47 |
--------------------------------------------------------------------------------
/src/vendor/recharts/demo/component/CartesianAxis.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { Surface, CartesianAxis } from 'recharts';
3 |
4 | export default React.createClass({
5 | render () {
6 | let ticks = [
7 | { value: 10, coord: 50 },
8 | { value: 1000, coord: 100 },
9 | { value: 20, coord: 150 },
10 | { value: 40, coord: 200 },
11 | { value: 90, coord: 250 }
12 | ];
13 |
14 | return (
15 |
16 |
24 |
32 |
40 |
48 |
49 | );
50 | }
51 | });
52 |
53 |
54 |
--------------------------------------------------------------------------------
/src/vendor/recharts/demo/component/CartesianGrid.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { Surface, CartesianGrid } from 'recharts';
3 |
4 | export default React.createClass({
5 | render () {
6 | let horizontalPoints = [10, 20, 30, 100, 400];
7 | let verticalPoints = [100, 200, 300, 400];
8 |
9 | return (
10 |
11 |
17 |
18 | );
19 | }
20 | });
21 |
22 |
--------------------------------------------------------------------------------
/src/vendor/recharts/demo/component/ComposedChart.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { ResponsiveContainer, ComposedChart, Line, Bar, Area, XAxis, YAxis,
3 | ReferenceLine, ReferenceDot, Tooltip, Legend, CartesianGrid, Brush } from 'recharts';
4 |
5 | const data = [
6 | { name: 'Page A', uv: 590, pv: 800, amt: 1400 },
7 | { name: 'Page B', uv: 868, pv: 967, amt: 1506 },
8 | { name: 'Page C', uv: 1397, pv: 1098, amt: 989 },
9 | { name: 'Page D', uv: 1480, pv: 1200, amt: 1228 },
10 | { name: 'Page E', uv: 1520, pv: 1108, amt: 1100 },
11 | { name: 'Page F', uv: 1400, pv: 680, amt: 1700 },
12 | ];
13 |
14 | export default React.createClass({
15 | displayName: 'ComposedChartDemo',
16 |
17 | render () {
18 | return (
19 |
20 |
A simple ComposedChart of Line, Bar, Area
21 |
22 |
23 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
A simple ComposedChart of Line, Bar
39 |
40 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
A vertical ComposedChart of Line, Bar
53 |
54 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 | );
68 | }
69 | });
70 |
--------------------------------------------------------------------------------
/src/vendor/recharts/demo/component/Curve.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { Surface, Curve, Layer } from 'recharts';
3 | import { curveBundle, curveCardinal, curveCardinalClosed, curveCardinalOpen,
4 | curveCatmullRomOpen } from 'd3-shape';
5 | import { scaleOrdinal, schemeCategory10 } from 'd3-scale';
6 |
7 | export default React.createClass({
8 | render () {
9 | const points = [
10 | { x: 10, y: 40 },
11 | { x: 50, y: 150 },
12 | { x: 90, y: 60 },
13 | { x: 130, y: 180 },
14 | { x: 170, y: 50 }
15 | ];
16 | const scale = scaleOrdinal(schemeCategory10);
17 | const ticks = [0, 0.25, 0.5, 0.75, 1];
18 |
19 | return (
20 |
21 |
22 | curveCardinalClosed
23 | {
24 | ticks.map((entry, index) => (
25 |
26 |
32 |
33 | {`curveCardinalClosed.tension(${entry})`}
34 |
35 |
36 | ))
37 | }
38 |
39 | {
40 | points.map((entry, index) => (
41 |
42 | ))
43 | }
44 |
45 |
46 |
47 | curveCatmullRomOpen
48 | {
49 | ticks.map((entry, index) => (
50 |
51 |
57 |
58 | {`curveCatmullRomOpen.alpha(${entry})`}
59 |
60 |
61 | ))
62 | }
63 |
64 | {
65 | points.map((entry, index) => (
66 |
67 | ))
68 | }
69 |
70 |
71 |
72 | curveBundle
73 | {
74 | ticks.map((entry, index) => (
75 |
76 |
82 |
83 | {`curveBundle.beta(${entry})`}
84 |
85 |
86 | ))
87 | }
88 |
89 | {
90 | points.map((entry, index) => (
91 |
92 | ))
93 | }
94 |
95 |
96 | );
97 | }
98 | });
99 |
100 |
101 |
--------------------------------------------------------------------------------
/src/vendor/recharts/demo/component/CustomLineDot.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 |
3 | export default React.createClass({
4 | render() {
5 | const { cx, cy, stroke, payload } = this.props;
6 |
7 | if (cx !== +cx || cy !== +cy) { return null; }
8 |
9 | if (payload.value > 250) {
10 | return (
11 |
14 | );
15 | }
16 |
17 | return (
18 |
21 | );
22 | }
23 | });
24 |
--------------------------------------------------------------------------------
/src/vendor/recharts/demo/component/DemoRadarItem.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { Dot, Polygon } from 'recharts';
3 |
4 | const RADIAN = Math.PI / 180;
5 |
6 | const DemoRadarItem = ({ radar }) => {
7 | const { radius, cx, cy, innerRadius, outerRadius, startAngle, clockWise } = radar;
8 | const sign = clockWise ? -1 : 1;
9 | const angleInterval = 360 / radius.length;
10 |
11 | const points = radar.radius.map((v, i) => ({
12 | x: cx + Math.cos(-(startAngle + i * sign * angleInterval) * RADIAN) * v,
13 | y: cy + Math.sin(-(startAngle + i * sign * angleInterval) * RADIAN) * v,
14 | }));
15 |
16 | return (
17 |
18 |
25 | {
26 | points.map((v, i) => {
27 | return ;
28 | })
29 | }
30 |
31 | );
32 | };
33 |
34 | export default DemoRadarItem;
35 |
--------------------------------------------------------------------------------
/src/vendor/recharts/demo/component/DemoSankeyLink.js:
--------------------------------------------------------------------------------
1 | import React, { PropTypes, Component } from 'react';
2 | import { Tooltip, Layer } from 'recharts';
3 |
4 | class DemoSankeyLink extends Component {
5 | static propTypes = {
6 | sourceX: PropTypes.number,
7 | targetX: PropTypes.number,
8 | sourceY: PropTypes.number,
9 | targetY: PropTypes.number,
10 | sourceControlX: PropTypes.number,
11 | targetControlX: PropTypes.number,
12 | sourceRelativeY: PropTypes.number,
13 | targetRelativeY: PropTypes.number,
14 | linkWidth: PropTypes.number,
15 | index: PropTypes.number,
16 | }
17 |
18 | state = {
19 | fill: 'url(#linkGradient)',
20 | }
21 |
22 | render() {
23 | const { sourceX, targetX,
24 | sourceY, targetY,
25 | sourceControlX, targetControlX,
26 | sourceRelativeY, targetRelativeY,
27 | linkWidth,
28 | index,
29 | } = this.props;
30 | const { fill } = this.state;
31 |
32 | return (
33 |
34 | { this.setState({ fill: 'rgba(0, 136, 254, 0.5)' }); }}
49 | onMouseLeave={() => { this.setState({ fill: 'url(#linkGradient)' }); }}
50 | />
51 |
52 | );
53 | }
54 | }
55 |
56 | export default DemoSankeyLink;
57 |
--------------------------------------------------------------------------------
/src/vendor/recharts/demo/component/DemoSankeyNode.js:
--------------------------------------------------------------------------------
1 | import React, { PropTypes, Component } from 'react';
2 | import { Rectangle, Layer } from 'recharts';
3 |
4 | function DemoSankeyNode({ x, y, width, height, index, payload, containerWidth}) {
5 | const isOut = x + width + 6 > containerWidth;
6 | return (
7 |
8 |
12 | {payload.name}
19 | {payload.value + 'k'}
27 |
28 | );
29 | }
30 |
31 | export default DemoSankeyNode;
32 |
--------------------------------------------------------------------------------
/src/vendor/recharts/demo/component/DemoTreemapItem.js:
--------------------------------------------------------------------------------
1 | import React, { PropTypes, Component } from 'react';
2 |
3 | class DemoTreemapItem extends Component {
4 | static displayName = 'DemoTreemapItem';
5 |
6 | static propTypes = {
7 | root: PropTypes.object,
8 | depth: PropTypes.number,
9 | x: PropTypes.number,
10 | y: PropTypes.number,
11 | width: PropTypes.number,
12 | height: PropTypes.number,
13 | index: PropTypes.number,
14 | payload: PropTypes.object,
15 | bgColors: PropTypes.arrayOf(PropTypes.string),
16 | };
17 |
18 | static defaultProps = {};
19 |
20 | constructor(props) {
21 | super(props);
22 | }
23 |
24 | render() {
25 | const { root, depth, x, y, width, height, index, rank, name, bgColors } = this.props;
26 |
27 | return (
28 |
29 |
39 | {
40 | depth === 1 ? (
41 |
49 | {name}
50 | )
51 | : null
52 | }
53 | {
54 | depth === 1 ?
55 |
63 | {index + 1}
64 |
65 | : null
66 | }
67 |
68 | );
69 | }
70 | }
71 |
72 | export default DemoTreemapItem;
73 |
--------------------------------------------------------------------------------
/src/vendor/recharts/demo/component/Legend.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { Surface, Legend } from 'recharts';
3 |
4 | const data = [
5 | { value: 'Apple', color: '#ff7300' },
6 | { value: 'Samsung', color: '#bb7300' },
7 | { value: 'Huawei', color: '#887300' },
8 | { value: 'Sony', color: '#667300' },
9 | ];
10 |
11 | const data2 = [
12 | { value: 'Apple', type: 'scatter', color: '#ff7300' },
13 | { value: 'Samsung', type: 'scatter', color: '#bb7300' },
14 | { value: 'Huawei', type: 'scatter', color: '#bb0067' },
15 | { value: 'Sony', type: 'scatter', color: '#167300' },
16 | ];
17 |
18 | const data3 = [
19 | { value: 'Apple', type: 'line', color: '#ff7300' },
20 | { value: 'Samsung', type: 'line', color: '#bb7300' },
21 | { value: 'Huawei', type: 'line', color: '#bb7300' },
22 | { value: 'Sony', type: 'line', color: '#ff7812' },
23 | ];
24 |
25 | export default React.createClass({
26 | render () {
27 | return (
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 | );
42 | }
43 | });
44 |
45 |
--------------------------------------------------------------------------------
/src/vendor/recharts/demo/component/Pie.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { Surface, Pie } from 'recharts';
3 |
4 | const data = [
5 | { name: 'iphone4', value: 120, fill: '#ff7300' },
6 | { name: 'iphone4s', value: 500, fill: '#e5671a' },
7 | { name: 'iphone5', value: 600, fill: '#907213' }
8 | ];
9 |
10 | export default React.createClass({
11 | displayName: 'PieDemo',
12 |
13 | render () {
14 | return (
15 |
16 |
17 |
18 |
19 | );
20 | }
21 | });
22 |
23 |
24 |
--------------------------------------------------------------------------------
/src/vendor/recharts/demo/component/PolarAngleAxis.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import {Surface, PolarAngleAxis} from 'recharts';
3 |
4 | const ticks = [
5 | { value: '100', angle: 20 },
6 | { value: '200', angle: 80 },
7 | { value: '300', angle: 120 },
8 | { value: '400', angle: 180 },
9 | { value: '500', angle: 240 },
10 | { value: '600', angle: 290 },
11 | ];
12 |
13 | export default React.createClass({
14 | render () {
15 | return (
16 |
17 |
23 |
24 | );
25 | }
26 | });
27 |
--------------------------------------------------------------------------------
/src/vendor/recharts/demo/component/PolarGrid.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { Surface, PolarGrid } from 'recharts';
3 |
4 | export default React.createClass({
5 | render () {
6 | const polarAngles = [0, 30, 60, 90, 145, 180, 200, 270, 300];
7 | const polarRadius = [10, 20, 40, 80];
8 |
9 | return (
10 |
11 |
21 |
22 | );
23 | }
24 | });
25 |
26 |
--------------------------------------------------------------------------------
/src/vendor/recharts/demo/component/PolarRadiusAxis.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { Surface, PolarRadiusAxis } from 'recharts';
3 |
4 | export default React.createClass({
5 | render () {
6 | const ticks = [
7 | { value: '100', radius: 50 },
8 | { value: '200', radius: 100 },
9 | { value: '300', radius: 150 },
10 | { value: '400', radius: 200 },
11 | { value: '500', radius: 250 },
12 | { value: '600', radius: 300 },
13 | ];
14 |
15 | return (
16 |
17 |
23 |
24 | );
25 | }
26 | });
27 |
28 |
--------------------------------------------------------------------------------
/src/vendor/recharts/demo/component/RadarChart.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { Surface, Radar, RadarChart, PolarGrid, Legend, Tooltip,
3 | PolarAngleAxis, PolarRadiusAxis, ResponsiveContainer } from 'recharts';
4 | import DemoRadarItem from './DemoRadarItem';
5 | import { changeNumberOfData } from './utils';
6 |
7 | const data = [
8 | { subject: 'Math', A: 120, B: 110 },
9 | { subject: 'Chinese', A: 98, B: 130 },
10 | { subject: 'English', A: 86, B: 130 },
11 | { subject: 'Geography', A: 99, B: 100 },
12 | { subject: 'Physics', A: 85, B: 90 },
13 | { subject: 'History', A: 65, B: 85 },
14 | ];
15 |
16 | const initilaState = { data };
17 |
18 | class RadarChartDemo extends React.Component {
19 | constructor() {
20 | super();
21 |
22 | this.state = initilaState;
23 | this.handleChangeData = this.handleChangeData.bind(this);
24 | }
25 |
26 | handleChangeData() {
27 | this.setState(() => _.mapValues(initilaState, changeNumberOfData));
28 | }
29 |
30 | render() {
31 | const { data } = this.state;
32 |
33 | return (
34 |
35 |
40 | change data
41 |
42 |
43 |
A simple RadarChart
44 |
45 |
46 |
47 |
48 |
49 |
50 |
A RadarChart of two students' score
51 |
52 |
58 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
RadarChart wrapped by ResponsiveContainer
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 | );
85 | }
86 | }
87 |
88 |
89 | export default RadarChartDemo;
90 |
--------------------------------------------------------------------------------
/src/vendor/recharts/demo/component/RadialBarChart.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { RadialBarChart, RadialBar, Cell, Legend, Tooltip, ResponsiveContainer } from 'recharts';
3 | import { changeNumberOfData } from './utils';
4 | import { scaleOrdinal, schemeCategory10 } from 'd3-scale';
5 |
6 | const colors = scaleOrdinal(schemeCategory10).range();
7 |
8 | const data = [
9 | { name: '18-24', uv: 31.47, pv: 2400, fill: '#8884d8' },
10 | { name: '25-29', uv: 26.69, pv: 4500, fill: '#83a6ed' },
11 | { name: '30-34', uv: 15.69, pv: -1398, fill: '#8dd1e1' },
12 | { name: '35-39', uv: 8.22, pv: 2800, fill: '#82ca9d' },
13 | { name: '40-49', uv: 8.63, pv: 1908, fill: '#a4de6c' },
14 | { name: '50+', uv: 2.63, pv: -2800, fill: '#d0ed57' },
15 | { name: 'unknow', uv: 6.67, pv: 4800, fill: '#ffc658' },
16 | ];
17 |
18 | const initilaState = { data };
19 |
20 | export default React.createClass({
21 | getInitialState() {
22 | return initilaState;
23 | },
24 |
25 | handleChangeData() {
26 | this.setState(() => _.mapValues(initilaState, changeNumberOfData));
27 | },
28 |
29 | render () {
30 | const { data } = this.state;
31 | const style = {
32 | lineHeight: '24px',
33 | left: 300,
34 | };
35 |
36 | const label = {
37 | orientation: 'outer'
38 | };
39 |
40 | return (
41 |
42 |
47 | change data
48 |
49 |
50 |
RadialBarChart
51 |
52 |
53 |
54 | {
55 | data.map((entry, index) => (
56 |
57 | ))
58 | }
59 | |
60 |
61 |
62 |
63 |
64 |
65 |
RadialBarChart with positive and negative value
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
RadialBarChart wrapped by ResponsiveContainer
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 | );
85 | }
86 | });
87 |
88 |
--------------------------------------------------------------------------------
/src/vendor/recharts/demo/component/Rectangle.js:
--------------------------------------------------------------------------------
1 | import React, { Component } from 'react';
2 | import { Surface, Rectangle } from 'recharts';
3 |
4 | class RectangleDemo extends Component {
5 | state = {
6 | x: 50,
7 | y: 50,
8 | width: 80,
9 | height: 100,
10 | };
11 |
12 | changeSize() {
13 | this.setState({
14 | x: Math.random() * 50,
15 | y: Math.random() * 50,
16 | width: Math.random() * 400,
17 | height: Math.random() * 400,
18 | });
19 | }
20 |
21 | render() {
22 | const { width, height, x, y } = this.state;
23 |
24 | return (
25 |
46 | );
47 | }
48 | }
49 |
50 | export default RectangleDemo;
51 |
--------------------------------------------------------------------------------
/src/vendor/recharts/demo/component/Sector.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { Surface, Sector } from 'recharts';
3 |
4 | export default React.createClass({
5 | render () {
6 | return (
7 |
8 |
9 |
10 | );
11 | }
12 | });
13 |
14 |
15 |
--------------------------------------------------------------------------------
/src/vendor/recharts/demo/component/index.js:
--------------------------------------------------------------------------------
1 | import Pie from './Pie';
2 |
3 | import CartesianAxis from './CartesianAxis';
4 | import CartesianGrid from './CartesianGrid';
5 | import Legend from './Legend';
6 | import PolarGrid from './PolarGrid';
7 | import PolarRadiusAxis from './PolarRadiusAxis';
8 | import PolarAngleAxis from './PolarAngleAxis';
9 | import Brush from './BrushDemo';
10 | import Text from './TextDemo';
11 |
12 | import Curve from './Curve';
13 | import Rectangle from './Rectangle';
14 | import Sector from './Sector';
15 |
16 | import LineChart from './LineChart';
17 | import AreaChart from './AreaChart';
18 | import BarChart from './BarChart';
19 | import ComposedChart from './ComposedChart';
20 | import PieChart from './PieChart';
21 | import ScatterChart from './ScatterChart';
22 | import RadarChart from './RadarChart';
23 | import RadialBarChart from './RadialBarChart';
24 | import Treemap from './Treemap';
25 | import Sankey from './Sankey';
26 |
27 | export default {
28 | chartWrapper: {
29 | LineChart,
30 | AreaChart,
31 | BarChart,
32 | ComposedChart,
33 | ScatterChart,
34 | PieChart,
35 | RadarChart,
36 | RadialBarChart,
37 | Treemap,
38 | Sankey,
39 | },
40 |
41 | polar: {
42 | Pie,
43 | PolarRadiusAxis,
44 | PolarAngleAxis,
45 | PolarGrid,
46 | },
47 |
48 | cartesian: {
49 | Brush,
50 | CartesianAxis,
51 | CartesianGrid,
52 | },
53 |
54 | component: {
55 | Legend,
56 | Text,
57 | },
58 |
59 | shape: {
60 | Curve,
61 | Rectangle,
62 | Sector,
63 | },
64 | };
65 |
--------------------------------------------------------------------------------
/src/vendor/recharts/demo/component/utils.js:
--------------------------------------------------------------------------------
1 | /*
2 | * change number in data
3 | */
4 |
5 | const randomChangeArray = (array) => {
6 |
7 | };
8 |
9 | export function changeNumberOfData(data) {
10 | if (Array.isArray(data)) {
11 | return data.map(changeNumberOfData);
12 | }
13 |
14 | if (typeof data === 'object') {
15 | return _.mapValues(data, val => {
16 | if (typeof val === 'number') {
17 | return parseInt(val * Math.random() * 2, 10);
18 | }
19 |
20 | return changeNumberOfData(val);
21 | });
22 | }
23 |
24 | return data;
25 | }
26 |
--------------------------------------------------------------------------------
/src/vendor/recharts/demo/container/App.js:
--------------------------------------------------------------------------------
1 | import React, { PropTypes } from 'react';
2 | import { Link } from 'react-router';
3 | import components from '../component/index';
4 |
5 | const App = React.createClass({
6 | propTypes: {
7 | params: PropTypes.object,
8 | location: PropTypes.object,
9 | },
10 |
11 | renderList() {
12 | const items = Object.keys(components).map(key => {
13 | const group = components[key];
14 | const list = Object.keys(group).map(c => {
15 | const entry = group[c];
16 |
17 | return (
18 |
19 | {c}
20 |
21 | );
22 | });
23 |
24 | return (
25 |
31 | );
32 | });
33 |
34 | return (
35 |
36 |
components
37 | {items}
38 |
39 | );
40 | },
41 |
42 | renderPageDetail() {
43 | const { params, location } = this.props;
44 | const { query } = location;
45 | const { group, page } = query;
46 |
47 | return (
48 |
49 |
Back to homepage
50 |
{page}
51 | {components[group] && components[group][page] ? React.createElement(components[group][page]) : null}
52 |
53 | );
54 | },
55 |
56 | render() {
57 | const { location, params } = this.props;
58 |
59 | if (!location.query || !location.query.page) {
60 | return this.renderList();
61 | }
62 |
63 | return this.renderPageDetail();
64 | },
65 | });
66 |
67 | export default App;
68 |
--------------------------------------------------------------------------------
/src/vendor/recharts/demo/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | Recharts Demo
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/src/vendor/recharts/demo/index.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import ReactDOM from 'react-dom';
3 | import { Router, Route, browserHistory } from 'react-router';
4 | import App from './container/App';
5 |
6 | ReactDOM.render((
7 |
8 |
9 |
10 | ), document.getElementById('root'));
11 |
--------------------------------------------------------------------------------
/src/vendor/recharts/demo/webpack.config.js:
--------------------------------------------------------------------------------
1 | var path = require('path');
2 | var webpack = require('webpack');
3 |
4 | module.exports = {
5 | context: __dirname,
6 | debug: true,
7 | devtool: '#inline-source-map',
8 | entry: [
9 | './index.js',
10 | ],
11 | output: {
12 | path: __dirname + '/build',
13 | filename: 'bundle.js',
14 | },
15 | plugins: [
16 | // new webpack.HotModuleReplacementPlugin(),
17 | // new webpack.NoErrorsPlugin()
18 | ],
19 | resolve: {
20 | alias: {
21 | 'recharts': path.join(__dirname, '..', 'src/index.js'),
22 | },
23 | extensions: ['', '.js'],
24 | },
25 | module: {
26 | loaders: [{
27 | test: /\.js$/,
28 | loaders: ['react-hot', 'babel-loader'],
29 | include: [
30 | __dirname,
31 | path.join(__dirname, '..', 'src'),
32 | ],
33 | }],
34 | },
35 | };
36 |
--------------------------------------------------------------------------------
/src/vendor/recharts/es6/cartesian/ZAxis.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | Object.defineProperty(exports, "__esModule", {
4 | value: true
5 | });
6 |
7 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
8 |
9 | var _class, _class2, _temp; /**
10 | * @fileOverview Z Axis
11 | */
12 |
13 |
14 | var _react = require('react');
15 |
16 | var _react2 = _interopRequireDefault(_react);
17 |
18 | var _PureRender = require('../util/PureRender');
19 |
20 | var _PureRender2 = _interopRequireDefault(_PureRender);
21 |
22 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23 |
24 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
25 |
26 | function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
27 |
28 | function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
29 |
30 | var ZAxis = (0, _PureRender2.default)(_class = (_temp = _class2 = function (_Component) {
31 | _inherits(ZAxis, _Component);
32 |
33 | function ZAxis() {
34 | _classCallCheck(this, ZAxis);
35 |
36 | return _possibleConstructorReturn(this, (ZAxis.__proto__ || Object.getPrototypeOf(ZAxis)).apply(this, arguments));
37 | }
38 |
39 | _createClass(ZAxis, [{
40 | key: 'render',
41 | value: function render() {
42 | return null;
43 | }
44 | }]);
45 |
46 | return ZAxis;
47 | }(_react.Component), _class2.displayName = 'ZAxis', _class2.propTypes = {
48 | // The name of data displayed in the axis
49 | name: _react.PropTypes.oneOfType([_react.PropTypes.string, _react.PropTypes.number]),
50 | // The unit of data displayed in the axis
51 | unit: _react.PropTypes.oneOfType([_react.PropTypes.string, _react.PropTypes.number]),
52 | // The unique id of z-axis
53 | zAxisId: _react.PropTypes.oneOfType([_react.PropTypes.string, _react.PropTypes.number]),
54 | // The key of data displayed in the axis
55 | dataKey: _react.PropTypes.oneOfType([_react.PropTypes.string, _react.PropTypes.number]),
56 | // The range of axis
57 | range: _react.PropTypes.arrayOf(_react.PropTypes.number)
58 | }, _class2.defaultProps = {
59 | zAxisId: 0,
60 | range: [64, 64]
61 | }, _temp)) || _class;
62 |
63 | exports.default = ZAxis;
--------------------------------------------------------------------------------
/src/vendor/recharts/es6/component/Background.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | Object.defineProperty(exports, "__esModule", {
4 | value: true
5 | });
6 |
7 | var _react = require('react');
8 |
9 | var _react2 = _interopRequireDefault(_react);
10 |
11 | var _classnames = require('classnames');
12 |
13 | var _classnames2 = _interopRequireDefault(_classnames);
14 |
15 | var _PureRender = require('../util/PureRender');
16 |
17 | var _PureRender2 = _interopRequireDefault(_PureRender);
18 |
19 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20 |
21 | function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } /**
22 | * @fileOverview Background
23 | */
24 |
25 |
26 | var propTypes = {
27 | x: _react.PropTypes.number,
28 | y: _react.PropTypes.number,
29 | width: _react.PropTypes.number,
30 | height: _react.PropTypes.number,
31 | strokeWidth: _react.PropTypes.number,
32 | stroke: _react.PropTypes.string,
33 | fill: _react.PropTypes.string,
34 | className: _react.PropTypes.string
35 | };
36 |
37 | function Background(props) {
38 | var className = props.className;
39 |
40 | var others = _objectWithoutProperties(props, ['className']);
41 |
42 | return _react2.default.createElement(
43 | 'g',
44 | { className: (0, _classnames2.default)('recharts-background', className) },
45 | _react2.default.createElement('rect', others)
46 | );
47 | }
48 |
49 | Background.propTypes = propTypes;
50 |
51 | exports.default = Background;
--------------------------------------------------------------------------------
/src/vendor/recharts/es6/component/Cell.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | Object.defineProperty(exports, "__esModule", {
4 | value: true
5 | });
6 |
7 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
8 |
9 | var _class, _class2, _temp; /**
10 | * @fileOverview Cross
11 | */
12 |
13 |
14 | var _react = require('react');
15 |
16 | var _react2 = _interopRequireDefault(_react);
17 |
18 | var _PureRender = require('../util/PureRender');
19 |
20 | var _PureRender2 = _interopRequireDefault(_PureRender);
21 |
22 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23 |
24 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
25 |
26 | function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
27 |
28 | function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
29 |
30 | var Cell = (0, _PureRender2.default)(_class = (_temp = _class2 = function (_Component) {
31 | _inherits(Cell, _Component);
32 |
33 | function Cell() {
34 | _classCallCheck(this, Cell);
35 |
36 | return _possibleConstructorReturn(this, (Cell.__proto__ || Object.getPrototypeOf(Cell)).apply(this, arguments));
37 | }
38 |
39 | _createClass(Cell, [{
40 | key: 'render',
41 | value: function render() {
42 | return null;
43 | }
44 | }]);
45 |
46 | return Cell;
47 | }(_react.Component), _class2.displayName = 'Cell', _temp)) || _class;
48 |
49 | exports.default = Cell;
--------------------------------------------------------------------------------
/src/vendor/recharts/es6/container/Layer.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | Object.defineProperty(exports, "__esModule", {
4 | value: true
5 | });
6 |
7 | var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
8 |
9 | var _react = require('react');
10 |
11 | var _react2 = _interopRequireDefault(_react);
12 |
13 | var _classnames = require('classnames');
14 |
15 | var _classnames2 = _interopRequireDefault(_classnames);
16 |
17 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
18 |
19 | function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } /**
20 | * @fileOverview Layer
21 | */
22 |
23 |
24 | var propTypes = {
25 | className: _react.PropTypes.string,
26 | children: _react.PropTypes.oneOfType([_react.PropTypes.arrayOf(_react.PropTypes.node), _react.PropTypes.node])
27 | };
28 |
29 | function Layer(props) {
30 | var children = props.children;
31 | var className = props.className;
32 |
33 | var others = _objectWithoutProperties(props, ['children', 'className']);
34 |
35 | var layerClass = (0, _classnames2.default)('recharts-layer', className);
36 |
37 | return _react2.default.createElement(
38 | 'g',
39 | _extends({ className: layerClass }, others),
40 | children
41 | );
42 | }
43 |
44 | Layer.propTypes = propTypes;
45 |
46 | exports.default = Layer;
--------------------------------------------------------------------------------
/src/vendor/recharts/es6/container/Surface.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | Object.defineProperty(exports, "__esModule", {
4 | value: true
5 | });
6 |
7 | var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
8 |
9 | var _react = require('react');
10 |
11 | var _react2 = _interopRequireDefault(_react);
12 |
13 | var _classnames = require('classnames');
14 |
15 | var _classnames2 = _interopRequireDefault(_classnames);
16 |
17 | var _ReactUtils = require('../util/ReactUtils');
18 |
19 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20 |
21 | function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } /**
22 | * @fileOverview Surface
23 | */
24 |
25 |
26 | var propTypes = {
27 | width: _react.PropTypes.number.isRequired,
28 | height: _react.PropTypes.number.isRequired,
29 | viewBox: _react.PropTypes.shape({
30 | x: _react.PropTypes.number,
31 | y: _react.PropTypes.number,
32 | width: _react.PropTypes.number,
33 | height: _react.PropTypes.number
34 | }),
35 | className: _react.PropTypes.string,
36 | style: _react.PropTypes.object,
37 | children: _react.PropTypes.oneOfType([_react.PropTypes.arrayOf(_react.PropTypes.node), _react.PropTypes.node])
38 | };
39 | function Surface(props) {
40 | var children = props.children;
41 | var width = props.width;
42 | var height = props.height;
43 | var viewBox = props.viewBox;
44 | var className = props.className;
45 | var style = props.style;
46 |
47 | var others = _objectWithoutProperties(props, ['children', 'width', 'height', 'viewBox', 'className', 'style']);
48 |
49 | var svgView = viewBox || { width: width, height: height, x: 0, y: 0 };
50 | var layerClass = (0, _classnames2.default)('recharts-surface', className);
51 | var attrs = (0, _ReactUtils.getPresentationAttributes)(others);
52 |
53 | return _react2.default.createElement(
54 | 'svg',
55 | _extends({}, attrs, {
56 | className: layerClass,
57 | width: width,
58 | height: height,
59 | style: style,
60 | viewBox: svgView.x + ' ' + svgView.y + ' ' + svgView.width + ' ' + svgView.height,
61 | version: '1.1'
62 | }),
63 | children
64 | );
65 | }
66 |
67 | Surface.propTypes = propTypes;
68 |
69 | exports.default = Surface;
--------------------------------------------------------------------------------
/src/vendor/recharts/es6/polyfill.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | /* eslint no-proto: 0 */
4 | var testObject = {};
5 |
6 | if (!(Object.setPrototypeOf || testObject.__proto__)) {
7 | (function () {
8 | var nativeGetPrototypeOf = Object.getPrototypeOf;
9 |
10 | Object.getPrototypeOf = function (object) {
11 | if (object.__proto__) {
12 | return object.__proto__;
13 | }
14 |
15 | return nativeGetPrototypeOf.call(Object, object);
16 | };
17 | })();
18 | }
--------------------------------------------------------------------------------
/src/vendor/recharts/es6/util/CssPrefixUtils.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | Object.defineProperty(exports, "__esModule", {
4 | value: true
5 | });
6 |
7 | var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
8 |
9 | function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
10 |
11 | var PREFIX_LIST = ['Webkit', 'Moz', 'O', 'ms'];
12 |
13 | var generatePrefixStyle = exports.generatePrefixStyle = function generatePrefixStyle(name, value) {
14 | if (!name) {
15 | return null;
16 | }
17 |
18 | var camelName = name.replace(/(\w)/, function (v) {
19 | return v.toUpperCase();
20 | });
21 | var result = PREFIX_LIST.reduce(function (res, entry) {
22 | return _extends({}, res, _defineProperty({}, entry + camelName, value));
23 | }, {});
24 |
25 | result[name] = value;
26 |
27 | return result;
28 | };
--------------------------------------------------------------------------------
/src/vendor/recharts/es6/util/Events.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | Object.defineProperty(exports, "__esModule", {
4 | value: true
5 | });
6 | exports.SYNC_EVENT = exports.eventCenter = undefined;
7 |
8 | var _events = require('events');
9 |
10 | var _events2 = _interopRequireDefault(_events);
11 |
12 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13 |
14 | var eventCenter = new _events2.default();
15 |
16 | if (eventCenter.setMaxListeners) {
17 | eventCenter.setMaxListeners(10);
18 | }
19 |
20 | exports.eventCenter = eventCenter;
21 | var SYNC_EVENT = exports.SYNC_EVENT = 'recharts.syncMouseEvents';
--------------------------------------------------------------------------------
/src/vendor/recharts/es6/util/LogUtils.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | Object.defineProperty(exports, "__esModule", {
4 | value: true
5 | });
6 | /* eslint no-console: 0 */
7 | var isDev = process.env.NODE_ENV !== 'production';
8 |
9 | var warn = exports.warn = function warn(condition, format, a, b, c, d, e, f) {
10 | if (isDev && typeof console !== 'undefined' && console.warn) {
11 | if (format === undefined) {
12 | console.warn('LogUtils requires an error message argument');
13 | }
14 |
15 | if (!condition) {
16 | if (format === undefined) {
17 | console.warn('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.');
18 | } else {
19 | (function () {
20 | var args = [a, b, c, d, e, f];
21 | var argIndex = 0;
22 |
23 | console.warn(format.replace(/%s/g, function () {
24 | return args[argIndex++];
25 | }));
26 | })();
27 | }
28 | }
29 | }
30 | };
--------------------------------------------------------------------------------
/src/vendor/recharts/es6/util/PolarUtils.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | Object.defineProperty(exports, "__esModule", {
4 | value: true
5 | });
6 | var RADIAN = Math.PI / 180;
7 |
8 | var polarToCartesian = exports.polarToCartesian = function polarToCartesian(cx, cy, radius, angle) {
9 | return {
10 | x: cx + Math.cos(-RADIAN * angle) * radius,
11 | y: cy + Math.sin(-RADIAN * angle) * radius
12 | };
13 | };
14 |
15 | var getMaxRadius = exports.getMaxRadius = function getMaxRadius(width, height) {
16 | var margin = arguments.length <= 2 || arguments[2] === undefined ? {
17 | top: 0, right: 0, bottom: 0, left: 0
18 | } : arguments[2];
19 | return Math.min(Math.abs(width - (margin.left || 0) - (margin.right || 0)), Math.abs(height - (margin.left || 0) - (margin.right || 0))) / 2;
20 | };
--------------------------------------------------------------------------------
/src/vendor/recharts/es6/util/PureRender.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | Object.defineProperty(exports, "__esModule", {
4 | value: true
5 | });
6 | exports.shallowEqual = undefined;
7 |
8 | var _isPlainObject2 = require('lodash/isPlainObject');
9 |
10 | var _isPlainObject3 = _interopRequireDefault(_isPlainObject2);
11 |
12 | var _isEqual2 = require('lodash/isEqual');
13 |
14 | var _isEqual3 = _interopRequireDefault(_isEqual2);
15 |
16 | var _isArray2 = require('lodash/isArray');
17 |
18 | var _isArray3 = _interopRequireDefault(_isArray2);
19 |
20 | var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };
21 |
22 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23 |
24 | function shallowEqual(objA, objB) {
25 | if (objA === objB) {
26 | return true;
27 | }
28 |
29 | if ((typeof objA === 'undefined' ? 'undefined' : _typeof(objA)) !== 'object' || objA === null || (typeof objB === 'undefined' ? 'undefined' : _typeof(objB)) !== 'object' || objB === null) {
30 | return false;
31 | }
32 |
33 | var keysA = Object.keys(objA);
34 | var keysB = Object.keys(objB);
35 |
36 | if (keysA.length !== keysB.length) {
37 | return false;
38 | }
39 |
40 | var bHasOwnProperty = hasOwnProperty.bind(objB);
41 | for (var i = 0; i < keysA.length; i++) {
42 | var keyA = keysA[i];
43 |
44 | if (objA[keyA] === objB[keyA]) {
45 | continue;
46 | }
47 |
48 | // special diff with Array or Object
49 | if ((0, _isArray3.default)(objA[keyA])) {
50 | if (!(0, _isArray3.default)(objB[keyA]) || objA[keyA].length !== objB[keyA].length) {
51 | return false;
52 | } else if (!(0, _isEqual3.default)(objA[keyA], objB[keyA])) {
53 | return false;
54 | }
55 | } else if ((0, _isPlainObject3.default)(objA[keyA])) {
56 | if (!(0, _isPlainObject3.default)(objB[keyA]) || !(0, _isEqual3.default)(objA[keyA], objB[keyA])) {
57 | return false;
58 | }
59 | } else if (!bHasOwnProperty(keysA[i]) || objA[keysA[i]] !== objB[keysA[i]]) {
60 | return false;
61 | }
62 | }
63 |
64 | return true;
65 | }
66 |
67 | function shallowCompare(instance, nextProps, nextState) {
68 | return !shallowEqual(instance.props, nextProps) || !shallowEqual(instance.state, nextState);
69 | }
70 |
71 | function shouldComponentUpdate(nextProps, nextState) {
72 | return shallowCompare(this, nextProps, nextState);
73 | }
74 | /* eslint-disable no-param-reassign */
75 | function pureRenderDecorator(component) {
76 | component.prototype.shouldComponentUpdate = shouldComponentUpdate;
77 | }
78 | exports.shallowEqual = shallowEqual;
79 | exports.default = pureRenderDecorator;
--------------------------------------------------------------------------------
/src/vendor/recharts/lib/cartesian/ZAxis.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | Object.defineProperty(exports, "__esModule", {
4 | value: true
5 | });
6 |
7 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
8 |
9 | var _class, _class2, _temp; /**
10 | * @fileOverview Z Axis
11 | */
12 |
13 |
14 | var _react = require('react');
15 |
16 | var _react2 = _interopRequireDefault(_react);
17 |
18 | var _PureRender = require('../util/PureRender');
19 |
20 | var _PureRender2 = _interopRequireDefault(_PureRender);
21 |
22 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23 |
24 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
25 |
26 | function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
27 |
28 | function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
29 |
30 | var ZAxis = (0, _PureRender2.default)(_class = (_temp = _class2 = function (_Component) {
31 | _inherits(ZAxis, _Component);
32 |
33 | function ZAxis() {
34 | _classCallCheck(this, ZAxis);
35 |
36 | return _possibleConstructorReturn(this, (ZAxis.__proto__ || Object.getPrototypeOf(ZAxis)).apply(this, arguments));
37 | }
38 |
39 | _createClass(ZAxis, [{
40 | key: 'render',
41 | value: function render() {
42 | return null;
43 | }
44 | }]);
45 |
46 | return ZAxis;
47 | }(_react.Component), _class2.displayName = 'ZAxis', _class2.propTypes = {
48 | // The name of data displayed in the axis
49 | name: _react.PropTypes.oneOfType([_react.PropTypes.string, _react.PropTypes.number]),
50 | // The unit of data displayed in the axis
51 | unit: _react.PropTypes.oneOfType([_react.PropTypes.string, _react.PropTypes.number]),
52 | // The unique id of z-axis
53 | zAxisId: _react.PropTypes.oneOfType([_react.PropTypes.string, _react.PropTypes.number]),
54 | // The key of data displayed in the axis
55 | dataKey: _react.PropTypes.oneOfType([_react.PropTypes.string, _react.PropTypes.number]),
56 | // The range of axis
57 | range: _react.PropTypes.arrayOf(_react.PropTypes.number)
58 | }, _class2.defaultProps = {
59 | zAxisId: 0,
60 | range: [64, 64]
61 | }, _temp)) || _class;
62 |
63 | exports.default = ZAxis;
--------------------------------------------------------------------------------
/src/vendor/recharts/lib/component/Background.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | Object.defineProperty(exports, "__esModule", {
4 | value: true
5 | });
6 |
7 | var _react = require('react');
8 |
9 | var _react2 = _interopRequireDefault(_react);
10 |
11 | var _classnames = require('classnames');
12 |
13 | var _classnames2 = _interopRequireDefault(_classnames);
14 |
15 | var _PureRender = require('../util/PureRender');
16 |
17 | var _PureRender2 = _interopRequireDefault(_PureRender);
18 |
19 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20 |
21 | function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } /**
22 | * @fileOverview Background
23 | */
24 |
25 |
26 | var propTypes = {
27 | x: _react.PropTypes.number,
28 | y: _react.PropTypes.number,
29 | width: _react.PropTypes.number,
30 | height: _react.PropTypes.number,
31 | strokeWidth: _react.PropTypes.number,
32 | stroke: _react.PropTypes.string,
33 | fill: _react.PropTypes.string,
34 | className: _react.PropTypes.string
35 | };
36 |
37 | function Background(props) {
38 | var className = props.className;
39 |
40 | var others = _objectWithoutProperties(props, ['className']);
41 |
42 | return _react2.default.createElement(
43 | 'g',
44 | { className: (0, _classnames2.default)('recharts-background', className) },
45 | _react2.default.createElement('rect', others)
46 | );
47 | }
48 |
49 | Background.propTypes = propTypes;
50 |
51 | exports.default = Background;
--------------------------------------------------------------------------------
/src/vendor/recharts/lib/component/Cell.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | Object.defineProperty(exports, "__esModule", {
4 | value: true
5 | });
6 |
7 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
8 |
9 | var _class, _class2, _temp; /**
10 | * @fileOverview Cross
11 | */
12 |
13 |
14 | var _react = require('react');
15 |
16 | var _react2 = _interopRequireDefault(_react);
17 |
18 | var _PureRender = require('../util/PureRender');
19 |
20 | var _PureRender2 = _interopRequireDefault(_PureRender);
21 |
22 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23 |
24 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
25 |
26 | function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
27 |
28 | function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
29 |
30 | var Cell = (0, _PureRender2.default)(_class = (_temp = _class2 = function (_Component) {
31 | _inherits(Cell, _Component);
32 |
33 | function Cell() {
34 | _classCallCheck(this, Cell);
35 |
36 | return _possibleConstructorReturn(this, (Cell.__proto__ || Object.getPrototypeOf(Cell)).apply(this, arguments));
37 | }
38 |
39 | _createClass(Cell, [{
40 | key: 'render',
41 | value: function render() {
42 | return null;
43 | }
44 | }]);
45 |
46 | return Cell;
47 | }(_react.Component), _class2.displayName = 'Cell', _temp)) || _class;
48 |
49 | exports.default = Cell;
--------------------------------------------------------------------------------
/src/vendor/recharts/lib/container/Layer.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | Object.defineProperty(exports, "__esModule", {
4 | value: true
5 | });
6 |
7 | var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
8 |
9 | var _react = require('react');
10 |
11 | var _react2 = _interopRequireDefault(_react);
12 |
13 | var _classnames = require('classnames');
14 |
15 | var _classnames2 = _interopRequireDefault(_classnames);
16 |
17 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
18 |
19 | function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } /**
20 | * @fileOverview Layer
21 | */
22 |
23 |
24 | var propTypes = {
25 | className: _react.PropTypes.string,
26 | children: _react.PropTypes.oneOfType([_react.PropTypes.arrayOf(_react.PropTypes.node), _react.PropTypes.node])
27 | };
28 |
29 | function Layer(props) {
30 | var children = props.children;
31 | var className = props.className;
32 |
33 | var others = _objectWithoutProperties(props, ['children', 'className']);
34 |
35 | var layerClass = (0, _classnames2.default)('recharts-layer', className);
36 |
37 | return _react2.default.createElement(
38 | 'g',
39 | _extends({ className: layerClass }, others),
40 | children
41 | );
42 | }
43 |
44 | Layer.propTypes = propTypes;
45 |
46 | exports.default = Layer;
--------------------------------------------------------------------------------
/src/vendor/recharts/lib/container/Surface.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | Object.defineProperty(exports, "__esModule", {
4 | value: true
5 | });
6 |
7 | var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
8 |
9 | var _react = require('react');
10 |
11 | var _react2 = _interopRequireDefault(_react);
12 |
13 | var _classnames = require('classnames');
14 |
15 | var _classnames2 = _interopRequireDefault(_classnames);
16 |
17 | var _ReactUtils = require('../util/ReactUtils');
18 |
19 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20 |
21 | function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } /**
22 | * @fileOverview Surface
23 | */
24 |
25 |
26 | var propTypes = {
27 | width: _react.PropTypes.number.isRequired,
28 | height: _react.PropTypes.number.isRequired,
29 | viewBox: _react.PropTypes.shape({
30 | x: _react.PropTypes.number,
31 | y: _react.PropTypes.number,
32 | width: _react.PropTypes.number,
33 | height: _react.PropTypes.number
34 | }),
35 | className: _react.PropTypes.string,
36 | style: _react.PropTypes.object,
37 | children: _react.PropTypes.oneOfType([_react.PropTypes.arrayOf(_react.PropTypes.node), _react.PropTypes.node])
38 | };
39 | function Surface(props) {
40 | var children = props.children;
41 | var width = props.width;
42 | var height = props.height;
43 | var viewBox = props.viewBox;
44 | var className = props.className;
45 | var style = props.style;
46 |
47 | var others = _objectWithoutProperties(props, ['children', 'width', 'height', 'viewBox', 'className', 'style']);
48 |
49 | var svgView = viewBox || { width: width, height: height, x: 0, y: 0 };
50 | var layerClass = (0, _classnames2.default)('recharts-surface', className);
51 | var attrs = (0, _ReactUtils.getPresentationAttributes)(others);
52 |
53 | return _react2.default.createElement(
54 | 'svg',
55 | _extends({}, attrs, {
56 | className: layerClass,
57 | width: width,
58 | height: height,
59 | style: style,
60 | viewBox: svgView.x + ' ' + svgView.y + ' ' + svgView.width + ' ' + svgView.height,
61 | version: '1.1'
62 | }),
63 | children
64 | );
65 | }
66 |
67 | Surface.propTypes = propTypes;
68 |
69 | exports.default = Surface;
--------------------------------------------------------------------------------
/src/vendor/recharts/lib/polyfill.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | /* eslint no-proto: 0 */
4 | var testObject = {};
5 |
6 | if (!(Object.setPrototypeOf || testObject.__proto__)) {
7 | (function () {
8 | var nativeGetPrototypeOf = Object.getPrototypeOf;
9 |
10 | Object.getPrototypeOf = function (object) {
11 | if (object.__proto__) {
12 | return object.__proto__;
13 | }
14 |
15 | return nativeGetPrototypeOf.call(Object, object);
16 | };
17 | })();
18 | }
--------------------------------------------------------------------------------
/src/vendor/recharts/lib/util/CssPrefixUtils.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | Object.defineProperty(exports, "__esModule", {
4 | value: true
5 | });
6 |
7 | var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
8 |
9 | function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
10 |
11 | var PREFIX_LIST = ['Webkit', 'Moz', 'O', 'ms'];
12 |
13 | var generatePrefixStyle = exports.generatePrefixStyle = function generatePrefixStyle(name, value) {
14 | if (!name) {
15 | return null;
16 | }
17 |
18 | var camelName = name.replace(/(\w)/, function (v) {
19 | return v.toUpperCase();
20 | });
21 | var result = PREFIX_LIST.reduce(function (res, entry) {
22 | return _extends({}, res, _defineProperty({}, entry + camelName, value));
23 | }, {});
24 |
25 | result[name] = value;
26 |
27 | return result;
28 | };
--------------------------------------------------------------------------------
/src/vendor/recharts/lib/util/Events.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | Object.defineProperty(exports, "__esModule", {
4 | value: true
5 | });
6 | exports.SYNC_EVENT = exports.eventCenter = undefined;
7 |
8 | var _events = require('events');
9 |
10 | var _events2 = _interopRequireDefault(_events);
11 |
12 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13 |
14 | var eventCenter = new _events2.default();
15 |
16 | if (eventCenter.setMaxListeners) {
17 | eventCenter.setMaxListeners(10);
18 | }
19 |
20 | exports.eventCenter = eventCenter;
21 | var SYNC_EVENT = exports.SYNC_EVENT = 'recharts.syncMouseEvents';
--------------------------------------------------------------------------------
/src/vendor/recharts/lib/util/LogUtils.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | Object.defineProperty(exports, "__esModule", {
4 | value: true
5 | });
6 | /* eslint no-console: 0 */
7 | var isDev = process.env.NODE_ENV !== 'production';
8 |
9 | var warn = exports.warn = function warn(condition, format, a, b, c, d, e, f) {
10 | if (isDev && typeof console !== 'undefined' && console.warn) {
11 | if (format === undefined) {
12 | console.warn('LogUtils requires an error message argument');
13 | }
14 |
15 | if (!condition) {
16 | if (format === undefined) {
17 | console.warn('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.');
18 | } else {
19 | (function () {
20 | var args = [a, b, c, d, e, f];
21 | var argIndex = 0;
22 |
23 | console.warn(format.replace(/%s/g, function () {
24 | return args[argIndex++];
25 | }));
26 | })();
27 | }
28 | }
29 | }
30 | };
--------------------------------------------------------------------------------
/src/vendor/recharts/lib/util/PolarUtils.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | Object.defineProperty(exports, "__esModule", {
4 | value: true
5 | });
6 | var RADIAN = Math.PI / 180;
7 |
8 | var polarToCartesian = exports.polarToCartesian = function polarToCartesian(cx, cy, radius, angle) {
9 | return {
10 | x: cx + Math.cos(-RADIAN * angle) * radius,
11 | y: cy + Math.sin(-RADIAN * angle) * radius
12 | };
13 | };
14 |
15 | var getMaxRadius = exports.getMaxRadius = function getMaxRadius(width, height) {
16 | var margin = arguments.length <= 2 || arguments[2] === undefined ? {
17 | top: 0, right: 0, bottom: 0, left: 0
18 | } : arguments[2];
19 | return Math.min(Math.abs(width - (margin.left || 0) - (margin.right || 0)), Math.abs(height - (margin.left || 0) - (margin.right || 0))) / 2;
20 | };
--------------------------------------------------------------------------------
/src/vendor/recharts/lib/util/PureRender.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | Object.defineProperty(exports, "__esModule", {
4 | value: true
5 | });
6 | exports.shallowEqual = undefined;
7 |
8 | var _isPlainObject2 = require('lodash/isPlainObject');
9 |
10 | var _isPlainObject3 = _interopRequireDefault(_isPlainObject2);
11 |
12 | var _isEqual2 = require('lodash/isEqual');
13 |
14 | var _isEqual3 = _interopRequireDefault(_isEqual2);
15 |
16 | var _isArray2 = require('lodash/isArray');
17 |
18 | var _isArray3 = _interopRequireDefault(_isArray2);
19 |
20 | var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };
21 |
22 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23 |
24 | function shallowEqual(objA, objB) {
25 | if (objA === objB) {
26 | return true;
27 | }
28 |
29 | if ((typeof objA === 'undefined' ? 'undefined' : _typeof(objA)) !== 'object' || objA === null || (typeof objB === 'undefined' ? 'undefined' : _typeof(objB)) !== 'object' || objB === null) {
30 | return false;
31 | }
32 |
33 | var keysA = Object.keys(objA);
34 | var keysB = Object.keys(objB);
35 |
36 | if (keysA.length !== keysB.length) {
37 | return false;
38 | }
39 |
40 | var bHasOwnProperty = hasOwnProperty.bind(objB);
41 | for (var i = 0; i < keysA.length; i++) {
42 | var keyA = keysA[i];
43 |
44 | if (objA[keyA] === objB[keyA]) {
45 | continue;
46 | }
47 |
48 | // special diff with Array or Object
49 | if ((0, _isArray3.default)(objA[keyA])) {
50 | if (!(0, _isArray3.default)(objB[keyA]) || objA[keyA].length !== objB[keyA].length) {
51 | return false;
52 | } else if (!(0, _isEqual3.default)(objA[keyA], objB[keyA])) {
53 | return false;
54 | }
55 | } else if ((0, _isPlainObject3.default)(objA[keyA])) {
56 | if (!(0, _isPlainObject3.default)(objB[keyA]) || !(0, _isEqual3.default)(objA[keyA], objB[keyA])) {
57 | return false;
58 | }
59 | } else if (!bHasOwnProperty(keysA[i]) || objA[keysA[i]] !== objB[keysA[i]]) {
60 | return false;
61 | }
62 | }
63 |
64 | return true;
65 | }
66 |
67 | function shallowCompare(instance, nextProps, nextState) {
68 | return !shallowEqual(instance.props, nextProps) || !shallowEqual(instance.state, nextState);
69 | }
70 |
71 | function shouldComponentUpdate(nextProps, nextState) {
72 | return shallowCompare(this, nextProps, nextState);
73 | }
74 | /* eslint-disable no-param-reassign */
75 | function pureRenderDecorator(component) {
76 | component.prototype.shouldComponentUpdate = shouldComponentUpdate;
77 | }
78 | exports.shallowEqual = shallowEqual;
79 | exports.default = pureRenderDecorator;
--------------------------------------------------------------------------------
/src/vendor/recharts/src/cartesian/CartesianGrid.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @fileOverview Cartesian Grid
3 | */
4 | import React, { Component, PropTypes } from 'react';
5 | import pureRender from '../util/PureRender';
6 | import { PRESENTATION_ATTRIBUTES, getPresentationAttributes } from '../util/ReactUtils';
7 | import _ from 'lodash';
8 |
9 | @pureRender
10 | class CartesianGrid extends Component {
11 |
12 | static displayName = 'CartesianGrid';
13 |
14 | static propTypes = {
15 | ...PRESENTATION_ATTRIBUTES,
16 | x: PropTypes.number,
17 | y: PropTypes.number,
18 | width: PropTypes.number,
19 | height: PropTypes.number,
20 | horizontal: PropTypes.bool,
21 | vertical: PropTypes.bool,
22 | horizontalPoints: PropTypes.arrayOf(PropTypes.number),
23 | verticalPoints: PropTypes.arrayOf(PropTypes.number),
24 | };
25 |
26 | static defaultProps = {
27 | x: 0,
28 | y: 0,
29 | width: 0,
30 | height: 0,
31 | horizontal: true,
32 | vertical: true,
33 | // The ordinates of horizontal grid lines
34 | horizontalPoints: [],
35 | // The abscissas of vertical grid lines
36 | verticalPoints: [],
37 |
38 | stroke: '#ccc',
39 | fill: 'none',
40 | };
41 |
42 | /**
43 | * Draw the horizontal grid lines
44 | * @return {Group} Horizontal lines
45 | */
46 | renderHorizontal() {
47 | const { x, width, horizontalPoints } = this.props;
48 |
49 | if (!horizontalPoints || !horizontalPoints.length) { return null; }
50 |
51 | const props = getPresentationAttributes(this.props);
52 | const items = horizontalPoints.map((entry, i) =>
53 | ());
54 |
55 | return {items};
56 | }
57 |
58 | /**
59 | * Draw vertical grid lines
60 | * @return {Group} Vertical lines
61 | */
62 | renderVertical() {
63 | const { y, height, verticalPoints } = this.props;
64 |
65 | if (!verticalPoints || !verticalPoints.length) { return null; }
66 |
67 | const props = getPresentationAttributes(this.props);
68 |
69 | const items = verticalPoints.map((entry, i) =>
70 | ());
71 |
72 | return {items};
73 | }
74 |
75 | render() {
76 | const { width, height, horizontal, vertical } = this.props;
77 |
78 | if (width <= 0 || height <= 0) {
79 | return null;
80 | }
81 |
82 | return (
83 |
84 | {horizontal && this.renderHorizontal()}
85 | {vertical && this.renderVertical()}
86 |
87 | );
88 | }
89 | }
90 |
91 | export default CartesianGrid;
92 |
--------------------------------------------------------------------------------
/src/vendor/recharts/src/cartesian/XAxis.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @fileOverview X Axis
3 | */
4 | import React, { Component, PropTypes } from 'react';
5 | import pureRender from '../util/PureRender';
6 |
7 | @pureRender
8 | class XAxis extends Component {
9 |
10 | static displayName = 'XAxis';
11 |
12 | static propTypes = {
13 | allowDecimals: PropTypes.bool,
14 | hide: PropTypes.bool,
15 | // The name of data displayed in the axis
16 | name: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
17 | // The unit of data displayed in the axis
18 | unit: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
19 | // The unique id of x-axis
20 | xAxisId: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
21 | domain: PropTypes.arrayOf(PropTypes.oneOfType([
22 | PropTypes.string,
23 | PropTypes.number,
24 | PropTypes.oneOf(['auto', 'dataMin', 'dataMax']),
25 | ])),
26 | // The key of data displayed in the axis
27 | dataKey: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
28 | // The width of axis which is usually calculated internally
29 | width: PropTypes.number,
30 | // The height of axis, which need to be setted by user
31 | height: PropTypes.number,
32 | // The orientation of axis
33 | orientation: PropTypes.oneOf(['top', 'bottom']),
34 | type: PropTypes.oneOf(['number', 'category']),
35 | // Ticks can be any type when the axis is the type of category
36 | // Ticks must be numbers when the axis is the type of number
37 | ticks: PropTypes.array,
38 | // The count of ticks
39 | tickCount: PropTypes.number,
40 | // The formatter function of tick
41 | tickFormatter: PropTypes.func,
42 | padding: PropTypes.shape({
43 | left: PropTypes.number,
44 | right: PropTypes.number,
45 | }),
46 | allowDataOverflow: PropTypes.bool,
47 | };
48 |
49 | static defaultProps = {
50 | allowDecimals: true,
51 | hide: false,
52 | orientation: 'bottom',
53 | width: 0,
54 | height: 30,
55 | xAxisId: 0,
56 | tickCount: 5,
57 | type: 'category',
58 | domain: [0, 'auto'],
59 | padding: { left: 0, right: 0 },
60 | allowDataOverflow: false,
61 | };
62 |
63 | render() {
64 | return null;
65 | }
66 | }
67 |
68 | export default XAxis;
69 |
--------------------------------------------------------------------------------
/src/vendor/recharts/src/cartesian/YAxis.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @fileOverview Y Axis
3 | */
4 | import React, { Component, PropTypes } from 'react';
5 | import pureRender from '../util/PureRender';
6 |
7 | @pureRender
8 | class YAxis extends Component {
9 |
10 | static displayName = 'YAxis';
11 |
12 | static propTypes = {
13 | allowDecimals: PropTypes.bool,
14 | hide: PropTypes.bool,
15 | // The name of data displayed in the axis
16 | name: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
17 | // The unit of data displayed in the axis
18 | unit: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
19 | // The unique id of y-axis
20 | yAxisId: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
21 | domain: PropTypes.arrayOf(PropTypes.oneOfType([
22 | PropTypes.string,
23 | PropTypes.number,
24 | PropTypes.oneOf(['auto', 'dataMin', 'dataMax']),
25 | ])),
26 | // The key of data displayed in the axis
27 | dataKey: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
28 | // Ticks can be any type when the axis is the type of category
29 | // Ticks must be numbers when the axis is the type of number
30 | ticks: PropTypes.array,
31 | // The count of ticks
32 | tickCount: PropTypes.number,
33 | // The formatter function of tick
34 | tickFormatter: PropTypes.func,
35 | // The width of axis, which need to be setted by user
36 | width: PropTypes.number,
37 | // The height of axis which is usually calculated in Chart
38 | height: PropTypes.number,
39 | // The orientation of axis
40 | orientation: PropTypes.oneOf(['left', 'right']),
41 | type: PropTypes.oneOf(['number', 'category']),
42 | padding: PropTypes.shape({
43 | top: PropTypes.number,
44 | bottom: PropTypes.number,
45 | }),
46 | allowDataOverflow: PropTypes.bool,
47 | };
48 |
49 | static defaultProps = {
50 | allowDecimals: true,
51 | hide: false,
52 | orientation: 'left',
53 | width: 60,
54 | height: 0,
55 | yAxisId: 0,
56 | tickCount: 5,
57 | type: 'number',
58 | domain: [0, 'auto'],
59 | padding: { top: 0, bottom: 0 },
60 | allowDataOverflow: false,
61 | };
62 |
63 | render() {
64 | return null;
65 | }
66 | }
67 |
68 | export default YAxis;
69 |
--------------------------------------------------------------------------------
/src/vendor/recharts/src/cartesian/ZAxis.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @fileOverview Z Axis
3 | */
4 | import React, { Component, PropTypes } from 'react';
5 | import pureRender from '../util/PureRender';
6 |
7 | @pureRender
8 | class ZAxis extends Component {
9 |
10 | static displayName = 'ZAxis';
11 |
12 | static propTypes = {
13 | // The name of data displayed in the axis
14 | name: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
15 | // The unit of data displayed in the axis
16 | unit: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
17 | // The unique id of z-axis
18 | zAxisId: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
19 | // The key of data displayed in the axis
20 | dataKey: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
21 | // The range of axis
22 | range: PropTypes.arrayOf(PropTypes.number),
23 | };
24 |
25 | static defaultProps = {
26 | zAxisId: 0,
27 | range: [64, 64],
28 | };
29 |
30 | render() {
31 | return null;
32 | }
33 | }
34 |
35 | export default ZAxis;
36 |
--------------------------------------------------------------------------------
/src/vendor/recharts/src/component/Background.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @fileOverview Background
3 | */
4 | import React, { Component, PropTypes } from 'react';
5 | import classNames from 'classnames';
6 | import pureRender from '../util/PureRender';
7 |
8 | const propTypes = {
9 | x: PropTypes.number,
10 | y: PropTypes.number,
11 | width: PropTypes.number,
12 | height: PropTypes.number,
13 | strokeWidth: PropTypes.number,
14 | stroke: PropTypes.string,
15 | fill: PropTypes.string,
16 | className: PropTypes.string,
17 | };
18 |
19 | function Background(props) {
20 | const { className, ...others } = props;
21 |
22 | return (
23 |
24 |
25 |
26 | );
27 | }
28 |
29 | Background.propTypes = propTypes;
30 |
31 | export default Background;
32 |
--------------------------------------------------------------------------------
/src/vendor/recharts/src/component/Cell.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @fileOverview Cross
3 | */
4 | import React, { Component, PropTypes } from 'react';
5 | import pureRender from '../util/PureRender';
6 |
7 | @pureRender
8 | class Cell extends Component {
9 |
10 | static displayName = 'Cell';
11 |
12 | render() {
13 | return null;
14 | }
15 | }
16 |
17 | export default Cell;
18 |
--------------------------------------------------------------------------------
/src/vendor/recharts/src/component/DefaultTooltipContent.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @fileOverview Default Tooltip Content
3 | */
4 | import React, { Component, PropTypes } from 'react';
5 | import pureRender from '../util/PureRender';
6 | import _ from 'lodash';
7 |
8 | @pureRender
9 | class DefaultTooltipContent extends Component {
10 |
11 | static displayName = 'DefaultTooltipContent';
12 |
13 | static propTypes = {
14 | separator: PropTypes.string,
15 | formatter: PropTypes.func,
16 | wrapperStyle: PropTypes.object,
17 | itemStyle: PropTypes.object,
18 | labelStyle: PropTypes.object,
19 | labelFormatter: PropTypes.func,
20 | label: PropTypes.any,
21 | payload: PropTypes.arrayOf(PropTypes.shape({
22 | name: PropTypes.any,
23 | value: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
24 | unit: PropTypes.any,
25 | })),
26 | itemSorter: PropTypes.func,
27 | };
28 |
29 | static defaultProps = {
30 | separator: ' : ',
31 | itemStyle: {},
32 | labelStyle: {},
33 | };
34 |
35 | renderContent() {
36 | const { payload, separator, formatter, itemStyle, itemSorter } = this.props;
37 |
38 | if (payload && payload.length) {
39 | const listStyle = { padding: 0, margin: 0 };
40 |
41 | const items = payload.filter(entry => (_.isNumber(entry.value) || _.isString(entry.value)))
42 | .sort(itemSorter)
43 | .map((entry, i) => {
44 | const finalItemStyle = {
45 | display: 'block',
46 | paddingTop: 4,
47 | paddingBottom: 4,
48 | color: entry.color || '#000',
49 | ...itemStyle,
50 | };
51 | const finalFormatter = entry.formatter || formatter;
52 |
53 | return (
54 |
55 | {entry.name}
56 | {separator}
57 |
58 | {finalFormatter ? finalFormatter(entry.value, entry.name, entry) : entry.value}
59 |
60 | {entry.unit || ''}
61 |
62 | );
63 | });
64 |
65 | return ;
66 | }
67 |
68 | return null;
69 | }
70 |
71 | render() {
72 | const { labelStyle, label, labelFormatter, wrapperStyle } = this.props;
73 | const finalStyle = {
74 | margin: 0,
75 | padding: 10,
76 | backgroundColor: '#fff',
77 | border: '1px solid #ccc',
78 | whiteSpace: 'nowrap',
79 | ...wrapperStyle,
80 | };
81 | const finalLabelStyle = {
82 | margin: 0,
83 | ...labelStyle,
84 | };
85 | const hasLabel = _.isNumber(label) || _.isString(label);
86 | let finalLabel = hasLabel ? label : '';
87 |
88 | if (hasLabel && labelFormatter) { finalLabel = labelFormatter(label); }
89 |
90 | return (
91 |
92 |
{finalLabel}
93 | {this.renderContent()}
94 |
95 | );
96 | }
97 | }
98 |
99 | export default DefaultTooltipContent;
100 |
--------------------------------------------------------------------------------
/src/vendor/recharts/src/component/ResponsiveContainer.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @fileOverview Wrapper component to make charts adapt to the size of parent * DOM
3 | */
4 | import React, { Component, PropTypes } from 'react';
5 | import ContainerDimensions from 'react-container-dimensions';
6 | import pureRender from '../util/PureRender';
7 | import { isPercent } from '../util/DataUtils';
8 | import { warn } from '../util/LogUtils';
9 |
10 | const render = ({ aspect, width, height, minWidth, minHeight, container, children }) => {
11 | warn(isPercent(width) || isPercent(height),
12 | `The width(%s) and height(%s) are both fixed numbers,
13 | maybe you don't need to use a ResponsiveContainer.`,
14 | width, height
15 | );
16 |
17 | warn(!aspect || aspect > 0,
18 | 'The aspect(%s) must be greater than zero.',
19 | aspect);
20 |
21 | let calculatedWidth = isPercent(width) ? container.width : width;
22 | let calculatedHeight = isPercent(height) ? container.height : height;
23 |
24 | if (aspect && aspect > 0) {
25 | // Preserve the desired aspect ratio
26 | if (calculatedHeight > 0 &&
27 | (calculatedWidth === 0 || calculatedWidth / calculatedHeight > aspect)) {
28 | calculatedWidth = calculatedHeight * aspect;
29 | } else if (calculatedHeight === 0 || calculatedWidth / calculatedHeight < aspect) {
30 | calculatedHeight = calculatedWidth / aspect;
31 | }
32 | }
33 |
34 | warn(calculatedWidth > 0 && calculatedHeight > 0,
35 | `The width(%s) and height(%s) of chart should be greater than 0,
36 | please check the style of container, or the props width(%s) and height(%s),
37 | or add a minWidth(%s) or minHeight(%s) or use aspect(%s) to control the
38 | height and width.`,
39 | calculatedWidth, calculatedHeight, width, height, minWidth, minHeight, aspect
40 | );
41 |
42 | return React.cloneElement(children, {
43 | width: calculatedWidth,
44 | height: calculatedHeight,
45 | });
46 | };
47 |
48 | const ResponsiveContainer = props => {
49 | const { minWidth, minHeight, width, height } = props;
50 | const style = { width, height, minWidth, minHeight };
51 | return (
52 |
53 |
54 | {
55 | container =>
56 | render({
57 | container,
58 | ...props,
59 | })
60 | }
61 |
62 |
63 | );
64 | };
65 |
66 | ResponsiveContainer.displayName = 'ResponsiveContainer';
67 | ResponsiveContainer.propTypes = {
68 | aspect: PropTypes.number,
69 | width: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
70 | height: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
71 | minHeight: PropTypes.number,
72 | minWidth: PropTypes.number,
73 | children: PropTypes.node.isRequired,
74 | };
75 |
76 | ResponsiveContainer.defaultProps = {
77 | width: '100%',
78 | height: '100%',
79 | };
80 |
81 | export default ResponsiveContainer;
82 |
--------------------------------------------------------------------------------
/src/vendor/recharts/src/container/Layer.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @fileOverview Layer
3 | */
4 | import React, { Component, PropTypes } from 'react';
5 | import classNames from 'classnames';
6 |
7 | const propTypes = {
8 | className: PropTypes.string,
9 | children: PropTypes.oneOfType([
10 | PropTypes.arrayOf(PropTypes.node),
11 | PropTypes.node,
12 | ]),
13 | };
14 |
15 | function Layer(props) {
16 | const { children, className, ...others } = props;
17 | const layerClass = classNames('recharts-layer', className);
18 |
19 | return (
20 |
21 | {children}
22 |
23 | );
24 | }
25 |
26 | Layer.propTypes = propTypes;
27 |
28 | export default Layer;
29 |
--------------------------------------------------------------------------------
/src/vendor/recharts/src/container/Surface.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @fileOverview Surface
3 | */
4 | import React, { Component, PropTypes } from 'react';
5 | import classNames from 'classnames';
6 | import { getPresentationAttributes } from '../util/ReactUtils';
7 |
8 | const propTypes = {
9 | width: PropTypes.number.isRequired,
10 | height: PropTypes.number.isRequired,
11 | viewBox: PropTypes.shape({
12 | x: PropTypes.number,
13 | y: PropTypes.number,
14 | width: PropTypes.number,
15 | height: PropTypes.number,
16 | }),
17 | className: PropTypes.string,
18 | style: PropTypes.object,
19 | children: PropTypes.oneOfType([
20 | PropTypes.arrayOf(PropTypes.node),
21 | PropTypes.node,
22 | ]),
23 | };
24 | function Surface(props) {
25 | const { children, width, height, viewBox, className, style, ...others } = props;
26 | const svgView = viewBox || { width, height, x: 0, y: 0 };
27 | const layerClass = classNames('recharts-surface', className);
28 | const attrs = getPresentationAttributes(others);
29 |
30 | return (
31 |
42 | );
43 | }
44 |
45 | Surface.propTypes = propTypes;
46 |
47 | export default Surface;
48 |
--------------------------------------------------------------------------------
/src/vendor/recharts/src/index.js:
--------------------------------------------------------------------------------
1 | import './polyfill';
2 | import 'core-js/es6/math';
3 |
4 | export Surface from './container/Surface';
5 | export Layer from './container/Layer';
6 |
7 | export Legend from './component/Legend';
8 | export Tooltip from './component/Tooltip';
9 | export ResponsiveContainer from './component/ResponsiveContainer';
10 | export Cell from './component/Cell';
11 | export Text from './component/Text';
12 |
13 | export Sector from './shape/Sector';
14 | export Curve from './shape/Curve';
15 | export Rectangle from './shape/Rectangle';
16 | export Polygon from './shape/Polygon';
17 | export Dot from './shape/Dot';
18 | export Cross from './shape/Cross';
19 | export Symbols from './shape/Symbols';
20 |
21 | export PolarGrid from './polar/PolarGrid';
22 | export PolarRadiusAxis from './polar/PolarRadiusAxis';
23 | export PolarAngleAxis from './polar/PolarAngleAxis';
24 | export Pie from './polar/Pie';
25 | export Radar from './polar/Radar';
26 | export RadialBar from './polar/RadialBar';
27 |
28 | export Brush from './cartesian/Brush';
29 | export ReferenceLine from './cartesian/ReferenceLine';
30 | export ReferenceDot from './cartesian/ReferenceDot';
31 | export ReferenceArea from './cartesian/ReferenceArea';
32 | export CartesianAxis from './cartesian/CartesianAxis';
33 | export CartesianGrid from './cartesian/CartesianGrid';
34 | export Line from './cartesian/Line';
35 | export Area from './cartesian/Area';
36 | export Bar from './cartesian/Bar';
37 | export Scatter from './cartesian/Scatter';
38 | export XAxis from './cartesian/XAxis';
39 | export YAxis from './cartesian/YAxis';
40 | export ZAxis from './cartesian/ZAxis';
41 |
42 | export LineChart from './chart/LineChart';
43 | export BarChart from './chart/BarChart';
44 | export PieChart from './chart/PieChart';
45 | export Treemap from './chart/Treemap';
46 | export Sankey from './chart/Sankey';
47 | export RadarChart from './chart/RadarChart';
48 | export ScatterChart from './chart/ScatterChart';
49 | export AreaChart from './chart/AreaChart';
50 | export RadialBarChart from './chart/RadialBarChart';
51 | export ComposedChart from './chart/ComposedChart';
52 |
--------------------------------------------------------------------------------
/src/vendor/recharts/src/polyfill.js:
--------------------------------------------------------------------------------
1 | /* eslint no-proto: 0 */
2 | const testObject = {};
3 |
4 | if (!(Object.setPrototypeOf || testObject.__proto__)) {
5 | const nativeGetPrototypeOf = Object.getPrototypeOf;
6 |
7 | Object.getPrototypeOf = (object) => {
8 | if (object.__proto__) {
9 | return object.__proto__;
10 | }
11 |
12 | return nativeGetPrototypeOf.call(Object, object);
13 | };
14 | }
15 |
--------------------------------------------------------------------------------
/src/vendor/recharts/src/shape/Cross.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @fileOverview Cross
3 | */
4 | import React, { Component, PropTypes } from 'react';
5 | import pureRender from '../util/PureRender';
6 | import classNames from 'classnames';
7 | import { PRESENTATION_ATTRIBUTES, getPresentationAttributes } from '../util/ReactUtils';
8 | import _ from 'lodash';
9 |
10 | @pureRender
11 | class Cross extends Component {
12 |
13 | static displayName = 'Cross';
14 |
15 | static propTypes = {
16 | ...PRESENTATION_ATTRIBUTES,
17 | x: PropTypes.number,
18 | y: PropTypes.number,
19 | width: PropTypes.number,
20 | height: PropTypes.number,
21 | top: PropTypes.number,
22 | left: PropTypes.number,
23 | className: PropTypes.string,
24 | };
25 |
26 | static defaultProps = {
27 | x: 0,
28 | y: 0,
29 | top: 0,
30 | left: 0,
31 | width: 0,
32 | height: 0,
33 | stroke: '#000',
34 | fill: 'none',
35 | };
36 |
37 | getPath(x, y, width, height, top, left) {
38 | return `M${x},${top}v${height}M${left},${y}h${width}`;
39 | }
40 |
41 | render() {
42 | const { x, y, width, height, top, left,
43 | className } = this.props;
44 |
45 | if (!_.isNumber(x) || !_.isNumber(y) || !_.isNumber(width)
46 | || !_.isNumber(height) || !_.isNumber(top) || !_.isNumber(left)) {
47 | return null;
48 | }
49 |
50 | return (
51 |
56 | );
57 | }
58 | }
59 |
60 | export default Cross;
61 |
--------------------------------------------------------------------------------
/src/vendor/recharts/src/shape/Dot.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @fileOverview Dot
3 | */
4 | import React, { Component, PropTypes } from 'react';
5 | import pureRender from '../util/PureRender';
6 | import classNames from 'classnames';
7 | import { getPresentationAttributes } from '../util/ReactUtils';
8 |
9 | @pureRender
10 | class Dot extends Component {
11 | static displayName = 'Dot';
12 |
13 | static propTypes = {
14 | className: PropTypes.string,
15 | cx: PropTypes.number,
16 | cy: PropTypes.number,
17 | r: PropTypes.number,
18 | };
19 |
20 | render() {
21 | const { cx, cy, r, className } = this.props;
22 | const layerClass = classNames('recharts-dot', className);
23 |
24 | if (cx === +cx && cy === +cy && r === +r) {
25 | return (
26 |
33 | );
34 | }
35 |
36 | return null;
37 | }
38 | }
39 |
40 | export default Dot;
41 |
--------------------------------------------------------------------------------
/src/vendor/recharts/src/shape/Polygon.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @fileOverview Polygon
3 | */
4 | import React, { Component, PropTypes } from 'react';
5 | import pureRender from '../util/PureRender';
6 | import classNames from 'classnames';
7 | import { PRESENTATION_ATTRIBUTES, getPresentationAttributes,
8 | filterEventAttributes } from '../util/ReactUtils';
9 |
10 | const getPolygonPoints = (points) => (
11 | points.reduce((result, entry) => {
12 | if (entry.x === +entry.x && entry.y === +entry.y) {
13 | result.push([entry.x, entry.y]);
14 | }
15 |
16 | return result;
17 | }, []).join(' ')
18 | );
19 |
20 | @pureRender
21 | class Polygon extends Component {
22 |
23 | static displayName = 'Polygon';
24 |
25 | static propTypes = {
26 | ...PRESENTATION_ATTRIBUTES,
27 | className: PropTypes.string,
28 | points: PropTypes.arrayOf(PropTypes.shape({
29 | x: PropTypes.number,
30 | y: PropTypes.number,
31 | })),
32 | };
33 |
34 | static defaultProps = {
35 | fill: 'none',
36 | stroke: '#333',
37 | strokeWidth: 1,
38 | };
39 |
40 | render() {
41 | const { points, className } = this.props;
42 |
43 | if (!points || !points.length) { return null; }
44 |
45 | const layerClass = classNames('recharts-polygon', className);
46 |
47 | return (
48 |
54 | );
55 | }
56 | }
57 |
58 | export default Polygon;
59 |
--------------------------------------------------------------------------------
/src/vendor/recharts/src/shape/Sector.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @fileOverview Sector
3 | */
4 | import React, { Component, PropTypes } from 'react';
5 | import pureRender from '../util/PureRender';
6 | import classNames from 'classnames';
7 | import { PRESENTATION_ATTRIBUTES, getPresentationAttributes,
8 | filterEventAttributes } from '../util/ReactUtils';
9 | import { polarToCartesian } from '../util/PolarUtils';
10 |
11 | const getDeltaAngle = (startAngle, endAngle) => {
12 | const sign = Math.sign(endAngle - startAngle);
13 | const deltaAngle = Math.min(Math.abs(endAngle - startAngle), 359.999);
14 |
15 | return sign * deltaAngle;
16 | };
17 |
18 | const getSectorPath = ({ cx, cy, innerRadius, outerRadius, startAngle, endAngle }) => {
19 | const angle = getDeltaAngle(startAngle, endAngle);
20 |
21 | // When the angle of sector equals to 360, star point and end point coincide
22 | const tempEndAngle = startAngle + angle;
23 | const outerStartPoint = polarToCartesian(cx, cy, outerRadius, startAngle);
24 | const outerEndPoint = polarToCartesian(cx, cy, outerRadius, tempEndAngle);
25 |
26 | let path;
27 |
28 | if (innerRadius > 0) {
29 | const innerStartPoint = polarToCartesian(cx, cy, innerRadius, startAngle);
30 | const innerEndPoint = polarToCartesian(cx, cy, innerRadius, tempEndAngle);
31 | path = `M ${outerStartPoint.x},${outerStartPoint.y}
32 | A ${outerRadius},${outerRadius},0,
33 | ${+(Math.abs(angle) > 180)},${+(startAngle > tempEndAngle)},
34 | ${outerEndPoint.x},${outerEndPoint.y}
35 | L ${innerEndPoint.x},${innerEndPoint.y}
36 | A ${innerRadius},${innerRadius},0,
37 | ${+(Math.abs(angle) > 180)},${+(startAngle <= tempEndAngle)},
38 | ${innerStartPoint.x},${innerStartPoint.y} Z`;
39 | } else {
40 | path = `M ${outerStartPoint.x},${outerStartPoint.y}
41 | A ${outerRadius},${outerRadius},0,
42 | ${+(Math.abs(angle) > 180)},${+(startAngle > tempEndAngle)},
43 | ${outerEndPoint.x},${outerEndPoint.y}
44 | L ${cx},${cy} Z`;
45 | }
46 |
47 | return path;
48 | };
49 |
50 | @pureRender
51 | class Sector extends Component {
52 |
53 | static displayName = 'Sector';
54 |
55 | static propTypes = {
56 | ...PRESENTATION_ATTRIBUTES,
57 | className: PropTypes.string,
58 | cx: PropTypes.number,
59 | cy: PropTypes.number,
60 | innerRadius: PropTypes.number,
61 | outerRadius: PropTypes.number,
62 | startAngle: PropTypes.number,
63 | endAngle: PropTypes.number,
64 | };
65 |
66 | static defaultProps = {
67 | cx: 0,
68 | cy: 0,
69 | innerRadius: 0,
70 | outerRadius: 0,
71 | startAngle: 0,
72 | endAngle: 0,
73 | };
74 |
75 | render() {
76 | const { cx, cy, innerRadius, outerRadius, startAngle, endAngle, className } = this.props;
77 |
78 | if (outerRadius < innerRadius || startAngle === endAngle) { return null; }
79 |
80 | const layerClass = classNames('recharts-sector', className);
81 |
82 | return (
83 |
89 | );
90 | }
91 | }
92 |
93 | export default Sector;
94 |
--------------------------------------------------------------------------------
/src/vendor/recharts/src/shape/Symbols.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @fileOverview Curve
3 | */
4 | import React, { Component, PropTypes } from 'react';
5 | import { symbol as shapeSymbol, symbolCircle, symbolCross, symbolDiamond,
6 | symbolSquare, symbolStar, symbolTriangle, symbolWye } from 'd3-shape';
7 | import pureRender from '../util/PureRender';
8 | import classNames from 'classnames';
9 | import _ from 'lodash';
10 | import { PRESENTATION_ATTRIBUTES, getPresentationAttributes,
11 | filterEventAttributes } from '../util/ReactUtils';
12 |
13 | const SYMBOL_FACTORIES = {
14 | symbolCircle, symbolCross, symbolDiamond,
15 | symbolSquare, symbolStar, symbolTriangle, symbolWye,
16 | };
17 | const RADIAN = Math.PI / 180;
18 |
19 | const getSymbolFactory = (type) => {
20 | const name = `symbol${type.slice(0, 1).toUpperCase()}${type.slice(1)}`;
21 |
22 | return SYMBOL_FACTORIES[name] || symbolCircle;
23 | };
24 |
25 | const calculateAreaSize = (size, sizeType, type) => {
26 | if (sizeType === 'area') { return size; }
27 |
28 | switch (type) {
29 | case 'cross':
30 | return 5 * size * size / 9;
31 | case 'diamond':
32 | return 0.5 * size * size / Math.sqrt(3);
33 | case 'square':
34 | return size * size;
35 | case 'star': {
36 | const angle = 18 * RADIAN;
37 |
38 | return 1.25 * size * size * (
39 | Math.tan(angle) - Math.tan(angle * 2) * Math.pow(Math.tan(angle), 2)
40 | );
41 | }
42 | case 'triangle':
43 | return Math.sqrt(3) * size * size / 4;
44 | case 'wye':
45 | return (21 - 10 * Math.sqrt(3)) * size * size / 8;
46 | default:
47 | return Math.PI * size * size / 4;
48 | }
49 | };
50 |
51 | @pureRender
52 | class Symbols extends Component {
53 |
54 | static displayName = 'Symbols';
55 |
56 | static propTypes = {
57 | ...PRESENTATION_ATTRIBUTES,
58 | className: PropTypes.string,
59 | type: PropTypes.oneOf(['circle', 'cross', 'diamond', 'square', 'star', 'triangle', 'wye']),
60 | cx: PropTypes.number,
61 | cy: PropTypes.number,
62 | size: PropTypes.number,
63 | sizeType: PropTypes.oneOf(['area', 'diameter']),
64 | };
65 |
66 | static defaultProps = {
67 | type: 'circle',
68 | stroke: 'none',
69 | fill: '#000',
70 | size: 64,
71 | sizeType: 'area',
72 | };
73 |
74 | /**
75 | * Calculate the path of curve
76 | * @return {String} path
77 | */
78 | getPath() {
79 | const { size, sizeType, type } = this.props;
80 | const symbolFactory = getSymbolFactory(type);
81 | const symbol = shapeSymbol().type(symbolFactory)
82 | .size(calculateAreaSize(size, sizeType, type));
83 |
84 | return symbol();
85 | }
86 |
87 | render() {
88 | const { className, cx, cy, size } = this.props;
89 |
90 | if (cx === +cx && cy === +cy && size === +size) {
91 |
92 | return (
93 |
100 | );
101 | }
102 |
103 | return null;
104 | }
105 | }
106 |
107 | export default Symbols;
108 |
--------------------------------------------------------------------------------
/src/vendor/recharts/src/util/AnimationDecorator.js:
--------------------------------------------------------------------------------
1 | import React, { Component, PropTypes } from 'react';
2 | import { getDisplayName } from './ReactUtils';
3 |
4 | export default function (WrappedComponent) {
5 | class AnimationDecorator extends Component {
6 | static displayName = `AnimationDecorator(${getDisplayName(WrappedComponent)})`;
7 |
8 | static propTypes = {
9 | ...WrappedComponent.propTypes,
10 | data: PropTypes.array,
11 | };
12 |
13 | static WrappedComponent = WrappedComponent;
14 |
15 | static defaultProps = WrappedComponent.defaultProps;
16 |
17 | state = {
18 | animationId: 0,
19 | };
20 |
21 | componentWillReceiveProps(nextProps) {
22 | const { animationId } = this.state;
23 |
24 | if (this.props.data !== nextProps.data) {
25 | this.setState({
26 | animationId: animationId + 1,
27 | });
28 | }
29 | }
30 |
31 | render() {
32 | return ;
33 | }
34 | }
35 |
36 | return AnimationDecorator;
37 | }
38 |
--------------------------------------------------------------------------------
/src/vendor/recharts/src/util/CssPrefixUtils.js:
--------------------------------------------------------------------------------
1 | const PREFIX_LIST = ['Webkit', 'Moz', 'O', 'ms'];
2 |
3 | export const generatePrefixStyle = (name, value) => {
4 | if (!name) { return null; }
5 |
6 | const camelName = name.replace(/(\w)/, v => v.toUpperCase());
7 | const result = PREFIX_LIST.reduce((res, entry) => (
8 | {
9 | ...res,
10 | [entry + camelName]: value,
11 | }
12 | ), {});
13 |
14 | result[name] = value;
15 |
16 | return result;
17 | };
18 |
--------------------------------------------------------------------------------
/src/vendor/recharts/src/util/Events.js:
--------------------------------------------------------------------------------
1 | import EventEmitter from 'events';
2 |
3 | const eventCenter = new EventEmitter();
4 |
5 | if (eventCenter.setMaxListeners) {
6 | eventCenter.setMaxListeners(10);
7 | }
8 |
9 | export { eventCenter };
10 | export const SYNC_EVENT = 'recharts.syncMouseEvents';
11 |
--------------------------------------------------------------------------------
/src/vendor/recharts/src/util/LogUtils.js:
--------------------------------------------------------------------------------
1 | /* eslint no-console: 0 */
2 | const isDev = process.env.NODE_ENV !== 'production';
3 |
4 | export const warn = (condition, format, a, b, c, d, e, f) => {
5 | if (isDev && typeof console !== 'undefined' && console.warn) {
6 | if (format === undefined) {
7 | console.warn('LogUtils requires an error message argument');
8 | }
9 |
10 | if (!condition) {
11 | if (format === undefined) {
12 | console.warn(
13 | 'Minified exception occurred; use the non-minified dev environment ' +
14 | 'for the full error message and additional helpful warnings.'
15 | );
16 | } else {
17 | const args = [a, b, c, d, e, f];
18 | let argIndex = 0;
19 |
20 | console.warn(format.replace(/%s/g, () => args[argIndex++]));
21 | }
22 | }
23 | }
24 | };
25 |
26 |
--------------------------------------------------------------------------------
/src/vendor/recharts/src/util/PolarUtils.js:
--------------------------------------------------------------------------------
1 | const RADIAN = Math.PI / 180;
2 |
3 | export const polarToCartesian = (cx, cy, radius, angle) => ({
4 | x: cx + Math.cos(-RADIAN * angle) * radius,
5 | y: cy + Math.sin(-RADIAN * angle) * radius,
6 | });
7 |
8 | export const getMaxRadius = (width, height, margin = {
9 | top: 0, right: 0, bottom: 0, left: 0,
10 | }) => (
11 | Math.min(
12 | Math.abs(width - (margin.left || 0) - (margin.right || 0)),
13 | Math.abs(height - (margin.left || 0) - (margin.right || 0))
14 | ) / 2);
15 |
--------------------------------------------------------------------------------
/src/vendor/recharts/src/util/PureRender.js:
--------------------------------------------------------------------------------
1 | import _ from 'lodash';
2 |
3 | function shallowEqual(objA, objB) {
4 | if (objA === objB) {
5 | return true;
6 | }
7 |
8 | if (typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null) {
9 | return false;
10 | }
11 |
12 | const keysA = Object.keys(objA);
13 | const keysB = Object.keys(objB);
14 |
15 | if (keysA.length !== keysB.length) {
16 | return false;
17 | }
18 |
19 | const bHasOwnProperty = hasOwnProperty.bind(objB);
20 | for (let i = 0; i < keysA.length; i++) {
21 | const keyA = keysA[i];
22 |
23 | if (objA[keyA] === objB[keyA]) {
24 | continue;
25 | }
26 |
27 | // special diff with Array or Object
28 | if (_.isArray(objA[keyA])) {
29 | if (!_.isArray(objB[keyA]) || objA[keyA].length !== objB[keyA].length) {
30 | return false;
31 | } else if (!_.isEqual(objA[keyA], objB[keyA])) {
32 | return false;
33 | }
34 | } else if (_.isPlainObject(objA[keyA])) {
35 | if (!_.isPlainObject(objB[keyA]) || !_.isEqual(objA[keyA], objB[keyA])) {
36 | return false;
37 | }
38 | } else if (!bHasOwnProperty(keysA[i]) || objA[keysA[i]] !== objB[keysA[i]]) {
39 | return false;
40 | }
41 | }
42 |
43 | return true;
44 | }
45 |
46 |
47 | function shallowCompare(instance, nextProps, nextState) {
48 | return !shallowEqual(instance.props, nextProps) || !shallowEqual(instance.state, nextState);
49 | }
50 |
51 | function shouldComponentUpdate(nextProps, nextState) {
52 | return shallowCompare(this, nextProps, nextState);
53 | }
54 | /* eslint-disable no-param-reassign */
55 | function pureRenderDecorator(component) {
56 | component.prototype.shouldComponentUpdate = shouldComponentUpdate;
57 | }
58 | export { shallowEqual };
59 | export default pureRenderDecorator;
60 |
--------------------------------------------------------------------------------
/test/.eslintrc:
--------------------------------------------------------------------------------
1 | {
2 | "env": {
3 | "mocha": true
4 | },
5 | "rules": {
6 | "no-unused-expressions": 0,
7 | "padded-blocks": 0
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/test/setup.js:
--------------------------------------------------------------------------------
1 | /**
2 | * React Starter Kit (https://www.reactstarterkit.com/)
3 | *
4 | * Copyright © 2014-2016 Kriasoft, LLC. All rights reserved.
5 | *
6 | * This source code is licensed under the MIT license found in the
7 | * LICENSE.txt file in the root directory of this source tree.
8 | */
9 |
10 | /* Configure Mocha test runner, see package.json/scripts/test */
11 |
12 | process.env.NODE_ENV = 'test';
13 |
14 | function noop() {
15 | return null;
16 | }
17 |
18 | require.extensions['.css'] = noop;
19 | require.extensions['.scss'] = noop;
20 | require.extensions['.md'] = noop;
21 | require.extensions['.png'] = noop;
22 | require.extensions['.svg'] = noop;
23 | require.extensions['.jpg'] = noop;
24 | require.extensions['.jpeg'] = noop;
25 | require.extensions['.gif'] = noop;
26 |
--------------------------------------------------------------------------------
/tools/.eslintrc:
--------------------------------------------------------------------------------
1 | {
2 | "rules": {
3 | "no-console": 0,
4 | "global-require": 0
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/tools/README.md:
--------------------------------------------------------------------------------
1 | ## Build Automation Tools
2 |
3 | ##### `npm start` (`start.js`)
4 |
5 | * Cleans up the output `/build` directory (`clean.js`)
6 | * Copies static files to the output folder (`copy.js`)
7 | * Launches [Webpack](https://webpack.github.io/) compiler in a watch mode (via [webpack-middleware](https://github.com/kriasoft/webpack-middleware))
8 | * Launches Node.js server from the compiled output folder (`runServer.js`)
9 | * Launches [Browsersync](https://browsersync.io/),
10 | [HMR](https://webpack.github.io/docs/hot-module-replacement), and
11 | [React Transform](https://github.com/gaearon/babel-plugin-react-transform)
12 |
13 | ##### `npm run build` (`build.js`)
14 |
15 | * Cleans up the output `/build` folder (`clean.js`)
16 | * Copies static files to the output folder (`copy.js`)
17 | * Creates application bundles with Webpack (`bundle.js`, `webpack.config.js`)
18 |
19 | ##### `npm run deploy` (`deploy.js`)
20 |
21 | * Builds the project from source files (`build.js`)
22 | * Pushes the contents of the `/build` folder to a remote server with Git
23 |
24 | ##### Options
25 |
26 | Flag | Description
27 | ----------- | --------------------------------------------------
28 | `--release` | Minimizes and optimizes the compiled output
29 | `--verbose` | Prints detailed information to the console
30 | `--static` | Renders [specified routes](./render.js#L15) as static html files
31 |
32 | For example:
33 |
34 | ```sh
35 | $ npm run build -- --release --verbose # Build the app in production mode
36 | ```
37 |
38 | or
39 |
40 | ```sh
41 | $ npm start -- --release # Launch dev server in production mode
42 | ```
43 |
44 | #### Misc
45 |
46 | * `webpack.config.js` - Webpack configuration for both client-side and server-side bundles
47 | * `run.js` - Helps to launch other scripts with `babel-node` (e.g. `babel-node tools/run build`)
48 | * `.eslintrc` - ESLint overrides for built automation scripts
49 |
--------------------------------------------------------------------------------
/tools/build.js:
--------------------------------------------------------------------------------
1 | /**
2 | * React Starter Kit (https://www.reactstarterkit.com/)
3 | *
4 | * Copyright © 2014-2016 Kriasoft, LLC. All rights reserved.
5 | *
6 | * This source code is licensed under the MIT license found in the
7 | * LICENSE.txt file in the root directory of this source tree.
8 | */
9 |
10 | import run from './run';
11 | import clean from './clean';
12 | import copy from './copy';
13 | import bundle from './bundle';
14 | import render from './render';
15 |
16 | /**
17 | * Compiles the project from source files into a distributable
18 | * format and copies it to the output (build) folder.
19 | */
20 | async function build() {
21 | await run(clean);
22 | await run(copy);
23 | await run(bundle);
24 |
25 | if (process.argv.includes('--static')) {
26 | await run(render);
27 | }
28 | }
29 |
30 | export default build;
31 |
--------------------------------------------------------------------------------
/tools/bundle.js:
--------------------------------------------------------------------------------
1 | /**
2 | * React Starter Kit (https://www.reactstarterkit.com/)
3 | *
4 | * Copyright © 2014-2016 Kriasoft, LLC. All rights reserved.
5 | *
6 | * This source code is licensed under the MIT license found in the
7 | * LICENSE.txt file in the root directory of this source tree.
8 | */
9 |
10 | import webpack from 'webpack';
11 | import webpackConfig from './webpack.config';
12 |
13 | /**
14 | * Creates application bundles from the source files.
15 | */
16 | function bundle() {
17 | return new Promise((resolve, reject) => {
18 | webpack(webpackConfig).run((err, stats) => {
19 | if (err) {
20 | return reject(err);
21 | }
22 |
23 | console.log(stats.toString(webpackConfig[0].stats));
24 | return resolve();
25 | });
26 | });
27 | }
28 |
29 | export default bundle;
30 |
--------------------------------------------------------------------------------
/tools/clean.js:
--------------------------------------------------------------------------------
1 | /**
2 | * React Starter Kit (https://www.reactstarterkit.com/)
3 | *
4 | * Copyright © 2014-2016 Kriasoft, LLC. All rights reserved.
5 | *
6 | * This source code is licensed under the MIT license found in the
7 | * LICENSE.txt file in the root directory of this source tree.
8 | */
9 |
10 | import del from 'del';
11 | import fs from './lib/fs';
12 |
13 | /**
14 | * Cleans up the output (build) directory.
15 | */
16 | async function clean() {
17 | await del(['.tmp', 'build/*', '!build/.git'], { dot: true });
18 | await fs.makeDir('build/public');
19 | }
20 |
21 | export default clean;
22 |
--------------------------------------------------------------------------------
/tools/copy.js:
--------------------------------------------------------------------------------
1 | /**
2 | * React Starter Kit (https://www.reactstarterkit.com/)
3 | *
4 | * Copyright © 2014-2016 Kriasoft, LLC. All rights reserved.
5 | *
6 | * This source code is licensed under the MIT license found in the
7 | * LICENSE.txt file in the root directory of this source tree.
8 | */
9 |
10 | import path from 'path';
11 | import gaze from 'gaze';
12 | import Promise from 'bluebird';
13 | import fs from './lib/fs';
14 | import pkg from '../package.json';
15 | /**
16 | * Copies static files such as robots.txt, favicon.ico to the
17 | * output (build) folder.
18 | */
19 | async function copy({ watch } = {}) {
20 | const ncp = Promise.promisify(require('ncp'));
21 |
22 | await Promise.all([
23 | ncp('node_modules/bootstrap/dist/css', 'build/public/css'),
24 | ncp('node_modules/bootstrap/dist/fonts', 'build/public/fonts'),
25 | ncp('src/public', 'build/public'),
26 | ]);
27 | await Promise.all([
28 | ncp('src/components/common/styles', 'build/public/css'),
29 | ]);
30 |
31 | await Promise.all([
32 | ncp('node_modules/font-awesome/css', 'build/public/css'),
33 | ncp('node_modules/font-awesome/fonts', 'build/public/fonts'),
34 | ]);
35 |
36 | await Promise.all([
37 | ncp('node_modules/bootstrap-social/bootstrap-social.css',
38 | 'build/public/css/bootstrap-social.css'),
39 | ]);
40 |
41 | await fs.writeFile('./build/package.json', JSON.stringify({
42 | private: true,
43 | engines: pkg.engines,
44 | dependencies: pkg.dependencies,
45 | scripts: {
46 | start: 'node server.js',
47 | },
48 | }, null, 2));
49 |
50 | if (watch) {
51 | const watcher = await new Promise((resolve, reject) => {
52 | gaze('src/content/**/*.*', (err, val) => err ? reject(err) : resolve(val));
53 | });
54 |
55 | const cp = async (file) => {
56 | const relPath = file.substr(path.join(__dirname, '../src/content/').length);
57 | await ncp(`src/content/${relPath}`, `build/content/${relPath}`);
58 | };
59 |
60 | watcher.on('changed', cp);
61 | watcher.on('added', cp);
62 | }
63 | }
64 |
65 | export default copy;
66 |
--------------------------------------------------------------------------------
/tools/deploy.js:
--------------------------------------------------------------------------------
1 | /**
2 | * React Starter Kit (https://www.reactstarterkit.com/)
3 | *
4 | * Copyright © 2014-2016 Kriasoft, LLC. All rights reserved.
5 | *
6 | * This source code is licensed under the MIT license found in the
7 | * LICENSE.txt file in the root directory of this source tree.
8 | */
9 |
10 | import GitRepo from 'git-repository';
11 | import run from './run';
12 | import fetch from './lib/fetch';
13 |
14 | // TODO: Update deployment URL
15 | // For more information visit http://gitolite.com/deploy.html
16 | const getRemote = (slot) => ({
17 | name: slot || 'production',
18 | url: `https://example${slot ? `-${slot}` : ''}.scm.azurewebsites.net:443/example.git`,
19 | website: `http://example${slot ? `-${slot}` : ''}.azurewebsites.net`,
20 | });
21 |
22 | /**
23 | * Deploy the contents of the `/build` folder to a remote
24 | * server via Git. Example: `npm run deploy -- production`
25 | */
26 | async function deploy() {
27 | // By default deploy to the staging deployment slot
28 | const remote = getRemote(process.argv.includes('--production') ? null : 'staging');
29 |
30 | // Initialize a new Git repository inside the `/build` folder
31 | // if it doesn't exist yet
32 | const repo = await GitRepo.open('build', { init: true });
33 | await repo.setRemote(remote.name, remote.url);
34 |
35 | // Fetch the remote repository if it exists
36 | if ((await repo.hasRef(remote.url, 'master'))) {
37 | await repo.fetch(remote.name);
38 | await repo.reset(`${remote.name}/master`, { hard: true });
39 | await repo.clean({ force: true });
40 | }
41 |
42 | // Build the project in RELEASE mode which
43 | // generates optimized and minimized bundles
44 | process.argv.push('--release');
45 | await run(require('./build'));
46 |
47 | // Push the contents of the build folder to the remote server via Git
48 | await repo.add('--all .');
49 | await repo.commit('Update');
50 | await repo.push(remote.name, 'master');
51 |
52 | // Check if the site was successfully deployed
53 | const response = await fetch(remote.website);
54 | console.log(`${remote.website} -> ${response.statusCode}`);
55 | }
56 |
57 | export default deploy;
58 |
--------------------------------------------------------------------------------
/tools/lib/fetch.js:
--------------------------------------------------------------------------------
1 | /**
2 | * React Starter Kit (https://www.reactstarterkit.com/)
3 | *
4 | * Copyright © 2014-2016 Kriasoft, LLC. All rights reserved.
5 | *
6 | * This source code is licensed under the MIT license found in the
7 | * LICENSE.txt file in the root directory of this source tree.
8 | */
9 |
10 | import http from 'http';
11 |
12 | export default async (url) => new Promise((resolve, reject) =>
13 | http.get(url, res => resolve(res)).on('error', err => reject(err))
14 | );
15 |
--------------------------------------------------------------------------------
/tools/lib/fs.js:
--------------------------------------------------------------------------------
1 | /**
2 | * React Starter Kit (https://www.reactstarterkit.com/)
3 | *
4 | * Copyright © 2014-2016 Kriasoft, LLC. All rights reserved.
5 | *
6 | * This source code is licensed under the MIT license found in the
7 | * LICENSE.txt file in the root directory of this source tree.
8 | */
9 |
10 | import fs from 'fs';
11 | import mkdirp from 'mkdirp';
12 |
13 | const writeFile = (file, contents) => new Promise((resolve, reject) => {
14 | fs.writeFile(file, contents, 'utf8', err => err ? reject(err) : resolve());
15 | });
16 |
17 | const makeDir = (name) => new Promise((resolve, reject) => {
18 | mkdirp(name, err => err ? reject(err) : resolve());
19 | });
20 |
21 | export default { writeFile, makeDir };
22 |
--------------------------------------------------------------------------------
/tools/render.js:
--------------------------------------------------------------------------------
1 | /**
2 | * React Starter Kit (https://www.reactstarterkit.com/)
3 | *
4 | * Copyright © 2014-2016 Kriasoft, LLC. All rights reserved.
5 | *
6 | * This source code is licensed under the MIT license found in the
7 | * LICENSE.txt file in the root directory of this source tree.
8 | */
9 |
10 | import fetch from 'node-fetch';
11 | import runServer from './runServer';
12 | import fs from './lib/fs';
13 | import { host } from '../src/config';
14 |
15 | // Enter your paths here which you want to render as static
16 | const routes = [
17 | '/',
18 | '/login',
19 | '/about',
20 | '/privacy',
21 | '/404', // https://help.github.com/articles/creating-a-custom-404-page-for-your-github-pages-site/
22 | ];
23 |
24 | async function render() {
25 | let server;
26 | await new Promise(resolve => (server = runServer(resolve)));
27 |
28 | await routes.reduce((promise, route) => promise.then(async () => {
29 | const url = `http://${host}${route}`;
30 | const dir = `build/public${route.replace(/[^\/]*$/, '')}`;
31 | const name = route.endsWith('/') ? 'index.html' : `${route.match(/[^/]+$/)[0]}.html`;
32 | const dist = `${dir}${name}`;
33 | const res = await fetch(url);
34 | const text = await res.text();
35 | await fs.makeDir(dir);
36 | await fs.writeFile(dist, text);
37 | console.log(`${dist} => ${res.status} ${res.statusText}`);
38 | }), Promise.resolve());
39 |
40 | server.kill('SIGTERM');
41 | }
42 |
43 | export default render;
44 |
--------------------------------------------------------------------------------
/tools/run.js:
--------------------------------------------------------------------------------
1 | /**
2 | * React Starter Kit (https://www.reactstarterkit.com/)
3 | *
4 | * Copyright © 2014-2016 Kriasoft, LLC. All rights reserved.
5 | *
6 | * This source code is licensed under the MIT license found in the
7 | * LICENSE.txt file in the root directory of this source tree.
8 | */
9 |
10 | function format(time) {
11 | return time.toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/, '$1');
12 | }
13 |
14 | function run(fn, options) {
15 | const task = typeof fn.default === 'undefined' ? fn : fn.default;
16 | const start = new Date();
17 | console.log(
18 | `[${format(start)}] Starting '${task.name}${options ? `(${options})` : ''}'...`
19 | );
20 | return task(options).then(resolution => {
21 | const end = new Date();
22 | const time = end.getTime() - start.getTime();
23 | console.log(
24 | `[${format(end)}] Finished '${task.name}${options ? `(${options})` : ''}' after ${time} ms`
25 | );
26 | return resolution;
27 | });
28 | }
29 |
30 | if (require.main === module && process.argv.length > 2) {
31 | delete require.cache[__filename]; // eslint-disable-line no-underscore-dangle
32 | const module = require(`./${process.argv[2]}.js`).default;
33 | run(module).catch(err => { console.error(err.stack); process.exit(1); });
34 | }
35 |
36 | export default run;
37 |
--------------------------------------------------------------------------------
/tools/runServer.js:
--------------------------------------------------------------------------------
1 | /**
2 | * React Starter Kit (https://www.reactstarterkit.com/)
3 | *
4 | * Copyright © 2014-2016 Kriasoft, LLC. All rights reserved.
5 | *
6 | * This source code is licensed under the MIT license found in the
7 | * LICENSE.txt file in the root directory of this source tree.
8 | */
9 |
10 | import path from 'path';
11 | import cp from 'child_process';
12 | import webpackConfig from './webpack.config';
13 |
14 | // Should match the text string used in `src/server.js/server.listen(...)`
15 | const RUNNING_REGEXP = /The server is running at http:\/\/(.*?)\//;
16 |
17 | let server;
18 | const { output } = webpackConfig.find(x => x.target === 'node');
19 | const serverPath = path.join(output.path, output.filename);
20 |
21 | // Launch or restart the Node.js server
22 | function runServer(cb) {
23 | let cbIsPending = !!cb;
24 |
25 | function onStdOut(data) {
26 | const time = new Date().toTimeString();
27 | const match = data.toString('utf8').match(RUNNING_REGEXP);
28 |
29 | process.stdout.write(time.replace(/.*(\d{2}:\d{2}:\d{2}).*/, '[$1] '));
30 | process.stdout.write(data);
31 |
32 | if (match) {
33 | server.stdout.removeListener('data', onStdOut);
34 | server.stdout.on('data', x => process.stdout.write(x));
35 | if (cb) {
36 | cbIsPending = false;
37 | cb(null, match[1]);
38 | }
39 | }
40 | }
41 |
42 | if (server) {
43 | server.kill('SIGTERM');
44 | }
45 |
46 | server = cp.spawn('node', [serverPath], {
47 | env: Object.assign({ NODE_ENV: 'development' }, process.env),
48 | silent: false,
49 | });
50 | if (cbIsPending) {
51 | server.once('exit', (code, signal) => {
52 | if (cbIsPending) {
53 | throw new Error(`Server terminated unexpectedly with code: ${code} signal: ${signal}`);
54 | }
55 | });
56 | }
57 |
58 | server.stdout.on('data', onStdOut);
59 | server.stderr.on('data', x => process.stderr.write(x));
60 | return server;
61 | }
62 |
63 | process.on('exit', () => {
64 | if (server) {
65 | server.kill('SIGTERM');
66 | }
67 | });
68 |
69 | export default runServer;
70 |
--------------------------------------------------------------------------------