SVGGraph 2.19

Published

The main change in version 2.19 of SVGGraph is the addition of a Histogram graph type. I haven't considered adding one until now because I figured people could work out how to do it for themselves and use one of the existing bar graph classes. I've changed my mind - histograms actually work quite differently to bar graphs, so I've produced these two graphs to demonstrate the difference.

BarGraph of SVGGraph PHP file sizes

The example above is a standard BarGraph displaying the current sizes of the PHP files in the SVGGraph library. There are a couple of fairly large files and quite a few smaller files. I've used a simple associative array to pass the file sizes to SVGGraph. (The actual values might have changed a bit since I generated them using ls and awk.)

$values = array(
  "SVGGraph.php" => 53849,
  "SVGGraph3DGraph.php" => 8037,
  ...
);
$graph->Values($values);

The graph below is a Histogram of the same values. For this graph, SVGGraph counts the values, groups them into ranges and draws bars that show how many occurrences of the values there are in each range. SVGGraph will pick the ranges automatically, or you can specify your own size for the ranges with the increment option.

Histogram of SVGGraph PHP file sizes

The number on the Y axis of the histogram is the number of occurrences - the Histogram class also supports displaying the results as a percentage (by setting the percentage option to true).

These graphs also demonstrate the axis_text_callback_x and axis_text_callback_y options introduced in version 2.18, and the new tooltip_callback option added in this version. The axis callbacks are used to convert plain integers into file sizes, and the tooltip callback turns the text into a more readable format. There is also a new callback for labels, data_label_callback, which works in the same way as the tooltip callback, taking the dataset number, key and value as arguments.

Other new options not demonstrated here are best_fit_opacity and best_fit_above for more control over the scatter graph best-fit lines, data_label_min_space for hiding labels for tiny bars or pie slices, and several new options for shading the top, side and front of the 3D bars to give them more depth. Those are covered in a new section on the 3D bar graphs page.

Apart from all that, this is the first version that I am going to make available for automatic installation using Composer. If you're not aware of it, Composer helps you manage the libraries that you are using in your PHP application. I've already made a couple of alpha and beta versions available for those who like to live on the edge (and to help me test that I've got it working right).

The new version is available from the downloads page, or from GitHub, or using Composer.

« Previous: TagCanvas 2.7 Next: SVGGraph 2.19.1 »

This site uses cookies - details here.