|
HTML charting in ASP - basics Charting is most common
task you will need in data presentation. This article shows simple method to
create charts without external client or server objects, without .gif,
jpg or png - the chart is created as HTML, directly
in page. The simpliest task is to create bar charts. HTML gives you many formatting
possibilities to show bars in graph. There are some important things we will need to create such chart - first of them is a plain bar. The bar can be created using Table tag - simple horizontal bars. <TABLE bgColor=red height=10 width=200 cellSpacing=0 cellPadding=0 border= 0> <TR><TD></TD></TR> </TABLE> <TABLE bgColor=green height=10 width=100 cellSpacing=0 cellPadding=0 border= 0> <TR><TD></TD></TR> </TABLE> Vertical barsThere is some more HTML code to create vertical bars - we have to create chart table with background to align vertical bars to bottom base. Next tables is stacked bars with 3 series and 3 points. <TABLE bgColor=yellow height=100 width=100 cellSpacing=0 cellPadding=0 border=0> <tr><TD VAlign=bottom> <TABLE height="100%" width=20 cellSpacing=0 cellPadding=0 border=0 Align=left> <TR><TD></TD></TR> <TR><TD Height="20%" bgColor=red></TD></TR> <TR><TD Height="30%" bgColor=green></TD></TR> <TR><TD Height="15%" bgColor=blue></TD></TR></TABLE> <TABLE height="100%" width=20 cellSpacing=0 cellPadding=0 border=0 Align=left> <TR><TD></TD></TR> <TR><TD Height="30%" bgColor=red></TD></TR> <TR><TD Height="40%" bgColor=green></TD></TR> <TR><TD Height="10%" bgColor=blue></TD></TR> </TABLE> <TABLE height="100%" width=20 cellSpacing=0 cellPadding=0 border=0 Align=left> <TR><TD></TD></TR> <TR><TD Height="50%" bgColor=red></TD></TR> <TR><TD Height="10%" bgColor=green></TD></TR> <TR><TD Height="30%" bgColor=blue></TD></TR> </TABLE> </TD></tr> </TABLE>
Series decriptionThe main problem of HTML charts is a description of series and points. We will need vertical orientation of text - but there is no HTML tag for such action. We can use <A Title="some description"> for points description, but the text is visible only with mouse pointer. IE has one more undocumented special style parameter - WRITING-MODE: tb-rl. <DIV style="FONT-SIZE: 15pt; WIDTH: 15pt; WRITING-MODE: tb-rl"> 527</DIV>
Simple HTML bar chart functionNext VBS code generates simple HTML bar chart from teo dimensional recordset. The recordset is a cross-table set containing serie names in field names, x-labels in first column and values in other columns. In our case, Top5Stats query contains next data:
The page result is the next chart:
See alsofor 'Create html bar graph in ASP/VBSscript' article HTML stacked bar graph in ASP/VBSscriptFunctions with full source code to creare simple stacked bar chart from an ASP page.Copyright and use this code
The source code on this page and other samples at https://www.motobit.com/tips/
are a free code, you can use it as you want: copy it, modify it, use it in your products, ...
If you use this code, please:
1. Leave the author note in the source.
or
2. Link this sample from you page.
<A Href="https://www.motobit.com/tips/detpg_html-bar-graph-chart/" Title="Functions with full source code to creare bar charts from an ASP page." >Create html bar graph in ASP/VBSscript</A> Do you like it? Rate me on LinkedIn |
© 1996 - 2019 Antonin Foller, Motobit Software | About, Contacts