GD-Chart
view release on metacpan or search on metacpan
gdchart0.11.4dev/gdchart.c view on Meta::CPAN
case GDC_COMBO_HLC_BAR:
case GDC_COMBO_HLC_AREA:
for( j=num_groups-1; j>=0; --j )
{
for( i=0; i<num_points; ++i )
if( uvals[CLOSESET+j*3][i] != GDC_NOVALUE )
{ /* all HLC have vert line */
if( uvals[LOWSET+j*3][i] != GDC_NOVALUE )
gdImageLine( im, PX(i), PY(uvals[CLOSESET+j*3][i]),
PX(i), PY(uvals[LOWSET+j*3][i]),
ExtColor[LOWSET+(j*3)][i] );
if( uvals[HIGHSET+j*3][i] != GDC_NOVALUE )
gdImageLine( im, PX(i), PY(uvals[HIGHSET+j*3][i]),
PX(i), PY(uvals[CLOSESET+j*3][i]),
ExtColor[HIGHSET+j*3][i] );
if( GDC_HLC_style & GDC_HLC_I_CAP )
{
if( uvals[LOWSET+j*3][i] != GDC_NOVALUE )
gdImageLine( im, PX(i)-hlf_hlccapwdth, PY(uvals[LOWSET+j*3][i]),
PX(i)+hlf_hlccapwdth, PY(uvals[LOWSET+j*3][i]),
ExtColor[LOWSET+j*3][i] );
if( uvals[HIGHSET+j*3][i] != GDC_NOVALUE )
gdImageLine( im, PX(i)-hlf_hlccapwdth, PY(uvals[HIGHSET+j*3][i]),
PX(i)+hlf_hlccapwdth, PY(uvals[HIGHSET+j*3][i]),
ExtColor[HIGHSET+j*3][i] );
}
if( GDC_HLC_style & GDC_HLC_DIAMOND )
{
gdPoint cd[4];
cd[0].x = PX(i)-hlf_hlccapwdth; cd[0].y = PY(uvals[CLOSESET+j*3][i]);
cd[1].x = PX(i); cd[1].y = PY(uvals[CLOSESET+j*3][i])+hlf_hlccapwdth;
cd[2].x = PX(i)+hlf_hlccapwdth; cd[2].y = PY(uvals[CLOSESET+j*3][i]);
cd[3].x = PX(i); cd[3].y = PY(uvals[CLOSESET+j*3][i])-hlf_hlccapwdth;
gdImageFilledPolygon( im, cd, 4, ExtColor[CLOSESET+j*3][i] );
}
}
for( i=1; i<num_points; ++i )
if( uvals[CLOSESET+j*3][i-1] != GDC_NOVALUE && uvals[CLOSESET+j*3][i] != GDC_NOVALUE )
{
if( GDC_HLC_style & GDC_HLC_CLOSE_CONNECTED ) /* line from prev close */
gdImageLine( im, PX(i-1), PY(uvals[CLOSESET+j*3][i-1]),
PX(i), PY(uvals[CLOSESET+j*3][i-1]),
ExtColor[CLOSESET+j*3][i] );
else /* CLOSE_CONNECTED and CONNECTING are mutually exclusive */
if( GDC_HLC_style & GDC_HLC_CONNECTING ) /* thin connecting line */
gdImageLine( im, PX(i-1), PY(uvals[CLOSESET+j*3][i-1]),
PX(i), PY(uvals[CLOSESET+j*3][i]),
ExtColor[CLOSESET+j*3][i] );
}
}
break;
}
setno = 0;
/* ---------- scatter points over all other plots ---------- */
/* scatters, by their very nature, don't lend themselves to standard array of points */
/* also, this affords the opportunity to include scatter points onto any type of chart */
/* drawing of the scatter point should be an exposed function, so the user can */
/* use it to draw a legend, and/or add their own */
if( GDC_scatter )
{
CREATE_ARRAY1( scatter_clr, int, GDC_num_scatter_pts );
gdPoint ct[3];
for( i=0; i<GDC_num_scatter_pts; ++i )
{
int hlf_scatterwdth = (int)( (float)(PX(2)-PX(1))
* (((float)((GDC_scatter+i)->width)/100.0)/2.0) );
int scat_x = PX( (GDC_scatter+i)->point + (do_bar?1:0) ),
scat_y = PY( (GDC_scatter+i)->val );
if( (GDC_scatter+i)->point >= num_points || /* invalid point */
(GDC_scatter+i)->point < 0 )
continue;
scatter_clr[i] = clrallocate( im, (GDC_scatter+i)->color );
switch( (GDC_scatter+i)->ind )
{
case GDC_SCATTER_CIRCLE:
{
long uniq_clr = get_uniq_color( im );
int s = 0,
e = 360,
fo = 0;
if( !do_bar )
if( (GDC_scatter+i)->point == 0 )
{ s = 270; e = 270+180; fo = 1; }
else
if( (GDC_scatter+i)->point == num_points-1 )
{ s = 90; e = 90+180; fo = -1; }
if( uniq_clr != -1L ) /* the safe way */
{
int uc = gdImageColorAllocate( im, l2gdcal(uniq_clr) );
gdImageArc( im, scat_x, scat_y,
hlf_scatterwdth*2, hlf_scatterwdth*2,
s, e,
uc );
if( fo ) /* close off semi-circle case */
gdImageLine( im, scat_x, scat_y+hlf_scatterwdth,
scat_x, scat_y-hlf_scatterwdth,
uc );
gdImageFillToBorder( im, scat_x+fo, scat_y, uc, scatter_clr[i] );
gdImageArc( im, scat_x, scat_y,
hlf_scatterwdth*2, hlf_scatterwdth*2,
s, e,
scatter_clr[i] );
if( fo )
gdImageLine( im, scat_x, scat_y+hlf_scatterwdth,
scat_x, scat_y-hlf_scatterwdth,
scatter_clr[i] );
gdImageColorDeallocate( im, uc );
}
else /* chance it */
{
gdImageArc( im, scat_x, scat_y,
hlf_scatterwdth*2, hlf_scatterwdth*2,
s, e,
scatter_clr[i] );
( run in 1.143 second using v1.01-cache-2.11-cpan-39bf76dae61 )