PHP Lines graph script

Since I was tired of creating ugly bar graphs I decided to explore an easy way to create a lines graph, mostly inspired by Google Analytics graphs. Ok nothing so advanced but the result is quite nice for my needs.

You can configure the image created by the script using the following parameters:

  • w: width of the graph
  • h: height of the graph
  • points: array of values separated by commas representing the points in the graph
  • labels: array of labels separated by commas to be displayed horizontally
  • rows: number of rows
  • color: the desired color in rgb format, values separated by commas
  • style: 1) bordered circle endpoints 2) filled circles endpoints

Following a couple of examples with parameters used:

graph.php?w=500&h=300&points=9,3,5,2,4,8,5
&labels=mon,tue,wed,thu,fri,sat,sun&rows=4
&color=0,119,204&style=1

graph.php?w=400&h=200&points=3,9,5
&labels=alpha,beta,release&rows=4
&color=255,153,51&style=2

You can download the script here: graph_0.1.0.zip (791)

Leave a Reply

Your email address will not be published. Required fields are marked *