Giter Site home page Giter Site logo

ttwkpiechart's Introduction

TTWKPieChart

A component that simplifies the creation of animated Apple Watch style pie charts similar to the ones used within the Activity app.

Screenshot

Quick Start

To use with your WatchKit extension:

  • add a WKInterfaceImage into your storyboard exactly where you want the chart to appear (you can use a WKInterfaceGroup as well);

  • make sure its Mode is set to 'Center' and Width and Height to 'Size To Fit Content';

  • connect the image or a group with a corresponding property in your subclass of WKInterfaceController;

  • import TTWKPieChart.h;

  • create and configure a pie chart within your awakeWithContext: method, for example:

     // Create and configure the chart generator
     TTWKPieChart *pieChart = [[TTWKPieChart alloc] init];
     pieChart.radius = floorf([WKInterfaceDevice currentDevice].screenBounds.size.width * 0.45);
     pieChart.bandWidth = 14;
     // ...
    
     TTWKPieChartBand *band1 = [[TTWKPieChartBand alloc] init];
     band1.icon = [UIImage imageNamed:@"test-icon-1"];
     band1.caption = @"LOREM";
     band1.startColor = [UIColor colorWithRed:1.0000 green:0.0941 blue:0.0392 alpha:1.0];
     band1.endColor = [UIColor colorWithRed:1.0000 green:0.0275 blue:0.6392 alpha:1.0];
     band1.backgroundColor = [UIColor colorWithRed:0.1608 green:0.0314 blue:0.0667 alpha:1.0];
     band1.value = 0.86;
     // ...
    
     // Configure the text to display
     pieChart.largeText = [[NSAttributedString alloc]  initWithString:@"125"
     //...
     
     // Generate the animated image at 15 FPS, send it off to the device and begin animation
     _image = [pieChart animatedImageWithFrameRate:15];
     [self.chartImage setImage:_image];
     [self.chartImage startAnimatingWithImagesInRange:NSMakeRange(0, _image.images.count) duration:_image.duration repeatCount:1];
    

Please see the example project for a complete example.

Installation

TTWKPieChart is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "TTWKPieChart"

Alternatively, you can simply drop in the classes from Pod/Classes into your project.

Author & License

TTWKPieChart is created by TouchTribe B.V. and is available under the MIT license. See the LICENSE file for more info.

ttwkpiechart's People

Contributors

aleh avatar undo1 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.