styleForPoint: does not work on stacked column charts


#1

Hello everybody,

I am having a problem with my stacked column charts when I try to style individual points.

I’m using the following code (adapted from the example in github):

-(SChartColumnSeriesStyle *)styleForPoint:(id<SChartData>)point {    
    SChartColumnSeriesStyle * style = [super styleForPoint:point];
 
    float yValue = [[point sChartYValue] floatValue];
    
     style.showAreaWithGradient = NO;
    if (yValue > 10) {
        style.areaColor = [UIColor redColor];
    } else if(yValue > 3) {
        style.areaColor = [UIColor yellowColor];
    } else {
        style.areaColor = [UIColor greenColor];
    }
    return style;
 
}

I noticed that the code set the correct color for all my points, but the chart renders with the last setted color. For example: If I have 3 point (1,4) , (2,2), (3,12), all my stacked columns get red and not yellow, green and red.

Can anyone help me? I’m using ShinobiCharts Premium v2.7.3


#2

Hi there,

I’m afraid I don’t completely understand what you mean, but I can’t seem to replicate your issue. Is this what you were after?

If you’re still having trouble, would you mind sending some screenshots of your issue and, if possible, a sample project to info@shinobicontrols.com

Many thanks,

Sam


#3

Hi,

sorry for my poor explanation. Some times I have problem explanings things in english. 

So here is a screenshot:

Each bar is a series (The bar ‘Centro’ has 2 series). I tryed to change the fill color of each bar segment using the method styleForPoint: but I get the whole series with the same color. The style that is applyed to the bar is always the last style returned by the method styleForPoint:. How can I change this behaviour and apply different styles for each bar segment?

I hope I have been more clear in my explanation this time :) 

Many thanks


#4

Hi Hugo,

The way you are implementing your series isn’t supported using our framework.

If a series has more than one datapoint given with the same X value, the datapoint with the largest Y value is taken and the rest ignored.

To create the chart you want you must create a horizontal series so you don’t have more than one datapoint per series with the same X value.

Let me know if you have any questions.

Kind regards,
Andrew Polkinghorn