Skip to content

Commit

Permalink
Supporting bar borders update in demo project
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreasIgelCC committed Mar 14, 2016
1 parent 09e8865 commit 3a05e83
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 8 deletions.
1 change: 1 addition & 0 deletions ChartsDemo/Classes/DemoBaseViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
@protected
NSArray *months;
NSArray *parties;
BOOL shouldRenderBarBorders;
}

@property (nonatomic, strong) IBOutlet UIButton *optionsButton;
Expand Down
6 changes: 6 additions & 0 deletions ChartsDemo/Classes/DemoBaseViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,12 @@ - (void)handleOption:(NSString *)key forChartView:(ChartViewBase *)chartView
_shouldHideData = !_shouldHideData;
[self updateChartData];
}

if ([key isEqualToString:@"toggleBarBorders"])
{
shouldRenderBarBorders = !shouldRenderBarBorders;
[self updateChartData];
}
}

#pragma mark - Actions
Expand Down
2 changes: 2 additions & 0 deletions ChartsDemo/Classes/Demos/AnotherBarChartViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ - (void)viewDidLoad
@{@"key": @"saveToGallery", @"label": @"Save to Camera Roll"},
@{@"key": @"togglePinchZoom", @"label": @"Toggle PinchZoom"},
@{@"key": @"toggleData", @"label": @"Toggle Data"},
@{@"key": @"toggleBarBorders", @"label": @"Show Bar Borders"},
];

_chartView.delegate = self;
Expand Down Expand Up @@ -106,6 +107,7 @@ - (void)setDataCount:(int)count range:(double)range
BarChartDataSet *set1 = [[BarChartDataSet alloc] initWithYVals:yVals label:@"DataSet"];
set1.colors = ChartColorTemplates.vordiplom;
set1.drawValuesEnabled = NO;
set1.barBorderWidth = shouldRenderBarBorders ? 1.0 : 0.0;

NSMutableArray *dataSets = [[NSMutableArray alloc] init];
[dataSets addObject:set1];
Expand Down
4 changes: 3 additions & 1 deletion ChartsDemo/Classes/Demos/BarChartViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ - (void)viewDidLoad
@{@"key": @"togglePinchZoom", @"label": @"Toggle PinchZoom"},
@{@"key": @"toggleAutoScaleMinMax", @"label": @"Toggle auto scale min/max"},
@{@"key": @"toggleData", @"label": @"Toggle Data"},
@{@"key": @"toggleBarBorders", @"label": @"Show Bar Borders"},
];

[self setupBarLineChartView:_chartView];
Expand Down Expand Up @@ -128,7 +129,8 @@ - (void)setDataCount:(int)count range:(double)range

BarChartDataSet *set1 = [[BarChartDataSet alloc] initWithYVals:yVals label:@"DataSet"];
set1.barSpace = 0.35;

set1.barBorderWidth = shouldRenderBarBorders ? 1.0 : 0.0;

NSMutableArray *dataSets = [[NSMutableArray alloc] init];
[dataSets addObject:set1];

Expand Down
4 changes: 3 additions & 1 deletion ChartsDemo/Classes/Demos/CombinedChartViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ - (void)viewDidLoad
@{@"key": @"toggleBarValues", @"label": @"Toggle Bar Values"},
@{@"key": @"saveToGallery", @"label": @"Save to Camera Roll"},
@{@"key": @"toggleData", @"label": @"Toggle Data"},
@{@"key": @"toggleBarBorders", @"label": @"Show Bar Borders"},
];

_chartView.delegate = self;
Expand Down Expand Up @@ -172,7 +173,8 @@ - (BarChartData *)generateBarData
[set setColor:[UIColor colorWithRed:60/255.f green:220/255.f blue:78/255.f alpha:1.f]];
set.valueTextColor = [UIColor colorWithRed:60/255.f green:220/255.f blue:78/255.f alpha:1.f];
set.valueFont = [UIFont systemFontOfSize:10.f];

set.barBorderWidth = shouldRenderBarBorders ? 1.0 : 0.0;

set.axisDependency = AxisDependencyLeft;

[d addDataSet:set];
Expand Down
4 changes: 3 additions & 1 deletion ChartsDemo/Classes/Demos/HorizontalBarChartViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ - (void)viewDidLoad
@{@"key": @"togglePinchZoom", @"label": @"Toggle PinchZoom"},
@{@"key": @"toggleAutoScaleMinMax", @"label": @"Toggle auto scale min/max"},
@{@"key": @"toggleData", @"label": @"Toggle Data"},
@{@"key": @"toggleBarBorders", @"label": @"Show Bar Borders"},
];

[self setupBarLineChartView:_chartView];
Expand Down Expand Up @@ -125,7 +126,8 @@ - (void)setDataCount:(int)count range:(double)range

BarChartDataSet *set1 = [[BarChartDataSet alloc] initWithYVals:yVals label:@"DataSet"];
set1.barSpace = 0.35;

set1.barBorderWidth = shouldRenderBarBorders ? 1.0 : 0.0;

NSMutableArray *dataSets = [[NSMutableArray alloc] init];
[dataSets addObject:set1];

Expand Down
6 changes: 5 additions & 1 deletion ChartsDemo/Classes/Demos/MultipleBarChartViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ - (void)viewDidLoad
@{@"key": @"togglePinchZoom", @"label": @"Toggle PinchZoom"},
@{@"key": @"toggleAutoScaleMinMax", @"label": @"Toggle auto scale min/max"},
@{@"key": @"toggleData", @"label": @"Toggle Data"},
@{@"key": @"toggleBarBorders", @"label": @"Show Bar Borders"},
];

_chartView.delegate = self;
Expand Down Expand Up @@ -125,11 +126,14 @@ - (void)setDataCount:(int)count range:(double)range

BarChartDataSet *set1 = [[BarChartDataSet alloc] initWithYVals:yVals1 label:@"Company A"];
[set1 setColor:[UIColor colorWithRed:104/255.f green:241/255.f blue:175/255.f alpha:1.f]];
[set1 setBarBorderWidth:(shouldRenderBarBorders ? 1.0 : 0.0)];
BarChartDataSet *set2 = [[BarChartDataSet alloc] initWithYVals:yVals2 label:@"Company B"];
[set2 setColor:[UIColor colorWithRed:164/255.f green:228/255.f blue:251/255.f alpha:1.f]];
//[set2 setBarBorderWidth:(shouldRenderBarBorders ? 1.0 : 0.0)];
BarChartDataSet *set3 = [[BarChartDataSet alloc] initWithYVals:yVals3 label:@"Company C"];
[set3 setColor:[UIColor colorWithRed:242/255.f green:247/255.f blue:158/255.f alpha:1.f]];

[set3 setBarBorderWidth:(shouldRenderBarBorders ? 1.0 : 0.0)];

NSMutableArray *dataSets = [[NSMutableArray alloc] init];
[dataSets addObject:set1];
[dataSets addObject:set2];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ - (void)viewDidLoad
@{@"key": @"togglePinchZoom", @"label": @"Toggle PinchZoom"},
@{@"key": @"toggleAutoScaleMinMax", @"label": @"Toggle auto scale min/max"},
@{@"key": @"toggleData", @"label": @"Toggle Data"},
@{@"key": @"toggleBarBorders", @"label": @"Show Bar Borders"},
];

NSNumberFormatter *customFormatter = [[NSNumberFormatter alloc] init];
Expand Down Expand Up @@ -124,7 +125,8 @@ - (void)setChartData
set.stackLabels = @[
@"Men", @"Women"
];

set.barBorderWidth = shouldRenderBarBorders ? 1.0 : 0.0;

NSArray *xVals = @[ @"0-10", @"10-20", @"20-30", @"30-40", @"40-50", @"50-60", @"60-70", @"70-80", @"80-90", @"90-100", @"100+" ];

BarChartData *data = [[BarChartData alloc] initWithXVals:xVals dataSet:set];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ - (void)viewDidLoad
@{@"key": @"togglePinchZoom", @"label": @"Toggle PinchZoom"},
@{@"key": @"toggleAutoScaleMinMax", @"label": @"Toggle auto scale min/max"},
@{@"key": @"toggleData", @"label": @"Toggle Data"},
@{@"key": @"toggleBarBorders", @"label": @"Show Bar Borders"},
];

[self setupBarLineChartView:_chartView];
Expand Down Expand Up @@ -152,7 +153,8 @@ - (void)setChartData
set.barSpace = 0.4f;
set.colors = colors;
set.valueColors = colors;

set.barBorderWidth = shouldRenderBarBorders ? 1.0 : 0.0;

BarChartData *data = [[BarChartData alloc] initWithXVals:dates dataSet:set];
[data setValueFont:[UIFont systemFontOfSize:13.f]];

Expand Down
6 changes: 4 additions & 2 deletions ChartsDemo/Classes/Demos/StackedBarChartViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ - (void)viewDidLoad
@{@"key": @"togglePinchZoom", @"label": @"Toggle PinchZoom"},
@{@"key": @"toggleAutoScaleMinMax", @"label": @"Toggle auto scale min/max"},
@{@"key": @"toggleData", @"label": @"Toggle Data"},
];
@{@"key": @"toggleBarBorders", @"label": @"Show Bar Borders"},
];

_chartView.delegate = self;

Expand Down Expand Up @@ -121,7 +122,8 @@ - (void)setDataCount:(int)count range:(double)range
BarChartDataSet *set1 = [[BarChartDataSet alloc] initWithYVals:yVals label:@"Statistics Vienna 2014"];
set1.colors = @[ChartColorTemplates.vordiplom[0], ChartColorTemplates.vordiplom[1], ChartColorTemplates.vordiplom[2]];
set1.stackLabels = @[@"Births", @"Divorces", @"Marriages"];

set1.barBorderWidth = shouldRenderBarBorders ? 1.0 : 0.0;

NSMutableArray *dataSets = [[NSMutableArray alloc] init];
[dataSets addObject:set1];

Expand Down

0 comments on commit 3a05e83

Please sign in to comment.