Skip to content

Commit 8ff45e4

Browse files
Added new chart
1 parent c4c12df commit 8ff45e4

File tree

5 files changed

+71
-3
lines changed

5 files changed

+71
-3
lines changed

app/index.html

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,18 @@
3636
</div>
3737
<div class="row">
3838
<div id="bar" class="col-md-6"></div>
39-
<div id="tree" class="col-md-6"></div>
39+
<div id="stack" class="col-md-6"></div>
4040
</div>
4141
<div class="row">
4242
<div id="graph" class="col-md-6"></div>
43+
<div id="tree" class="col-md-6"></div>
44+
</div>
45+
<div class="row">
4346
<div id="scatterplot" class="col-md-6"></div>
47+
<div id="sankey" class="col-md-6"></div>
4448
</div>
4549
<div class="row">
4650
<div id="waterfall" class="col-md-6"></div>
47-
<div id="sankey" class="col-md-6"></div>
4851
</div>
4952
</body>
5053
</html>

app/templates/stack.html

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<div class="panel panel-default">
2+
<div class="panel-heading">
3+
<h2 class="panel-title">Bar Chart</h2>
4+
<span class="links">
5+
<a on-click="coffee">Coffescript</a>
6+
<a on-click="html">HTML</a>
7+
</span>
8+
</div>
9+
10+
<div class="panel-body">
11+
<p class="alert alert-info">Here is a stacked bar chart example. Try hovering on the bars.</p>
12+
13+
<svg width=500 height=380>
14+
<g>
15+
{{# Bar({data: data, accessor: accessor, width: width, height: height, gutter: gutter }) }}
16+
{{# curves:num }}
17+
<path on-mouseenter="detail" on-mouseleave="restore" d="{{ line.path.print() }}" stroke="none" fill="{{ colors(group) }}" />
18+
{{/ curves }}
19+
{{/ end of bar }}
20+
</g>
21+
</svg>
22+
</div>
23+
</div>

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"requirejs-plugins": "1.0.2",
88
"ractive": "0.3.9",
99
"pajamas": "1.6.1",
10-
"paths-js": "0.4.0"
10+
"paths-js": "0.4.1"
1111
},
1212
"devDependencies": {}
1313
}

src/coffee/app.coffee

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ define [
66
'views/radar'
77
'views/line'
88
'views/bar'
9+
'views/stack'
910
'views/tree'
1011
'views/graph'
1112
'views/scatterplot'

src/coffee/views/stack.coffee

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
define [
2+
'ractive'
3+
'show_source'
4+
'paths/stack'
5+
'palette/util'
6+
'text!templates/stack.html'
7+
], (Ractive, show_source, Stack, util, template)->
8+
palette = ["#FEE871", "#E5FAAF", "#B7E5F5"]
9+
colors = util.palette_to_function(palette)
10+
11+
data = [
12+
[1, 2, 3, 4]
13+
[3, 5, 4, 2]
14+
[1, 6, 1, 6]
15+
]
16+
17+
lower = (data, index) ->
18+
data.map (d, i) ->
19+
if i == index then d else (0 for x in d)
20+
21+
bar = new Ractive
22+
el: '#stack'
23+
template: template
24+
data:
25+
Bar: Stack
26+
data: data
27+
accessor: (x) -> x
28+
width: 500
29+
height: 350
30+
gutter: 10
31+
colors: colors
32+
33+
bar.on 'detail', (event) ->
34+
console.log event
35+
index = event.context.group
36+
@animate 'data', lower(data, index)
37+
38+
bar.on 'restore', ->
39+
@animate 'data', data
40+
41+
show_source('bar', bar)

0 commit comments

Comments
 (0)