-
Notifications
You must be signed in to change notification settings - Fork 1
/
template.html
98 lines (81 loc) · 2.7 KB
/
template.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Pie Chart</title>
<script type="text/javascript" src="d3.v3.min.js"></script>
<script type="text/javascript" src="pie.js"></script>
<link rel="stylesheet" href="style.css" />
</head>
<body>
<section>
<h1>Chart 1</h1>
<button onclick="updateChartA()">Data 1</button>
<button onclick="updateChartB()">Data 2</button>
<button onclick="updateChartC()">Data 3</button>
<div id="chart1"></div>
<script type="text/javascript">
var chart1 = document.getElementById("chart1");
d3.pie(chart1, {
'outerRadius' : 300,
'innerRadius' : 0,
'width' : 700,
'height' : 700,
'padding': 1,
'dataUrl' : 'data.json',
'dataType' : 'json',
'dataStructure' : {
'name' : 'name',
'value' : 'value'
},
'chartName' : 'Single-Layer Chart'
});
function updateChartA() {
d3.pie(chart1, {height:300,width:300,outerRadius:50,dataUrl:"data.json",'colorRange' : [d3.rgb(200, 10, 60), d3.rgb(70, 10, 190), d3.rgb(10, 20, 30), d3.rgb(40, 10, 60), d3.rgb(70, 10, 190), d3.rgb(10, 10, 60), d3.rgb(240, 150, 160), d3.rgb(40, 150, 260)]});
};
function updateChartB() {
d3.pie(chart1, {height:600,width:600,outerRadius:250,dataUrl:"data3.json"});
};
function updateChartC() {
d3.pie(chart1, "updateData", "data2.json");
};
</script>
</section>
<section>
<h1>Chart 2</h1>
<button onclick="updateChart2A()">Data 1</button>
<button onclick="updateChart2B()">Data 2</button>
<button onclick="updateChart2C()">Data 3</button>
<div id="chart2"></div>
<script type="text/javascript">
var chart2 = document.getElementById("chart2");
d3.pie(chart2, {
'radius': 200,
'width' : 500,
'height' : 500,
'padding': 1,
'dataUrl' : 'flare4.json',
'dataType' : 'json',
'dataStructure' : {
'name' : 'name',
'value' : 'size',
'children' : 'group'
},
'chartName' : 'Multi-Layer Chart',
'tooltip' : {
'id' : 'tooltip2'
}
});
function updateChart2A() {
d3.pie(chart2, "updateData", "flare4.json");
};
function updateChart2B() {
d3.pie(chart2, "updateData", "flare.json");
};
function updateChart2C() {
d3.pie(chart2, "updateData", "flare3.json");
};
</script>
</section>
</body>
</html>