SVGGraph 3.8


SVGGraph 3.8 is another release focussed on small improvements. There are two new graph types though, since someone asked how to display a stepped line graph and I didn't have an easy answer.

Stepped line graphs

I don't think anyone has ever asked for this before, but it was very easy to add. The two new graph types are SteppedLineGraph and MultiSteppedLineGraph. They behave exactly the same as normal line graphs, but the line progresses in steps instead of straight lines between the data points.

MultiSteppedLineGraph example

The best-fit lines follow the same path as on normal line graphs, based on the position of the markers. All of the usual line graph options are available, though there is no stacked version of the graph because it looked very strange when I tried it out. If you really want a stacked, stepped line graph I can add it quite easily, just contact me at the usual address.

New axis tweaks

The example graph above also demonstrates two new options that affect the axes. The first is axis_zero_y, which can be set to false to make SVGGraph pick a value other than 0 for the bottom end of the graph. On the example graph all the values are between 100 and 200, so the graph starts at 100.

The second new option is force_block_label_x, and when set to true it makes SVGGraph label the spaces in between divisions on the X-axis instead of labelling the divisions. This is only useful for line and scatter graphs, since bar graphs always use block labelling.

More options

Until now, line spacing in places where multi-line text was possible was always set to the font size in use. Version 3.8 adds a load of *_line_spacing options for setting your own spacing instead. The value must be in pixels, because supporting all the other types of measurement available in CSS would mean measuring the size of various characters and adding that to the font metrics files. Maybe I'll add it in a future version, but I didn't think it was worth the effort this time.

The only other new option is data_label_opacity, for setting the opacity of the whole label. This also works as opacity in custom labels. The label fading options work by modifying the opacity as well, so using both together might have weird effects.

Localization and time zones

Did you know that the PHP DateTime class doesn't support localization? I didn't until recently, so SVGGraph 3.8 now supports localization of date strings by using strftime() when outputting a weekday or month name in a non-English locale. The other fields are mostly numbers, apart from things like the ordinal suffix (e.g. the “-nd” in “22nd”) which doesn't have an easy translation.

The time zone updates are in places where the date/time is output or used in a calculation, like the ends of the X axis on a line graph. This was not working properly because I live in a country where it is UTC at the start of the year, so I didn't notice things being slightly offset. This update should also fix the date/time values shown in tooltips and crosshair labels.

Other stuff

There are a few more bug fixes in this version. The axis labels were being drawn on top of the division labels when there were negative values on a graph. Some date/time values used as guideline positions were being drawn in the wrong place. The legend on a multi-line graph with a single point in a dataset was not drawing the entry for that dataset.

The new version of SVGGraph is available from the downloads page, or from GitHub / Packagist with Composer.

« Previous: JPEG Saver 5.12 Next: JPEG Saver 5.13 »