No axes lines to tooltip on Chart


#1

I cant seem to get the lines to my tooltip to show, I set a custom tooltip like so, and the cross hair is enabled on the series. The custom tool tip shows, but I get no lines to the X/Y axes. Do I need to set something that I am missing?

CustomGraphToolTip* tt = [CustomGraphToolTip new];

SChartCrosshairStyle * newStyle = [SChartCrosshairStyle new];
newStyle.lineColor =[UIColor yellowColor];
newStyle.lineWidth = [NSNumber numberWithInteger:10];
newStyle.defaultFont =[UIFont boldSystemFontOfSize:14];
newStyle.defaultTextColor =[UIColor whiteColor];
newStyle.defaultLabelBackgroundColor =[UIColor clearColor];
newStyle.defaultBackgroundColor = [[UIColor blueColor] colorWithAlphaComponent:0.5];
newStyle.defaultBorderWidth = [NSNumber numberWithInteger:1];
newStyle.defaultCornerRadius = [NSNumber numberWithInteger:5];
newStyle.defaultBorderColor =[UIColor whiteColor];

SChartCrosshair *myCrosshair = [[SChartCrosshair alloc] initWithChart:m_chart];
myCrosshair.style = newStyle;
myCrosshair.tooltip = tt;
m_chart.crosshair = myCrosshair;

#2

Hi AEB,

I’ve just tried out your code and I’m seeing the crosshair lines as expected. I created a very simple tooltip subclass which just prepends a string to the label, then used your code to set up the crosshair styling, along with setting series.crosshairEnabled = true when creating the series. Here’s what I’m seeing:

If you use the standard tooltip rather than a custom one, do you see the crosshair lines as expected? Which version of shinobicharts are you using?

Alison


#3

Hey Alison,
Im using a custom tool tip, its like this, the customized behaviour of the tooltip works perfectly, but cant seem to get the lines showing:

@implementation CustomGraphToolTip

  • (void)setDataPoint:(id)dataPoint fromSeries:(SChartSeries *)series fromChart:(ShinobiChart *)chart {
    }

  • (NSString *)timeFormatted:(float)totalSeconds
    {

    int seconds = (int)totalSeconds % 60;
    int minutes = ((int)totalSeconds / 60) % 60;
    int hours = (int)totalSeconds / 3600;
    float fmseconds = totalSeconds - (int)totalSeconds;
    int mseconds = fmseconds*10.;

    if(hours > 0)
    return [NSString stringWithFormat:@"%dh %dm %d.%ds",hours, minutes, seconds,mseconds];

    return [NSString stringWithFormat:@"%dm %d.%ds",minutes, seconds,mseconds];

}

  • (void) setResolvedDataPoint:(SChartPoint)datapoint fromSeries:(SChartSeries *)series fromChart:(ShinobiChart *)chart
    {

    self.label.text = [NSString stringWithFormat:formatString,value, units, time];

}

@end


#4

Hi AEB,

I’m afraid I still can’t reproduce your issue - the lines do appear for me.

Could you try temporarily changing the tooltip to an instance of SChartCrosshairTooltip instead of your custom one? If the crosshair lines appear then that suggests there’s something awry in your custom implementation.

If you’re still struggling with this issue then perhaps you could send a cut-down version of your project illustrating the problem to us at info@shinobicontrols.com so we can help you further.

Kind regards,

Alison


#5

Thanks, maybe its a side effect of something else I am doing then. Are there things that would potentially override the showing of the lines other than the SChartCrosshairStyle and setting the line width/color? I cant see anywhere else that I am overriding similar things.


#6

Hi AEB,

Please can you confirm which version of shinobicharts you are using?

My colleague has reminded me that there was an issue in versions <2.9.4 where the crosshair’s line drawer was not being created by default. It was fixed in version 2.9.4. You could either try upgrading to the most recent version of shinobicharts, or add in the following line when creating your crosshair:

    myCrosshair.lineDrawer = [SChartTargetLineDrawer new];

Please let me know if that helps.

Kind regards,

Alison