Diaries

SVG Pie Chart


Posted by DesertDawg apropos on Sun Nov 11th, 2007 at 14:07:41 BST

Inspired by the following:

Internet Explorer below 50%, always, and dropping ... Posted by stelt apropos on Fri Oct 26th, 2007 at 13:33:10 BST At my SVG links resource http://svg.startpagina.nl Internet Explorer use is always below 50%. Quite often it's not even the first browser, but behind Firefox. Opera that keeps improving its already good SVG support is small, but growing and looking forward to having SVG support added to Safari in only hours is improving its numbers as well.
<svg onload='go()' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'> <text x='220' y='080'> 45.20% Mozilla </text> <text x='220' y='100'> 00.61% Netscape, Mobile Wap, Other </text> <text x='220' y='120'> 05.51% Safari </text> <text x='220' y='140'> 04.95% Opera </text> <text x='220' y='160'> 43.66% Microsoft Internet Explorer </text> <script> <![CDATA[ pcarray='0.6 5.0 5.5 43.7 45.2' // percentages of pie pieces for each wedge pc=pcarray.split(' ') var n = pc.length // Number of pie wedges (centered at 0 0 and translated to 250 250) var a = 0 // Angle of each wedge (even pie wedge angle = Math.PI*2/n) var b = 0 // Start and accum angles - trailing edge (starts at 3:00 and goes CCW) var c = 0 // Accum angles - forward edge (goes CCW) var r = 100 // Radius of pie colorarray='red yellow blue lime violet' color=colorarray.split(' ') function go() { for (i=0; i<n; i++) { clr=i;if(i>=color.length)clr=(i%color.length) a = Math.PI*2*(pc[i]/100) // compute each pie wedge angle separately c += a // accumulate the pie wedge angles - forward var x1 = Math.round(r*Math.cos(b)) + ' ' // trailing var y1 = Math.round(r*Math.sin(b)) + ' ' var x2 = Math.round(r*Math.cos(c)) + ' ' // forward var y2 = Math.round(r*Math.sin(c)) + ' ' d = 'M0 0 '+ x1+' ' + y1+' ' + 'A' + r+' ' + r+' ' + ' 0 0 1 ' + x2+' ' + y2+' ' + 'L0 0' dog = document.createElementNS('http://www.w3.org/2000/svg', 'path') dog.setAttributeNS(null,'d', d ) dog.setAttributeNS(null,'fill',color[clr]) dog.setAttributeNS(null,'transform','translate(100,100)') document.documentElement.appendChild(dog) b += a // save the old accumulation }} //]]> </script> </svg>

Permanent link to this story (1 comment)

Sighting of New SVG Logo


Posted by DesertDawg apropos on Mon Jan 8th, 2007 at 23:19:08 BST

at w3org.

Permanent link to this story (8 comments)

New SVG Logo


Posted by DesertDawg apropos on Thu Dec 28th, 2006 at 23:04:48 BST

My take on the New SVG Logo.

<svg version='1.0' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'>
<defs>
<g id='A'>
<line x1='200' y1='100' x2='200' y2='300' stroke='orange' stroke-width='27' fill='none' />
<circle  cx='200' cy='100' r='20' fill='orange' />
<circle  cx='200' cy='300' r='20' fill='orange' />
</g>

<g id='All'>
<line x1='200' y1='100' x2='200' y2='300' stroke='black' stroke-width='80' stroke-linecap='round' fill='none' />
<line x1='200' y1='100' x2='200' y2='300' transform='rotate(045,200,200)' stroke='black' stroke-width='80' stroke-linecap='round' fill='none' />
<line x1='200' y1='100' x2='200' y2='300' transform='rotate(090,200,200)' stroke='black' stroke-width='80' stroke-linecap='round' fill='none' />
<line x1='200' y1='100' x2='200' y2='300' transform='rotate(135,200,200)' stroke='black' stroke-width='80' stroke-linecap='round' fill='none' />
<use x='0' y='0' xlink:href='#A' transform='rotate(0)' />
<use x='0' y='0' xlink:href='#A' transform='rotate(45,200,200) ' />
<use x='0' y='0' xlink:href='#A' transform='rotate(90,200,200) ' />
<use x='0' y='0' xlink:href='#A' transform='rotate(135,200,200)' />
</g>
</defs>

<use x='0' y='0' xlink:href='#All' transform='translate(0,0) scale(1,1)' />

</svg>

Permanent link to this story (17 comments)

Login

Make a new account

Username:
Password:

Poll

How would you like to see advertizing on SVG.org?

  • Regular animated banners (9%)
  • Using Google AdWords (33%)
  • Custom advertizing from sponsors (23%)
  • No advertizing, please (32%)
Votes: 151 | Comments: 12
Results | Other Polls
Diaries

Friday July 11th

Wednesday June 25th

Wednesday June 11th

Saturday June 7th

Monday May 26th

  • Hi (0 comments)

Saturday May 24th

Saturday May 3rd

Friday April 25th

Thursday April 24th

Wednesday April 23rd

Older Stories...