Pie Chart Generator

By BlueThen on Apr 01, 2008

Nothing too fancy, yet. Punch in the numbers you want it to generate, and let the script do the rest. I'll add colors, labels, and maybe some more if on demand, otherwise, I'd guess it's useless if no one wants more.

Image

Updates:
Unsets variables now.
Totally 3D!

;Pie Chart Generator 1.1
;Made by BlueThen on April 1, 2008.
;Last updated April 2, 2008.
;To install, paste this code into your remotes (alt + r)
;then type /pie or right click in the channel or status and click Pie.
alias pie {
  dialog -m Pie Pie
}
dialog Pie {
  title "Pie Graph Generator"
  size -1 -1 194 192
  option pixels notheme
  list 1, 8 22 110 167, size
  button "Add", 2, 122 116 65 25
  button "Remove", 3, 122 87 65 25
  edit "", 4, 122 43 65 20, autohs
  text "Number:", 5, 122 22 65 17
  button "Generate!", 6, 122 164 65 25
  text "Made by ", 7, 49 4 69 17, right
  button "BlueThen!", 8, 122 5 65 15
}
on *:dialog:pie:sclick:8: run http://bluethen.com/

menu channel,status {
  Pie: pie
}
on *:dialog:pie:sclick:*: {
  if ($did == 2) {
    if (($calc($did(4) + 1) == 0)) echo -bf 4Error(1)! Please enter a valid number above 0. | else did -a Pie 1 $did(4)
  }
  if ($did == 3) {
    if ($did(pie,1).seltext != $null) did -d pie 1 $did(pie,1).sel
    else echo -bf 4Error(2)! Please select a number to delete.
  }
  if ($did == 6) {
    if ($did(pie,1).lines == 0) echo -bf 4Error(3)! Please add some numbers first.
    set %pie.t $did(pie,1).lines | %pie.x = %pie.t | set %pie.a 0
    while (%pie.x > 0) {
      set %pie. $+ %pie.x $did(pie,1, %pie.x) | set %pie.a $calc(%pie. [ $+ [ %pie.x ] ] + %pie.a) | dec %pie.x
    }
    pie.init
  }
}
on *:close:@pie: window -c @pie.buf
alias -l pie.init {
  if ($window(@pie) == $null) window -paoCzdk0 +tnbL @Pie -1 -1 400 400 
  if ($window(@pie.buf) == $null) window -poCzdhk0 +tnbL @Pie.buf -1 -1 800 800 | drawfill @pie.buf 0 0 1 1 1 1
  drawdot @pie.buf 1 300 430 430 
  drawdot @pie.buf 14 295 430 430
  drawdot @pie.buf 1 300 400 400 
  drawdot @pie.buf 0 290 400 400 | %pie.x = %pie.t | %pie.y = 0
  while (%pie.x >= 0) {
    %pie.p = $calc(%pie. [ $+ [ %pie.x ] ] / %pie.a) | %pie.ang = $calc(360 * %pie.p) 
    %pie.ang21 = $calc(400 + (295 * $cos(%pie.y + %pie.ang).deg))
    %pie.ang22 = $calc(400 + (295 * $sin(%pie.y + %pie.ang).deg))
    drawline @pie.buf 1 5 400 400 %pie.ang21 %pie.ang22
    if ((%pie.ang22 > 250) && (%pie.ang21 > 250)) drawline @pie.buf 1 5 %pie.ang21 %pie.ang22 $calc(%pie.ang21 + 30) $calc(%pie.ang22 + 30)
    unset %pie. [ $+ [ %pie.x ] ] | %pie.y = $calc(%pie.ang + %pie.y) | dec %pie.x 1
  }
  drawcopy -m @pie.buf 0 0 800 800 @pie 0 0 400 400
  unset %pie.ang %pie.ang21 %pie.ang22 %pie.t %pie.x %pie.a %pie.y %pie.p
}

Comments

Sign in to comment.
knoeki   -  May 08, 2008

Hrm... this seems very useful. imagine letting all the input be certain variables, for example, words said by everyone on the channel, generating the chart, outputting a .png, putting it on a server, so that everyone can see a nice little piechart about who is talking the most in your channel :_)

( it\'d need to be modified though )

 Respond  
Mitchell   -  Apr 28, 2008

looks nice :) perhaps add colour to it to make it even better?

 Respond  
^Neptune   -  Apr 03, 2008

Very useless but very cool! 8/10

 Respond  
Jonesy44   -  Apr 02, 2008

also, whats with the;

notheme

looks skanky :P

 Respond  
Jonesy44   -  Apr 02, 2008

bangin !

haha good job =D

 Respond  
BlueThen   -  Apr 02, 2008

Like totally updated! :P

 Respond  
Jonesy44   -  Apr 02, 2008

lmfao !

love it BlueThen xD

 Respond  
BlueThen   -  Apr 01, 2008

Well I figured that people would know what the numbers would be, hense the title \"pie chart\"

 Respond  
guest598594   -  Apr 01, 2008

Oh, I get it now, you should have put that in the intro Image

 Respond  
BlueThen   -  Apr 01, 2008

Anything. If you put \"5\" \"5\" \"5\" \"5\", the pie chart would seperate itself into 4 equal parts. If you put \"75\" \"25\", then the lines will seperate the chart 3/4th\'s wise.

 Respond  
guest598594   -  Apr 01, 2008

I don\'t get what the numbers represent.

 Respond  
BlueThen   -  Apr 01, 2008

Fawesome, ain\'t it? :D

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.