kaiserfarrell / core-plot

Automatically exported from code.google.com/p/core-plot
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Shadows broken and/or inconsistent #484

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
1) Axes and titles (text) now have a shadow. This is because I used the 
CALayer.shadow* properties (on the plot area frame) to set shadows for my 
plots. This did not cause a problem before.
2) CPTPlotAreaFrame no longer shows a shadow at all. Even with a 
CPTMutableShadow I can't get any shadow to show up. Though using the core plot 
shadow solves the text shadow problem.
3) In scatter plots I see shadows only if I use the CALayer.shadow* properties. 
Using CPTPlot.shadow causes no shadow to display.
3) In bar plots I have a similar problem as with scatter plots, however when I 
use th CPTPlot.shadow property then only borders cast a shadow (which looks 
wrong because they cast both outer and innner shadows). Removing the border 
also removes the shadow(s).

The code I use is very simple:

… for the graphs (here already changed to CPTMutableShadow)

    CPTPlotAreaFrame* frame = selectionGraph.plotAreaFrame;
    ...    
    frame.cornerRadius = 5;
    frame.borderLineStyle = nil;

    CPTGradient* gradient = [CPTGradient gradientWithBeginningColor: [CPTColor colorWithGenericGray: 80 / 255.0]
                                                        endingColor: [CPTColor colorWithGenericGray: 30 / 255.0]
                             ];
    gradient.angle = -87.0;
    CPTFill* gradientFill = [CPTFill fillWithGradient: gradient];
    frame.fill = gradientFill;

    CPTMutableShadow *shadow = [CPTMutableShadow shadow];
    shadow.shadowColor = [CPTColor yellowColor];
    shadow.shadowBlurRadius = 3.0;
    shadow.shadowOffset = CGSizeMake(2, -2);
    frame.shadow = shadow;

… for the plots

- (void)setupShadowForPlot: (CPTPlot*) plot
{
    plot.shadowColor = CGColorCreateGenericGray(0, 1);
    plot.shadowRadius = 3.0;
    plot.shadowOffset = CGSizeMake(2, -2);
    plot.shadowOpacity = 0.75;
     /*
    CPTMutableShadow *shadow = [CPTMutableShadow shadow];
    shadow.shadowColor = [CPTColor colorWithComponentRed: 0 green: 0 blue: 0 alpha: 0.75];
    shadow.shadowBlurRadius = 3.0;
    shadow.shadowOffset = CGSizeMake(2, -2);
    plot.shadow = shadow;
     */
}

Original issue reported on code.google.com by mike.lischke on 18 Dec 2012 at 9:25

GoogleCodeExporter commented 8 years ago

Original comment by eskr...@mac.com on 19 Dec 2012 at 1:42

GoogleCodeExporter commented 8 years ago

Original comment by eskr...@mac.com on 22 Dec 2012 at 12:13

GoogleCodeExporter commented 8 years ago
#1: The CALayer shadow properties have never been fully supported in Core Plot. 
CPTShadow exists to solve several rendering issues that came up while trying to 
use the built-in shadows. Won't fix.

#2: This is a side-effect of the changes made to the border masking. Working on 
a fix.

#3. The CPTPlot.shadow property affects only the plot line. Plot symbols have 
their own shadows. This allows flexibility when you have multiple symbols so 
you can, for example, match the shadow color to the symbol color. I did a quick 
test and scatter plot shadows seem to work as intended. Please post more 
details if you see additional problems with these.

#4. Fixed.

Original comment by eskr...@mac.com on 22 Dec 2012 at 1:13

GoogleCodeExporter commented 8 years ago
Thanks Eric. For #3: this is essentially about the plot line. However I fill 
the area between the plot line and the base line. I don't use any plot symbols. 
I think this should work with CPTPlot.shadow instead. You can see this here: 
http://www.pasteall.org/pic/show.php?id=41951. Both scatter plots have a shadow 
for the content, but I can get this only to work by using CALayer.shadow*.

Original comment by mike.lischke on 22 Dec 2012 at 11:22

GoogleCodeExporter commented 8 years ago
Check your link—I don't see a scatter plot in that image. I tested this by 
adding shadows in the Plot Gallery app. The red line in the attached image is 
the shadow.

Original comment by eskr...@mac.com on 22 Dec 2012 at 1:47

Attachments:

GoogleCodeExporter commented 8 years ago
Hu? You don't see the light gray plot in the dark area at the top and the dark 
gray plot which covers the lower right of the image? Both have been created 
with:

- (CPTScatterPlot*)createScatterPlotWithFill: (CPTFill*)fill
{
    CPTScatterPlot* linePlot = [[CPTScatterPlot alloc] init];
    linePlot.alignsPointsToPixels = YES;

    linePlot.dataLineStyle = nil;
    linePlot.interpolation = CPTScatterPlotInterpolationStepped;

    linePlot.areaFill = fill;
    linePlot.areaBaseValue = CPTDecimalFromInt(0);

    linePlot.delegate = self;
    linePlot.dataSource = self;

    return linePlot;
}

When I try to set a shadow for this very plot using:

- (void)setupShadowForPlot: (CPTPlot*) plot
{
    plot.shadowColor = CGColorCreateGenericGray(0, 1);
    plot.shadowRadius = 3.0;
    plot.shadowOffset = CGSizeMake(2, -2);
    plot.shadowOpacity = 0.75;
 }

then I get no shadow at all (see image).

Original comment by mike.lischke on 22 Dec 2012 at 1:55

Attachments:

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Additional note: should be clear by now that I do not use a border for the 
plot. This makes me think why shadows are bound to the border instead the 
entire plot...

btw, the shadow setup code I posted is wrong. I used actually:

- (void)setupShadowForPlot: (CPTPlot*) plot
{
    CPTMutableShadow *shadow = [CPTMutableShadow shadow];
    shadow.shadowColor = [CPTColor colorWithComponentRed: 0 green: 0 blue: 0 alpha: 0.75];
    shadow.shadowBlurRadius = 3.0;
    shadow.shadowOffset = CGSizeMake(2, -2);
    plot.shadow = shadow;
}

Original comment by mike.lischke on 22 Dec 2012 at 2:02

GoogleCodeExporter commented 8 years ago
The scatter plot only draws shadows behind the data line, not the area fill. 
Since you're using what appears to be a solid color fill, you can add a data 
line in the same color. It won't stand out from the fill, but it will cast a 
shadow.

Original comment by eskr...@mac.com on 22 Dec 2012 at 6:05

GoogleCodeExporter commented 8 years ago
Well, it's not a solid color but a partially transparent gradient. Adding a 
border line will destroy the design and is essentially just a hack. IMO it 
should be possible to get a shadow without a border (data line). What about the 
bar plot? Does the same limitation exist there?

Anyway, a bug tracker is not a discussion forum...

Original comment by mike.lischke on 23 Dec 2012 at 9:34

GoogleCodeExporter commented 8 years ago
This issue was closed by revision 9ec0ff575197.

Original comment by eskr...@mac.com on 27 Dec 2012 at 12:22