Well, JPGraph is a popular, well documented graphing library for PHP and it uses the GD extension functions in PHP. You don't NEED it to create graphs, but I'd recommend using it -- it's pretty complicated to create a new graphing library from scratch, and why reinvent the wheel when you've got a really nice one already available?
If you are going to use a button to change between graph styles, you can have that button be a form submit button that tells the receiving PHP script what kind of graph to generate.
Take care,
Nik
http://www.bigaction.org/