diff --git a/ChartsDemo/Classes/DemoBaseViewController.m b/ChartsDemo/Classes/DemoBaseViewController.m index 3a142369fd..c5908a844c 100644 --- a/ChartsDemo/Classes/DemoBaseViewController.m +++ b/ChartsDemo/Classes/DemoBaseViewController.m @@ -83,6 +83,16 @@ - (void)handleOption:(NSString *)key forChartView:(ChartViewBase *)chartView [chartView setNeedsDisplay]; } + if ([key isEqualToString:@"toggleIcons"]) + { + for (id set in chartView.data.dataSets) + { + set.drawIconsEnabled = !set.isDrawIconsEnabled; + } + + [chartView setNeedsDisplay]; + } + if ([key isEqualToString:@"toggleHighlight"]) { chartView.data.highlightEnabled = !chartView.data.isHighlightEnabled; diff --git a/ChartsDemo/Classes/Demos/BarChartViewController.m b/ChartsDemo/Classes/Demos/BarChartViewController.m index cdf8583cec..0a91a1d340 100644 --- a/ChartsDemo/Classes/Demos/BarChartViewController.m +++ b/ChartsDemo/Classes/Demos/BarChartViewController.m @@ -33,6 +33,7 @@ - (void)viewDidLoad self.options = @[ @{@"key": @"toggleValues", @"label": @"Toggle Values"}, + @{@"key": @"toggleIcons", @"label": @"Toggle Icons"}, @{@"key": @"toggleHighlight", @"label": @"Toggle Highlight"}, @{@"key": @"animateX", @"label": @"Animate X"}, @{@"key": @"animateY", @"label": @"Animate Y"}, @@ -136,7 +137,11 @@ - (void)setDataCount:(int)count range:(double)range { double mult = (range + 1); double val = (double) (arc4random_uniform(mult)); - [yVals addObject:[[BarChartDataEntry alloc] initWithX:(double)i y:val]]; + if (arc4random_uniform(100) < 25) { + [yVals addObject:[[BarChartDataEntry alloc] initWithX:val y:i data: [UIImage imageNamed:@"icon"]]]; + } else { + [yVals addObject:[[BarChartDataEntry alloc] initWithX:val y:i]]; + } } BarChartDataSet *set1 = nil; diff --git a/ChartsDemo/Classes/Demos/BubbleChartViewController.m b/ChartsDemo/Classes/Demos/BubbleChartViewController.m index e311f67b26..32a5889035 100644 --- a/ChartsDemo/Classes/Demos/BubbleChartViewController.m +++ b/ChartsDemo/Classes/Demos/BubbleChartViewController.m @@ -32,6 +32,7 @@ - (void)viewDidLoad self.options = @[ @{@"key": @"toggleValues", @"label": @"Toggle Values"}, + @{@"key": @"toggleIcons", @"label": @"Toggle Icons"}, @{@"key": @"toggleHighlight", @"label": @"Toggle Highlight"}, @{@"key": @"animateX", @"label": @"Animate X"}, @{@"key": @"animateY", @"label": @"Animate Y"}, @@ -103,11 +104,11 @@ - (void)setDataCount:(int)count range:(double)range { double val = (double) (arc4random_uniform(range)); double size = (double) (arc4random_uniform(range)); - [yVals1 addObject:[[BubbleChartDataEntry alloc] initWithX:i y:val size:size]]; + [yVals1 addObject:[[BubbleChartDataEntry alloc] initWithX:i y:val size:size data: [UIImage imageNamed:@"icon"]]]; val = (double) (arc4random_uniform(range)); size = (double) (arc4random_uniform(range)); - [yVals2 addObject:[[BubbleChartDataEntry alloc] initWithX:i y:val size:size]]; + [yVals2 addObject:[[BubbleChartDataEntry alloc] initWithX:i y:val size:size data: [UIImage imageNamed:@"icon"]]]; val = (double) (arc4random_uniform(range)); size = (double) (arc4random_uniform(range)); @@ -118,6 +119,7 @@ - (void)setDataCount:(int)count range:(double)range [set1 setColor:ChartColorTemplates.colorful[0] alpha:0.50f]; [set1 setDrawValuesEnabled:YES]; BubbleChartDataSet *set2 = [[BubbleChartDataSet alloc] initWithValues:yVals2 label:@"DS 2"]; + set1.iconsOffset = CGSizeMake(0, 15); [set2 setColor:ChartColorTemplates.colorful[1] alpha:0.50f]; [set2 setDrawValuesEnabled:YES]; BubbleChartDataSet *set3 = [[BubbleChartDataSet alloc] initWithValues:yVals3 label:@"DS 3"]; diff --git a/ChartsDemo/Classes/Demos/CandleStickChartViewController.m b/ChartsDemo/Classes/Demos/CandleStickChartViewController.m index d4e03a40a2..992cd807e9 100644 --- a/ChartsDemo/Classes/Demos/CandleStickChartViewController.m +++ b/ChartsDemo/Classes/Demos/CandleStickChartViewController.m @@ -32,6 +32,7 @@ - (void)viewDidLoad self.options = @[ @{@"key": @"toggleValues", @"label": @"Toggle Values"}, + @{@"key": @"toggleIcons", @"label": @"Toggle Icons"}, @{@"key": @"toggleHighlight", @"label": @"Toggle Highlight"}, @{@"key": @"animateX", @"label": @"Animate X"}, @{@"key": @"animateY", @"label": @"Animate Y"}, @@ -100,7 +101,7 @@ - (void)setDataCount:(int)count range:(double)range double open = (double) (arc4random_uniform(6)) + 1.0; double close = (double) (arc4random_uniform(6)) + 1.0; BOOL even = i % 2 == 0; - [yVals1 addObject:[[CandleChartDataEntry alloc] initWithX:i shadowH:val + high shadowL:val - low open:even ? val + open : val - open close:even ? val - close : val + close]]; + [yVals1 addObject:[[CandleChartDataEntry alloc] initWithX:i shadowH:val + high shadowL:val - low open:even ? val + open : val - open close:even ? val - close : val + close data: [UIImage imageNamed:@"icon"]]]; } CandleChartDataSet *set1 = [[CandleChartDataSet alloc] initWithValues:yVals1 label:@"Data Set"]; diff --git a/ChartsDemo/Classes/Demos/HorizontalBarChartViewController.m b/ChartsDemo/Classes/Demos/HorizontalBarChartViewController.m index e59c7976e2..aeaa6cbf31 100644 --- a/ChartsDemo/Classes/Demos/HorizontalBarChartViewController.m +++ b/ChartsDemo/Classes/Demos/HorizontalBarChartViewController.m @@ -32,6 +32,7 @@ - (void)viewDidLoad self.options = @[ @{@"key": @"toggleValues", @"label": @"Toggle Values"}, + @{@"key": @"toggleIcons", @"label": @"Toggle Icons"}, @{@"key": @"toggleHighlight", @"label": @"Toggle Highlight"}, @{@"key": @"animateX", @"label": @"Animate X"}, @{@"key": @"animateY", @"label": @"Animate Y"}, @@ -119,7 +120,7 @@ - (void)setDataCount:(int)count range:(double)range { double mult = (range + 1); double val = (double) (arc4random_uniform(mult)); - [yVals addObject:[[BarChartDataEntry alloc] initWithX:i * spaceForBar y:val]]; + [yVals addObject:[[BarChartDataEntry alloc] initWithX:i * spaceForBar y:val data: [UIImage imageNamed:@"icon"]]]; } BarChartDataSet *set1 = nil; diff --git a/ChartsDemo/Classes/Demos/LineChart1ViewController.m b/ChartsDemo/Classes/Demos/LineChart1ViewController.m index 528c9facd9..4e1abf33af 100644 --- a/ChartsDemo/Classes/Demos/LineChart1ViewController.m +++ b/ChartsDemo/Classes/Demos/LineChart1ViewController.m @@ -36,6 +36,7 @@ - (void)viewDidLoad @{@"key": @"toggleCircles", @"label": @"Toggle Circles"}, @{@"key": @"toggleCubic", @"label": @"Toggle Cubic"}, @{@"key": @"toggleHorizontalCubic", @"label": @"Toggle Horizontal Cubic"}, + @{@"key": @"toggleIcons", @"label": @"Toggle Icons"}, @{@"key": @"toggleStepped", @"label": @"Toggle Stepped"}, @{@"key": @"toggleHighlight", @"label": @"Toggle Highlight"}, @{@"key": @"animateX", @"label": @"Animate X"}, @@ -137,7 +138,7 @@ - (void)setDataCount:(int)count range:(double)range for (int i = 0; i < count; i++) { double val = arc4random_uniform(range) + 3; - [values addObject:[[ChartDataEntry alloc] initWithX:i y:val]]; + [values addObject:[[ChartDataEntry alloc] initWithX:i y:val data: [UIImage imageNamed:@"icon"]]]; } LineChartDataSet *set1 = nil; diff --git a/ChartsDemo/Classes/Demos/NegativeStackedBarChartViewController.m b/ChartsDemo/Classes/Demos/NegativeStackedBarChartViewController.m index e969e6806e..f2b6aa36c1 100644 --- a/ChartsDemo/Classes/Demos/NegativeStackedBarChartViewController.m +++ b/ChartsDemo/Classes/Demos/NegativeStackedBarChartViewController.m @@ -28,6 +28,7 @@ - (void)viewDidLoad self.options = @[ @{@"key": @"toggleValues", @"label": @"Toggle Values"}, + @{@"key": @"toggleIcons", @"label": @"Toggle Icons"}, @{@"key": @"toggleHighlight", @"label": @"Toggle Highlight"}, @{@"key": @"animateX", @"label": @"Animate X"}, @{@"key": @"animateY", @"label": @"Animate Y"}, @@ -112,7 +113,7 @@ - (void)setChartData [yValues addObject:[[BarChartDataEntry alloc] initWithX:15 yValues:@[ @-12, @13 ]]]; [yValues addObject:[[BarChartDataEntry alloc] initWithX:25 yValues:@[ @-15, @15 ]]]; [yValues addObject:[[BarChartDataEntry alloc] initWithX:35 yValues:@[ @-17, @17 ]]]; - [yValues addObject:[[BarChartDataEntry alloc] initWithX:45 yValues:@[ @-19, @20 ]]]; + [yValues addObject:[[BarChartDataEntry alloc] initWithX:45 yValues:@[ @-19, @20 ] data: [UIImage imageNamed:@"icon"]]]; [yValues addObject:[[BarChartDataEntry alloc] initWithX:55 yValues:@[ @-19, @19 ]]]; [yValues addObject:[[BarChartDataEntry alloc] initWithX:65 yValues:@[ @-16, @16 ]]]; [yValues addObject:[[BarChartDataEntry alloc] initWithX:75 yValues:@[ @-13, @14 ]]]; diff --git a/ChartsDemo/Classes/Demos/PieChartViewController.m b/ChartsDemo/Classes/Demos/PieChartViewController.m index b453f2a50e..f5c670cafd 100644 --- a/ChartsDemo/Classes/Demos/PieChartViewController.m +++ b/ChartsDemo/Classes/Demos/PieChartViewController.m @@ -35,6 +35,7 @@ - (void)viewDidLoad @{@"key": @"toggleXValues", @"label": @"Toggle X-Values"}, @{@"key": @"togglePercent", @"label": @"Toggle Percent"}, @{@"key": @"toggleHole", @"label": @"Toggle Hole"}, + @{@"key": @"toggleIcons", @"label": @"Toggle Icons"}, @{@"key": @"animateX", @"label": @"Animate X"}, @{@"key": @"animateY", @"label": @"Animate Y"}, @{@"key": @"animateXY", @"label": @"Animate XY"}, @@ -93,11 +94,12 @@ - (void)setDataCount:(int)count range:(double)range for (int i = 0; i < count; i++) { - [values addObject:[[PieChartDataEntry alloc] initWithValue:(arc4random_uniform(mult) + mult / 5) label:parties[i % parties.count]]]; + [values addObject:[[PieChartDataEntry alloc] initWithValue:(arc4random_uniform(mult) + mult / 5) label:parties[i % parties.count] data: [UIImage imageNamed:@"icon"]]]; } PieChartDataSet *dataSet = [[PieChartDataSet alloc] initWithValues:values label:@"Election Results"]; dataSet.sliceSpace = 2.0; + dataSet.iconsOffset = CGSizeMake(0, 40); // add a lot of colors diff --git a/ChartsDemo/Classes/Demos/StackedBarChartViewController.m b/ChartsDemo/Classes/Demos/StackedBarChartViewController.m index 345c4b3d95..7cd285f50f 100644 --- a/ChartsDemo/Classes/Demos/StackedBarChartViewController.m +++ b/ChartsDemo/Classes/Demos/StackedBarChartViewController.m @@ -32,6 +32,7 @@ - (void)viewDidLoad self.options = @[ @{@"key": @"toggleValues", @"label": @"Toggle Values"}, + @{@"key": @"toggleIcons", @"label": @"Toggle Icons"}, @{@"key": @"toggleHighlight", @"label": @"Toggle Highlight"}, @{@"key": @"animateX", @"label": @"Animate X"}, @{@"key": @"animateY", @"label": @"Animate Y"}, @@ -111,7 +112,7 @@ - (void)setDataCount:(int)count range:(double)range double val2 = (double) (arc4random_uniform(mult) + mult / 3); double val3 = (double) (arc4random_uniform(mult) + mult / 3); - [yVals addObject:[[BarChartDataEntry alloc] initWithX:i yValues:@[@(val1), @(val2), @(val3)]]]; + [yVals addObject:[[BarChartDataEntry alloc] initWithX:i yValues:@[@(val1), @(val2), @(val3)] data: [UIImage imageNamed:@"icon"]]]; } BarChartDataSet *set1 = nil;