HTML Clickable or Drillable Pie Charts Using Graphael -


background

i able graphael example of dynamic pie chart working. however, i'm having problem understanding syntax...

the example passes in 2 html links , seems associate links 2 labels , 2 specific slices of pie it's not obvious how correlations or associations happen in string that's passed "piechart" method. tried pass in few more links code seems randomly associate links labels. there doesn't seem obvious way ensure link1 associated label1.

question

does know how explain what's happening in code? how 2 links being associated 2 slices of pie? how consistently associate links labels , specific slices of pie?

note

i don't piechart function takes in 3 "separate" strings of values, labels, , links not collocated each other, makes code hard read. original looks follows...

example

pie = r.piechart(320, 240, 100, [55, 20, 13, 32, 5, 1, 2, 10], { legend: ["%%.%% - enterprise users", "ie users"], legendpos: "west", href: ["http://raphaeljs.com", "http://g.raphaeljs.com"]}); r.text(320, 100, "interactive pie chart").attr({ font: "20px sans-serif" });) 

instead nicer able pass in array of arrays... array = [[slicevalue1, label1, link1], [slicevalue2, label2, link2], etc. if has idea of how this, great way clean code , make more readable.

source code

<script>   window.onload = function () {     var r = raphael("holder"),     pie = r.piechart(320, 240, 100, [55, 20, 13, 32, 5, 1, 2, 10], { legend: ["%%.%% - enterprise users", "ie users"], legendpos: "west", href: ["http://raphaeljs.com", "http://g.raphaeljs.com"]});     r.text(320, 100, "interactive pie chart").attr({ font: "20px sans-serif" });     pie.hover(function () {       this.sector.stop();       this.sector.scale(1.1, 1.1, this.cx, this.cy);       if (this.label) {         this.label[0].stop();         this.label[0].attr({ r: 7.5 });         this.label[1].attr({ "font-weight": 800 });       }     }, function () {     this.sector.animate({ transform: 's1 1 ' + this.cx + ' ' + this.cy }, 500, "bounce");     if (this.label) {     this.label[0].animate({ r: 5 }, 500, "bounce");     this.label[1].attr({ "font-weight": 400 });     }     });   }; </script> 

the better answer using d3.js. here's working example... "multiple d3 pie charts mixed in html layout constructs".


Comments

Popular posts from this blog

jasper reports - Fixed header in Excel using JasperReports -

media player - Android: mediaplayer went away with unhandled events -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -