1
1
var React = require ( 'react' ) ;
2
2
var Row = require ( 'react-bootstrap/Row' ) ;
3
+ var Button = require ( 'react-bootstrap/Button' ) ;
4
+ var ButtonGroup = require ( 'react-bootstrap/ButtonGroup' ) ;
3
5
var Panel = require ( './panel.jsx' ) ;
4
6
var Logo = require ( './logo.jsx' ) ;
5
7
var Pie = require ( './pie.jsx' ) ;
@@ -13,52 +15,78 @@ var Stack = require('./stack.jsx');
13
15
var Voronoi = require ( './voronoi.jsx' ) ;
14
16
15
17
module . exports = React . createClass ( {
18
+ getInitialState : function ( ) {
19
+ return {
20
+ select : 0
21
+ } ;
22
+ } ,
23
+
24
+ select : function ( i ) {
25
+ this . setState ( { select : i } ) ;
26
+ } ,
27
+
28
+ components : [
29
+ < Panel title = "Pie Chart" key = "pie" text = "Here is a pie chart example. Sectors are clickable" sources = { [ 'components/pie' , 'charts/pie' ] } >
30
+ < Pie />
31
+ </ Panel > ,
32
+ < Panel title = "Path animation"
33
+ key = "path-animation"
34
+ text = { < span > Integrate with < a href = "http://maxwellito.github.io/vivus/" target = "_blank" > Vivus</ a > to animate paths</ span > }
35
+ sources = { [ 'components/drawing' ] } >
36
+ < Drawing />
37
+ </ Panel > ,
38
+ < Panel key = "line" title = "Line Chart" text = "Here is a zoomable timeline" sources = { [ 'components/timeline' , 'charts/timeline' ] } >
39
+ < Timeline />
40
+ </ Panel > ,
41
+ < Panel
42
+ key = "zoomable"
43
+ title = "Zoomable timeline" text = "Use the minimap to zoom the timeline"
44
+ sources = { [ 'components/timeline2' , 'charts/zoomable' , 'charts/zoomedmap' , 'charts/minimap' ] } >
45
+ < Timeline2 />
46
+ </ Panel > ,
47
+ < Panel key = "speed-dial" title = "Speed dial" text = "We use a pie chart to track the mouse speed" sources = { [ 'components/dial' ] } >
48
+ < Dial />
49
+ </ Panel > ,
50
+ < Panel key = "tree" title = "Tree" text = "Here is a Tree Graph" sources = { [ 'components/tree' ] } >
51
+ < Tree />
52
+ </ Panel > ,
53
+ < Panel key = "bar" title = "Bar" text = "Point over the bars to animate" sources = { [ 'components/bar' ] } >
54
+ < Bar data = { [ [ 1 , 2 , 3 , 4 ] , [ 3 , 4 , 5 , 6 ] , [ 4 , 2 , 3 , 2 ] ] } />
55
+ </ Panel > ,
56
+ < Panel key = "stack" title = "Stack" text = "Point over the bars to animate" sources = { [ 'components/stack' ] } >
57
+ < Stack data = { [ [ 1 , 2 , 3 , 4 ] , [ 3 , 4 , 5 , 6 ] , [ 4 , 2 , 3 , 2 ] ] } />
58
+ </ Panel > ,
59
+ < Panel key = "voronoi" title = "Voronoi" text = "Move the mouse over the diagram to add a point"
60
+ sources = { [ 'components/voronoi' , 'charts/voronoi' ] } >
61
+ < Voronoi />
62
+ </ Panel >
63
+ ] ,
64
+
16
65
render : function ( ) {
66
+ var n = this . state . select % this . components . length ;
67
+ var self = this ;
68
+ var selectors = this . components . map ( function ( c , i ) {
69
+ var active = i == self . state . select ;
70
+ var bsStyle = active ? "primary" : "default" ;
71
+ return < Button
72
+ key = { i }
73
+ onClick = { self . select . bind ( self , i ) }
74
+ active = { active }
75
+ bsStyle = { bsStyle } > { c . props . title } </ Button > ;
76
+ } ) ;
77
+
17
78
return (
18
79
< div className = "container" >
19
80
< Row >
20
81
< Logo />
21
82
</ Row >
22
83
< Row >
23
- < Panel title = "Pie Chart" text = "Here is a pie chart example. Sectors are clickable" sources = { [ 'components/pie' , 'charts/pie' ] } >
24
- < Pie />
25
- </ Panel >
26
- < Panel title = "Path animation"
27
- text = { < span > Integrate with < a href = "http://maxwellito.github.io/vivus/" target = "_blank" > Vivus</ a > to animate paths</ span > }
28
- sources = { [ 'components/drawing' ] } >
29
- < Drawing />
30
- </ Panel >
31
- </ Row >
32
- < Row >
33
- < Panel title = "Line Chart" text = "Here is a zoomable timeline" sources = { [ 'components/timeline' , 'charts/timeline' ] } >
34
- < Timeline />
35
- </ Panel >
36
- < Panel title = "Zoomable timeline" text = "Use the minimap to zoom the timeline"
37
- sources = { [ 'components/timeline2' , 'charts/zoomable' , 'charts/zoomedmap' , 'charts/minimap' ] } >
38
- < Timeline2 />
39
- </ Panel >
40
- </ Row >
41
- < Row >
42
- < Panel title = "Speed dial" text = "We use a pie chart to track the mouse speed" sources = { [ 'components/dial' ] } >
43
- < Dial />
44
- </ Panel >
45
- < Panel title = "Tree" text = "Here is a Tree Graph" sources = { [ 'components/tree' ] } >
46
- < Tree />
47
- </ Panel >
48
- </ Row >
49
- < Row >
50
- < Panel title = "Bar" text = "Point over the bars to animate" sources = { [ 'components/bar' ] } >
51
- < Bar data = { [ [ 1 , 2 , 3 , 4 ] , [ 3 , 4 , 5 , 6 ] , [ 4 , 2 , 3 , 2 ] ] } />
52
- </ Panel >
53
- < Panel title = "Stack" text = "Point over the bars to animate" sources = { [ 'components/stack' ] } >
54
- < Stack data = { [ [ 1 , 2 , 3 , 4 ] , [ 3 , 4 , 5 , 6 ] , [ 4 , 2 , 3 , 2 ] ] } />
55
- </ Panel >
84
+ < div className = "center-wrap" >
85
+ < ButtonGroup className = "center" > { selectors } </ ButtonGroup >
86
+ </ div >
56
87
</ Row >
57
88
< Row >
58
- < Panel title = "Voronoi" text = "Move the mouse over the diagram to add a point"
59
- sources = { [ 'components/voronoi' , 'charts/voronoi' ] } >
60
- < Voronoi />
61
- </ Panel >
89
+ { this . components [ n ] }
62
90
</ Row >
63
91
</ div >
64
92
) }
0 commit comments