-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
761 lines (625 loc) · 22.2 KB
/
index.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
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7.2/leaflet.css" />
<script src="jquery-ui-1.11.0/external/jquery/jquery.js"></script>
<script src="jquery-ui-1.11.0/jquery-ui.min.js"></script>
<script src="http://cdn.leafletjs.com/leaflet-0.7.2/leaflet.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<link rel="stylesheet" href="jquery-ui-1.11.0/jquery-ui.css" />
<link rel="stylesheet" href="jquery-ui-1.11.0/jquery-ui.structure.css" />
<link rel="stylesheet" href="jquery-ui-1.11.0/jquery-ui.theme.css" />
<link rel="stylesheet" href="mobile.css" />
<link rel="stylesheet" href="dist/MarkerCluster.css" />
<link rel="stylesheet" href="dist/MarkerCluster.Default.css" />
<link rel="stylesheet" href="community.css" />
<link rel="stylesheet" href="clusterpie.css" />
<script src="dist/leaflet.markercluster-src.js"></script>
<script src="http://maps.google.com/maps/api/js?v=3&sensor=false"></script>
<script src="layer/tile/Google.js"></script>
<script src="wb.js"></script>
<script src="filter.js"></script>
<!-- // <script src="html5slider.js"></script> -->
</head>
<style type="text/css">
</style>
</head>
<body>
<!-- <div id="sdiv"><h4>Toilet Types</h4><label id="myLabel">12</label><p><input id="slide" name="slider" type="range" min="1" max="12" step="1" value="12" onchange="updateSlider(this.value)"/></p></div> -->
<div id="map"></div>
<!-- <div id="controlpanel" class='draggable ui-corner-all ui-widget-content uipanel'>
<h4>Filters</h4>
<select id="1">
<option value="All">All</option>
<option value="Primary">Primary</option>
<option value="Non-Primary">Non-Primary</option>
</select>
<select id="2">
<option value="All">All</option>
<option value="Boys">Boys</option>
<option value="Girls">Girls</option>
<option value="Co-education">Co-education</option>
</select>
<select id="3">
<option value=""></option>
<option value="Attendance">Attendance</option>
<option value="Adequacy of teacher">Adequacy of teacher</option>
<option value="Adequacy and sustainability of WASH infrastructure">Adequacy and sustainability of WASH infrastructure</option>
<option value="School Management">School Management</option>
</select>
<select id="4"></select>
<!-- <select id="5">
<option value="Yes">Yes</option>
<option value="No">No</option>
<option value="All">All</option>
</select> -->
<!--<input id="Go" type="button" value="Go" ></input>
</div> -->
<div id='controlpanel' class='draggable ui-corner-all ui-widget-content uipanel'>
<h3>Data Chooser</h3>
<div id='controlpanelcontent'>
<div id='schoolCode'>
<label for="code">School Code</label>
<input type='text' id='code' size=15 class="textbox"></input>
<input id="Search" type="button" value="Go to School" ></input>
</div>
<div id='topiclist' class='controlpaneloption'>1.<div id='topicbuttons'></div>
</div>
<div id='tablelist' class='controlpaneloption'>2.
<label for="1">Category</label>
<select id="1">
<option value="All">All</option>
<option value="Primary">Primary</option>
<option value="Non-Primary">Non-Primary</option>
</select>
<label for="2">Type</label>
<select id="2">
<option value="All">All</option>
<option value="Boys">Boys</option>
<option value="Girls">Girls</option>
<option value="Co-education">Co-education</option>
</select>
</div>
<div id='tablelist' class='controlpaneloption'>3.
<select id='4' class='ui-widget select'></select>
<input id="Go" type="button" value="Search" ></input>
</div>
<!-- <div id='tablequal' class='qual'> </div>
<div id='collist' class='controlpaneloption'>3
<select id='colselect' onchange='setSubCols()'></select>
</div>
<div id='subcollist' class='controlpaneloption'>4
<select id='subcolselect' onchange='setColQualAndTileNames()'></select>
</div> -->
<div id='colqual' class='qual'> </div>
</div>
</div>
<div id='infopanel' class="draggable ui-corner-all ui-widget-content uipanel">
<h3>Key</h3>
<div id='infopanelcontent'>
<div id='colpanel'>
</div>
<div id='keypanel'>
<div id='keylqs'>
</div>
<div id='keyitems'>
</div>
<div id='keynumbers'>
</div>
</div>
<div id='placepanel'>
</div>
<div style='clear: both; '></div>
</div>
</div>
<script src="lib/d3.v3.min.js" charset="utf-8"></script>
<script type="text/javascript">
d3.csv("data.csv",function(data){
var origData=data;
var gjLayer;
var currentIndicator="";
var legendAdded=false;
var rmax=30;
var map = L.map('map',{zoomControl: false }).setView([24.729284, 87.982334], 7);
var osm = new L.TileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png');
var ggl = new L.Google();
var ggl2 = new L.Google('TERRAIN');
map.addLayer(ggl2);
var baseMaps={'OSM':osm, 'Satellite':ggl, 'Google Terrain':ggl2};
// map.addControl(new L.Control.Layers( baseMaps, {}));
gjLayer=L.geoJson(geojson,{style:style,onEachFeature:onEachFeature});
// gjLayer.addTo(map);
new L.control.zoom({position:'bottomright'}).addTo(map);
map.on('zoomend',update);
$("#controlpanel").accordion({ collapsible: true, heightStyle: "content"}).draggable({ snap: true, snapTolerance: 6, scroll: false, distance: 10, cursorAt: { top: 30, left: 290 } });
$("#infopanel").accordion({ collapsible: true, heightStyle: "content"}).draggable({ snap: true, snapTolerance: 6, scroll: false, cursorAt: { top: 30, left: 105 } });
var areas=getAreas();
createRadioButtons(areas);
function createRadioButtons(areas){
var html=""
$.each(areas,function(i,value){
html += '<input type="radio" id="radio' + value + '" name="radio"><label for="radio' + value + '">' + value + "</label>";
});
$( "#topicbuttons" ).buttonset()
$("#topicbuttons").append(html);
}
$( "#topicbuttons" ).buttonset('refresh').find(':radio').click( function()
{
populateCombo($(this).attr("id").substring(5),"#4");
});
// Removes/adds the organge highlight
function update(){
var zoom=map.getZoom();
if(zoom>=11){
map.removeLayer(gjLayer);
}else if(!map.hasLayer(gjLayer)){
gjLayer.addTo(map);
}
}
function getAreas(){
var map3={};
for(var j=0;j<filterStruct.length;j++){
var name3=filterStruct[j].Area;
if(!(name3 in map3)){
map3[name3]=name3;
}
};
return map3;
}
function onEachFeature(feature, layer) {
layer.on({
mouseover: highlightFeature,
mouseout: resetHighlight,
click: zoomToFeature
});
}
function highlightFeature(e) {
var layer = e.target;
layer.setStyle({
weight: 1,
color: 'red',
dashArray: ''
// fillOpacity: 0.7
});
if (!L.Browser.ie && !L.Browser.opera) {
layer.bringToFront();
}
info.update(layer.feature.properties);
}
function resetHighlight(e) {
gjLayer.resetStyle(e.target);
info.update();
}
function zoomToFeature(e) {
map.fitBounds(e.target.getBounds());
}
var info = L.control();
info.onAdd = function (map) {
this._div = L.DomUtil.create('div', 'info'); // create a div with a class "info"
this.update();
return this._div;
};
// method that we will use to update the control based on feature properties passed
info.update = function (props) {
this._div.innerHTML = '<h4>TALUK</h4>' + (props ?'<b>' + props.NAME_3 + '</b><br />': 'Hover over a taluk');
};
// info.addTo(map);
function style(feature) {
return {
fillColor: '#ef9400',
weight: 2,
opacity: .5,
color: 'brown',
dashArray: '2',
fillOpacity: 0.001
};
}
var markers = L.markerClusterGroup({spiderfyOnMaxZoom: true, showCoverageOnHover: true, zoomToBoundsOnClick: true});
var markerList = [];
var markerIcon= L.Icon.extend({
options:{
iconSize: [32, 48] ,// size of the icon
shadowSize: [41, 41], // size of the shadow
popupAnchor: [-3, -15] // point from which the popup should open relative to the iconAnchor
}
});
var greenIcon=new markerIcon({iconUrl:"green.png"});
var redIcon=new markerIcon({iconUrl:"red.png"});
var brownIcon=new markerIcon({iconUrl:"brown.png"});
var blueIcon=new markerIcon({iconUrl:"blue.png"});
var yellowIcon=new markerIcon({iconUrl:"yellow.png"});
var emeraldIcon=new markerIcon({iconUrl:"emerald.png"});
var orangeIcon=new markerIcon({iconUrl:"orange.png"});
// function getIcon(type){
// if(type=="PSF/RWHS"){
// return greenIcon;
// }else if(type=="Unprotected"){
// return redIcon;
// }else if(type=="Pipe water Supply"){
// return blueIcon;
// }else if(type=="Purchased Water"){
// return yellowIcon;
// }else if(type=="Deep Tube Well/DSP"){
// return brownIcon;
// }else if(type=="Shallow Tube Well"){
// return emeraldIcon;
// }else if(type=="Ring Well/Dug well"){
// return orangeIcon;
// }
// }
function populate(val1,val2,val3,val4,val5) {
var data;
if(val1==null && val2==null && val3==null && val4==null && val5==null){
data=origData;
createAndPushMarkers(data);
}else if(val5==null){
data=filterType(val1,origData);
data=filterCategory(val2,data);
data=filterNA(data);
createAndPushMarkers(data,val4,val5)
}else if(val5!=null){
data=filterType(val1,origData);
data=filterCategory(val2,data);
data=filterNA(data);
data=filterOnSelection(val5,data);
createAndPushMarkers(data,val4,val5);
}
map.addLayer(markers);
if(markers.toGeoJSON().features.length==0){
alert("No matches found for this filter");
}
}
populate();
function createAndPushMarkers(data,val4,val5){
for(var j=0;j<data.length;j++){
var marker=L.marker(L.latLng(data[j].Lat, data[j].Long), { alt:data[j][currentIndicator],icon: getIcon(data[j],val4,val5)});
marker.bindPopup('<div style="padding:0px;font-size:12px;"><table border="0" cellpadding="1" cellspacing="0" style="width: 300px;border-style:outset;border-color:#000000;"><tbody><tr><td><p><b>School :</b>'+data[j].School+'</p><p><b>School Code :</b>'+data[j].School_Code+'</p><p><b>Type :</b>'+ data[j].Type +'</p><p><b>Category :</b>'+data[j].Category+'</p></td></tr></tbody></table></div>');
markers.addLayer(marker);
markerList.push(marker);
}
}
function getIcon(data,val4,val5){
if(val4==null){
return blueIcon;
}else if (val4!=null){
var key=data[currentIndicator];
var attributes=getLegendAttributes(currentIndicator);
var iconAttributes=getIconAttributes(currentIndicator);
var iconPNG=iconAttributes[attributes.indexOf(key)];
return new markerIcon({iconUrl:iconPNG});
}
}
function filterNA(data){
var modData=[];
for(var i=0;i<data.length;i++){
if(data[i][currentIndicator]!="NA"){
modData.push(data[i]);
}
}
return modData;
}
function filterOnSelection(val5,data){
var modData=[];
for(var i=0;i<data.length;i++){
if(val5==data[i][currentIndicator]){
modData.push(data[i]);
}else if(val5=="All"){
modData=data;
break;
}
}
return modData;
}
// function addMarkers(data,icon,column,boolean){
// var marker;
// var markers = L.markerClusterGroup({spiderfyOnMaxZoom: true, showCoverageOnHover: true, zoomToBoundsOnClick: true,maxClusterRadius:50,iconCreateFunction:defineClusterIcon});
// var markerList = [];
// for (var i = 0; i < data.length; i++) {
// if(column!=null && data[i][column]==boolean){
// marker = createMarker(data[i],icon);
// markers.addLayer(marker);
// markerList.push(marker);
// }
// if(column==null){
// marker = createMarker(data[i],icon);
// markers.addLayer(marker);
// markerList.push(marker);
// }
// }
// return markers;
// }
// function createMarker(dataElement,icon){
// return marker;
// }
function filterType(val1,data){
var modData=[];
for(var i=0;i<data.length;i++){
if(val1==data[i].Type){
modData.push(data[i]);
}else if(val1=="All"){
modData=data;
break;
}
}
return modData;
}
function filterCategory(val2,data){
var modData=[];
for(var i=0;i<data.length;i++){
if(val2==data[i].Category){
modData.push(data[i]);
}else if(val2=="All"){
modData=data;
break;
}
}
return modData;
}
function filter(d,users){
var modData=[];
for(var i=0;i<=d.length;i++){
if (d[i] !=undefined){
if(users=="5" && parseInt(d[i].Users)<=5){
modData.push(d[i]);
}else if(users=="10" && parseInt(d[i].Users)>5 && parseInt(d[i].Users)<=10){
modData.push(d[i]);
}else if(users=="10+" && parseInt(d[i].Users)>10){
modData.push(d[i]);
}else if(users=="All" && (d[i].Users)!=null){
modData=d;
break;
}else if(users=="Blanks" && (d[i].Users)==""){
modData.push(d[i]);
}
}
}
return modData;
}
function filterSource(d,type){
var modData=[];
for(var i=0;i<=d.length;i++){
if (d[i] !=undefined){
if(d[i].Type==type){
modData.push(d[i]);
}else if(type=="All" && (d[i].Type)!=null){
modData=d;
break;
}
}
}
return modData;
}
function filterYear(d,year){
var modData=[];
for(var i=0;i<=d.length;i++){
if (d[i] !=undefined){
if(d[i].Year==year){
modData.push(d[i]);
}else if(year=="2012"){
modData=d;
break;
}
}
}
return modData;
}
var legend = L.control({position: 'bottomleft'});
legend.onAdd = function (map) {
var attributes=getLegendAttributes(currentIndicator);
var iconAttributes=getIconAttributes(currentIndicator);
var div = L.DomUtil.create('div', 'infoLegend');
div.innerHTML=getLegendHTML(attributes,iconAttributes);/*'<h4>Toilet Users</h4><p><input name="RD1" type="radio" id="filter" value="5">0-5</p><p><input name="RD1"type="radio" id="filter" value="10"/>6-10</p><p><input name="RD1"type="radio" id="filter" value="10+"/>10+</p><p><input name="RD1"type="radio" id="filter" value="All"/>All</p><p><input name="RD1"type="radio" id="filter" value="Blanks"/>Blanks</p>';*/
legendAdded=true;
return div;
};
function getLegendHTML(attributes,iconAttributes){
if(attributes==""){
return "";
}else{
var htmlStr='';
for(var j=0;j<attributes.length;j++){
htmlStr=htmlStr+'<p><img src='+iconAttributes[j]+'/><input name="RD1" type="radio" id="filter" value="'+attributes[j]+'"/>'+attributes[j]+'</p>'
}
return htmlStr;
}
}
function getLegendAttributes(currentIndicator){
if(currentIndicator==""){
return "";
}else{
var attributes=[];
for(var j=0;j<filterStruct.length;j++){
var name2=filterStruct[j].Indicator;
// var legend= filterStruct[j].Legend;
if(name2==currentIndicator){
attributes=filterStruct[j].Legend.split("/");
return attributes;
}
}
}
}
function getIconAttributes(currentIndicator){
if(currentIndicator==""){
return "";
}else{
var attributes=[];
for(var j=0;j<filterStruct.length;j++){
var name2=filterStruct[j].Indicator;
// var legend= filterStruct[j].Legend;
if(name2==currentIndicator){
attributes=filterStruct[j].Icon.split("/");
return attributes;
}
}
}
}
$('body').on('change','input:radio[name=RD1]',function(e){
var value=e.currentTarget.attributes[1].value;
map.removeLayer(markers);
markers=L.markerClusterGroup({spiderfyOnMaxZoom: true, showCoverageOnHover: true, zoomToBoundsOnClick: true,maxClusterRadius:50,iconCreateFunction:defineClusterIcon});
populate($("#1").val(),$("#2").val(),$("#3").val(),$("#4").val(),value);
}
);
$("#Go").click(function(e){
if($("#4").val()==null){
alert("Please select indicator");
return;
}
if(legendAdded){
legend.removeFrom(map);
}
map.removeLayer(markers);
markers=L.markerClusterGroup({spiderfyOnMaxZoom: true, showCoverageOnHover: true, zoomToBoundsOnClick: true,maxClusterRadius:50,iconCreateFunction:defineClusterIcon});
var v1=$("#1").val();
var v2=$("#2").val();
var v3=$("#3").val();
var v4=$("#4").val();
var v5=$("#5").val();
currentIndicator=v4;
$("#colpanel").empty();
var attributes=getLegendAttributes(currentIndicator);
var iconAttributes=getIconAttributes(currentIndicator);
$("#colpanel").append(getLegendHTML(attributes,iconAttributes));
populate(v1,v2,v3,v4,v5);
// renderLegend(v4);
})
function getIndicators(value){
var map3={};
if(value==""){
return map3;
}
map3[0]="";
for(var j=0;j<filterStruct.length;j++){
var name3=filterStruct[j].Area;
var name2=filterStruct[j].Indicator;
var legend= filterStruct[j].Legend;
if(name3==value && !(name2 in map3)){
map3[name2]=name2;
}
};
return map3;
}
$("#3").change(function () {
var selected = $(this).val();
var options="";
if(selected==""){
$("#4").empty();
}else{
$.each(getIndicators(selected),function(i,value){
options += '<option value="' + value + '">' + value + '</option>';
$("#4").html(options);
});
}
});
function populateCombo(selectedValue,target){
var options="";
if(selectedValue==""){
$(target).empty();
}else{
$.each(getIndicators(selectedValue),function(i,value){
options += '<option value="' + value + '">' + value + '</option>';
$(target).html(options);
});
}
}
function defineClusterIcon(cluster){
// console.log(cluster);
var children = cluster.getAllChildMarkers(),
n = children.length, //Get number of markers in cluster
strokeWidth = 1, //Set clusterpie stroke width
r = rmax-2*strokeWidth-(n<10?12:n<100?8:n<1000?4:0), //Calculate clusterpie radius...
iconDim = (r+strokeWidth)*2, //...and divIcon dimensions (leaflet really want to know the size)
data = d3.nest() //Build a dataset for the pie chart
.key(function(d) {
return d.options.alt;
}).entries(children, d3.map),
//bake some svg markup
html = bakeThePie({data: data,
valueFunc: function(d){return d.values.length;},
strokeWidth: 1,
outerRadius: r,
innerRadius: r-10,
pieClass: 'cluster-pie',
pieLabel: n,
pieLabelClass: 'marker-cluster-pie-label',
pathClassFunc: function(d)
{var value=d.data.key;
if(value=="Yes"){
return 'category-3';
}
var attributes=getLegendAttributes(currentIndicator);
return "category-"+attributes.indexOf(value);
},
pathTitleFunc: function(d){return d.data.key+' ('+d.data.values.length+')';}
}),
//Create a new divIcon and assign the svg markup to the html property
myIcon = new L.DivIcon({
html: html,
className: 'marker-cluster',
iconSize: new L.Point(iconDim, iconDim)
});
return myIcon;
}
function bakeThePie(options) {
/*data and valueFunc are required*/
if (!options.data || !options.valueFunc) {
return '';
}
var data = options.data,
valueFunc = options.valueFunc,
r = options.outerRadius?options.outerRadius:28, //Default outer radius = 28px
rInner = options.innerRadius?options.innerRadius:r-10, //Default inner radius = r-10
strokeWidth = options.strokeWidth?options.strokeWidth:1, //Default stroke is 1
pathClassFunc = options.pathClassFunc?options.pathClassFunc:function(){return '';}, //Class for each path
pathTitleFunc = options.pathTitleFunc?options.pathTitleFunc:function(){return '';}, //Title for each path
pieClass = options.pieClass?options.pieClass:'marker-cluster-pie', //Class for the whole pie
pieLabel = options.pieLabel?options.pieLabel:d3.sum(data,valueFunc), //Label for the whole pie
pieLabelClass = options.pieLabelClass?options.pieLabelClass:'marker-cluster-pie-label',//Class for the pie label
origo = (r+strokeWidth), //Center coordinate
w = origo*2, //width and height of the svg element
h = w,
donut = d3.layout.pie(),
arc = d3.svg.arc().innerRadius(rInner).outerRadius(r);
//Create an svg element
var svg = document.createElementNS(d3.ns.prefix.svg, 'svg');
//Create the pie chart
var vis = d3.select(svg)
.data([data])
.attr('class', pieClass)
.attr('width', w)
.attr('height', h);
var arcs = vis.selectAll('g.arc')
.data(donut.value(valueFunc))
.enter().append('svg:g')
.attr('class', 'arc')
.attr('transform', 'translate(' + origo + ',' + origo + ')');
arcs.append('svg:path')
.attr('class', pathClassFunc)
.attr('stroke-width', strokeWidth)
.attr('d', arc)
.append('svg:title')
.text(pathTitleFunc);
vis.append('text')
.attr('x',origo)
.attr('y',origo)
.attr('class', pieLabelClass)
.attr('text-anchor', 'middle')
//.attr('dominant-baseline', 'central')
/*IE doesn't seem to support dominant-baseline, but setting dy to .3em does the trick*/
.attr('dy','.3em')
.text(pieLabel);
//Return the svg-markup rather than the actual element
return serializeXmlNode(svg);
}
function serializeXmlNode(xmlNode) {
if (typeof window.XMLSerializer != "undefined") {
return (new window.XMLSerializer()).serializeToString(xmlNode);
} else if (typeof xmlNode.xml != "undefined") {
return xmlNode.xml;
}
return "";
}
});
</script>
</body>
</html>