| dbColGraph |
Display a column of numeric values as a horizontal bar chart in both grid and form mode. Data can be automatically normalized or a Min/Max scale be specified. Note that the group repeat starts at the FieldNameNumber and doesn't include the TableName.
| Property Syntax |
dbColGraph = "TableName, FieldNameNumber1, Width1, Height1, Icon1, Style1, Min1, Max1, Multiplier1, roundto1
, Named_Format1; FieldNameNumber2, Width2, Height2, Icon2, Style2, Min2, Max2, Multiplier2, roundto2, Named_Format2; ...repeat"dbColGraphMinMaxSQL = "SQL returning first feild as Min and second field as Max" (See example)
| Parameters |
|
Parameters |
Description |
| TableName | Name of active table. |
| FieldNameNumber | Field name or number containing the numeric values. |
| Width | Width of the Bar. |
| Height | Height of the Bar. |
| Icon | Name of the gif or jpg file used to produce the chart. |
| Style | Style (1-8) of bar chart.
|
| Min | These two value are
only necessary when the data source is a user supplied recordset
(dbRecordSet property). They
must be set to the minimum and maximum values that the field will contain.
They are necessary for ASP-db to scale the character of icon to the
proper size. With other than
the dbRecordSet data sources, ASP-db automatically figures out the minimum
and maximum values before displaying the first record, and then scales the
bars proportionally. |
| Mix | |
| Multiplier | Multiply the value by the scale factor. Percentage can use this to display 15% instead of the actual value of 0.15. |
| Roundto | Round to after multiplier. Value = Int(Value * multiplier * 10 ^ (roundto) + Sgn(Value) * 0.5) / 10 ^ (roundto) |
| Named_Format | Format the number at end of graph according to the ASP-db MagicCell Named Formats. (General, Currency, Fixed, Standard, Percent, Scientific, Yes/No, True/False or On/Off ). Formatting would only be done with these formats. |
| Example |
|
<% Set X=Server.CreateObject("ASP.DB") X.dbQuickProps="1;NWIND;Order details;grid;4" response.write("<center><h3>Style 1 & 2</h3>") X.dbColGraph="Order details, UnitPrice,100,,x,1;quantity,100,,,2" X.ASPDB response.write("<center><h3>Style 3 & 4</h3>") X.dbunit=2 X.dbColGraph="Order details, UnitPrice,20,,moneybag.gif,3;quantity,20,,moneybag.gif,4" X.ASPDB response.write("<center><h3>Style 5 & 6</h3>") X.dbunit=3 X.dbColGraph="Order details, UnitPrice,500,18,bluebar.gif,5;quantity,500,12,redbar.gif,6" X.ASPDB response.write("<center><h3>Style 7 & 8</h3>") X.dbUnit=4 X.dbColGraph="Order details,UnitPrice,500,18,bluebar.gif,7;quantity,500,12,redbar.gif,8" X.ASPDB %> |
| Browser Output
|
Example #2 - Using Multiplier
| <% Set X=Server.CreateObject("ASP.DB") X.dbQuickProps="1;NWIND;Order details;grid;4" response.write("<center><h3>Style 1 & 8</h3>") X.dbColGraph="Order details, UnitPrice,100,,x,1;discount,100,,bluebar.gif,8,,,100" X.ASPDB %> |
Note that the discount field is displayed after applying the multiplier of 100. |
Example #3 - Using User supplied Min/Max SQL
| <h3><CENTER>dbColGraph with Auto Scale</CENTER></h3> <% Set x=Server.CreateObject("ASP.db") x.dbUnit = 1 x.dbDSN = "NWIND" x.dbMode = "GRID" x.dbImageDir = "/aspdb/images" sqlcmd = "Select customerID,count(*) as qnty FROM orders where (customerID like 'r%' or customerID like 'a%') group by customerID order by customerID" x.dbSQL = sqlcmd x.dbNameMap = "qnty,recCnt,,count(*);" x.dbColGraph = "orders,qnty,200,12,bluebar.gif,8 ;" ',0,10;" auto scale 'x.dbColGraph = "orders,qnty,200,12,bluebar.gif,8 ,0,10;" 'user scale x.dbColGraphMinMaxSQL= "Select customerID,count(*) as qnty FROM orders where (customerID like 'r%' or customerID like 'a%') group by customerID order by customerID" x.ASPdb %> Note - Text and Null in Min/Max value will be treated as 0. |
|
| Notes |
Remember that for shadowed style 1 & 8, shadowbar.gif must be there in addition to the redbar.gif and bluebar.gif. These files are supplied with the standard package.
Styles
1 and 2 simply repeat the specified "Character" (e.g.
"$") in the cell a number of times proportional to the value of
the field.
The Icon parameter can be any GIF or JPG file you wish to have displayed.
The
type of graphic you would use will depend on the style you choose.
If the style is 3 or 4, then ASP-db will simply "repeat"
the graphic a number of times proportional to the value of the field.
An example of how this might be used, would be to use a "dollar
sign" GIF file. A database
with the values 1 and 3 might then have 10 and 30 of those GIF files
displayed in this field. If
Style 5 , 6, 7 or 8 is chosen, then the specified Icon file would be
stretched to be as wide as necessary to achieve the desired width (as a
percentage of the specified Width parameter).
With Styles 7 and 8, the file "shadowbar.gif" is drawn
below and to the right of the specified Icon to give the chart a drop shadow
effect. It is suggested for
styles 6 through 8 that a 1x1 GIF file be used.
ASP-db will then "stretch" that GIF file (using the IMG
width and height) parameters to whatever size is necessary.
The sample GIF files redbar.gif, greenbar.gif, bluebar.gif,
blankbar.gif and shadowbar.gif are included in your ASP-db ZIP file.
It is suggested that these files be placed in an "IMAGES"
subdirectory and that you set the dbImageDir
property to point to this directory.
Graphs
in Multiple Columns: If you want to have graphs in two or more columns,
separate the graph definitions with semi-colons.
The Tabel name should only be used once.
For example: dbColGgraph = "Table1,Fld1,Width,Height,Icon,Style;
Fld2,Width,Height,Icon,Style;"
If
you do not specify the dbImageDir property, ASP-db will not know where to
find either the ICON file specified in the "Icon" parameter, or
the blankbar.gif or shadowbar.gif which are used in styles 5 through 8.