Home » iOS » Charts control with animations for iOS

Charts control with animations for iOS

Almost half year ago I’ve made this control. For one idea, but then I found that my idea does not good enough to be implemented.

It has just 2 classes VBPieChart, superclass UIView, and VBPiePiece, superclass CAShapeLayer. And really used just VBPieChart. All chart based on CALayer’s and depends to QuartzCore.

Example:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
VBPieChart *_chart = [[VBPieChart alloc] init];
[self.view addSubview:_chart];
   
[_chart setFrame:CGRectMake(10, 50, 300, 300)];
[_chart setEnableStrokeColor:YES];
_chart.length = M_PI;
_chart.startAngle = M_PI;

[_chart.layer setShadowOffset:CGSizeMake(2, 2)];
[_chart.layer setShadowRadius:3];
[_chart.layer setShadowColor:[UIColor blackColor].CGColor];
[_chart.layer setShadowOpacity:0.7];

[_chart setHoleRadiusPrecent:0.3];
NSDictionary *chartValues = @{

                       @"data one":  @{@"value":@35 },
                       @"data two":  @{@"value":@20 },
                       @"data tree":  @{@"value":@10 },
                       @"first ":  @{@"value":@40},
                       @"second": @20,
                       @"third": @40,
                       @"fourth": @10,
                       };

[_chart setChartValues:chartValues animation:YES];

chartValues contains items of chart.
1. name of piece
2. dictionary with NSNumber or parameters:
– value actually size of piece
– color, UIColor
– accent, bool value to show this item with shift

VBPieChart has 5 different types of animations.

Cocoacontrols logo

cocoapods logo

This entry was posted in iOS and tagged Animation, CAAnimation, CABasicAnimation, CALayer, CAShapeLayer, Chart, Charts, Control, dev, , , . Bookmark the permalink.