• Stars
    star
    1,193
  • Rank 39,220 (Top 0.8 %)
  • Language
    Objective-C
  • License
    MIT License
  • Created about 11 years ago
  • Updated almost 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Simple and intuitive iOS chart library. Contribution graph, clock chart, and bar chart.

TEAChart

Travis CI Version License Platform

Simple and intuitive iOS chart library, for Pomotodo app. Contribution graph, clock chart, and bar chart.

Supports Storyboard and is fully accessible to VoiceOver users.

Usage

The most convinient way is to use Storyboard, where you can set the attributes right in the Interface Builder.

Interface Builder

See the header files for complete documents.

Contribution Graph

Contribution Graph

The contribution graph mimics the GitHub one. You can implement the TEAContributionGraphDataSource protocol to provide data and customize the style of the graph. The required methods are:

// The DataSource should return an NSDate that occurs inside the month to graph
- (NSDate *)monthForGraph;

// The day variable is an integer from 1 to the last day of the month given by monthForGraph
// Return the value to graph for each calendar day or 0.
- (NSInteger)valueForDay:(NSUInteger)day;

There are currently three more DataSource methods to customize the coloring of the graph. Each grade is represented by a different color.

// Defines the number of distinct colors in the graph
- (NSUInteger)numberOfGrades;

// Defines what color should be used by each grade.
- (UIColor *)colorForGrade:(NSUInteger)grade;

// Defines the cutoff values used for translating values into grades.
// For example, you may want different grades for the values grade == 0, 1 <= grade < 5, 5 <= grade.
// This means there are three grades total
// The minimumValue for the first grade is 0, the minimum for the second grade is 1, and the minimum for the third grade is 5
- (NSInteger)minimumValueForGrade:(NSUInteger)grade;

There’s also a method to define the tap behavior on contribution graph cells:

- (void)dateTapped:(NSDictionary *)dict;

Here is a simple sample of implementing the delegate methods after connecting delegate in Interface Builder.

#pragma mark - TEAContributionGraphDataSource Methods

- (void)dateTapped:(NSDictionary *)dict
{
    NSLog(@"date: %@ -- value: %@", dict[@"date"], dict[@"value"]);
}

- (NSDate *)monthForGraph
{
	// Graph the current month
    return [NSDate date];
}

- (NSInteger)valueForDay:(NSUInteger)day
{
	// Return 0-5
    return day % 6;
}

Clock Chart

Clock Chart

// This sample uses Storyboard
@property (weak, nonatomic) IBOutlet TEAClockChart *clockChart;

self.clockChart.data = @[
    [TEATimeRange timeRangeWithStart:[NSDate date] end:[NSDate dateWithTimeIntervalSinceNow:3600]],
    // ...
];

Bar Chart

Bar Chart

Just a bar chart, no interaction, no animation.

#import "TEAChart.h"

TEABarChart *barChart = [[TEABarChart alloc] initWithFrame:CGRectMake(20, 20, 100, 40)];
barChart.data = @[@2, @7, @1, @8, @2, @8];
[self.view addSubview:barChart];

Colored Bar Chart

To add colors to the bar chart, add an array of colors

#import "TEAChart.h"

TEABarChart *barChart = [[TEABarChart alloc] initWithFrame:CGRectMake(20, 20, 100, 40)];
barChart.barColors = @[[UIColor orangeColor], [UIColor yellowColor], [UIColor greenColor], [UIColor blueColor]];
barChart.data = @[@2, @7, @1, @8, @2, @8];
[self.view addSubview:barChart];

To add x-labels to the bar chart, set xLabels property. Should be just one character per label since the bars are narrow.

barChart.xLabels = @[@"A", @"B", @"C", @"D", @"E", @"F"];

Installation

Use CocoaPods:

pod 'TEAChart', '~> 1.0'

Or drag TEAChart folder into your project.

Contribution

Pull requests are welcome! If you want to do something big, please open an issue first.

License

MIT

More Repositories

1

miracle-board

Just another simple and elegant status board / dashboard.
Less
214
star
2

awesome-github-extensions

A curated list of awesome browser extensions for GitHub. Inspired by awesome-python, which is inspired by awesome-php.
Python
138
star
3

GitProTips

Git Pro Tips
56
star
4

RDT-over-UDP

RDT over UDP.
Python
23
star
5

Cryptomeria-iOS

Learn Japanese kana on iOS.
JavaScript
23
star
6

SMPPL

Send Me a Postcard Public License
22
star
7

iOS-prototype-icons

Try these pretty prototype icons during development.
HTML
21
star
8

zju-jwb-to-icalendar

将浙江大学教务网课程导出为 iCalendar 文件(可用于 iCal、Google Calendar 等)。
Python
17
star
9

minna-no-nihongo

大家的日语初级1第二版
Python
11
star
10

tetris-opengl

Tetris game in OpenGL.
C
10
star
11

PONG

PONG game on Nexys3, in Verilog.
Verilog
9
star
12

babel-swift

Babel Swift is an Objective-C to Swift converter based on libclang.
Python
9
star
13

google-pinyin-api

基于 Lua 的谷歌拼音扩展 // Automatically exported from code.google.com/p/google-pinyin-api
Lua
6
star
14

xhacker.github.io

Xhacker’s 3rd Base
CSS
6
star
15

musicman

Music game inspired by Frets on Fire.
C++
5
star
16

me

Personal website.
CSS
4
star
17

cryptomeria

Learn Japanese kana.
JavaScript
4
star
18

chinese-uyghur

Anatilim Uyghur ↔︎ Chinese Dictionary for macOS
Makefile
3
star
19

Bunting.tmLanguage

Syntax highlighting for Bunting language
3
star
20

awesome-README

A curated list of awesome READMEs on GitHub
3
star
21

DBMASPL

Don’t Beat Me on the App Store Public License
3
star
22

capio

Capella (the humble LOGO interpreter) with command line interface.
C++
3
star
23

neural-alt

Auto-generate alt attribute for img tags using neural network.
Python
3
star
24

how-long-can-i-write-commit-message-without-wrapping

How long can I write commit message without wrapping?
2
star
25

robotic-arm

C
2
star
26

tweet-dht22

Tweet sensor data from DHT22
Arduino
2
star
27

tank-ai

Tank AI
JavaScript
2
star
28

Stargazer-iOS

All your star are belong to us.
Swift
2
star
29

gitloc

Count line of code for a certain time period and a certain author in a git repository.
Python
2
star
30

Resumize

Resume generator.
Python
1
star
31

arduino-itunes

Arduino iTunes Remote Controller
Objective-C
1
star
32

icgrep-devel

C++
1
star
33

radar

Sample code for my radar.
Swift
1
star
34

PHP

:php:
1
star
35

xn--zh8h2n.ws

🌶️🐔.ws
HTML
1
star
36

googlepinyin-plugins

Imported from Google Code
Lua
1
star