Square symbolCornerRadius


#1

Hello,

I’m trying to make my symbols square. I have tried the following, but it doesnt make them square. they still have radius. how do I meake them square?
_chart.legend.style.symbolCornerRadius = 0;


#2

Hello Ahmet,

Thanks for letting us know about this issue - we’ll look into it and get a fix out as soon as possible. In the meanwhile, you can workaround this by placing square views over the legend symbols. We know their frames, we know their colours, so this is actually pretty simple:

  1. Import “SChartLegendSymbolBlock.h” to your view controller.

  2. Set your view controller as your chart’s delegate.

  3. Implement the delegate method sChartRenderFinished: like so:

    -(void)sChartRenderFinished:(ShinobiChart *)chart {
    for (SChartLegendSymbolBlock *symbol in chart.legend.symbols) {
    UIView *squareSymbol = [[UIView alloc] initWithFrame:symbol.frame];
    squareSymbol.backgroundColor = symbol.areaColor;

         [symbol.superview addSubview:squareSymbol];
     }
    

    }

Thanks,
Jan


#3

Is this not fixed yet? I’ve been having the same problem. If I set a high value of corner radius, I can see the symbol getting rounder, but if I set it to @0, it stays with the default corner radius.


#4

Hi Tati,

Thanks for getting in touch!

I have just tested setting the SChartLegend’s style.symbolCornerRadius to 0 by printing the symbol’s “layer.cornerRadius” which is what we set it to in the SChartDelegate’s “sChartRenderFinished:” method. I can confirm it it being set to 0 and the symbol corners look correct to me.

Could you provide a screenshot of the legend symbols you are seeing when setting the “symbolCornerRadius” to 0?

Kind regards,
Andrew Polkinghorn.


#5

Hi Andrew,

I don’t know if I’m not setting it right. My code regarding the legend configuration:

chart.legend.hidden = NO;
chart.legend.position = SChartLegendPositionBottomMiddle;
chart.legend.style.borderColor = [UIColor clearColor];
chart.legend.style.symbolAlignment = SChartSeriesLegendAlignSymbolsLeft;
chart.legend.style.symbolCornerRadius = @0;

I’ve tried with “0” and “@0”, and neither worked. 

This is the result that I get:

http://imgur.com/ahbJlZj


#6

Hi Tati,

The image you provided doesn’t seem to have worked.

Could you edit the message and try again or host the image somewhere for me to view?

The code you have provided looks correct to me.

Kind regards,
Andrew Polkinghorn.


#7

Hi Andrew, sorry about that, I can’t seem to be able to embed an image to the post. I’ve edited it with the link for the image.


#8

Hi Tati,

Thanks very much for posting the image and apologies for the time it’s taken to get back to you.

Unfortunately, there’s a small bug in our legend symbol drawing code which prevents a corner radius of less than 4 being applied.

A fix should be available in our next release, but for the time being you can use the following workaround:

@interface SChartLegendSymbolBlock (RadiusFix)

@end

@implementation SChartLegendSymbolBlock (RadiusFix)

-(void)drawRect:(CGRect)rect {
    
    [super drawRect:rect];
    
    UIBezierPath *rectanglePath = [UIBezierPath bezierPathWithRect:rect];
    if (self.areaColor) {
        [self.areaColor setFill];
        [rectanglePath fill];
    }
    if(self.outlineColor) {
        [rectanglePath setLineWidth: 2];
        [self.outlineColor setStroke];
        [rectanglePath stroke];
    }
}

@end

I hope that helps!

Sam


#9

Hi Sam,

thanks for the response, it worked now :slight_smile: