SVGGraph 2.16

Published

SVGGraph 2.16 is not a huge update, but it does include a new graph type and several changes that I have been asked about over the last few months. There are a couple of bugs fixed too.

The new graph type is a stacked and grouped bar graph, for when some of your data adds up and some should be compared. That's a terrible description. I'll try an example.

Stacked and grouped bar graph

I picked these numbers out of thin air to produce a nice graph, so don't try to figure out what they are showing. The graph shows four datasets, with the first and second drawn in a stack with red and blue gradients and the third and fourth datasets drawn in a stack with red and blue polkadot patterns.

SVGGraph can't guess which datasets you want to stack and which to group, so the default is to stack them. There is one option that you must provide when using the StackedGroupedBarGraph, called stack_group. This is either a single value for which dataset to start the second stack with, or an array of dataset numbers for when you want more than two stacks in each group. For the example above it has a value of “2” to start the second stack with dataset number 2.

The example graph also shows the effect of the new decimal_digits option, which specifies the number of decimal places used for axis text labels. There are decimal_digits_x and decimal_digits_y options to set the number of digits for each axis separately too.

The example graph doesn't show what the new bar_width option does, but it is easy enough to describe. Without bar_width the width of each bar is calculated from the size of the graph, the number of bars and the amount of space between them. bar_width overrides these calculations to set the width of the bar to a specific number of pixels instead. If the bars don't fit in the available space then they will overlap, which can look very strange. The new option is supported by all the bar graph types including the horizontal, 3D bar and cylinder graphs, and the other various graph types that use bars.

For the 3D bar graphs I've added some options to choose between the old, flat filling of the top and side of the bar and a new method that skews the gradient or pattern. I've added a section to the 3D bar graphs page to show how this works, so I won't try to explain it again here. The new skew_top and skew_side options are defaulted to true to use the new skewing method, so you will have to turn them off if you don't like the effect.

Version 2.16 also supports image-based markers for line and scatter graphs. Using this is fairly simple and is achieved by specifying a marker_type of “image:” followed by the path to the image to use as the marker.

Image markers

The default marker size of 5 pixels is a bit small for image markers, so I recommend using the marker_size option to scale them up a bit. The markers in this example have sizes between 14 and 16 pixels, though the actual images are 64×64 pixels in size. SVGGraph doesn't know or care about the dimensions of the images since they are loaded by the browser. And because they are loaded by the browser any relative paths that you use for the images must be relative to the script generating the SVG graph, or to the page if the SVG markup is directly embedded within it.

The bugs fixed in this version are single value graphs displaying an error message instead of the graph and blank lines in multi-line text labels being ignored. I've also improved the escaping of text labels, which means that you can now include “<” in your labels without the browser complaining about invalid XML. I've gone through and taken out all the instances of the “@” error control operator and replaced it with some sanity checking, just to make sure SVGGraph doesn't cause trouble with custom error handlers.

Finally, I've added support for specifying an opacity value in the colour of the graph background. This is really only useful if you put the generated SVG code into the HTML code of your page, where the page background or any elements behind the graph can show through. You could already make the background completely transparent by setting back_colour to “none”.

The new version is available from the downloads page.

« Previous: TagCanvas 2.5.1 Next: JPEG Saver 4.13.1 »

This site uses cookies - details here.