SVGGraph 2.24
Published
SVGGraph 2.24 is one of those releases that doesn't look like much, but took
ages anyway. The most obvious change in this version is the addition of the
SemiDonutGraph
graph type, which looks like this:
It's just half a donut graph, really. The code of the SemiDonutGraph is very
simple and mostly relies upon setting a new option added for all pie graphs
called end_angle
, which tells SVGGraph where the circle should
end. There is another option to go with it, slice_fit
which is
enabled by default and positions the partial pie graph so that it is scaled to
fit the available space.
There is another new option for pie graphs called
keep_colour_order
which assigns colours to the pie slices in the
original order they appear in the data instead of the order they are drawn in
the pie. It is disabled by default, but it is handy for assigning specific
colours to the pie slices without having to use structured data. The example
above is using it with this code:
$settings = array(
// there are more options than this set...
'keep_colour_order' => true,
);
$values = array(
'#ff66cc' => 10,
'#ffffcc' => 40,
'#ffccff' => 50,
'#ccffcc' => 90,
'#ccccff' => 20,
'#ccffff' => 30,
);
$colours = array_keys($values);
$graph = new SVGGraph(670, 200, $settings);
$graph->Values($values);
$graph->Colours($colours);
$graph->Render('SemiDonutGraph');
There are two new options for marker styling, marker_opacity
and
marker_angle
. They work in all the usual ways, as single values or
arrays and as structured data options. The marker_type
option now
supports using a snippet of SVG code as a marker too.
The Javascript crosshairs have been improved so that the coordinates box now displays associative keys or date/time values when relevant. The coordinates class now supports using associative keys for grid values when specifying the position of shapes and custom labels.
The FetchJavascript
function can now be called statically, for
example:
$script = SVGGraph::FetchJavascript();
This means that you can fetch the Javascript code for however many instances of SVGGraph there have been without needing to keep a variable around. The old way still works as well.
There are a few fixes in this version: the minify_js
option now
supports anonymous callback functions. There was an error when an array of
guidelines was used, but only containing a single guideline array. The
bar_total_outline_colour
option was not working on horizontal
stacked graphs. There was a Javascript error in legend_autohide
when the tooltips were disabled. The order of the legend was incorrect for
graphs with multiple datasets starting at different key values.
The new version is available from the downloads page, or from GitHub, or using Composer.