A configurable chart that depicts the value of a measurement using a subtle animation.
CHCircleGaugeView is available through CocoaPods, to install it simply add the following line to your Podfile:
pod "CHCircleGaugeView"
To install manually, just copy everything in the CHCircleGaugeView directory into your Xcode project.
Important: If your project doesn't use ARC you must add the -fobjc-arc compiler flag to all CHCircleGaugeView implementation files in Target Settings > Build Phases > Compile Sources.
Instantiate like any other view and customize it as needed:
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
CGRect frame = CGRectMake(0, 0, 200, 200);
CHCircleGaugeView *circleGaugeView = [[CHCircleGaugeView alloc] initWithFrame:frame];
[self.view addSubView:circleGaugeView];
[circleGauge setValue:0.5 animated:YES];
}There is a state property of type CHCircleGaugeViewState that determines how to display a few things.
CHCircleGaugeViewStateNA: "n/a" is displayed in the center of the circle and the gauge inside the track will not be present. The displayed string can be changed by setting thenotApplicableStringproperty on the gauge.CHCircleGaugeViewStatePercentSign: "%" is displayed in the center of the circle and the gauge inside the track will not be present. The displayed string can be changed by setting thenoDataStringproperty on the gauge.CHCircleGaugeViewStateScore: A whole number (with an optional units suffix) is displayed in the center of the circle and the gauge inside the track will represent the value.
Modifying or setting the value property will automatically cause the state to switch to CHCircleGaugeViewStateScore.
To change the value of the gauge you can call setValue:animated: or set value.
The gauge can easily be configured by adjusting public properties:
trackTintColor: The color shown for the portion of the gauge that is always filled.gaugeTintColor: The color shown on top oftrackTintColorfor the portion of the gauge that varies based on thevalueproperty.textColor: The color of the text.font: The font of the text.trackWidth: The width for the portion of the gauge that is always filled. Defaults to a value of 0.5.gaugeWidth: The width for the portion of the gauge that varies based on thevalueproperty. Defaults to a value of 2.unitsString: String that is a suffix on thevalue. This string is meant to be just a few characters long. Defaults tonil.notApplicableString: The text shown when the state of the gauge isCHCircleGaugeViewStateNA. Defaults to "n/a".noDataString: The text shown when the state of the gauge isCHCircleGaugeViewStatePercentSign. Defaults to "%".gaugeStyle: Determines how the gauge is drawn relative to the track. Defaults toCHCircleGaugeStyleInside.
Pull request are welcomed. To add functionality or to make changes:
- Fork this repo.
- Open
CHCircleGuageViewExample.xcworkspacein theCHCircleGuageViewExampledirectory. - Make changes to the necessary files in the
CHCircleGaugeViewgroup. - Ensure new public methods are documented.
- Submit a pull request.
Created by Osama Ashawa, Matthew Morey, Rogelio Gudino, and other contributors.
CHCircleGaugeView is available under the MIT license. See the LICENSE file for more information. If you're using CHCircleGaugeView in your project, attribution would be nice.


