| Return Type | Function name | Arguments |
|---|---|---|
| void | hdsChartPie::Generate | (hzChain&,hzHttpEvent*,unsigned int&,) |
Declared in file: hzDissemino.h
Defined in file : hdsGenerate.cpp
Function Logic:
Function body:
void hdsChartPie::Generate (hzChain& Z, hzHttpEvent* pE, unsigned int& nLine)
{
_hzfunc("hdsChartPie::Generate") ;
_pie* pSlice ;
double val ;
double sofar ;
double deg ;
double ang ;
uint32_t X ;
uint32_t Y ;
uint32_t last_y = 0;
uint32_t last_x = 0;
uint32_t n ;
uint32_t bSmall ;
Z.Printf("\n<svg id="%s" height="%d" width="%d" style="background:#%06x;">" , *m_Id, m_Height, m_Width, m_BgColor) ;
if (m_Header)
_hds_svg_drawText(Z, m_Header, m_Width/2,20,m_FgColor,1);
last_x = m_ccX ;
last_y = m_ccY - m_Rad ;
sofar = val = 0.0;
for (n = 0; n < m_nSlices ; n++)
{
pSlice = m_pSlices + n ;
bSmall = pSlice->m_nValue/m_Total >&eq; 0.5?1:0;
Z << "\t<path d="" ;
if ((n+1)== m_nSlices)
{
X = m_ccX ;
Y = m_ccY - m_Rad ;
Z.Printf("M %u %u L %u %u A %u %u 0 %d 1 %u %u Z" fill="#%06x"/>\n" , m_ccX, m_ccY, last_x, last_y, m_Rad, m_Rad, bSmall, X, Y, pSlice->color) ;
}
else
{
sofar += pSlice->m_nValue ;
deg = (360*sofar)/m_Total;
ang = (deg * M_PI)/180;
X = m_ccX + (m_Rad * sin(ang)) ;
Y = m_ccY - (m_Rad * cos(ang)) ;
Z.Printf("M %u %u L %u %u A %u %u 0 %d 1 %u %u Z" fill="#%06x"/>\n" , m_ccX, m_ccY, last_x, last_y, m_Rad, m_Rad, bSmall, X, Y, pSlice->color) ;
last_x = X ;
last_y = Y ;
}
}
X = m_ccX + m_Rad + 40;
Y = m_ccY - m_Rad ;
for (n = 0; n < m_nSlices ; n++)
{
pSlice = m_pSlices + n ;
Z.Printf("<rect x="%u" y="%u" width="%u" height="%u" style="fill:#%06x;stroke:#%06x;stroke-width:1"/>\n" ,
X, Y, 12,12,pSlice->color,m_FgColor,1);
_hds_svg_drawText(Z, pSlice->header, X+15,Y+12,m_FgColor,0);
Y += 20;
}
if (m_Footer)
_hds_svg_drawText(Z, m_Footer, m_Width/2,m_Height - 20,m_FgColor,1);
Z << "</svg>\n" ;
}