Displays a chart by placing in the page HTML, a <svg> tag. Returns: None
| Return Type | Function name | Arguments |
|---|---|---|
| void | hdsChartBar::Generate | (hzChain&,hzHttpEvent*,uint32_t&,) |
Declared in file: hzDissemino.h
Defined in file : hdsGenerate.cpp
Function Logic:
Function body:
void hdsChartBar::Generate (hzChain& Z)hzHttpEvent* pE, uint32_t& nLine,
{
// Category: HTML Generation
//
// Displays a chart by placing in the page HTML, a <svg> tag.
//
// Arguments: 1) Z The HTML output chain
// 2) pE The HTTP event being responded to
// 3) nLine Line number tracker (controls NL printing)
//
// Returns: None
_hzfunc("hdsChartBar::Generate") ;
hzList<_rset*>::Iter ri ; // Dataset iterator
_rset* pSet ; // Dataset
// double per_pixel_X ; // For ploting x
double per_pixel_Y ; // For ploting y
double stepSize ; // Axis value per step
uint32_t val ; // Current value
uint32_t X ; // Current horizontal coord
uint32_t Y ; // Current vertical coord
uint16_t axisPixelsX ; // Total pixels on X-axis
uint16_t axisPixelsY ; // Total pixels on Y-axis
uint32_t n ; // Loop iterator
/*
** ** Start draw instrutions
** */
Z.Printf("<svg id=\"%s\" height=\"%d\" width=\"%d\" style=\"border:1px solid #000000; background:#%06x;\">", *m_Id, m_Height, m_Width, m_BgColor) ;
// Draw header and footer if applicable
if (m_Header)
_hds_svg_drawText(Z, m_Header, m_Width/2,20,m_FgColor,1);
// Calculate pixels
axisPixelsX = m_nSlotsX * m_nPxSlotX ;
axisPixelsY = m_nSlotsY * m_nPxSlotY ;
// per_pixel_X = (m_nMaxX - m_nMinX)/axisPixelsX ;
per_pixel_Y = (m_nMaxY - m_nMinY)/axisPixelsY ;
// Draw vertical and horizontal axis
Z.Printf("<line x1=\"%u\" y1=\"%u\" x2=\"%u\" y2=\"%u\" style=\"stroke:#%06x;stroke-width:1\"/>\n", m_origX, m_origY - axisPixelsY, m_origX, m_origY, m_FgColor) ;
Z.Printf("<line x1=\"%u\" y1=\"%u\" x2=\"%u\" y2=\"%u\" style=\"stroke:#%06x;stroke-width:1\"/>\n", m_origX, m_origY, m_origX + axisPixelsX, m_origY, m_FgColor) ;
// Draw out vertical axis heading and markers
Y = 30;
X = 20;
Z.Printf("<text x=\"%u\" y=\"%u\" fill=\"#%06x\">%s</text>\n", X, Y, m_FgColor, *m_HdrY) ;
stepSize = (m_nMaxY - m_nMinY)/m_nSlotsY ;
Y = m_origY ;
for (val = m_nMinY ; val <&eq; m_nMaxY ; val += stepSize)
{
Z.Printf("<text x=\"%u\" y=\"%u\" fill=\"#%06x\">%u</text>\n", X, Y, m_FgColor, (uint32_t) val) ;
Y -= m_nPxSlotY ;
}
// Draw out horizontal axis heading and markers
stepSize = (m_nMaxX - m_nMinX)/m_nSlotsX ;
Y = m_origY + 20;
X = m_origX ;
for (val = m_nMinX ; val <&eq; m_nMaxX ; val += stepSize)
{
Z.Printf("<text x=\"%u\" y=\"%u\" fill=\"#%06x\">%u</text>\n", X, Y, m_FgColor, (uint32_t) val) ;
X += m_nPxSlotX ;
}
// Plot values
for (n = 0; n <&eq; m_nSlotsX ; n++)
{
Y = m_origY ;
X = m_origX + (n * m_nPxSlotX) + 1;
for (ri = m_Sets ; ri.Valid() ; ri++)
{
pSet = ri.Element() ;
val = ((pSet->m_vVals[n] - m_nMinY) * per_pixel_Y) ;
Z.Printf("<rect x=\"%u\" y=\"%u\" width=\"%u\" height=\"%u\" style=\"fill:#%06x;\"/>\n", X, Y - val, (uint32_t)m_nPxSlotX - 1,val, pSet->color) ;
Y -= val ;
}
}
// Do the component index if applicable
Y = m_origY + 40;
if (m_Sets.Count() > 1)
{
X = m_origX ;
for (ri = m_Sets ; ri.Valid() ; ri++)
{
pSet = ri.Element() ;
Z.Printf("<rect x=\"%u\" y=\"%u\" width=\"%u\" height=\"%u\" style=\"fill:#%06x;\"/>\n", X, Y, 12,12,pSet->color);
Z.Printf("<text x=\"%u\" y=\"%u\" fill=\"#%06x\">%s</text>\n", X+15,Y+15,m_FgColor,*pSet->header);
X += 10*(pSet->header.Length()) ;
}
Y += 20;
}
if (m_Footer)
_hds_svg_drawText(Z, m_Footer, m_Width/2,Y, m_FgColor, 1);
Z
<< "Your Browser does not support the HTML5 SVG tag\n</svg>\n"
;
}