gujjula / core-plot

Automatically exported from code.google.com/p/core-plot
0 stars 0 forks source link

When generating PDF data from CPLayer, alpha channel information is lost if a bar chart & gradient is used #297

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago

When a bar graph uses a gradient for the bars, -(NSData 
*)dataForPDFRepresentationOfLayer loses the alpha information.

Try a bar chart with the following first - notice that when 
dataForPDFRepresentationOfLayer is called the alpha is lost:

CPBarPlot *barPlot = [CPBarPlot tubularBarPlotWithColor:[CPColor 
colorWithComponentRed:.1 green:.5 blue:.4 alpha:.2] horizontalBars:NO];

Then try this - when dataForPDFRepresentationOfLayer is called the alpha is 
correct.
CPBarPlot *barPlot = [[CPBarPlot alloc] initWithFrame:CGRectZero];
barPlot.fill = [CPFill fillWithColor:[CPColor colorWithComponentRed:.1 green:.5 
blue:.4 alpha:.2]];

Original issue reported on code.google.com by eriksbac...@gmail.com on 21 Jun 2011 at 4:20

GoogleCodeExporter commented 9 years ago
This is a limitation of the PDF implementation on Mac OS. It doesn't support 
transparency in gradients. That's why bars filled with a transparent color 
work, but not the ones with a gradient fill (the "tubular" bars).

See these links for more info:

http://www.cocoabuilder.com/archive/cocoa/289044-problem-using-nsgradient-with-d
atawithpdfinsiderect.html 

http://cocoawithlove.com/2011/01/advanced-drawing-using-appkit.html for more 
information.

Until Apple builds support for a later version of PDF into the OS, your options 
are to avoid gradients and stick to the solid colors or to output to PNG.

Original comment by eskr...@mac.com on 21 Jun 2011 at 11:43

GoogleCodeExporter commented 9 years ago
Hi Guys. A quick question about this reported limitation. Does the problem 
simply result in bar charts with incorrect color fills OR will this combination 
produce exceptions during the generation of PDF data?

I ask because we are struggling with an intermittent bug that appears to be 
related to some code in the CPTGradient class. You can see in the attached 
image that we get a EXEC_BAD_ACCESS error. 

This error occurs during a process where we are writing multiple (approx 28 to 
38) charts into a PDF file. We first generate the PDF data for each chart 
individually, cache that data to disk as a PDF file, then draw it back into the 
master PDF file in the final step. It is during this final step that the error 
sometimes occurs. We have not had much success nailing it down to a specific 
plot. It seems very random at this time.

Some of our core plot charts do have bar charts using gradient fills, so we'll 
try playing with those settings to see if we can correct the problem, but any 
feedback you can provide would be helpful.

Thanks!

Original comment by chronics...@gmail.com on 23 May 2012 at 5:08

Attachments:

GoogleCodeExporter commented 9 years ago
This issue only occurs when gradients use non-opaque colors. Do all of the 
intermediate graphs look ok if you open the PDF files separately? If your app 
is crashing after all of the individual graphs have been generated, I don't 
think the problem is related to Core Plot.

Original comment by eskr...@mac.com on 23 May 2012 at 11:02