How do I center the Y axis label in the new version?


#1

For some odd reason, in a bar column chart, the Y axis label didn’t center properly.  To compensate for that, I used the following code in the old version:

-(void)sChartRenderFinished:(ShinobiChart *)chart
{           
    CGRect frame = chart.yAxis.titleLabel.frame;
        
    frame.origin.y = 16 + chart.legend.frame.size.height;
        
    frame.size.height = chart.frame.size.height - (chart.frame.size.height - chart.xAxis.axisFrame.size.height) - frame.origin.y;
        
    chart.yAxis.titleLabel.frame = frame;        
}

If I try to adjust the frame before it is rendered, my changes are lost.  Unfortunately, in the latest version of ShinobiCharts, the above code causes sChartRenderFinished to be called again, which ends up in an endless loop.  A check of the values also shows that they aren’t retained.

How can I get the title centered?  It currently ends up too high vertically (and yes, I set yAxis.style.titleStyle.position = SChartTitlePositionCenter;)?

Thanks,

Gary


#2

Hi Gary,

Have you tried using your adjustment code in  sChartRenderStarted:withFullRedraw:? If you only adjust the frame the first time the chart renders, it shouldn’t loop indefinitely. You could do this either by checking the withFullRedraw parameter or with a static/local variable on your view containing the chart.

Setting the frame causes layoutSubviews to ripple back down through the views each time, which may cause your chart to redraw - can I just confirm with you which version of charts you were using before (which worked with the above) and which you’re using now that loops?

Cheers,

Simon