<!--wb_beginsub_init-->
$wbif[$wbgetv[w]>99|$wbsetv[width|$wbgetv[w]]|$wbsetv[width|100]]
<!--WB_EndSub-->
<!--wb_beginsub_addColumn-->
$WBAADD[headers|$wbgetv[hN]|F]
$WBAADD[barVals|$wbgetv[bV]|F]
$wbsetv[sum|$wbcalc[$wbgetv[sum] + $wbgetv[bV]]]
$WBAADD[colorBars|$wbgetv[cB]|F]
<!--WB_EndSub-->
<!--wb_beginsub_calcPercents-->
$wbsetv[numBars|$WBALEN[barVals]]
$wbsetv[i|0]
$wbwhile[$wbgetv[i]<$wbgetv[numBars]|
$WBAADD[barPerc|$wbformat$wbcalc[($wbgetv[barVals($wbgetv[i])]/$wbgetv[sum])*100]|#]|F]
$wbsetv[i|$wbcalc[$wbgetv[i]+1]]
]
<!--WB_EndSub-->
interger of( (Bar value devided by total) multiply with 100)
<!--wb_beginsub_calcWidthVals-->
$wbsetv[numBars|$WBALEN[barVals]]
$wbsetv[i|0]
$wbwhile[$wbgetv[i]<$wbgetv[numBars]|
$WBAADD[widthVals|$wbcalc[abs(($wbgetv[barPerc($wbgetv[i])]/$wbgetv[width])*100)]|F]
$wbsetv[i|$wbcalc[$wbgetv[i]+1]]
]
<!--WB_EndSub-->
Absolute of((bar percentage devided by maximum width) multiply with 100)
<!--wb_beginsub_drawGraph-->
$wbsub[calcPercents]
$wbsub[calcWidthVals]
$wbsetv[numBars|$WBALEN[barVals]]
<table cellpadding="0" cellspacing="0" border="0">
$wbsetv[i|0]
$wbwhile[$wbgetv[i]<$wbgetv[numBars]|
<tr>
<td class="$wbgetv[cellClassName]">
$wbgetv[headers($wbgetv[i])]</td>
<td align="right" width="$wbcalc[$wbgetv[width]/2]">
<table cellpadding="0" cellspacing="0" width="$wbif[$wbgetv[barVals($wbgetv[i])]<0|$wbgetv[widthVals($wbgetv[i])]|0]%" border="0">
<tr height="20"><td width="100%" bgcolor="$wbgetv[colorBars($wbgetv[i])]"></td></tr>
</table>
</td>
<td align="left" width="$wbcalc[$wbgetv[width]/2]">
<table cellpadding="0" cellspacing="0" width="$wbif[$wbgetv[barVals($wbgetv[i])]>0|$wbgetv[widthVals($wbgetv[i])]|0]%" border="0">
<tr height="20"><td width="100%" bgcolor="$wbgetv[colorBars($wbgetv[i])]"></td></tr>
</table>
</td>
</tr>
$wbsetv[i|$wbcalc[$wbgetv[i]+1]]
]</table>
<!--WB_EndSub-->
#* Initialization width *#
<!--wb_beginsub_init-->
$wbif[$wbgetv[w]>99|$wbsetv[width|$wbgetv[w]]|$wbsetv[width|100]]
<!--WB_EndSub-->
#*
This subroutine adds a new values to the graphic
"hN" This is the name of the column (string type)
"bV" This is a number that specifies the value of the bar
"cB" This is an string that specifies the color of the bar
*#
<!--wb_beginsub_addColumn-->
$WBAADD[headers|$wbgetv[hN]|F]
$WBAADD[barVals|$wbgetv[bV]|F]
$wbsetv[sum|$wbcalc[$wbgetv[sum] + $wbgetv[bV]]]
$WBAADD[colorBars|$wbgetv[cB]|F]
<!--WB_EndSub-->
#* This subroutine calculates the percents of the total *#
<!--wb_beginsub_calcPercents-->
$wbsetv[numBars|$WBALEN[barVals]]
$wbsetv[i|0]
$wbwhile[$wbgetv[i]<$wbgetv[numBars]|
$WBAADD[barPerc|$wbformat[$wbcalc[($wbgetv[barVals($wbgetv[i])]/$wbgetv[sum])*100]|#]|F]
$wbsetv[i|$wbcalc[$wbgetv[i]+1]]
]
<!--WB_EndSub-->
#* This subroutine calculates the width values *#
<!--wb_beginsub_calcWidthVals-->
$wbsetv[numBars|$WBALEN[barVals]]
$wbsetv[i|0]
$wbwhile[$wbgetv[i]<$wbgetv[numBars]|
$WBAADD[widthVals|$wbcalc[abs(($wbgetv[barPerc($wbgetv[i])]/$wbgetv[width])*100)]|F]
$wbsetv[i|$wbcalc[$wbgetv[i]+1]]
]
<!--WB_EndSub-->
#*
This subroutine draws the graph
"cellClassName" a css class name for easier formatting
*#
<!--wb_beginsub_drawGraph-->
$wbsub[calcPercents]
$wbsub[calcWidthVals]
$wbsetv[numBars|$WBALEN[barVals]]
<table cellpadding="0" cellspacing="0" border="0">
$wbsetv[i|0]
$wbwhile[$wbgetv[i]<$wbgetv[numBars]|
<tr>
<td class="$wbgetv[cellClassName]">
$wbgetv[headers($wbgetv[i])]</td>
<td align="right" width="$wbcalc[$wbgetv[width]/2]">
<table cellpadding="0" cellspacing="0" width="$wbif[$wbgetv[barVals($wbgetv[i])]<0|$wbgetv[widthVals($wbgetv[i])]|0]%" border="0">
<tr height="20"><td width="100%" bgcolor="$wbgetv[colorBars($wbgetv[i])]"></td></tr>
</table>
</td>
<td align="left" width="$wbcalc[$wbgetv[width]/2]">
<table cellpadding="0" cellspacing="0" width="$wbif[$wbgetv[barVals($wbgetv[i])]>0|$wbgetv[widthVals($wbgetv[i])]|0]%" border="0">
<tr height="20"><td width="100%" bgcolor="$wbgetv[colorBars($wbgetv[i])]"></td></tr>
</table>
</td>
</tr>
$wbsetv[i|$wbcalc[$wbgetv[i]+1]]
]</table>
<!--WB_EndSub-->
[FormFields]
wb_command=r
WB_showlogo=F
<!--WB_BeginTemplate-->
$wbrinc[graph.ic]
$wbsetv[w|100]$wbsub[init]
$wbsetv[hN|Column 1]$wbsetv[bV|25,2]$wbsetv[cB|#CCCCCC]$wbsub[addColumn]
$wbsetv[hN|Column 2]$wbsetv[bV|-25,2]$wbsetv[cB|#AAAAAA]$wbsub[addColumn]
$wbsetv[hN|Column 3]$wbsetv[bV|100,32]$wbsetv[cB|#999999]$wbsub[addColumn]
$wbsetv[hN|Column 4]$wbsetv[bV|88,236]$wbsetv[cB|#777777]$wbsub[addColumn]
$wbsetv[hN|Column 5]$wbsetv[bV|11,236]$wbsetv[cB|#555555]$wbsub[addColumn]
<html>
<head>
<title>Test graphs</title>
<style>
<!--
.cell_header {
font-family: "Arial Narrow";
font-size: 12px;
font-style: normal;
line-height: normal;
font-weight: bold;
font-variant: normal;
text-transform: uppercase;
color: #E0E0E0;
text-decoration: none;
background-color: #4E4E4E;
}
-->
</style>
</head>
<body>$wbsetv[cellClassName|icon_links_off]$wbsub[drawGraph]</body></html>
Have a question about something in this article? You can receive help directly from the article author. Sign up for a free trial to get started.
Comments (0)