SVGGraph 3.9
Published
This new version of SVGGraph adds some axis, legend and grid options, and
some small updates to the shape
option.
Tick, tick, ticking in my head
I haven't tried to cram all the new options into the example below, but the
most important change is probably the addition of the axis_ticks_x
and axis_ticks_y
options. Both of these options are used in the
example graph, explicitly setting the positions of the X and Y axis markings.
The graph shows box office revenue of the Marvel films to date, though I don't know how accurate the numbers are (I found them on a website after a quick search). The X axis ticks are placed on the release dates of the first Iron Man film and all the Avengers films. The Y axis ticks are just spread evenly with a couple of extra ticks for top and bottom values.
Hiding to nothing
There are two changes in this version related to hiding things - the first
adds two new fields for shapes, autohide
and autohide_opacity
.
The autohide
option is a simple boolean value, but the other one
can be a single opacity value or an array of two values for both the hidden and
shown opacities. The pale pink and blue boxes at the top of the example graph
demonstrate this, with the "hidden" value set to 0.8 and the "shown" value set
to 0.1.
The next new option is legend_autohide_opacity
, which allows
you to set how opaque the legend will be when it is hidden. It also supports
supplying a negative value to make the legend start off hidden and become
visible when the cursor hovers over it, which is shown in the example.
More legend and grid stuff
I haven't put it on the example, but there is a new legend_title_link
option for adding a hyperlink to the legend title. There are no new options
for setting links for the legend entries - but you can pass an array as an entry
instead, containing the text and a link:
$settings['legend_entries'] = [
'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', ['Weekend', '/not-found/'],
];
This works for the legend_entries
option as well as for legend
entries from structured data and callback functions.
Lastly, there are six new options for setting the thickness of grid lines -
all together, horizontal, vertical and subdivision lines. I've used the
grid_stroke_width_h
option in the example to make the vertical
grid lines two pixels wide.
The new version of SVGGraph is available from the downloads page, or from GitHub / Packagist with Composer.