This script will generate a realtime graph based on data provided via URL parameter. The graph can be customized to match whatever display options you would like to use.
It runs on PHP 4.0 and above with the GD library installed. It makes use of the default fonts and displays a PHP image back to the user.
Please let us know if you improve or are using this script.
This file only includes the .php file needed to generate the graph. Documentation is only available currently online.
All parameters are optional except for the series values. Obviously: no data - no graph.
| Name | Values | Example | Description |
|---|---|---|---|
| color_background | hex color code | #ffffff | Sets the background color of the image. |
| color_error | hex color code | #ff0000 | Selects the color of any error text. |
| color_grid | hex color code | #999999 | Selects the color of the x and y-axis. |
| color_label | hex color code | #000000 | Sets the color of the x and y-axis labels and title. |
| graph_height | integer | 480 | Sets the pixel height of the entire graph image. |
| graph_title | string | Sample Graph | Changes the large text at the top left of the graph. |
| graph_width | integer | 640 | Sets the pixel width of the entire graph image. |
| label_points | [1|0] | 1 | Setting to 1 turns on the point value labels on the line. |
| series[1-10] | comma delimited list of numbers | 1,2,3,4,5,6,7 0.1,0.2,0.3 |
This is the actual values that will be plotted. If no data is passed and error will be displayed. Up to 10 different lines may be plotted at once. Each line will have a different color. |
| series_colors | comma delimited list of hex color codes | #ff0000 | Each position in the list corresponds to a series. If only 2 series will be plotted, only two color codes need to be passed. The example list is the default color set. |
| xAxis | comma delimited list | 1/2,1/3,1/4 a,b,c |
Sets the points on the x-axis to whatever values are passed in the comma delimited list. Default will number the points numerically starting with one and continuing until all points are accounted for. |
| yAxis | comma delimited list | 1/2,1/3,1/4 a,b,c |
Sets the points on the y-axis to whatever values are passed in the comma delimited list. Default behavior is to fit as many tick marks as the system can on the y-axis with the minimum value set to the minimum of the data and the maximum as the maximum of the data. NOTE: this doesn't change the actual scale of the axis, only re-maps the values assigned. |
This first graph is sized to 600 pixels wide with only a title and series data provided.
Not that you should, but you can change lots of parameters to really make the graph apply to your site.