Good afternoon.
It pains me to ask... but perhaps you can surprise me.
Can the gauge support non-linear ticks and ranges?
For example, can I have a range that does this:
|0-10-20-30--40--50---60---70-----80-----90------100|
If not, how difficult would that be? I'm trying to think of a way to programmatically define such a thing.
This might be achieved using some kind of delegate and "mapping" from a visible or non-visible existing range. For example...
INPUT: |0-------200-------400-------600-------800-------1000|
OUTPUT: |0-10-20-30--40--50---60---70-----80-----90------100|
Hello Caylan,
The GaugeView does not support non-linear tickmarks or ranges. You can submit a feature request on our website at <ideas.infragistics.com>
Alternatively, you can change the label strings to make it appear like it's non-linear:
For example, this will display labels on a log2 scale,
int previousLabelValue = -1; -(NSString *)gaugeView:(IGGaugeView *)gaugeView formatStringForValue:(double)labelValue { int newLabelValue = (int)log2(labelValue); if (newLabelValue != previousLabelValue) { previousLabelValue = newLabelValue; return [[NSNumber numberWithInt:newLabelValue]stringValue]; } return @""; } _gauge.delegate = self; _gauge.value = 40; _gauge.minimumValue = 1; _gauge.maximumValue = 128; _gauge.interval = 1;
int previousLabelValue = -1; -(NSString *)gaugeView:(IGGaugeView *)gaugeView formatStringForValue:(double)labelValue { int newLabelValue = (int)log2(labelValue);
if (newLabelValue != previousLabelValue) { previousLabelValue = newLabelValue; return [[NSNumber numberWithInt:newLabelValue]stringValue]; } return @""; }
_gauge.delegate = self; _gauge.value = 40; _gauge.minimumValue = 1; _gauge.maximumValue = 128; _gauge.interval = 1;
Smart. Thanks.
This has worked out great so far, but I have a esoteric bug...
If I use gaugeView:formatStringForValue in conjunction with pointForValue while the gauge is loading, the first few points are reflected in the animation's expansion into the view. This is fixed with the following, but it would be nice if the pointForValue relied on the final destination of the animation.
-(void)viewDidAppear:(BOOL)animated
{
[self performSelector:@selector(setupTransitionDuration:) withObject:nil afterDelay:0.25];
}
-(void)setupTransitionDuration:(id)sender
_gaugeView.transitionDuration = 0.25;