TKGauge
's component TKGaugeScale provides two types of visual representation:
TKGaugeRadialScale *scale = [[TKGaugeRadialScale alloc] initWithMinimum:@0 maximum:@6];
[self.radialGauge addScale:scale];
let scale = TKGaugeRadialScale(minimum: 0, maximum: 6)
radialGauge.addScale(scale)
TKGaugeRadialScale scale = new TKGaugeRadialScale (new NSNumber (0), new NSNumber (6));
this.radialGauge.AddScale (scale);
TKGaugeLinearScale* scale1 = [[TKGaugeLinearScale alloc] initWithMinimum:@34 maximum:@40];
scale1.ticks.position = TKGaugeTicksPositionInner;
[self.linearGauge addScale:scale1];
let scale1 = TKGaugeLinearScale(minimum: 34, maximum: 40)
scale1.ticks.position = TKGaugeTicksPosition.inner
self.linearGauge.addScale(scale1)
TKGaugeLinearScale scale1 = new TKGaugeLinearScale ();
scale1.Range = new TKRange (new NSNumber(34), new NSNumber(40));
scale1.Ticks.Position = TKGaugeTicksPosition.Inner;
this.linearGauge.AddScale(scale1);
The scales appereance can be easily customized by adding different segments to it.
TKGaugeSegment* blueSegment = [TKGaugeSegment new];
blueSegment.range = [[TKRange alloc] initWithMinimum:@(34) andMaximum:@(36)];
blueSegment.location = .62;
blueSegment.width = 0.08;
blueSegment.width2 = 0.08;
[scale1 addSegment: blueSegment];
let blueSegment = TKGaugeSegment(minimum: 34, maximum: 36)
blueSegment.width = 0.08
blueSegment.width2 = 0.08
blueSegment.location = 0.62
scale1.addSegment(blueSegment)
TKGaugeSegment blueSegment = new TKGaugeSegment ();
blueSegment.Range = new TKRange (new NSNumber(34), new NSNumber(36));
blueSegment.Location = 0.70f;
blueSegment.Width = 0.08f;
scale1.AddSegment(blueSegment);
TKGauge
also allows applying multiple scales on a single gauge.
TKGaugeScale
has various properties for customizing its ticks and labels.
So, let's add a second scale and customize both:
TKGaugeLinearScale* scale2 = [[TKGaugeLinearScale alloc] initWithMinimum:@93.2 maximum:@104];
scale2.ticks.position = TKGaugeTicksPositionOuter;
scale2.ticks.majorTicksCount = 6;
scale2.ticks.minorTicksCount = 20;
scale2.labels.position = TKGaugeLabelsPositionOuter;
scale2.labels.labelFormat = @"%.01f";
scale2.labels.count = 6;
[self.linearGauge addScale:scale2];
for (int i = 0; i<self.linearGauge.scales.count; i++) {
TKGaugeLinearScale *scale = self.linearGauge.scales[i];
scale.stroke = [TKStroke strokeWithColor:[UIColor grayColor] width:2];
scale.ticks.majorTicksStroke = [TKStroke strokeWithColor:[UIColor grayColor] width:1];
scale.labels.color = [UIColor grayColor];
scale.ticks.offset = 0;
scale.offset = i*.12 + .60;
}
let scale2 = TKGaugeLinearScale(minimum: 93.2, maximum: 104)
self.linearGauge.addScale(scale2)
scale2.ticks.position = TKGaugeTicksPosition.outer
scale2.ticks.majorTicksCount = 6
scale2.ticks.minorTicksCount = 20
scale2.labels.position = TKGaugeLabelsPosition.outer
scale2.labels.labelFormat = "%.01f"
scale2.labels.count = 6
for i in 0..<self.linearGauge.scales.count {
let s = self.linearGauge.scales[i] as! TKGaugeLinearScale
s.stroke = TKStroke(color:UIColor.gray, width:2)
s.ticks.majorTicksStroke = TKStroke(color:UIColor.gray, width:1)
s.labels.color = UIColor.gray
s.ticks.offset = 0
s.offset = CGFloat(i)*0.12 + 0.60
}
TKGaugeLinearScale scale2 = new TKGaugeLinearScale ();
scale2.Range = new TKRange (new NSNumber(93.2), new NSNumber(104));
scale2.Ticks.Position = TKGaugeTicksPosition.Outer;
scale2.Ticks.MajorTicksCount = 6;
scale2.Ticks.MinorTicksCount = 20;
scale2.Labels.Position = TKGaugeLabelsPosition.Outer;
scale2.Labels.LabelFormat = "%.01f";
scale2.Labels.Count = 6;
this.linearGauge.AddScale(scale2);
for(int i = 0; i< this.linearGauge.Scales.Length; i++) {
TKGaugeLinearScale scale = this.linearGauge.Scales[i] as TKGaugeLinearScale;
scale.Stroke = new TKStroke(UIColor.Gray, 2);
scale.Ticks.MajorTicksStroke = new TKStroke(UIColor.Gray, 1);
scale.Labels.Color = UIColor.Gray;
scale.Ticks.Offset = 0;
scale.Offset = i*0.12f + 0.60f;
}