{"id":27148782,"url":"https://github.com/sakrist/vbpiechart","last_synced_at":"2025-10-28T08:44:26.148Z","repository":{"id":19066374,"uuid":"22293227","full_name":"sakrist/VBPieChart","owner":"sakrist","description":"🍰📈 Pie Chart iOS control with different animations to present.","archived":false,"fork":false,"pushed_at":"2017-12-03T19:57:39.000Z","size":4706,"stargazers_count":283,"open_issues_count":0,"forks_count":79,"subscribers_count":18,"default_branch":"master","last_synced_at":"2025-04-07T13:48:21.227Z","etag":null,"topics":["animation","calayer","ios","objective-c","pie-chart","swift"],"latest_commit_sha":null,"homepage":"","language":"Objective-C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sakrist.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-07-26T18:20:31.000Z","updated_at":"2024-10-21T08:50:30.000Z","dependencies_parsed_at":"2022-09-22T14:25:58.092Z","dependency_job_id":null,"html_url":"https://github.com/sakrist/VBPieChart","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sakrist%2FVBPieChart","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sakrist%2FVBPieChart/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sakrist%2FVBPieChart/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sakrist%2FVBPieChart/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sakrist","download_url":"https://codeload.github.com/sakrist/VBPieChart/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247839638,"owners_count":21004783,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["animation","calayer","ios","objective-c","pie-chart","swift"],"created_at":"2025-04-08T12:24:18.376Z","updated_at":"2025-10-28T08:44:21.132Z","avatar_url":"https://github.com/sakrist.png","language":"Objective-C","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![](https://travis-ci.org/sakrist/VBPieChart.svg?branch=master)](https://travis-ci.org/sakrist/VBPieChart)\n[![](https://img.shields.io/cocoapods/v/VBPieChart.svg?style=flat)](https://cocoapods.org/pods/VBPieChart)\n[![License](http://img.shields.io/:license-mit-blue.svg)](http://doge.mit-license.org)\n\n# [VBPieChart](https://github.com/sakrist/VBPieChart)\n\nAnimated Pie Chart control for iOS apps, based on CALayer. Very easy in use and have custom labeling.\n\n\u003cimg src=\"https://raw.githubusercontent.com/sakrist/VBPieChart/master/Screenshot.png\" \u003e\n\n## Usage\n\n\n#### Create simple pi chart with VBPieChart:\n\n```objc\nVBPieChart *chart = [[VBPieChart alloc] initWithFrame:CGRectMake(10, 50, 300, 300)];\n[self.view addSubview:chart];\n\n// Setup some options:\n[chart setEnableStrokeColor:YES]; \n[chart setHoleRadiusPrecent:0.3]; /* hole inside of chart */\n\n// Prepare your data\nNSArray *chartValues = @[\n @{@\"name\":@\"Apples\", @\"value\":@50, @\"color\":[UIColor redColor]},\n @{@\"name\":@\"Pears\", @\"value\":@20, @\"color\":[UIColor blueColor]},\n @{@\"name\":@\"Oranges\", @\"value\":@40, @\"color\":[UIColor orangeColor]},\n @{@\"name\":@\"Bananas\", @\"value\":@70, @\"color\":[UIColor purpleColor]}\n];\n\n// Present pie chart with animation\n[chart setChartValues:chartValues animation:YES duration:0.4 options:VBPieChartAnimationFan];\n```\n\n`chartValues` needs to be defined as an array of dictionaries.\u003cbr\u003e\nDictionary **required** to contain value for piece with key `value`.\u003cbr\u003e\nOptional:\n\n- `name`\n- `color`\n- `labelColor`\n- `accent`\n- `strokeColor`\n\n\n\n#### Chart from JSON\n\n```objc\nVBPieChart *chart = [[VBPieChart alloc] initWithFrame:CGRectMake(10, 50, 300, 300)];\nchart.startAngle = M_PI+M_PI_2;\nchart.holeRadiusPrecent = 0.5;\n[self.view addSubview:chart];\nNSString *json_example = @\"[ {\\\"name\\\":\\\"first\\\", \\\"value\\\":\\\"50\\\", \\\"color\\\":\\\"#84C69B\\\", \\\"strokeColor\\\":\\\"#fff\\\"}, \\\n{\\\"name\\\":\\\"second\\\", \\\"value\\\":\\\"60\\\", \\\"color\\\":\\\"#FECEA8\\\", \\\"strokeColor\\\":\\\"#fff\\\"}, \\\n{\\\"name\\\":\\\"second\\\", \\\"value\\\":\\\"75\\\", \\\"color\\\":\\\"#F7EEBB\\\", \\\"strokeColor\\\":\\\"#fff\\\"}, \\\n{\\\"name\\\":\\\"second\\\", \\\"value\\\":\\\"90\\\", \\\"color\\\":\\\"#D7C1E0\\\", \\\"strokeColor\\\":\\\"#fff\\\"} ]\";\n\nNSData *data = [json_example dataUsingEncoding:NSUTF8StringEncoding];\nNSArray *chartValues = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];\n\n[chart setChartValues:chartValues animation:YES duration:0.5 options:VBPieChartAnimationFan];\n```\n\n#### Chart with custom label position\n```objc\nVBPieChart *chart = [[VBPieChart alloc] initWithFrame:CGRectMake(10, 50, 300, 300)];\nchart.startAngle = M_PI+M_PI_2;\nchart.holeRadiusPrecent = 0.5;\n[self.view addSubview:chart];\n[chart setLabelsPosition:VBLabelsPositionCustom];\n[chart setLabelBlock:^CGPoint( CALayer *layer, NSInteger index) {\n    CGPoint p = CGPointMake(sin(-index/10.0*M_PI)*50+50, index*30);\n    return p;\n}];\n\n[chart setChartValues:@[\n                         @{@\"name\":@\"37%\", @\"value\":@65, @\"color\":@\"#5677fcaa\", @\"labelColor\":@\"#000\"},\n                         @{@\"name\":@\"13%\", @\"value\":@23, @\"color\":@\"#2baf2baa\", @\"labelColor\":@\"#000\"},\n                         @{@\"name\":@\"19.3%\", @\"value\":@34, @\"color\":@\"#b0bec5aa\", @\"labelColor\":@\"#000\"},\n                         @{@\"name\":@\"30.7%\", @\"value\":@54, @\"color\":@\"#f57c00aa\", @\"labelColor\":@\"#000\"}\n                         ]\n             animation:YES];\n```\n\n## Basic Documentation\n\n`VBPieChart` is subclass of `UIView`.\n\n#### Properties\n\n`length`\u003cbr /\u003e\nLength of circle pie. Min values is 0 and max value 2*M_PI.\n\n`startAngle`\u003cbr /\u003e\nStart angle of pie. (M_PI will make start at left side)\n\n`holeRadiusPrecent`\u003cbr /\u003e\nhole radius in % of whole radius. Values 0..1. (acual hole radius will be calculated **radius***`holeRadiusPrecent`)\n\n`radiusPrecent` \u003cbr /\u003e\nDefines the **radius**,  **full radius** = frame.size.width/2, actual **radius** = **full radius***`radiusPrecent`. Value 0..1.\n\n`labelBlock`\u003cbr /\u003e\nBlock will help to redefine positions for labels.\n\n#### Methods\n\nGet all changed chart values back.\u003cbr /\u003e\n`- (NSArray *) chartValues;`\u003cbr /\u003e\n\nSimple setup data.\u003cbr /\u003e\n`- (void) setChartValues:(NSArray *)chartValues;`\u003cbr /\u003e\n\nSetup data to pie chart with animation or not, animation options and duration.\u003cbr /\u003e\n`- (void) setChartValues:(NSArray *)chartValues animation:(BOOL)animation duration:(float)duration options:(VBPieChartAnimationOptions)options;`\n\nAnimation options:\n\n* `VBPieChartAnimationFanAll`\n* `VBPieChartAnimationGrowth`\n* `VBPieChartAnimationGrowthAll`\n* `VBPieChartAnimationGrowthBack`\n* `VBPieChartAnimationGrowthBackAll`\n* `VBPieChartAnimationFan`\n* `VBPieChartAnimationTimingEaseInOut`\n* `VBPieChartAnimationTimingEaseIn`\n* `VBPieChartAnimationTimingEaseOut`\n* `VBPieChartAnimationTimingLinear`\n\nChange value for elemet at index. Value will be changed with animation. \u003cbr /\u003e\n`- (void) setValue:(NSNumber*)value pieceAtIndex:(NSInteger)index;` \u003cbr /\u003e\n\nInsert new piece at index. Animated.\n`- (void) insertChartValue:(NSDictionary*)chartValue atIndex:(NSInteger)index;`\n\nRemove piece at index.\u003cbr /\u003e\n`- (void) removePieceAtIndex:(NSInteger)index;`\u003cbr /\u003e\n\nSupported with ad:\n\n\u003cscript async src=\"https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js\"\u003e\u003c/script\u003e\n\u003c!-- Github --\u003e\n\u003cins class=\"adsbygoogle\"\n     style=\"display:block\"\n     data-ad-client=\"ca-pub-1267260663063670\"\n     data-ad-slot=\"2880275683\"\n     data-ad-format=\"auto\"\u003e\u003c/ins\u003e\n\u003cscript\u003e\n(adsbygoogle = window.adsbygoogle || []).push({});\n\u003c/script\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsakrist%2Fvbpiechart","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsakrist%2Fvbpiechart","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsakrist%2Fvbpiechart/lists"}