Axis label problem


#1

I’m noticing a small visual glitch in axis labels - see the ovelapping labels in the attached image.

It happens sometimes after the chart has been reloaded several times. Has anyone else noticed this? 

(I’m using Shinobi Charts version 2.2)


#2

Hi Rob,

Thank you for raising this issue, it looks like you’ve found a bug within chart axes.  We’ve come up with a fix for it, so that should be included in the next ShinobiCharts release.  In the meantime, I’ve created a workaround for you in order that you’re not held up on your project work.

It looks like the bug is that the axes aren’t aggressive enough in clearing out the old tick mark labels when you reload the data on the chart.  We’ve created a subclass of SChartAxis which you can use in the short term, which addresses this issue.  I’ve named the class SChartAxisFixLabels, although obviously feel free to rename it if you need.  :-)

The new class overrides a method which is called on your chart axes when you reload data in the chart.  Each of the chart series are linked to one of the x and y axes in the chart. When you reload your data, you are refreshing all the series, so you un-link all the series from your chart axes.  This subclass adds extra functionality at this point, and hides all of the tick mark labels as well.  The chart then refreshes the chart axis as it renders.  

As you appear to be using a numeric axis for your y axis, I’ve written the class to subclass SChartNumberAxis.  I’ve put the source code below, so you should be able to just create a new class in your project, then paste the code in.

I hope this helps, let me know how things go!

Dan

SChartAxisFixLabels.h

#import <ShinobiCharts/ShinobiChart.h>

@interface SChartAxisFixLabels : SChartNumberAxis

@end

SChartAxisFixLabels.m

#import "SChartAxisFixLabels.h"

@interface SChartAxis ()

- (void)unlinkAllSeries;

@end

@implementation SChartAxisFixLabels

- (void)unlinkAllSeries {
    [super unlinkAllSeries];
    for (SChartTickMark *tickMark in tickMarks) {
        [tickMark disableTick:self];
    }
}

@end

#3

Wow that’s great, thank you!

Rob.


#4

Hi Dan,

I’m running into the same bug using the same version 2.2 Premium. I tried to imlpement the workaround but Xcode is complaining that unlinkAllSeries isn’t defined in the superclass SChartNumberAxis.

I looked at the .h files for both SChartNumberAxis and SChartAxis and I couldn’t find it. I’m confused, what am I missing here?

Thanks.


#5

Hi Carlos,

unlinkAllSeries is a private method on SChartAxis.  Can I just quickly confirm that you’ve declared the class extension at the top of the code snippet in my previous post?  That declares that the method exists on SChartAxis, even though it isn’t declared in the public header.  If you add the class extension to the top of your file like so:

@interface SChartAxis ()
 
- (void)unlinkAllSeries;
 
@end

this should fix the compiler warning you’re seeing.

Hope that helps, let me know if thats not the issue!

Cheers,

Dan


#6

Oh that’s my problem… I put my class name in that part at the top instead of SChartAxis … duh, my bad.  :blush:

Thanks!