Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
Any way to force tick intervals at specific values?

I have a gauge that goes from -70 to 150 with the interval set to 50. I would like the ticks and labels to mark the [-50,0,50,100,150] values but they currently mark the [-70,-20,30,80,130] values.

Is there a way to specify the interval starting point?

  • 26458
    Verified Answer
    Offline posted

    Unfortunately, the gauge doesn't have such feature. I can think of one potential workaround, but it's not very graceful.
    You would use the following IGGaugeViewDelegate method to override the label:

    -(NSString *)gaugeView:(IGGaugeView *)gaugeView formatStringForValue:(double)labelValue
        NSArray *validValues = @[@-50, @0, @50, @100, @150];
        for (int i=0; i<validValues.count; i++)
            double val = [validValues[i] doubleValue];
            if (val == labelValue)
                return [NSString stringWithFormat:@"%.2f", labelValue];
        return @"";

    This would require you to set your gauge interval to a lowest common denominator between the original and new set of labels. In your case, if you start at -70 the interval would have to be set to 10, and while it does give you the correct labels in the end, you end up with quite a bit more tick marks.

Reply Children
No Data