Skip to content

Commit e1f6013

Browse files
committed
improve document
1 parent da1629c commit e1f6013

30 files changed

+1143
-1296
lines changed

.babelrc

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"presets": ["react", "es2015", "stage-0"],
3+
"env": {
4+
"development": {
5+
"presets": ["react-hmre"],
6+
"plugins": [
7+
"add-module-exports"
8+
]
9+
},
10+
"production": {
11+
"plugins": [
12+
"add-module-exports"
13+
]
14+
}
15+
}
16+
}

devServer.js

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
var path = require('path');
2+
var express = require('express');
3+
var webpack = require('webpack');
4+
var config = require('./webpack.config');
5+
6+
var app = express();
7+
var compiler = webpack(config);
8+
9+
app.use(require('webpack-dev-middleware')(compiler, {
10+
noInfo: true,
11+
publicPath: config.output.publicPath
12+
}));
13+
14+
app.use(require('webpack-hot-middleware')(compiler));
15+
16+
app.get('/example', function(req, res) {
17+
res.sendFile(path.join(__dirname, './example/index.html'));
18+
});
19+
20+
app.get('/example/*', function(req, res) {
21+
res.sendFile(path.join(__dirname, './example/index.html'));
22+
});
23+
24+
app.listen(5000, 'localhost', function(err) {
25+
if (err) {
26+
console.log(err);
27+
return;
28+
}
29+
30+
console.log('Listening at http://localhost:5000/example');
31+
});

example/area.html

-21
This file was deleted.

example/area_stack.html

-21
This file was deleted.

example/bar.html

-21
This file was deleted.

example/bar_group.html

-21
This file was deleted.

example/bar_group_horizontal.html

-21
This file was deleted.

example/bar_horizontal.html

-21
This file was deleted.

example/bar_stack.html

-21
This file was deleted.

example/bar_stack_horizontal.html

-21
This file was deleted.

example/container.js

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import React, { Component } from 'react'
2+
import {Nav, NavItem} from 'react-bootstrap'
3+
4+
export default class ContainerExample extends Component {
5+
constructor(props) {
6+
super(props)
7+
}
8+
9+
render() {
10+
11+
const route = this.props.routes[1].path || 'area_stack'
12+
13+
return (
14+
<div>
15+
<nav className="navbar navbar-default navbar-fixed-top">
16+
<div className="container">
17+
<div className="navbar-header">
18+
<a className="navbar-brand" href="/example">
19+
React-d3 shape
20+
</a>
21+
</div>
22+
</div>
23+
</nav>
24+
<div style={{marginTop: '50px', padding: '30px'}}>
25+
<Nav bsStyle="pills" justified activeKey={route}>
26+
<NavItem eventKey="area_stack" href="/example/area_stack">Area Stack</NavItem>
27+
<NavItem eventKey="bar" href="/example/bar">Bar</NavItem>
28+
<NavItem eventKey="bar_group" href="/example/bar_group">Bar Group</NavItem>
29+
<NavItem eventKey="bar_group_horizontal" href="/example/bar_group_horizontal">Bar Group Horizontal</NavItem>
30+
<NavItem eventKey="bar_horizontal" href="/example/bar_horizontal">Bar Horizontal</NavItem>
31+
<NavItem eventKey="bar_stack" href="/example/bar_stack">Bar Stack</NavItem>
32+
<NavItem eventKey="bar_stack_horizontal" href="/example/bar_stack_horizontal">Bar Stack Horizontal</NavItem>
33+
<NavItem eventKey="donut" href="/example/donut">Donut</NavItem>
34+
<NavItem eventKey="line" href="/example/line">Line</NavItem>
35+
<NavItem eventKey="pie" href="/example/pie">Pie</NavItem>
36+
<NavItem eventKey="scatter" href="/example/scatter">Scatter</NavItem>
37+
</Nav>
38+
</div>
39+
{this.props.children}
40+
</div>
41+
)
42+
}
43+
}

example/donut.html

-21
This file was deleted.

example/index.html

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
5+
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">
6+
<title>react-d3-shape</title>
7+
</head>
8+
<body>
9+
<div id="root"></div>
10+
<script src="https://code.jquery.com/jquery-2.2.0.min.js"></script>
11+
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-easing/1.3/jquery.easing.min.js"></script>
12+
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
13+
<script src="/static/index.js"></script>
14+
</body>
15+
</html>

example/index.js

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import React, { Component } from 'react'
2+
import ReactDOM from 'react-dom'
3+
import { Router, Route, browserHistory, IndexRedirect} from 'react-router'
4+
import Container from './container'
5+
6+
import AreaStack from './src/area_stack'
7+
import Bar from './src/bar'
8+
import BarGroup from './src/bar_group'
9+
import BarGroupHorizontal from './src/bar_group_horizontal'
10+
import BarHorizontal from './src/bar_horizontal'
11+
import BarStack from './src/bar_stack'
12+
import BarStackHorizontal from './src/bar_stack_horizontal'
13+
import Donut from './src/donut'
14+
import Line from './src/line'
15+
import Pie from './src/pie'
16+
import Scatter from './src/scatter'
17+
18+
// Declarative route configuration (could also load this config lazily
19+
// instead, all you really need is a single root route, you don't need to
20+
// colocate the entire config).
21+
22+
23+
ReactDOM.render((
24+
<Router history={browserHistory}>
25+
<Route path="/example" component={Container}>
26+
<IndexRedirect to="area_stack"/>
27+
<Route path="bar" component={Bar}/>
28+
<Route path="area_stack" component={AreaStack}/>
29+
<Route path="bar_group" component={BarGroup}/>
30+
<Route path="bar_group_horizontal" component={BarGroupHorizontal}/>
31+
<Route path="bar_horizontal" component={BarHorizontal}/>
32+
<Route path="bar_stack" component={BarStack}/>
33+
<Route path="bar_stack_horizontal" component={BarStackHorizontal}/>
34+
<Route path="donut" component={Donut}/>
35+
<Route path="line" component={Line}/>
36+
<Route path="pie" component={Pie}/>
37+
<Route path="scatter" component={Scatter}/>
38+
</Route>
39+
</Router>
40+
), document.getElementById('root'))

example/line.html

-21
This file was deleted.

0 commit comments

Comments
 (0)