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

Refactored ChartData #3169

Merged
merged 52 commits into from
Apr 8, 2018
Merged
Show file tree
Hide file tree
Changes from 49 commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
6e80eb0
Added Collection conformances
jjatie Nov 18, 2017
d36d11b
[#3018]
jjatie Nov 19, 2017
36ca566
Fixed required initializers
jjatie Nov 20, 2017
cb32b08
ChartData adopts ExressibleByArrayLiteral
jjatie Dec 1, 2017
ad0d148
Merge remote-tracking branch 'origin/chartdata-collection-conformance…
jjatie Dec 1, 2017
fcd9fa2
Modified demos
jjatie Dec 1, 2017
716f182
Pulled latest 4.0.0 and code style fixes
jjatie Jan 6, 2018
ca5afad
Updates for PR
jjatie Jan 11, 2018
0d41175
Pulled latest base
jjatie Jan 11, 2018
fdae403
Refactored ChartData
jjatie Jan 11, 2018
8976b95
PR review fixes
jjatie Jan 12, 2018
f28d3d5
Removed unnecessary `get` from subscripts.
jjatie Jan 12, 2018
793e437
Merge remote-tracking branch 'origin/chartdata-collection-conformance…
jjatie Jan 15, 2018
583dab6
Disabled `remove(at:)` for CombinedChartView
jjatie Jan 15, 2018
0cce64d
Merge remote-tracking branch 'origin/chartdata-collection-conformance…
jjatie Jan 15, 2018
47b6a1c
Removed redundant methods
jjatie Jan 15, 2018
c0b7d65
Relocated `appendEntry(_:todataSet:)`
jjatie Jan 15, 2018
1d1e380
Merge remote-tracking branch 'origin/chartdata-collection-conformance…
jjatie Jan 15, 2018
79cae83
Merge remote-tracking branch 'origin/chartdata-collection-refactor' i…
jjatie Jan 15, 2018
c76ed46
pulled latest 4.0.0
jjatie Jan 15, 2018
09d27a7
Disabled Collection support for CombinedChartData
jjatie Jan 15, 2018
a71f87c
Removed methods from CombinedChartData
jjatie Jan 15, 2018
efc5a72
Merge remote-tracking branch 'origin/chartdata-collection-conformance…
jjatie Jan 15, 2018
bfb750b
Merge branch '4.0.0' into chartdata-collection-refactor
jjatie Jan 15, 2018
6adde98
Merge branch '4.0.0' into chartdata-collection-refactor
jjatie Jan 15, 2018
023ff19
Merge remote-tracking branch 'origin/chartdata-collection-refactor' i…
jjatie Jan 16, 2018
e6eb970
Pulled latest 4.0
jjatie Jan 16, 2018
29d3e91
Fixes after merge
jjatie Jan 16, 2018
a388f8a
Removed used of dataSet(forIndex:)
jjatie Jan 16, 2018
ae8279a
Merge branch '4.0.0' into chartdata-collection-refactor
jjatie Jan 16, 2018
6de1114
Merge branch '4.0.0' into chartdata-collection-refactor
jjatie Jan 16, 2018
37b29ad
Merge branch '4.0.0' of https://github.com/danielgindi/Charts into ch…
jjatie Jan 21, 2018
329e00c
Fixed merge conflicts
jjatie Jan 21, 2018
2572f04
Merge remote-tracking branch 'upstream/4.0.0' into chartdata-collecti…
jjatie Jan 23, 2018
31a76eb
Fixed merge conflicts
jjatie Jan 23, 2018
5cbafb4
Merge remote-tracking branch 'origin/chartdata-collection-refactor' i…
jjatie Jan 23, 2018
b7e6f93
updated demos
jjatie Jan 26, 2018
5f3b528
Merge remote-tracking branch 'origin/chartdata-collection-refactor' i…
jjatie Jan 26, 2018
5816632
Merge remote-tracking branch 'upstream/4.0.0' into chartdata-cleanup
jjatie Jan 26, 2018
9f5a7f9
Pulled latest 4.0.0
jjatie Jan 26, 2018
b73ac7e
Fixed demos
jjatie Jan 26, 2018
33ed6b5
Fixed objective c demos
jjatie Jan 26, 2018
585e605
Merge remote-tracking branch 'origin/4.0.0' into chartdata-cleanup
jjatie Mar 13, 2018
b1ca0c5
Moved travis to Xcode 9.3 beta temporarily
jjatie Mar 13, 2018
5faad7b
Merge remote-tracking branch 'origin/4.0.0' into chartdata-cleanup
jjatie Mar 14, 2018
a049cd3
Merge remote-tracking branch 'origin/4.0.0' into chartdata-cleanup
jjatie Mar 14, 2018
251f501
Fixed macOS demo info.plist and tv demo device name
jjatie Mar 14, 2018
8031da7
PR Fixes
jjatie Mar 27, 2018
d371fa8
Fixed objective-c naming
jjatie Mar 27, 2018
43e32a5
PR Fixes
jjatie Mar 29, 2018
978857d
fix comment
jjatie Mar 30, 2018
fe0af58
pulled 4.0.0
jjatie Mar 30, 2018
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
86 changes: 47 additions & 39 deletions Charts.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,9 @@
098621EDFBF928494B94BEA1 /* Data */ = {
isa = PBXGroup;
children = (
3B9DD76FCE8D873300A822C7 /* Implementations */,
22C014222006FFE800D5B025 /* ChartData */,
3B9DD76FCE8D873300A822C7 /* ChartDataSet */,
22C014232006FFFA00D5B025 /* ChartEntry */,
DB2D9648877455028EBEAA8F /* DataSet Protocols */,
);
name = Data;
Expand Down Expand Up @@ -409,6 +411,37 @@
name = ChartRenderers;
sourceTree = "<group>";
};
22C014222006FFE800D5B025 /* ChartData */ = {
isa = PBXGroup;
children = (
0108D5925E21A47DA36A66AA /* BarChartData.swift */,
559DB735FEA17AB90676D6CA /* BarLineScatterCandleBubbleChartData.swift */,
7EDA3AD550AEFC93C8D15B9C /* BubbleChartData.swift */,
F4785FEACAE4367F36FB8868 /* CandleChartData.swift */,
E120E76C6F1B5877D56126DD /* ChartData.swift */,
0DDE409E9ECF54D2C146A6F0 /* CombinedChartData.swift */,
4C978F31F23C7D21197DC2A1 /* LineChartData.swift */,
6E03A4987F72414A02A0631B /* PieChartData.swift */,
4BBB57D6FA41029B08F26D7B /* RadarChartData.swift */,
E7AD2FC320A16CA1EE0A52F4 /* ScatterChartData.swift */,
);
name = ChartData;
sourceTree = "<group>";
};
22C014232006FFFA00D5B025 /* ChartEntry */ = {
isa = PBXGroup;
children = (
E3F8BFF1CBC58D5B9DBFFB9B /* BarChartDataEntry.swift */,
DD8ED233775EEC31243A6919 /* BubbleChartDataEntry.swift */,
D2E698FF540029B70AC97AD7 /* CandleChartDataEntry.swift */,
F22750328058DEC2F019646F /* ChartDataEntry.swift */,
12409C3EA15787C11AF0D2BC /* ChartDataEntryBase.swift */,
BD02157CF8CEE1189BF681DA /* PieChartDataEntry.swift */,
91EEEDE2AB8F2DA3AFCF0733 /* RadarChartDataEntry.swift */,
);
name = ChartEntry;
sourceTree = "<group>";
};
2647844720BC6574A544A337 /* Charts */ = {
isa = PBXGroup;
children = (
Expand All @@ -427,13 +460,23 @@
name = Charts;
sourceTree = "<group>";
};
3B9DD76FCE8D873300A822C7 /* Implementations */ = {
3B9DD76FCE8D873300A822C7 /* ChartDataSet */ = {
isa = PBXGroup;
children = (
C9FE42E868A225C116537368 /* ChartBaseDataSet.swift */,
740017197A160047EBB8A9A0 /* Standard */,
C31AA65EA27776F8C653C7E8 /* BarChartDataSet.swift */,
6D717F0808DE7EC8A4AE9C2A /* BarLineScatterCandleBubbleChartDataSet.swift */,
B44829AF0ADA583F1F0279B7 /* BubbleChartDataSet.swift */,
274116834B1B0345D622E027 /* CandleChartDataSet.swift */,
6CEC0C69C89CE9B99F3B4409 /* ChartDataSet.swift */,
A5A75AA73C5AA381DA517959 /* LineChartDataSet.swift */,
45E31A4356CC6F283C29954B /* LineRadarChartDataSet.swift */,
C58BD7B14BEA440783ED8D2B /* LineScatterCandleRadarChartDataSet.swift */,
A4FB5E3761EF8B4D1E1E1014 /* PieChartDataSet.swift */,
B1BA6B21CBDF77A15848994F /* RadarChartDataSet.swift */,
CB1DD1A0F64266A10EE94194 /* ScatterChartDataSet.swift */,
);
name = Implementations;
name = ChartDataSet;
sourceTree = "<group>";
};
42824E1F334B0C484AF4C594 /* Highlight */ = {
Expand Down Expand Up @@ -471,41 +514,6 @@
name = Components;
sourceTree = "<group>";
};
740017197A160047EBB8A9A0 /* Standard */ = {
isa = PBXGroup;
children = (
0108D5925E21A47DA36A66AA /* BarChartData.swift */,
E3F8BFF1CBC58D5B9DBFFB9B /* BarChartDataEntry.swift */,
C31AA65EA27776F8C653C7E8 /* BarChartDataSet.swift */,
559DB735FEA17AB90676D6CA /* BarLineScatterCandleBubbleChartData.swift */,
6D717F0808DE7EC8A4AE9C2A /* BarLineScatterCandleBubbleChartDataSet.swift */,
7EDA3AD550AEFC93C8D15B9C /* BubbleChartData.swift */,
DD8ED233775EEC31243A6919 /* BubbleChartDataEntry.swift */,
B44829AF0ADA583F1F0279B7 /* BubbleChartDataSet.swift */,
F4785FEACAE4367F36FB8868 /* CandleChartData.swift */,
D2E698FF540029B70AC97AD7 /* CandleChartDataEntry.swift */,
274116834B1B0345D622E027 /* CandleChartDataSet.swift */,
E120E76C6F1B5877D56126DD /* ChartData.swift */,
F22750328058DEC2F019646F /* ChartDataEntry.swift */,
12409C3EA15787C11AF0D2BC /* ChartDataEntryBase.swift */,
6CEC0C69C89CE9B99F3B4409 /* ChartDataSet.swift */,
0DDE409E9ECF54D2C146A6F0 /* CombinedChartData.swift */,
4C978F31F23C7D21197DC2A1 /* LineChartData.swift */,
A5A75AA73C5AA381DA517959 /* LineChartDataSet.swift */,
45E31A4356CC6F283C29954B /* LineRadarChartDataSet.swift */,
C58BD7B14BEA440783ED8D2B /* LineScatterCandleRadarChartDataSet.swift */,
6E03A4987F72414A02A0631B /* PieChartData.swift */,
BD02157CF8CEE1189BF681DA /* PieChartDataEntry.swift */,
A4FB5E3761EF8B4D1E1E1014 /* PieChartDataSet.swift */,
4BBB57D6FA41029B08F26D7B /* RadarChartData.swift */,
91EEEDE2AB8F2DA3AFCF0733 /* RadarChartDataEntry.swift */,
B1BA6B21CBDF77A15848994F /* RadarChartDataSet.swift */,
E7AD2FC320A16CA1EE0A52F4 /* ScatterChartData.swift */,
CB1DD1A0F64266A10EE94194 /* ScatterChartDataSet.swift */,
);
name = Standard;
sourceTree = "<group>";
};
74A391010038924F637D6752 /* Formatters */ = {
isa = PBXGroup;
children = (
Expand Down
2 changes: 1 addition & 1 deletion ChartsDemo-iOS/Objective-C/DemoBaseViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ - (void)handleOption:(NSString *)key forChartView:(ChartViewBase *)chartView

if ([key isEqualToString:@"toggleHighlight"])
{
chartView.data.highlightEnabled = !chartView.data.isHighlightEnabled;
chartView.data.isHighlightEnabled = !chartView.data.isHighlightEnabled;
[chartView setNeedsDisplay];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ - (void)viewDidLoad

- (void)setupChart:(LineChartView *)chart data:(LineChartData *)data color:(UIColor *)color
{
[(LineChartDataSet *)[data getDataSetByIndex:0] setCircleHoleColor:color];
[(LineChartDataSet *)[data dataSetAtIndex:0] setCircleHoleColor:color];

chart.delegate = self;
chart.backgroundColor = color;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ - (void)optionTapped:(NSString *)key
if ([key isEqualToString:@"removeDataSet"])
{
int rnd = (int)arc4random_uniform((float)_chartView.data.dataSetCount);
[_chartView.data removeDataSet:[_chartView.data getDataSetByIndex:rnd]];
[_chartView.data removeDataSet:[_chartView.data dataSetAtIndex:rnd]];
[_chartView.data notifyDataChanged];
[_chartView notifyDataSetChanged];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ - (void)chartValueSelected:(ChartViewBase * __nonnull)chartView entry:(ChartData
{
NSLog(@"chartValueSelected");

[_chartView centerViewToAnimatedWithXValue:entry.x yValue:entry.y axis:[_chartView.data getDataSetByIndex:highlight.dataSetIndex].axisDependency duration:1.0];
[_chartView centerViewToAnimatedWithXValue:entry.x yValue:entry.y axis:[_chartView.data dataSetAtIndex:highlight.dataSetIndex].axisDependency duration:1.0];
//[_chartView moveViewToAnimatedWithXValue:entry.x yValue:entry.y axis:[_chartView.data getDataSetByIndex:dataSetIndex].axisDependency duration:1.0];
//[_chartView zoomAndCenterViewAnimatedWithScaleX:1.8 scaleY:1.8 xValue:entry.x yValue:entry.y axis:[_chartView.data getDataSetByIndex:dataSetIndex].axisDependency duration:1.0];

Expand Down
2 changes: 1 addition & 1 deletion ChartsDemo-iOS/Swift/DemoBaseViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ class DemoBaseViewController: UIViewController, ChartViewDelegate {
chartView.setNeedsDisplay()

case .toggleHighlight:
chartView.data!.highlightEnabled = !chartView.data!.isHighlightEnabled
chartView.data!.isHighlightEnabled = !chartView.data!.isHighlightEnabled
chartView.setNeedsDisplay()

case .animateX:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class ColoredLineChartViewController: DemoBaseViewController {
}

func setupChart(_ chart: LineChartView, data: LineChartData, color: UIColor) {
(data.getDataSetByIndex(0) as! LineChartDataSet).circleHoleColor = color
(data[0] as! LineChartDataSet).circleHoleColor = color

chart.delegate = self
chart.backgroundColor = color
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class CombinedChartViewController: DemoBaseViewController {

case .removeDataSet:
let rnd = Int(arc4random_uniform(UInt32(chartView.data!.dataSetCount)))
chartView.data?.removeDataSet(chartView.data!.getDataSetByIndex(rnd))
chartView.data?.removeDataSet(chartView.data![rnd])
chartView.data?.notifyDataChanged()
chartView.notifyDataSetChanged()

Expand Down
2 changes: 1 addition & 1 deletion ChartsDemo-iOS/Swift/Demos/LineChart2ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ class LineChart2ViewController: DemoBaseViewController {
super.chartValueSelected(chartView, entry: entry, highlight: highlight)

self.chartView.centerViewToAnimated(xValue: entry.x, yValue: entry.y,
axis: self.chartView.data!.getDataSetByIndex(highlight.dataSetIndex).axisDependency,
axis: self.chartView.data![highlight.dataSetIndex].axisDependency,
duration: 1)
//[_chartView moveViewToAnimatedWithXValue:entry.x yValue:entry.y axis:[_chartView.data getDataSetByIndex:dataSetIndex].axisDependency duration:1.0];
//[_chartView zoomAndCenterViewAnimatedWithScaleX:1.8 scaleY:1.8 xValue:entry.x yValue:entry.y axis:[_chartView.data getDataSetByIndex:dataSetIndex].axisDependency duration:1.0];
Expand Down
4 changes: 2 additions & 2 deletions ChartsDemo-macOS/ChartsDemo-macOS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@
CODE_SIGN_STYLE = Manual;
COMBINE_HIDPI_IMAGES = YES;
DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = "ChartsDemo-OSX/Info.plist";
INFOPLIST_FILE = "$(SRCROOT)/ChartsDemo-macOS/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.dcg.ChartsDemo-OSX";
PRODUCT_NAME = "$(TARGET_NAME)";
Expand All @@ -389,7 +389,7 @@
CODE_SIGN_STYLE = Manual;
COMBINE_HIDPI_IMAGES = YES;
DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = "ChartsDemo-OSX/Info.plist";
INFOPLIST_FILE = "$(SRCROOT)/ChartsDemo-macOS/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.dcg.ChartsDemo-OSX";
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down
4 changes: 2 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ def devices
},
tvOS: {
sdk: 'appletvsimulator',
device: "name='Apple TV 1080p'",
name: 'Apple TV 1080p'
device: "name='Apple TV'",
name: 'Apple TV'
}
}
end
Expand Down
4 changes: 2 additions & 2 deletions Source/Charts/Charts/BarLineChartViewBase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1675,7 +1675,7 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD
{
if let h = getHighlightByTouchPoint(pt)
{
return data!.entryForHighlight(h)
return data!.entry(for: h)
}
return nil
}
Expand All @@ -1686,7 +1686,7 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD
let h = getHighlightByTouchPoint(pt)
if h !== nil
{
return data?.getDataSetByIndex(h!.dataSetIndex) as! BarLineScatterCandleBubbleChartDataSetProtocol
return data?[h!.dataSetIndex] as! BarLineScatterCandleBubbleChartDataSetProtocol
}
return nil
}
Expand Down
16 changes: 8 additions & 8 deletions Source/Charts/Charts/ChartViewBase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ open class ChartViewBase: NSUIView, ChartDataProvider, AnimatorDelegate
guard let data = data else { return }

// calculate how many digits are needed
setupDefaultFormatter(min: data.getYMin(), max: data.getYMax())
setupDefaultFormatter(min: data.yMin, max: data.yMax)

for set in data.dataSets
{
Expand Down Expand Up @@ -411,14 +411,14 @@ open class ChartViewBase: NSUIView, ChartDataProvider, AnimatorDelegate
Swift.print("Value not highlighted because data is nil")
return
}
if dataSetIndex < 0 || dataSetIndex >= data.dataSetCount

if data.indices.contains(dataSetIndex)
{
highlightValue(nil, callDelegate: callDelegate)
highlightValue(Highlight(x: x, y: y, dataSetIndex: dataSetIndex, dataIndex: dataIndex), callDelegate: callDelegate)
}
else
{
highlightValue(Highlight(x: x, y: y, dataSetIndex: dataSetIndex, dataIndex: dataIndex), callDelegate: callDelegate)
highlightValue(nil, callDelegate: callDelegate)
}
}

Expand All @@ -436,7 +436,7 @@ open class ChartViewBase: NSUIView, ChartDataProvider, AnimatorDelegate
var high = highlight
guard
let h = high,
let entry = data?.entryForHighlight(h)
let entry = data?.entry(for: h)
else
{
high = nil
Expand Down Expand Up @@ -493,8 +493,8 @@ open class ChartViewBase: NSUIView, ChartDataProvider, AnimatorDelegate
for highlight in highlighted
{
guard
let set = data?.getDataSetByIndex(highlight.dataSetIndex),
let e = data?.entryForHighlight(highlight)
let set = data?[highlight.dataSetIndex],
let e = data?.entry(for: highlight)
else { continue }

let entryIndex = set.entryIndex(entry: e)
Expand Down
2 changes: 1 addition & 1 deletion Source/Charts/Charts/CombinedChartView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ open class CombinedChartView: BarLineChartViewBase, CombinedChartDataProvider

guard
let set = combinedData?.getDataSetByHighlight(highlight),
let e = data?.entryForHighlight(highlight)
let e = data?.entry(for: highlight)
else { continue }

let entryIndex = set.entryIndex(entry: e)
Expand Down
5 changes: 1 addition & 4 deletions Source/Charts/Charts/PieChartView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -194,14 +194,11 @@ open class PieChartView: PieRadarChartViewBase
_absoluteAngles.reserveCapacity(entryCount)

let yValueSum = (data as! PieChartData).yValueSum

var dataSets = data.dataSets

var cnt = 0

for i in 0 ..< data.dataSetCount
for set in data
{
let set = dataSets[i]
let entryCount = set.entryCount

for j in 0 ..< entryCount
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ open class BarChartData: BarLineScatterCandleBubbleChartData
super.init()
}

public override init(dataSets: [ChartDataSetProtocol]?)
public override init(dataSets: [ChartDataSetProtocol])
{
super.init(dataSets: dataSets)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ open class BarLineScatterCandleBubbleChartData: ChartData
super.init()
}

public override init(dataSets: [ChartDataSetProtocol]?)
public override init(dataSets: [ChartDataSetProtocol])
{
super.init(dataSets: dataSets)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ open class BubbleChartData: BarLineScatterCandleBubbleChartData
super.init()
}

public override init(dataSets: [ChartDataSetProtocol]?)
public override init(dataSets: [ChartDataSetProtocol])
{
super.init(dataSets: dataSets)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ open class CandleChartData: BarLineScatterCandleBubbleChartData
super.init()
}

public override init(dataSets: [ChartDataSetProtocol]?)
public override init(dataSets: [ChartDataSetProtocol])
{
super.init(dataSets: dataSets)
}
Expand Down
Loading