Zoomable Annotation - SChartAnnotationZooming



I am trying to achieve an background image which marks some chart area (live image for a chart on which a path is drawn).

I have managed to display the image on the chart but it does not stretch when im zooming (I maintain the aspect ratio).

Code from your example:

    //Add a nice Pi logo to the background

    SChartAnnotationZooming *icon = [[SChartAnnotationZoomingalloc] initWithFrame:CGRectMake(0, 0, 1, 1)];

    icon.xValue = [NSNumbernumberWithInt:0];

    icon.yValue = [NSNumbernumberWithInt:0];

    icon.stretchToBoundsOnX = NO;

    icon.stretchToBoundsOnY = NO;

    icon.position = SChartAnnotationBelowData;


    UIImageView *iconView = [[UIImageViewalloc] initWithImage:[UIImageimageNamed:@“pi.png”]];

    [icon addSubview:iconView];

    icon.alpha = 0.1f;

    [chart addAnnotation:icon];

I assigned the yValueMax and xValueMax values.

I tried changing the stretch to bounds (yup its the image size only). What should be done? What to change to make it happen? Should I override the:

(void)updateViewWithCanvas:(SChartCanvas *)canvas;

 method? The image is supose to be clipped to the given range and just be stretched with the chart itself.

Thank you in advance.



You need to set the maxXValue and maxYValues for your chart. It shoud look something like this:

icon.xValueMax = @50;
icon.yValueMax = @170;

You might need to tweak the values a little to get it to display correctly as I don’t know the range of your chart, but this should make it zoom.




I’ve managed to get to this before your repy -> but thanks! It seemed really weird… that a class like that did not work out of the box… it was a x-y mismatch thus it was out of bounds and not visible and earlir i had the stretchToBounds to YES. Oce again thanks for the help.