Custom Graphs
Custom graphs work just like the custom reports. The difference is
that instead of generating HTML, you just put the word ``GRAPH''
(without the speechmarks) in the HTML box to indicate you want ASM
to draw a graph instead. All the SQL keys, including $ASK and $VAR
are still supported in the normal way.
ASM will dissect the results of the query in the following way to
generate a graph:
- Each row in your result data becomes a point on the X axis
- The first column in each row is assumed to contain the name used for
the label on the X axis. Only string data should be used for the first
column.
- Each subsequent column is assumed to be a piece of data at that point
on the X axis (and thus gives the Y axis its scale). Only numeric
data can appear in columns after the first one.
- The fieldname of each column after the label column is used to denote
the data on the legend.
For example, this SQL will produce a graph that shows the amount of
donations from animal movements each year. Following our scheme, the
Year column being first is the X axis label, TotalAmount is the first
datapoint for that item on the X axis.
-
- SELECT
YEAR(DateReceived) AS Year,
SUM(ownerdonation.Donation) AS TotalAmount
FROM ownerdonation
WHERE MovementID > 0
GROUP BY YEAR(DateReceived)
ORDER BY Year
Would produce data that might look something like:
-
-
And in turn, a graph that looks like:
Note that the graphs use a relative scale, interpreted from the data.
If all of your column data is the same value, then the graph will
not display because it has no variance.
http://sheltermanager.sf.net