Skip to content

Commit

Permalink
Merge pull request #2 from grgcombs/master.
Browse files Browse the repository at this point in the history
Several additions and modifications for fonts, colors, negative values, etc.
  • Loading branch information
honcheng committed May 4, 2011
2 parents d6c3f1d + 2d5fd6b commit 7f2df83
Show file tree
Hide file tree
Showing 16 changed files with 189 additions and 249 deletions.
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "iOSPlot/SBJSON"]
path = iOSPlot/SBJSON
url = git@github.com:honcheng/SBJSON-library.git
[submodule "iOSPlot/JSONKit"]
path = iOSPlot/JSONKit
url = git://github.com/johnezang/JSONKit.git
9 changes: 8 additions & 1 deletion README
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
iOSPlot

- Draw pie charts and line charts in iOS apps
- Draw pie charts and line charts in iOS apps

*todo list for line chart*
Use gesture/tap to show the value label (or mild statistics) for a data point.
Further break out colors for customization of background, x/y labels, and shadows.
Allow legend labels to appear on either the right or left side of the chart (or not at all).
Use the rendered string width of the legend labels to determine right/left side margin.
If a legend string is significantly long (200% percentage of default margin width?), truncate or abbreviate it to X characters.
Binary file removed iOSPlot/HelveticaNeue.ttc
Binary file not shown.
1 change: 1 addition & 0 deletions iOSPlot/JSONKit
Submodule JSONKit added at b8359c
110 changes: 41 additions & 69 deletions iOSPlot/PlotCreator.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion iOSPlot/SBJSON
Submodule SBJSON deleted from 2cfbb4
16 changes: 8 additions & 8 deletions iOSPlot/Sample Data/sample_linechart_data.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
69,
70
],
"title": "AAA"
"title": "Smith"
},
{
"data": [
Expand All @@ -20,27 +20,27 @@
22,
30
],
"title": "BBB"
"title": "Repub"
},
{
"data": [
40,
55,
56,
66,
70,
70
40,
-30
],
"title": "CCC"
"title": "Dem"
},
{
"data": [
null,
89,
90,
85,
90,
95
60,
-15
],
"title": "DDD"
},
Expand All @@ -51,7 +51,7 @@
55,
33,
50,
46
-6
],
"title": "EEE"
}
Expand Down
28 changes: 17 additions & 11 deletions iOSPlot/Shared/PCLineChartView.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,31 +37,37 @@
{
NSString *title;
NSArray *points;
NSArray *colour;
UIColor *colour;
BOOL shouldLabelValues;
}
@property (nonatomic, assign) BOOL shouldLabelValues;
@property (nonatomic, retain) NSArray *points;
@property (nonatomic, retain) NSArray *colour;
@property (nonatomic, retain) UIColor *colour;
@property (nonatomic, retain) NSString *title;
@end

#define PCColorBlue [NSArray arrayWithObjects:[NSNumber numberWithFloat:0.0],[NSNumber numberWithFloat:153/255.0],[NSNumber numberWithFloat:204/255.0],[NSNumber numberWithFloat:1.0],nil]
#define PCColorGreen [NSArray arrayWithObjects:[NSNumber numberWithFloat:153/255.0],[NSNumber numberWithFloat:204/255.0],[NSNumber numberWithFloat:51/255.0],[NSNumber numberWithFloat:1.0],nil]
#define PCColorOrange [NSArray arrayWithObjects:[NSNumber numberWithFloat:1.0],[NSNumber numberWithFloat:153/255.0],[NSNumber numberWithFloat:51/255.0],[NSNumber numberWithFloat:1.0],nil]
#define PCColorRed [NSArray arrayWithObjects:[NSNumber numberWithFloat:1.0],[NSNumber numberWithFloat:51/255.0],[NSNumber numberWithFloat:51/255.0],[NSNumber numberWithFloat:1.0],nil]
#define PCColorYellow [NSArray arrayWithObjects:[NSNumber numberWithFloat:255/255.0],[NSNumber numberWithFloat:220/255.0],[NSNumber numberWithFloat:0.0],[NSNumber numberWithFloat:1.0],nil]
#define PCColorDefault [NSArray arrayWithObjects:[NSNumber numberWithFloat:0.5],[NSNumber numberWithFloat:0.5],[NSNumber numberWithFloat:0.5],[NSNumber numberWithFloat:1.0],nil]

#define PCColorBlue [UIColor colorWithRed:0.0 green:153/255.0 blue:204/255.0 alpha:1.0]
#define PCColorGreen [UIColor colorWithRed:153/255.0 green:204/255.0 blue:51/255.0 alpha:1.0]
#define PCColorOrange [UIColor colorWithRed:1.0 green:153/255.0 blue:51/255.0 alpha:1.0]
#define PCColorRed [UIColor colorWithRed:1.0 green:51/255.0 blue:51/255.0 alpha:1.0]
#define PCColorYellow [UIColor colorWithRed:1.0 green:220/255.0 blue:0.0 alpha:1.0]
#define PCColorDefault [UIColor colorWithRed:0.5 green:0.5 blue:0.5 alpha:1.0]


@interface PCLineChartView : UIView {
NSMutableArray *components;
NSMutableArray *xLabels;
UIFont *yLabelFont, *xLabelFont, *valueLabelFont, *legendFont;
int interval;
float minValue;
float maxValue;
}

@property (nonatomic, assign) int interval;
@property (nonatomic, assign) float minValue;
@property (nonatomic, assign) float maxValue;
@property (nonatomic, retain) NSMutableArray *components, *xLabels;

int sortByNumber(NSNumber *firstComponent, NSNumber *secondComponent, void*context);
int sortLegend(NSMutableDictionary *firstComponent, NSMutableDictionary *secondComponent, void*context);
@property (nonatomic, retain) UIFont *yLabelFont, *xLabelFont, *valueLabelFont, *legendFont;

@end
Loading

0 comments on commit 7f2df83

Please sign in to comment.