| Graph ZX - Using ASP/PHP with graphs |
Graph ZX allows you to modify a graph via ASP parameters passed to the SWF file in an ASP page. here is a brief outline should you wish to take advantage of this feature. Note that while the parameters are in ASP format they can be used just as effectively with PHP. Folloe the principles laid out below to pass the parameters into the Graphs exactly as laid out below. Graph ZX uses these parameters to modify the content shown.
Before continuing it should be pointed out that you can generate a sample ASP page for any graph with the Create ASP page for Graph menu option in the Tools menu. This will guide you through the process and make it much simpler. NOTE: ASP/PHP pages will only display correctly when running off a web server and not if you open them directly in a browser.
Download two Simple samples here
STEP 1 - Designing for ASP
You need to tell Graph ZX that you intend to pass parameters to the graph. On the Data tab in the Design screens click on Allow ASP parameters passed to file to load data. The next step is to determine the maximum number of columns and series you will be displaying and design your graph with that number of each. In the case of Pie graphs, the maximum number of slices. Follow thse steps:
1. Create a graph in the designer as normal. You may want to insert sample data to make sure the graph looks great. It is important to note that you must design the graph with the MAXIMUM number of columns or slices that you intend to use. You may adjust the value with a parameter COLS= passed into the graph, but the COLS parameter may not be greater than the number of columns you designed the graph to cater for.
2. Now on the data Tab in the graph designer, select the option to 'Use ASP parameters passed to file to load values'. You wil now be able to reference the values in the grid by variable names. So Column 1 of Series 1 becomes A1, column 2 becomes A2 etc. These are the variables that will be passed into the SWF file once you create it.
3. On the Y-Axis Tab. Select Auto calculate for the Y Axis values. Unless you are displaying a percentage graph or values that you know will have a fixed limit, it is a good idea to select these options. You can if you want leave the minimum value as 0 and set the others as auto calculate.
4. Save the graph with a name of your choice. Repeat these steps for all the graphs you want to publish as you can publish multiple graphs at once.
5. Select Publish from the Main Menu. Choose Internet (For publish for the Internet) and follow the steps given. You will be asked if you want to embed the graph/s in a page or have them poppup in their own window.
STEP 2 - Passing parameters
Graph ZX understands a number of parameters. If these parameters are not passed the default value will be as designed:
Bar, Line and Area Graphs
Cols - The number of columns to be displayed (NB must be less than or equal to the designed graph)
Series - The number of series to display (NB Must be less than or equal to the designed graph)
Header - The header to display. Replaces the Header text in the designed graph.
Footer - The footer to display. Replaces the Footer text in the designed graph.
XTitle - The Title of the X Axis to display.
YTitle - The Title of the Y Axis to display.
XVal1, XVal2, XVal3 ... etc The X Axis labels for each column or tick.A1,A2,A3,A4 etc... The values of the first Series. 'A' represents the series and 1..x represents the column.
B1, B2, B3, B4 ... The values of the second Series.
C1, C2, C3, C4 ... etc
TypeA, TypeB, TypeC ... (The Series Type. This may be 'line', 'area' or 'bar' (lowercase))
TransA, TransB, TransC ... (The Series Transparency as a percentage (0 - Transparent ..100 - Opaque)
LWA, LWB, LWC ... (The Line Width of each series. Only applicaple if the Series Type is 'line')
FSizeA, FSizeB, FSizeC ... (The Font Size of the value to display for bar graphs. Only applicaple if the Series Type is 'bar')BarGap - The gap to leave between bars in a bar graph. (eg BarGap=10)
Stack - (Whether to stack bar graphs or not. Value may be 'YES' or 'NO' )
YMin, YMax, YStep - The Minimum Y Axis Value, the Max Y Axis Value and the gap between ticks on the Y Axis.
Pie Charts
Slices - The number of slices to show (NB Must be less than or equal to the designed graph)
Slice1, Slice2, Slice3 ... - The data value for each slice (must be numeric)
Label1, Label2, Label3.... - The label to show next to each slice.
Offset1, Offset2, Offset3 ... - The amount to displace each slice to make.Header - The header to display. Replaces the Header text in the designed graph.
Footer - The footer to display. Replaces the Footer text in the designed graph.
These parameters are passed directly into the SWF created in Publish in Graph ZX. If you have 'Allow ASP parameters passed to file to load data' switched on in the Graph design on the Data tab then when you publish the graph for the Internet, an ASP page will be created for you in the directory of your choice.
If you open this file you will see a section that looks like this:
<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"
WIDTH="700" HEIGHT="475" id="GraphZX" ALIGN="">
<PARAM NAME=movie VALUE="MyGraph.swf?v=1">
<PARAM NAME=quality VALUE=high>
<PARAM NAME=bgcolor VALUE=#000000>
<EMBED src="ZXTrigger.swf" quality=high bgcolor=#000000
WIDTH="700" HEIGHT="475" NAME="GraphZX" ALIGN=""
TYPE="application/x-shockwave-flash"
PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED>
</OBJECT>The value section highlighted above has a single parameter (v=1). You would add any parameters you want to change on the graph you have designed here. Note however that the values you pass must be relevant for the graph you designed or the results may be unpredictable.
You must for example design you graph with the maximum amount of series and columns that you would be passing to it in the parameters. Graph ZX will not allow you to have more columns than in the original graph.
Bar/Area/Line - Graph Example
VALUE="MyGraph.swf?v=1&cols=6&series=2&typeA=bar&typeB=line&TransA=60&LWB=10&bargap=5&A1=23.4&A2=34.5&A3=12.45&A4=56.2&A5=44&A6=43.2&B1=23.4&B2=34.5&B3=12.45&B4=56.2&B5=44&B6=43.2&header=My Graph Results&footer=Copyright c 2004&XTitle=Months&YTitle=Sales&XVal1=Jan&XVal2=Feb&XVal3=Mar&XVal4=Apr&XVal5=May&XVal6=Jun"
SAMPLE
There is a full sample of passing parameters to a sample graph online at http://www.graphzx.com/gallery/aspgraph.asp
Download Source files used for this demo: ASPGraph.zip
PLEASE NOTE: You may need to download and install the latest version of Graph ZX. You can do so from the Downloads Page (Click Here).