The goal of this demo is to show some of the PHP SVGGraph features, and to help reduce the learning curve to get you started with creating your own SVG Graphs.
SVG (Scalable Vector Graphics) is a widely-deployed royalty-free graphics format developed and maintained by the W3C SVG Working Group.
The Master Summary with drill down sample that comes with Forena, includes an SVG graph. It's named the state graph and comes with a set of predefined graph generation options, such as colors (green and yellow), graph type (bargraph), data selection criteria (total at least 10000), etc. This included state graph is actually another sample that comes with forena, though it is hidden (using a forena option to do so) in the list of sample reports. Checkout this state graph link to see it anyhow.
Even though forena does an amazing job in creating SVG graphs, it is not (yet) obvious to get started with creating your own forena based SVG Graphs. And this because, as delivered, the state graph:
- is the very only SVG sample within the delivered samples.
- contains some predefined options that take some time to learn about.
That's why this SVG Graph Demo was created ... enjoy reviewing it!
To get started, how about this vertical BarGraph (in 3D, so it is actually Bar3DGraph) with like 20 different colors:
Here is a sample of a CylinderGraph with fewer colors than the BarGraph before:
Let's find out what a LineGraph would look like, using green triangles as markers, the line that connects the markers should be a blue dashed line (dashes of 3 pixels combined with 3 pixels of gap), and the area under the line should be filled in red, using 25% opacity for that filled area:
Here is the ScatterGraph variation, using purple diamonds as markers, and with an extra best fit line added to it to draw a straight (red) line through the data points (using 7 pixels dashes combined with 7 pixels of gap).
Let's also zoom into the more interesting part of all the data included in the graph, i.e. start the Y-axis only from 7000, and increment the Y-axis values with 1000 (to get more detailed Y-axis data starting from 7000):
Let's change to a PieGraph (also in 3D, so it is actually Pie3DGraph).
And let's use lots of colors (purple, cyan, red, blue, gold, green, indigo, orange, brown, pink, ...):
Here is a sample of a RadarGraph using red triangles as markers, the line that connects the markers should be a purple dashed line (dashes of 3 pixels combined with 3 pixels of gap), and the area within the line should be filled in green, using 40% opacity for that filled area:
Let's return to a BarGraph with horizontal bars, actually a HorizontalBarGraph. Let's only show states with a total nr of users of at least 12000 (instead of 10000) and we need to swap the labels also.
This horizontal BarGraph looks rather ugly, no? The data labels below the chart have become unreadable, even enlarging the width of the graph a bit won't really help (too much data-labels to be shown).
By applying some advanced SVG Graph features it is possible to enhance the previous graph to something that looks already much better.
In case you haven't noticed yet, all graphs above also includes drill-down links. Just click on any of the colored items in any of the charts to view another report with the selected data.
As a reminder: this is just an introduction to create SVG Graphs. We haven't even mentioned some of the additional features, such as:
- stacked and grouped variations of horizontal or vertical BarGraphs or CylinderGraphs, which out-of-the-box are supported also (can't cover everything in an introduction ...).
- MultiRadarGraph variations of RadarGraphs.