forked from peterrcook/d3-radialbar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate-example.html
112 lines (95 loc) · 1.91 KB
/
update-example.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Radial Bar Chart example</title>
<style>
#chart {
font-family: "Helvetica Neue", Helvetica, sans-serif;
font-size: 14px;
}
#chart path {
fill: none;
}
/* layers */
#chart .layer-0 path {
fill: steelblue;
}
#chart .layer-1 path {
fill: white !important;
opacity: 0.3;
stroke-width: 2px;
stroke: #999;
}
/* Outer circle, tick-circles and spokes */
#chart circle.outer {
stroke: #aaa;
stroke-dasharray: 4, 4;
}
#chart .tick-circles circle {
stroke: #ddd;
stroke-dasharray: 2, 2;
}
#chart .spokes line {
stroke: #666;
stroke-width: 0.2;
}
/* Axis */
#chart .axis text {
font-size: 11px;
}
#chart .axis path {
stroke: #999;
shape-rendering: crispEdges;
}
#chart .axis line {
stroke: #999;
shape-rendering: crispEdges;
}
/* Labels */
#chart .labels text {
fill: #333;
font-size: 10px;
font-weight: 500;
}
/* update button */
#update {
width: 100px;
height: 30px;
cursor: pointer;
}
</style>
</head>
<body>
<button type="button" id="update">Update</button>
<div id="chart"></div>
<script src="js/d3.v3.min.js"></script>
<script src="js/radialBarChart.js"></script>
<script>
var data = null;
var keys = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
function initData() {
data = [{data: {}}];
for(var i=0; i<keys.length; i++)
data[0].data[keys[i]] = Math.random() * 10;
};
function update() {
initData();
d3.select('#chart')
.datum(data)
.call(chart);
}
d3.select('#update')
.on('click', update);
var chart = radialBarChart()
.barHeight(250)
.reverseLayerOrder(true)
.capitalizeLabels(true)
.barColors(['#B66199', '#9392CB', '#76D9FA', '#BCE3AD', '#FFD28C', '#F2918B'])
.domain([0,10])
.tickValues([1,2,3,4,5,6,7,8,9,10])
.tickCircleValues([1,2,3,4,5,6,7,8,9]);
update();
</script>
</body>
</html>