SVGGraph 2.18
Published
In previous versions of SVGGraph there were labels for some bars and labels for pie slices, but that was about it. They used different code, had different option names, and supported different styles and things. Version 2.18 attempts to bring the labels together, support labelling all the data items, and provide more options for what the labels look like.
This example StackedBarGraph shows some of the new features. The labels are
displayed using a data_label_type
of “bubble”, with the
data_label_filter
option used to only create 1 in 3 labels for
the second dataset and all labels for the first. What do you mean, you
can't see the labels for the first dataset?
You can't see the labels for the first dataset because the
data_label_fade_in_speed
and data_label_fade_out_speed
are both set to allow the labels to fade in and out, and the
data_label_click
option is set to array('hide','show')
.
This hides the labels of the first dataset and shows the labels of the second from
the start, but they are all still there.
Moving the cursor over a bar with a hidden label will fade it in, clicking on
a labelled bar will make the label stay open, clicking it again will enable
fading out again. The data_label_popfront
option is also used in
this example, which makes the label of the item that the cursor is over appear
in front of any other overlapping labels. To explain things a bit better, I've
created a new page with information about
using data labels.
One important thing to note about this update: the default colour of pie graph label text is now black instead of white. This is so that the text does not disappear when you change the label style to “box” or “bubble”, which both have a white background by default. Keeping the default text colour white for pie labels when it is black everywhere else seemed like a bad idea, so I decided to make the change.
Another new thing in this version is something that people have been asking me about for years – a bar and line graph:
Actually, the question people tend to ask is “Can I mix two kinds of
graph? I want to put a line graph and bar graph together.” The answer to
that question is still “no”, but the new BarAndLineGraph does work
internally as a GroupedBarGraph with a MultiLineGraph drawn over it. It isn't
quite the same though, as line graphs normally have their markers at grid points,
whereas the BarAndLineGraph draws line markers at the centre of the bar (or
group of bars). You can tell SVGGraph which datasets to use as lines and which
as grouped bars using the line_dataset
option.
There are two user-submitted updates in this version - the first is support
for a callback function for the axis text numbering strings using new options
axis_text_callback
, axis_text_callback_x
and
axis_text_callback_y
. These are quite use useful for formatting the
numbers in exactly the way you want, and I'm planning to extend the callback
support to tooltips, labels, etc. in a future version.
The second user-submitted update is an option called semantic_classes
.
Enabling this adds some class attributes to the SVG code to make it easier to
identify which areas of the graph are bars, markers, graph lines, etc. This
should allow for easier modification of the graph using D3.js, plain Javascript,
or any XML parser you have handy.
There are a couple of bugs fixed in this version too: the axis_right
option was broken on some types of graph, and dragging the legend was broken
when crosshairs were not enabled. I've also added a check for the mbstring
extension - SVGGraph will use mbstring functions if it is available, or fall
back to using plain old string functions otherwise. Filling in the legend for
multi-line graphs was broken too.
The new version is available from the downloads page.