|
Pie Chart doesn't render to PNG file properly if setting its background to transparent and there is no content to be drawn in the chart |
Posted by Ryan on Jan-26-2011 07:37 |
|
Hi,
Below is a simple form of the code:
PieChart *c = new PieChart(360, 300);
// Set the center of the pie at (180, 140) and the radius to 100 pixels
c->setPieSize(180, 140, 100);
DoubleArray *p_seriesData_o = new DoubleArray( NULL, 0 );
StringArray *p_labelData_o = new StringArray( NULL, 0 );
// Set the pie data and the pie labels
c->setData(*p_seriesData_o, *p_labelData_o);
c->setBackground(Chart::Transparent);
DrawArea *da = c->getDrawArea();
da->setTransparentColor( -1 );
MemBlock outChart = c->makeChart( Chart::PNG );
char * p_newbuff = (char *) malloc( outChart.len );
memcpy( p_newbuff, outChart.data, outChart.len );
Then we will use p_newbuff to render an image on the dialog. However, the output
image is black. What I expect is the output be transparent, so there is nothing shown on
the dialog.
Our product runs on Win and Mac. And the issue only happens on windows. Both
platforms share the same rendering code. So I guess would there be a bug in the library?
Thanks in advance!
Ryan |
Re: Pie Chart doesn't render to PNG file properly if setting its background to transparent and there is no content to be drawn in the chart |
Posted by Ryan on Jan-26-2011 07:39 |
|
To correct. It's rendered to PNG Format not to PNG File. |
Re: Pie Chart doesn't render to PNG file properly if setting its background to transparent and there is no content to be drawn in the chart |
Posted by Ryan on Jan-26-2011 12:07 |
|
As I check the code, I find there exists the possibility that the GDI call we use might not be
able to handle the transparent empty PNG image. I would like to ask, is there a way to plot
something for pie chart if no attribute hasn't been specified( Similar as we can specify the
plot area for XY chart, so at least, XY Chart can plot a plot frame if nothing else).
Thanks!
Ryan |
Re: Pie Chart doesn't render to PNG file properly if setting its background to transparent and there is no content to be drawn in the chart |
Posted by Peter Kwan on Jan-26-2011 16:52 |
|
Hi Ryan,
Yes. You can always plot anything you want whether there are data or not. For example:
if (p_seriesData_o->len <= 0)
c->addTitle(Chart::Center, "No Data");
You may also plot a very small and almost invisible line (using BaseChart.addLine). For example, you may plot a line that is 1 pixel long in the top left corner, using an almost transparent color.
Hope this can help.
Regards
Peter Kwan |
|