Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ChartViewBase cleanup #3034

Closed
wants to merge 16 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
236 changes: 129 additions & 107 deletions Charts.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

2,123 changes: 1,059 additions & 1,064 deletions ChartsDemo/ChartsDemo.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions ChartsDemo/Objective-C/Components/XYMarkerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import Charts

open class XYMarkerView: BalloonMarker
{
@objc open var xAxisValueFormatter: IAxisValueFormatter?
@objc open var xAxisValueFormatter: AxisValueFormatter?
fileprivate var yFormatter = NumberFormatter()

@objc public init(color: UIColor, font: UIFont, textColor: UIColor, insets: UIEdgeInsets,
xAxisValueFormatter: IAxisValueFormatter)
xAxisValueFormatter: AxisValueFormatter)
{
super.init(color: color, font: font, textColor: textColor, insets: insets)
self.xAxisValueFormatter = xAxisValueFormatter
Expand Down
8 changes: 4 additions & 4 deletions ChartsDemo/Objective-C/DemoBaseViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ - (void)handleOption:(NSString *)key forChartView:(ChartViewBase *)chartView
{
if ([key isEqualToString:@"toggleValues"])
{
for (id<IChartDataSet> set in chartView.data.dataSets)
for (id<ChartDataSetProtocol> set in chartView.data.dataSets)
{
set.drawValuesEnabled = !set.isDrawValuesEnabled;
}
Expand All @@ -85,7 +85,7 @@ - (void)handleOption:(NSString *)key forChartView:(ChartViewBase *)chartView

if ([key isEqualToString:@"toggleIcons"])
{
for (id<IChartDataSet> set in chartView.data.dataSets)
for (id<ChartDataSetProtocol> set in chartView.data.dataSets)
{
set.drawIconsEnabled = !set.isDrawIconsEnabled;
}
Expand Down Expand Up @@ -143,9 +143,9 @@ - (void)handleOption:(NSString *)key forChartView:(ChartViewBase *)chartView

if ([key isEqualToString:@"toggleBarBorders"])
{
for (id<IBarChartDataSet, NSObject> set in chartView.data.dataSets)
for (id<BarChartDataSetProtocol, NSObject> set in chartView.data.dataSets)
{
if ([set conformsToProtocol:@protocol(IBarChartDataSet)])
if ([set conformsToProtocol:@protocol(BarChartDataSetProtocol)])
{
set.barBorderWidth = set.barBorderWidth == 1.0 ? 0.0 : 1.0;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ - (void)optionTapped:(NSString *)key
{
if ([key isEqualToString:@"toggleShadowColorSameAsCandle"])
{
for (id<ICandleChartDataSet> set in _chartView.data.dataSets)
for (id<CandleChartDataSetProtocol> set in _chartView.data.dataSets)
{
set.shadowColorSameAsCandle = !set.shadowColorSameAsCandle;
}
Expand Down
12 changes: 6 additions & 6 deletions ChartsDemo/Objective-C/Demos/CombinedChartViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

#define ITEM_COUNT 12

@interface CombinedChartViewController () <ChartViewDelegate, IChartAxisValueFormatter>
@interface CombinedChartViewController () <ChartViewDelegate, ChartAxisValueFormatter>
{
NSArray<NSString *> *months;
}
Expand Down Expand Up @@ -122,7 +122,7 @@ - (void)optionTapped:(NSString *)key
{
if ([key isEqualToString:@"toggleLineValues"])
{
for (NSObject<IChartDataSet> *set in _chartView.data.dataSets)
for (NSObject<ChartDataSetProtocol> *set in _chartView.data.dataSets)
{
if ([set isKindOfClass:LineChartDataSet.class])
{
Expand All @@ -136,7 +136,7 @@ - (void)optionTapped:(NSString *)key

if ([key isEqualToString:@"toggleBarValues"])
{
for (NSObject<IChartDataSet> *set in _chartView.data.dataSets)
for (NSObject<ChartDataSetProtocol> *set in _chartView.data.dataSets)
{
if ([set isKindOfClass:BarChartDataSet.class])
{
Expand Down Expand Up @@ -206,7 +206,7 @@ - (BarChartData *)generateBarData
[set1 setColor:[UIColor colorWithRed:60/255.f green:220/255.f blue:78/255.f alpha:1.f]];
set1.valueTextColor = [UIColor colorWithRed:60/255.f green:220/255.f blue:78/255.f alpha:1.f];
set1.valueFont = [UIFont systemFontOfSize:10.f];
set1.axisDependency = AxisDependencyLeft;
set1.axisDependency = AxisDependencyRight;

BarChartDataSet *set2 = [[BarChartDataSet alloc] initWithValues:entries2 label:@""];
set2.stackLabels = @[@"Stack 1", @"Stack 2"];
Expand All @@ -216,7 +216,7 @@ - (BarChartData *)generateBarData
];
set2.valueTextColor = [UIColor colorWithRed:61/255.f green:165/255.f blue:255/255.f alpha:1.f];
set2.valueFont = [UIFont systemFontOfSize:10.f];
set2.axisDependency = AxisDependencyLeft;
set2.axisDependency = AxisDependencyRight;

float groupSpace = 0.06f;
float barSpace = 0.02f; // x2 dataset
Expand Down Expand Up @@ -313,7 +313,7 @@ - (void)chartValueNothingSelected:(ChartViewBase * __nonnull)chartView
NSLog(@"chartValueNothingSelected");
}

#pragma mark - IAxisValueFormatter
#pragma mark - AxisValueFormatter

- (NSString *)stringForValue:(double)value
axis:(ChartAxisBase *)axis
Expand Down
12 changes: 6 additions & 6 deletions ChartsDemo/Objective-C/Demos/CubicLineChartViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#import "CubicLineChartViewController.h"
#import "ChartsDemo-Swift.h"

@interface CubicLineSampleFillFormatter : NSObject <IChartFillFormatter>
@interface CubicLineSampleFillFormatter : NSObject <ChartFillFormatter>
{
}
@end
Expand Down Expand Up @@ -158,7 +158,7 @@ - (void)optionTapped:(NSString *)key
{
if ([key isEqualToString:@"toggleFilled"])
{
for (id<ILineChartDataSet> set in _chartView.data.dataSets)
for (id<LineChartDataSetProtocol> set in _chartView.data.dataSets)
{
set.drawFilledEnabled = !set.isDrawFilledEnabled;
}
Expand All @@ -169,7 +169,7 @@ - (void)optionTapped:(NSString *)key

if ([key isEqualToString:@"toggleCircles"])
{
for (id<ILineChartDataSet> set in _chartView.data.dataSets)
for (id<LineChartDataSetProtocol> set in _chartView.data.dataSets)
{
set.drawCirclesEnabled = !set.isDrawCirclesEnabled;
}
Expand All @@ -180,7 +180,7 @@ - (void)optionTapped:(NSString *)key

if ([key isEqualToString:@"toggleCubic"])
{
for (id<ILineChartDataSet> set in _chartView.data.dataSets)
for (id<LineChartDataSetProtocol> set in _chartView.data.dataSets)
{
set.mode = set.mode == LineChartModeCubicBezier ? LineChartModeLinear : LineChartModeCubicBezier;
}
Expand All @@ -191,7 +191,7 @@ - (void)optionTapped:(NSString *)key

if ([key isEqualToString:@"toggleStepped"])
{
for (id<ILineChartDataSet> set in _chartView.data.dataSets)
for (id<LineChartDataSetProtocol> set in _chartView.data.dataSets)
{
set.mode = set.mode == LineChartModeStepped ? LineChartModeLinear : LineChartModeStepped;
}
Expand All @@ -201,7 +201,7 @@ - (void)optionTapped:(NSString *)key

if ([key isEqualToString:@"toggleHorizontalCubic"])
{
for (id<ILineChartDataSet> set in _chartView.data.dataSets)
for (id<LineChartDataSetProtocol> set in _chartView.data.dataSets)
{
set.mode = set.mode == LineChartModeCubicBezier ? LineChartModeHorizontalBezier : LineChartModeCubicBezier;
}
Expand Down
10 changes: 5 additions & 5 deletions ChartsDemo/Objective-C/Demos/LineChart1ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ - (void)optionTapped:(NSString *)key
{
if ([key isEqualToString:@"toggleFilled"])
{
for (id<ILineChartDataSet> set in _chartView.data.dataSets)
for (id<LineChartDataSetProtocol> set in _chartView.data.dataSets)
{
set.drawFilledEnabled = !set.isDrawFilledEnabled;
}
Expand All @@ -203,7 +203,7 @@ - (void)optionTapped:(NSString *)key

if ([key isEqualToString:@"toggleCircles"])
{
for (id<ILineChartDataSet> set in _chartView.data.dataSets)
for (id<LineChartDataSetProtocol> set in _chartView.data.dataSets)
{
set.drawCirclesEnabled = !set.isDrawCirclesEnabled;
}
Expand All @@ -214,7 +214,7 @@ - (void)optionTapped:(NSString *)key

if ([key isEqualToString:@"toggleCubic"])
{
for (id<ILineChartDataSet> set in _chartView.data.dataSets)
for (id<LineChartDataSetProtocol> set in _chartView.data.dataSets)
{
set.mode = set.mode == LineChartModeCubicBezier ? LineChartModeLinear : LineChartModeCubicBezier;
}
Expand All @@ -225,7 +225,7 @@ - (void)optionTapped:(NSString *)key

if ([key isEqualToString:@"toggleStepped"])
{
for (id<ILineChartDataSet> set in _chartView.data.dataSets)
for (id<LineChartDataSetProtocol> set in _chartView.data.dataSets)
{
switch (set.mode) {
case LineChartModeLinear:
Expand All @@ -242,7 +242,7 @@ - (void)optionTapped:(NSString *)key

if ([key isEqualToString:@"toggleHorizontalCubic"])
{
for (id<ILineChartDataSet> set in _chartView.data.dataSets)
for (id<LineChartDataSetProtocol> set in _chartView.data.dataSets)
{
set.mode = set.mode == LineChartModeHorizontalBezier ? LineChartModeCubicBezier : LineChartModeHorizontalBezier;
}
Expand Down
10 changes: 5 additions & 5 deletions ChartsDemo/Objective-C/Demos/LineChart2ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ - (void)optionTapped:(NSString *)key
{
if ([key isEqualToString:@"toggleFilled"])
{
for (id<ILineChartDataSet> set in _chartView.data.dataSets)
for (id<LineChartDataSetProtocol> set in _chartView.data.dataSets)
{
set.drawFilledEnabled = !set.isDrawFilledEnabled;
}
Expand All @@ -215,7 +215,7 @@ - (void)optionTapped:(NSString *)key

if ([key isEqualToString:@"toggleCircles"])
{
for (id<ILineChartDataSet> set in _chartView.data.dataSets)
for (id<LineChartDataSetProtocol> set in _chartView.data.dataSets)
{
set.drawCirclesEnabled = !set.isDrawCirclesEnabled;
}
Expand All @@ -226,7 +226,7 @@ - (void)optionTapped:(NSString *)key

if ([key isEqualToString:@"toggleCubic"])
{
for (id<ILineChartDataSet> set in _chartView.data.dataSets)
for (id<LineChartDataSetProtocol> set in _chartView.data.dataSets)
{
set.mode = set.mode == LineChartModeCubicBezier ? LineChartModeLinear : LineChartModeCubicBezier;
}
Expand All @@ -237,7 +237,7 @@ - (void)optionTapped:(NSString *)key

if ([key isEqualToString:@"toggleStepped"])
{
for (id<ILineChartDataSet> set in _chartView.data.dataSets)
for (id<LineChartDataSetProtocol> set in _chartView.data.dataSets)
{
switch (set.mode) {
case LineChartModeLinear:
Expand All @@ -254,7 +254,7 @@ - (void)optionTapped:(NSString *)key

if ([key isEqualToString:@"toggleHorizontalCubic"])
{
for (id<ILineChartDataSet> set in _chartView.data.dataSets)
for (id<LineChartDataSetProtocol> set in _chartView.data.dataSets)
{
set.mode = set.mode == LineChartModeCubicBezier ? LineChartModeHorizontalBezier : LineChartModeCubicBezier;
}
Expand Down
4 changes: 2 additions & 2 deletions ChartsDemo/Objective-C/Demos/LineChartFilledViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ - (void)setDataCount:(int)count range:(double)range
set1.fillColor = UIColor.whiteColor;
set1.highlightColor = [UIColor colorWithRed:244/255.0 green:117/255.0 blue:117/255.0 alpha:1.0];
set1.drawCircleHoleEnabled = NO;
set1.fillFormatter = [ChartDefaultFillFormatter withBlock:^CGFloat(id<ILineChartDataSet> _Nonnull dataSet, id<LineChartDataProvider> _Nonnull dataProvider) {
set1.fillFormatter = [ChartDefaultFillFormatter withBlock:^CGFloat(id<LineChartDataSetProtocol> _Nonnull dataSet, id<LineChartDataProvider> _Nonnull dataProvider) {
return _chartView.leftAxis.axisMinimum;
}];

Expand All @@ -138,7 +138,7 @@ - (void)setDataCount:(int)count range:(double)range
set2.fillColor = UIColor.whiteColor;
set2.highlightColor = [UIColor colorWithRed:244/255.0 green:117/255.0 blue:117/255.0 alpha:1.0];
set2.drawCircleHoleEnabled = NO;
set2.fillFormatter = [ChartDefaultFillFormatter withBlock:^CGFloat(id<ILineChartDataSet> _Nonnull dataSet, id<LineChartDataProvider> _Nonnull dataProvider) {
set2.fillFormatter = [ChartDefaultFillFormatter withBlock:^CGFloat(id<LineChartDataSetProtocol> _Nonnull dataSet, id<LineChartDataProvider> _Nonnull dataProvider) {
return _chartView.leftAxis.axisMaximum;
}];

Expand Down
10 changes: 5 additions & 5 deletions ChartsDemo/Objective-C/Demos/LineChartTimeViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ - (void)optionTapped:(NSString *)key
{
if ([key isEqualToString:@"toggleFilled"])
{
for (id<ILineChartDataSet> set in _chartView.data.dataSets)
for (id<LineChartDataSetProtocol> set in _chartView.data.dataSets)
{
set.drawFilledEnabled = !set.isDrawFilledEnabled;
}
Expand All @@ -169,7 +169,7 @@ - (void)optionTapped:(NSString *)key

if ([key isEqualToString:@"toggleCircles"])
{
for (id<ILineChartDataSet> set in _chartView.data.dataSets)
for (id<LineChartDataSetProtocol> set in _chartView.data.dataSets)
{
set.drawCirclesEnabled = !set.isDrawCirclesEnabled;
}
Expand All @@ -180,7 +180,7 @@ - (void)optionTapped:(NSString *)key

if ([key isEqualToString:@"toggleCubic"])
{
for (id<ILineChartDataSet> set in _chartView.data.dataSets)
for (id<LineChartDataSetProtocol> set in _chartView.data.dataSets)
{
set.mode = set.mode == LineChartModeCubicBezier ? LineChartModeLinear : LineChartModeCubicBezier;
}
Expand All @@ -191,7 +191,7 @@ - (void)optionTapped:(NSString *)key

if ([key isEqualToString:@"toggleStepped"])
{
for (id<ILineChartDataSet> set in _chartView.data.dataSets)
for (id<LineChartDataSetProtocol> set in _chartView.data.dataSets)
{
switch (set.mode) {
case LineChartModeLinear:
Expand All @@ -208,7 +208,7 @@ - (void)optionTapped:(NSString *)key

if ([key isEqualToString:@"toggleHorizontalCubic"])
{
for (id<ILineChartDataSet> set in _chartView.data.dataSets)
for (id<LineChartDataSetProtocol> set in _chartView.data.dataSets)
{
set.mode = set.mode == LineChartModeCubicBezier ? LineChartModeHorizontalBezier : LineChartModeCubicBezier;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ - (void)optionTapped:(NSString *)key
{
if ([key isEqualToString:@"toggleFilled"])
{
for (id<ILineChartDataSet> set in _chartView.data.dataSets)
for (id<LineChartDataSetProtocol> set in _chartView.data.dataSets)
{
set.drawFilledEnabled = !set.isDrawFilledEnabled;
}
Expand All @@ -141,7 +141,7 @@ - (void)optionTapped:(NSString *)key

if ([key isEqualToString:@"toggleCircles"])
{
for (id<ILineChartDataSet> set in _chartView.data.dataSets)
for (id<LineChartDataSetProtocol> set in _chartView.data.dataSets)
{
set.drawCirclesEnabled = !set.isDrawCirclesEnabled;
}
Expand All @@ -152,7 +152,7 @@ - (void)optionTapped:(NSString *)key

if ([key isEqualToString:@"toggleCubic"])
{
for (id<ILineChartDataSet> set in _chartView.data.dataSets)
for (id<LineChartDataSetProtocol> set in _chartView.data.dataSets)
{
set.mode = set.mode == LineChartModeCubicBezier ? LineChartModeLinear : LineChartModeCubicBezier;
}
Expand All @@ -163,7 +163,7 @@ - (void)optionTapped:(NSString *)key

if ([key isEqualToString:@"toggleStepped"])
{
for (id<ILineChartDataSet> set in _chartView.data.dataSets)
for (id<LineChartDataSetProtocol> set in _chartView.data.dataSets)
{
switch (set.mode) {
case LineChartModeLinear:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#import "NegativeStackedBarChartViewController.h"
#import "ChartsDemo-Swift.h"

@interface NegativeStackedBarChartViewController () <ChartViewDelegate, IChartAxisValueFormatter>
@interface NegativeStackedBarChartViewController () <ChartViewDelegate, ChartAxisValueFormatter>

@property (nonatomic, strong) IBOutlet HorizontalBarChartView *chartView;

Expand Down Expand Up @@ -184,7 +184,7 @@ - (void)chartValueNothingSelected:(ChartViewBase * __nonnull)chartView
NSLog(@"chartValueNothingSelected");
}

#pragma mark - IAxisValueFormatter
#pragma mark - AxisValueFormatter

- (NSString *)stringForValue:(double)value
axis:(ChartAxisBase *)axis
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#import "PositiveNegativeBarChartViewController.h"
#import "ChartsDemo-Swift.h"

@interface PositiveNegativeBarChartViewController () <ChartViewDelegate, IChartAxisValueFormatter>
@interface PositiveNegativeBarChartViewController () <ChartViewDelegate, ChartAxisValueFormatter>
{
NSArray<NSDictionary *> *dataList;
}
Expand Down Expand Up @@ -182,7 +182,7 @@ - (void)chartValueNothingSelected:(ChartViewBase * __nonnull)chartView
NSLog(@"chartValueNothingSelected");
}

#pragma mark - IAxisValueFormatter
#pragma mark - AxisValueFormatter

- (NSString *)stringForValue:(double)value
axis:(ChartAxisBase *)axis
Expand Down
Loading