SVGGraph Errors
When working with SVGGraph you might sometimes find an error message in the SVG output instead of the graph you were expecting. This page should help to explain what some of these messages mean and how to deal with the issues that cause them.
No data
The “No data” error is shown when SVGGraph has no data values to
work with. This can happen when you forget to call $graph->Values()
,
or when the array of data passed to the Values()
function is
empty.
If you really want to show an empty graph then you must provide at least one
value to the Values()
function, even if it is 0 (but see the
“Zero length axis” section below for more about that).
Zero length axis
This error means that SVGGraph could not determine the scale for the axis -
which tends to happen when all of the values in your data are 0. To display the
empty graph, you should set the axis_max_v
option to the number you
want at the top of the axis (something like 1, 10, 50, 1000, or whatever makes
the most sense for your application).
If you are using a horizontal graph then you should set the scale end value
using the axis_max_h
option instead. If you want the scale to
encompass negative numbers then you would have to set the axis_min_h
or axis_min_h
options to the negative number that you want at the
lower end of the axis.
From version 3.2 you should not see this error - SVGGraph will use the value
of the axis_fallback_max
option to set a length for the axis.
Non-numeric min/max
Or sometimes “Non-numeric value”, depending on the graph type and whether you are using structured data or not.
These errors both mean that SVGGraph has searched through the data for the minimum and maximum values and found that either:
- all of your values are
NULL
or - some of your values are neither a number nor
NULL
or - your structured data
value
fields are empty.
When this happens, using print_r($values);
to dump the data
will usually make the source of the problem apparent.
No values in grid range
This happens when you have used some or all of the axis_max_v
,
axis_min_v
, axis_max_h
and axis_min_h
options and none of your data values are greater than the axis_min_v
(or _h
) setting.
It can also happen when all of the data values are greater than
axis_max_v
(or _h
) when set to a negative number.
If you keep having this problem, try not setting the
axis_min_v
or axis_min_h
options, and not setting the
axis_max_v
or axis_max_h
to negative numbers.
Invalid axes specified
This is a simple error to explain - it means that you have provided
axis_min_v
and axis_max_v
(or axis_min_h
and axis_max_h
) settings, but your axis_max_
is not
greater than your axis_min_
.
Your maximum must always be more than your minimum - putting them the other way around will not trick SVGGraph into drawing the graph upside-down!
Not enough values for <graph type>
This is an error from the line and radar graphs - you must have at least two data values to be able to draw a line between them. If you really want to show a graph with a single marker, you should switch to using a scatter graph for that instead.
Negative value for double-ended axis
At the moment you would only receive this error from the population pyramid graph type because it is the only one to use the double-ended axis. The X axis of the population pyramid has its 0 in the middle and two positive scales on either side. Because of this, it cannot display negative numbers.
Structured data errors
These are the errors you might see if you are using structured data (or if you are not using structured data when you should be for the graph to work).
Repeated keys in data
This happens when you are using structured data and the same key value appears in multiple records. Some graph types (the scatter and bubble graphs) can cope with this kind of data, but for most graphs it would not make sense. To solve this problem either modify your data to contain unique keys or change to using a scatter graph (or bubble graph) to display it instead.
<graph type> requires structured data
The graph you have tried to generate requires the use of structured data to
specify some extra information, but you have not set the necessary
structured_data
or structure
options.
Check the other graphs page for details of how to
create the graph type that you want.
Required field(s) [<field list>] not set in data structure
You have specified structured_data
and/or structure
for a graph that requires it, but you have not listed one or more of the extra
fields in your structure
array.
The error message lists the fields that you are missing - refer to the other graphs page for the full details of what must be included to make the graph work.
Pie graph errors
The pie graph and 3D pie graph don't use axes, so they have their own error messages.
Empty pie chart
This is the pie graph equivalent of “Zero length axis” - all of your values are 0, so a pie chart can't be drawn.
Negative value for pie chart
Pie graphs can not display negative values, so SVGGraph will give up if it finds any in your data.
Log axis errors
When you enable the log_axis_y
option, these error messages
could emerge.
log_axis_y not supported by <graph type>
This means that the selected graph type doesn't support using the logarithmic axis, probably because it would produce a confusing and distorted graph.
0 value on log axis
You have enabled the log_axis_y
option, but SVGGraph has found
a 0 in your data. The logarithm of 0 is undefined, so it can't be drawn on a
logarithmic scale. You can solve this by removing any 0 values from the data,
or by setting the axis_min_v
option to something greater than 0 to
skip the 0 values.
Obviously you should set the axis_min_h
option instead if you
are using a horizontal graph.
-ve and +ve on log axis
This is very similar to the previous problem, but you have both positive and negative values in your data. SVGGraph can draw all positive or all negative values on a logarithmic scale, but to draw both on one graph would mean putting 0 somewhere.
The solution is similar too - set axis_min_v
to a positive number
to show only positive values, or set axis_max_v
to a negative
number to show only the negative numbers.
For horizontal graphs you should use axis_min_h
and
axis_max_h
instead.