-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathring_chart.html
331 lines (323 loc) · 16.3 KB
/
ring_chart.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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Canvas Ring Chart with Tooltips</title>
<meta name="description" content="HTML canvas-based ring chart with tooltips and update animations. Open source.">
<meta http-equiv="X-UA-Compatible" content="IE=Edge">
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<link href="src/Chart.css" rel="stylesheet" type="text/css">
<link href="http://fonts.googleapis.com/css?family=Droid+Sans:400,700" rel="stylesheet" type="text/css">
<style>
HTML{margin:0px;padding:0px;min-height:100%;background-color:#5597cf;color:#eee;background-image:-webkit-linear-gradient(bottom, #80b4e1, #5597cf);background-image:-moz-linear-gradient(bottom, #80b4e1, #5597cf);background-image:-ms-linear-gradient(bottom, #80b4e1, #5597cf);background-image:-o-linear-gradient(bottom, #80b4e1, #5597cf);background-image:linear-gradient(bottom, #80b4e1, #5597cf);}
BODY{margin:0px;padding:0px;font-family:"Droid Sans",sans-serif;-webkit-font-smoothing:antialiased;}
::-webkit-scrollbar{width:12px;height:12px;}
::-webkit-scrollbar-thumb{border:1px solid #B8B8B8;-webkit-border-radius:0px;border-radius:0px;background:#ccc;}
::-webkit-scrollbar-track,::-webkit-scrollbar-corner{background:#eee;}
A{color:#eee;text-decoration:none;cursor:pointer;}
A:hover{text-decoration:underline;}
#hdr{display:block;margin:40px 0px 0px 80px;padding:0px;line-height:1.2em;font-size:28px;color:#fff;text-shadow:0px 1px 1px rgba(51, 51, 51, 0.1);}
#demoLinks{margin:0px 0px 0px 80px;line-height:1.5em;font-size:12px;}
#demoCon{margin:20px 0px 40px 80px;padding:16px;border:1px solid #ccc;border-radius:16px;width:820px;background-color:#eee;background-image:-webkit-linear-gradient(top, #fff 0%, rgba(255, 255, 255, 0) 2%);background-image:-moz-linear-gradient(top, #fff 0%, rgba(255, 255, 255, 0) 2%);background-image:-ms-linear-gradient(top, #fff 0%, rgba(255, 255, 255, 0) 2%);background-image:-o-linear-gradient(top, #fff 0%, rgba(255, 255, 255, 0) 2%);background-image:linear-gradient(top, #fff 0%, rgba(255, 255, 255, 0) 2%);box-shadow:1px 1px 1px rgba(51, 51, 51, 0.1);}
#demoConB{border-radius:16px;background-color:#fff;color:#1a2731;box-shadow:1px 1px 5px rgba(51, 51, 51, 0.10);}
#demoInfo{display:inline-block;*display:inline;zoom:1;padding:30px 20px 30px 40px;vertical-align:top;}
#demoInfoHdr{display:block;margin:0px;padding:0px;line-height:1.4em;font-weight:bold;font-size:16px;}
#demoInfoSubHdr{display:block;line-height:1.4em;font-size:12px;}
#demoLegend{display:block;margin:12px 0px 0px 0px;padding:0px;list-style-type:none;}
.dLi{display:block;margin:0px 0px 3px 0px;line-height:1.5em;font-size:12px;vertical-align:middle;}
.colorBox{display:inline-block;*display:inline;zoom:1;margin:0px 6px 3px 0px;width:9px;height:9px;border:1px solid #777;border-radius:2px;overflow:hidden;vertical-align:middle;}
.clrBoxAlt{position:absolute;margin:1px 0px 0px -23px;}
#demoDiv{display:inline-block;*display:inline;zoom:1;padding:20px 20px 20px 10px;width:220px;height:220px;vertical-align:top;}
#demoChartDiv{position:relative;width:220px;height:220px;}
#demoTableDiv{position:relative;display:inline-block;*display:inline;zoom:1;padding:20px 30px 20px 57px;cursor:default;}
#updateBtn{position:absolute;z-index:1;top:-10px;right:28px;display:block;font-size:12px;}
#demoTable{border-collapse:collapse;border-spacing:0px;font-size:12px;}
#demoTable th{padding:4px 6px;text-align:left;border-width:1px 0px;border-style:solid;border-color:#ddd;background-color:#f4f4f4;white-space:nowrap;}
#demoTable td{padding:6px;white-space:nowrap;}
.main{border-width:1px 0px;border-style:solid;border-color:#e4e4e4;background-color:#fafafa;}
.divider{padding:3px 0px !important;line-height:0px;font-size:0px !important;}
.rOInput{margin:0px;padding:0px;border:none;text-align:right;font-size:12px;font-family:"Droid Sans",sans-serif;width:50px;vertical-align:middle;background-color:transparent;}
.num{padding-left:30px !important;text-align:right !important;}
.padLeft{padding-left:30px !important;}
.padLeftSmall{padding-left:20px !important;}
.chartTooltip{font-size:11px;font-family:Verdana;color:#1a2731;} /* Example customization */
</style>
<!--[if lte IE 8]><style>#demoCon{width:860px;}</style><![endif]-->
</head>
<body>
<h1 id="hdr">Canvas Ring Chart with Tooltips</h1>
<div id="demoLinks">
<a href="http://www.matts411.com/post/canvas-pie-and-ring-charts-with-tooltips/" title="Home">Home</a>
-
<a href="http://github.com/mmurph211/Chart" title="GitHub">Github Project</a>
-
<a href="https://github.com/mmurph211/Chart/blob/master/src/Chart.js" title="View Script">Script Source</a>
-
<a href="https://github.com/mmurph211/Chart/blob/master/src/Chart.css" title="View CSS">CSS Source</a>
</div>
<div id="demoCon">
<div id="demoConB">
<div id="demoInfo">
<h3 id="demoInfoHdr">Target Weight</h3>
<span id="demoInfoSubHdr">By Asset Category<br>and Asset Class</span>
<ul id="demoLegend">
<li class="dLi"><span class="colorBox" style="background-color:#76df72;"></span> Fixed Income</li>
<li class="dLi"><span class="colorBox" style="background-color:#759ddf;"></span> Equity</li>
<li class="dLi"><span class="colorBox" style="background-color:#f1d94b;"></span> Real Estate</li>
<li class="dLi"><span class="colorBox" style="background-color:#f1994a;"></span> Alternatives</li>
<li class="dLi"><span class="colorBox" style="background-color:#f15f5f;"></span> Cash</li>
</ul>
</div>
<div id="demoDiv"><div id="demoChartDiv"></div></div><br>
<div id="demoTableDiv">
<input id="updateBtn" type="button" value="Update" data-next="update">
<table id="demoTable" cellpadding="0">
<thead>
<tr>
<th title="Asset Category">Asset Cat. </th>
<th>Asset Class</th>
<th class="num">Target %</th>
<th class="num"> Min %</th>
<th class="num"> Max %</th>
<th class="padLeft">Manager</th>
<th class="padLeftSmall">Account</th>
</tr>
</thead>
<tbody>
<tr>
<td class="main"><span class="colorBox clrBoxAlt" style="background-color:#76df72;"></span> Fixed Income</td>
<td class="main"> </td>
<td class="main num"><input id="pctMain-0" class="rOInput" type="text" value="30.00" tabIndex="-1" readOnly></td>
<td class="main num">20.00</td>
<td class="main num">40.00</td>
<td class="main padLeft"> </td>
<td class="main padLeftSmall"> </td>
</tr>
<tr>
<td> </td>
<td>Taxable Bonds</td>
<td class="num"><input id="pct-0" class="rOInput" type="text" value="10.00" tabIndex="-1" readOnly></td>
<td class="num">5.00</td>
<td class="num">15.00</td>
<td class="padLeft">ATC Investors</td>
<td class="padLeftSmall">ACCT-0340499320</td>
</tr>
<tr>
<td> </td>
<td>High Yield Bonds</td>
<td class="num"><input id="pct-1" class="rOInput" type="text" value="10.00" tabIndex="-1" readOnly></td>
<td class="num">5.00</td>
<td class="num">15.00</td>
<td class="padLeft">ATC Investors</td>
<td class="padLeftSmall">ACCT-0340499320</td>
</tr>
<tr>
<td> </td>
<td>Int'l Debt</td>
<td class="num"><input id="pct-2" class="rOInput" type="text" value="10.00" tabIndex="-1" readOnly></td>
<td class="num">5.00</td>
<td class="num">15.00</td>
<td class="padLeft">ATC Investors</td>
<td class="padLeftSmall">ACCT-0340499320</td>
</tr>
<tr>
<td colSpan="7" class="divider"> </td>
</tr>
<tr>
<td class="main"><span class="colorBox clrBoxAlt" style="background-color:#759ddf;"></span> Equity</td>
<td class="main"> </td>
<td class="main num"><input id="pctMain-1" class="rOInput" type="text" value="40.00" tabIndex="-1" readOnly></td>
<td class="main num">30.00</td>
<td class="main num">50.00</td>
<td class="main padLeft"> </td>
<td class="main padLeftSmall"> </td>
</tr>
<tr>
<td> </td>
<td>Large Cap Equity</td>
<td class="num"><input id="pct-3" class="rOInput" type="text" value="15.00" tabIndex="-1" readOnly></td>
<td class="num">10.00</td>
<td class="num">20.00</td>
<td class="padLeft">DTG Capital</td>
<td class="padLeftSmall">DTG-3023-3432</td>
</tr>
<tr>
<td> </td>
<td>Mid Cap Equity</td>
<td class="num"><input id="pct-4" class="rOInput" type="text" value="10.00" tabIndex="-1" readOnly></td>
<td class="num">5.00</td>
<td class="num">15.00</td>
<td class="padLeft">DTG Capital</td>
<td class="padLeftSmall">DTG-3023-3432</td>
</tr>
<tr>
<td> </td>
<td>Small Cap Equity</td>
<td class="num"><input id="pct-5" class="rOInput" type="text" value="5.00" tabIndex="-1" readOnly></td>
<td class="num">5.00</td>
<td class="num">10.00</td>
<td class="padLeft">DTG Capital</td>
<td class="padLeftSmall">DTG-3023-3432</td>
</tr>
<tr>
<td> </td>
<td>Int'l Equity</td>
<td class="num"><input id="pct-6" class="rOInput" type="text" value="10.00" tabIndex="-1" readOnly></td>
<td class="num">5.00</td>
<td class="num">15.00</td>
<td class="padLeft">DTG Capital</td>
<td class="padLeftSmall">DTG-3023-3432</td>
</tr>
<tr>
<td colSpan="7" class="divider"> </td>
</tr>
<tr>
<td class="main"><span class="colorBox clrBoxAlt" style="background-color:#f1d94b;"></span> Real Estate</td>
<td class="main"> </td>
<td class="main num"><input id="pctMain-2" class="rOInput" type="text" value="15.00" tabIndex="-1" readOnly></td>
<td class="main num">10.00</td>
<td class="main num">20.00</td>
<td class="main padLeft"> </td>
<td class="main padLeftSmall"> </td>
</tr>
<tr>
<td> </td>
<td>Global Public REITs</td>
<td class="num"><input id="pct-7" class="rOInput" type="text" value="5.00" tabIndex="-1" readOnly></td>
<td class="num">5.00</td>
<td class="num">10.00</td>
<td class="padLeft">DTG Capital</td>
<td class="padLeftSmall">DTG-3023-3432</td>
</tr>
<tr>
<td> </td>
<td>Private Real Estate</td>
<td class="num"><input id="pct-8" class="rOInput" type="text" value="10.00" tabIndex="-1" readOnly></td>
<td class="num">5.00</td>
<td class="num">15.00</td>
<td class="padLeft"> </td>
<td class="padLeftSmall"> </td>
</tr>
<tr>
<td colSpan="7" class="divider"> </td>
</tr>
<tr>
<td class="main"><span class="colorBox clrBoxAlt" style="background-color:#f1994a;"></span> Alternatives</td>
<td class="main"> </td>
<td class="main num"><input id="pctMain-3" class="rOInput" type="text" value="10.00" tabIndex="-1" readOnly></td>
<td class="main num">5.00</td>
<td class="main num">15.00</td>
<td class="main padLeft"> </td>
<td class="main padLeftSmall"> </td>
</tr>
<tr>
<td> </td>
<td>Diversified Hedge</td>
<td class="num"><input id="pct-9" class="rOInput" type="text" value="5.00" tabIndex="-1" readOnly></td>
<td class="num">2.50</td>
<td class="num">10.00</td>
<td class="padLeft">QQ Partners LLC</td>
<td class="padLeftSmall">ACCT-00032</td>
</tr>
<tr>
<td> </td>
<td>Private Equity</td>
<td class="num"><input id="pct-10" class="rOInput" type="text" value="5.00" tabIndex="-1" readOnly></td>
<td class="num">2.50</td>
<td class="num">10.00</td>
<td class="padLeft"> </td>
<td class="padLeftSmall"> </td>
</tr>
<tr>
<td colSpan="7" class="divider"> </td>
</tr>
<tr>
<td class="main"><span class="colorBox clrBoxAlt" style="background-color:#f15f5f;"></span> Cash</td>
<td class="main"> </td>
<td class="main num"><input id="pctMain-4" class="rOInput" type="text" value="5.00" tabIndex="-1" readOnly></td>
<td class="main num">2.50</td>
<td class="main num">10.00</td>
<td class="main padLeft"> </td>
<td class="main padLeftSmall"> </td>
</tr>
<tr>
<td> </td>
<td>Cash</td>
<td class="num"><input id="pct-11" class="rOInput" type="text" value="5.00" tabIndex="-1" readOnly></td>
<td class="num">2.50</td>
<td class="num">10.00</td>
<td class="padLeft">DTG Capital</td>
<td class="padLeftSmall">DTG-3023-3432</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<!--[if lte IE 8]><script src="src/excanvas2.js"></script><![endif]-->
<script src="src/Chart.js"></script>
<script>
(function(window, document, undefined) {
"use strict";
var chartData = [["Fixed Income", [
["Taxable Bonds", 10.00, ""],
["High Yield Bonds", 10.00, ""],
["Int'l Debt", 10.00, ""]], "", "#76df72"],
["Equity", [
["Large Cap Equity", 15.00, ""],
["Mid Cap Equity", 10.00, ""],
["Small Cap Equity", 5.00, ""],
["Int'l Equity", 10.00, ""]], "", "#759ddf"],
["Real Estate", [
["Global Public REITs", 5.00, ""],
["Private Real Estate", 10.00, ""]], "", "#f1d94b"],
["Alternatives", [
["Diversified Hedge", 5.00, ""],
["Private Equity", 5.00, ""]], "", "#f1994a"],
["Cash", [
["Cash", 5.00, ""]], "", "#f15f5f"]],
updateData = [["Fixed Income", [
["Taxable Bonds", 5.00, ""],
["High Yield Bonds", 10.00, ""],
["Int'l Debt", 5.00, ""]], "", "#76df72"],
["Equity", [
["Large Cap Equity", 15.00, ""],
["Mid Cap Equity", 15.00, ""],
["Small Cap Equity", 5.00, ""],
["Int'l Equity", 10.00, ""]], "", "#759ddf"],
["Real Estate", [
["Global Public REITs", 5.00, ""],
["Private Real Estate", 12.00, ""]], "", "#f1d94b"],
["Alternatives", [
["Diversified Hedge", 5.00, ""],
["Private Equity", 8.00, ""]], "", "#f1994a"],
["Cash", [
["Cash", 5.00, ""]], "", "#f15f5f"]];
// Create the ring chart:
var ringChart = new Chart.Ring("demoChartDiv", {
showTooltips : true,
chartMinSize : [220, 220],
chartMaxSize : [220, 220],
chartData : chartData
});
// Add button event to update the ring chart data set:
document.getElementById("updateBtn").onclick = function(event) {
var target = (event = event || window.event).target || event.srcElement,
isUpdate = (target.getAttribute("data-next") === "update"),
dataSet = (isUpdate) ? updateData : chartData,
slice, subSlice, sPct, sIdx, i, j,
doc = document;
for (i=sIdx=0; slice=dataSet[i]; i++) {
sPct = 0;
for (j=0; subSlice=slice[1][j]; j++) {
doc.getElementById("pct-" + (sIdx++)).value = subSlice[1].toFixed(2);
sPct += (subSlice[1] || 0);
}
doc.getElementById("pctMain-" + i).value = sPct.toFixed(2);
}
target.setAttribute("data-next", (isUpdate) ? "revert" : "update");
ringChart.updateData(dataSet);
};
})(this, this.document);
</script>
</body>
</html>