diff --git a/.travis.yml b/.travis.yml index 57d310f8df..9f8be9f73b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,11 +2,11 @@ language: objective-c osx_image: xcode10 matrix: include: - - osx_image: xcode10 + - osx_image: xcode10.2 env: PLATFORM="iOS" - - osx_image: xcode10 + - osx_image: xcode10.2 env: PLATFORM="tvOS" - - osx_image: xcode10 + - osx_image: xcode10.2 env: PLATFORM="macOS" env: global: diff --git a/CHANGELOG.md b/CHANGELOG.md index ec57242a8b..e45f888907 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,280 @@ # Change Log +## [v3.3](https://github.com/danielgindi/Charts/tree/v3.3) (2019-04-15) +[Full Changelog](https://github.com/danielgindi/Charts/compare/v3.2.2...v3.3) + +**Implemented enhancements:** + +- Renamed `values` to `entries` to reflect the property's type [\#3847](https://github.com/danielgindi/Charts/pull/3847) ([jjatie](https://github.com/jjatie)) + +**Fixed bugs:** + +- Pie chart with vertical orientation clips last legend entry [\#3860](https://github.com/danielgindi/Charts/issues/3860) + +**Closed issues:** + +- the first point of LineChartView is not displayed, and so is demo [\#3938](https://github.com/danielgindi/Charts/issues/3938) +- How can i get CenterEntry in the View when i setted the MaxVisibleRange? [\#3925](https://github.com/danielgindi/Charts/issues/3925) +- EXC\_BAD\_ACCESS error on PieChart [\#3923](https://github.com/danielgindi/Charts/issues/3923) +- The first dot doesn't show up when I use lineChart [\#3915](https://github.com/danielgindi/Charts/issues/3915) +- Swift 5 Support w/ Cocoapods [\#3913](https://github.com/danielgindi/Charts/issues/3913) +- HOW to create pie chart like below image . https://user-images.githubusercontent.com/20434573/54804603-1d31fa80-4c9a-11e9-9960-00cf7c7d117d.png [\#3908](https://github.com/danielgindi/Charts/issues/3908) +- x Axis grid line origin is wrong ! maybe a bug, anxious!!! [\#3904](https://github.com/danielgindi/Charts/issues/3904) +- why not use CAShapeLayer? [\#3903](https://github.com/danielgindi/Charts/issues/3903) +- Chart legend [\#3896](https://github.com/danielgindi/Charts/issues/3896) +- Wrong values from pixelForValues [\#3895](https://github.com/danielgindi/Charts/issues/3895) +- Cannot set labels for RadarChart [\#3893](https://github.com/danielgindi/Charts/issues/3893) +- I can't migrate the swift files\(combined chart\) in objective c project. Could please share the objective c code fully. Thanks in advance. [\#3890](https://github.com/danielgindi/Charts/issues/3890) +- Draw circle only on last value [\#3887](https://github.com/danielgindi/Charts/issues/3887) +- Mismatch left axis maximum and minimum values [\#3886](https://github.com/danielgindi/Charts/issues/3886) +- How to animate? start poisiton is not from zero. [\#3885](https://github.com/danielgindi/Charts/issues/3885) +- I want to change line chart fill colours [\#3882](https://github.com/danielgindi/Charts/issues/3882) +- Circle view is not showing for first point of line chart [\#3881](https://github.com/danielgindi/Charts/issues/3881) +- support ECG demo? [\#3880](https://github.com/danielgindi/Charts/issues/3880) +- How to remove the values given outside the circle in piechart [\#3878](https://github.com/danielgindi/Charts/issues/3878) +- file was built for x86\_64 which is not the architecture being linked \(arm64\):error: linker command failed with exit code 1 \(use -v to see invocation\) [\#3877](https://github.com/danielgindi/Charts/issues/3877) +- Clipping first and last circle from line chart IOS. [\#3873](https://github.com/danielgindi/Charts/issues/3873) +- Smoothly moving a slowly changing linechart [\#3859](https://github.com/danielgindi/Charts/issues/3859) +- Monthly X-Axis labels \(corresponding values\) in my LineChart are not at the right position [\#3858](https://github.com/danielgindi/Charts/issues/3858) +- CandleChart do not render the first candle in CombineChartView [\#3857](https://github.com/danielgindi/Charts/issues/3857) +- Have 2 or more tresholds for one graph [\#3856](https://github.com/danielgindi/Charts/issues/3856) +- Unexpected crash on 3.2.2 [\#3855](https://github.com/danielgindi/Charts/issues/3855) +- How to change the display of legends? [\#3853](https://github.com/danielgindi/Charts/issues/3853) +- I want to call a method after the chart has been dragged and stopped. How can I detect it and the chart has stopped? [\#3851](https://github.com/danielgindi/Charts/issues/3851) +- HorizontalBarChartView bar negative values position [\#3850](https://github.com/danielgindi/Charts/issues/3850) +- charts 有数据创建图表后,点击按钮将数据置为空则崩溃 [\#3849](https://github.com/danielgindi/Charts/issues/3849) +- No circle is drawn on a line chart when there is only one data. \(version 3.2.2 only\) [\#3848](https://github.com/danielgindi/Charts/issues/3848) +- slice color [\#3844](https://github.com/danielgindi/Charts/issues/3844) +- BarChartView showing consecutive values in xAxis [\#3843](https://github.com/danielgindi/Charts/issues/3843) +- How to hide those icons? [\#3842](https://github.com/danielgindi/Charts/issues/3842) +- Swift 4.2: 'values' is deprecated Warnings [\#3840](https://github.com/danielgindi/Charts/issues/3840) +- Y-axis values draw error [\#3837](https://github.com/danielgindi/Charts/issues/3837) +- Horizontal Bar Chart Value Labels Cut Off [\#3836](https://github.com/danielgindi/Charts/issues/3836) +- The right Y axis displays incorrect values that does not fit the chart [\#3835](https://github.com/danielgindi/Charts/issues/3835) +- How to align labels on left side and put values inside bars on HorizontalBarChartView? \[HELP WANTED\] [\#3833](https://github.com/danielgindi/Charts/issues/3833) +- How to show the tooltip like value when clicked on candle of candleStick chart [\#3832](https://github.com/danielgindi/Charts/issues/3832) +- In line chart, can I make all labels in Chart area even with changing yOffset? [\#3829](https://github.com/danielgindi/Charts/issues/3829) +- Multiline value labels on BarChart. [\#3826](https://github.com/danielgindi/Charts/issues/3826) +- how can I spin the selected slice of piechart to top. [\#3825](https://github.com/danielgindi/Charts/issues/3825) +- Update Cocoapods [\#3773](https://github.com/danielgindi/Charts/issues/3773) +- Select circles on line chart [\#3307](https://github.com/danielgindi/Charts/issues/3307) + +**Merged pull requests:** + +- Fix horizontal bar chart not drawing values and add unit tests [\#3906](https://github.com/danielgindi/Charts/pull/3906) ([liuxuan30](https://github.com/liuxuan30)) +- fix \#3860. maxHeight didn't count the last label [\#3900](https://github.com/danielgindi/Charts/pull/3900) ([liuxuan30](https://github.com/liuxuan30)) +- Migrating to built-in algorithms [\#3892](https://github.com/danielgindi/Charts/pull/3892) ([jjatie](https://github.com/jjatie)) +- Use a stock iterator instead of a custom one. [\#3891](https://github.com/danielgindi/Charts/pull/3891) ([phughes](https://github.com/phughes)) +- Removed unnecessary \#if statements and unified style to align with Xc… [\#3884](https://github.com/danielgindi/Charts/pull/3884) ([jjatie](https://github.com/jjatie)) +- Velocity samples calculation [\#3883](https://github.com/danielgindi/Charts/pull/3883) ([jjatie](https://github.com/jjatie)) +- Minor updates for Swift 5 [\#3874](https://github.com/danielgindi/Charts/pull/3874) ([jjatie](https://github.com/jjatie)) +- Replace AnyObject with Any [\#3864](https://github.com/danielgindi/Charts/pull/3864) ([jjatie](https://github.com/jjatie)) +- Data as any [\#3863](https://github.com/danielgindi/Charts/pull/3863) ([jjatie](https://github.com/jjatie)) +- Reassess convenience initializers [\#3862](https://github.com/danielgindi/Charts/pull/3862) ([jjatie](https://github.com/jjatie)) +- HorizontalBarChar value label offset calculation [\#3854](https://github.com/danielgindi/Charts/pull/3854) ([chaaarly](https://github.com/chaaarly)) +- Create `chartViewDidEndAnimate` in ChartViewDelegate [\#3852](https://github.com/danielgindi/Charts/pull/3852) ([Lcsmarcal](https://github.com/Lcsmarcal)) +- Align `ChartLimit.LabelPosition` naming with `UIRectCorner` [\#3846](https://github.com/danielgindi/Charts/pull/3846) ([jjatie](https://github.com/jjatie)) + +## [v3.2.2](https://github.com/danielgindi/Charts/tree/v3.2.2) (2019-02-13) +[Full Changelog](https://github.com/danielgindi/Charts/compare/v3.2.1...v3.2.2) + +**Implemented enhancements:** + +- 【PieChart】Please support multiple colors for valueline. [\#3480](https://github.com/danielgindi/Charts/issues/3480) + +**Fixed bugs:** + +- CombinedChartView's candleData don't display in v3.2.0 [\#3662](https://github.com/danielgindi/Charts/issues/3662) +- Incorrect behavior for AxisBase.axisMaxLabels [\#3656](https://github.com/danielgindi/Charts/issues/3656) +- Horizontal Bar Chart legend issue [\#3301](https://github.com/danielgindi/Charts/issues/3301) + +**Closed issues:** + +- barchartview draw value in bottom of chart [\#3827](https://github.com/danielgindi/Charts/issues/3827) +- Regarding to label of axis, I think it displays .03 instead of 0.03 [\#3824](https://github.com/danielgindi/Charts/issues/3824) +- Bar Chart Not Showing Colours Correctly [\#3823](https://github.com/danielgindi/Charts/issues/3823) +- Pie Chart on click show value on label. Does anyone know how to do it? [\#3822](https://github.com/danielgindi/Charts/issues/3822) +- chartTranslated in a Pie Chart is not called [\#3821](https://github.com/danielgindi/Charts/issues/3821) +- Issue creating a simple line chart [\#3820](https://github.com/danielgindi/Charts/issues/3820) +- How to save image of scrollable graph [\#3819](https://github.com/danielgindi/Charts/issues/3819) +- Candle charts not showing candles on swift 4.2 [\#3818](https://github.com/danielgindi/Charts/issues/3818) +- How to get a value from line graph if there is more than one lines [\#3817](https://github.com/danielgindi/Charts/issues/3817) +- Multiple colors for the same line [\#3816](https://github.com/danielgindi/Charts/issues/3816) +- Memory Leaks in subclass of LineChartView [\#3813](https://github.com/danielgindi/Charts/issues/3813) +- Distortion When Animating Height of Auto Layout `LineChartView` [\#3811](https://github.com/danielgindi/Charts/issues/3811) +- How to show break in line chart for more than one graph? [\#3810](https://github.com/danielgindi/Charts/issues/3810) +- PIE Chart Colors not properly set [\#3809](https://github.com/danielgindi/Charts/issues/3809) +- A Question to contribution [\#3808](https://github.com/danielgindi/Charts/issues/3808) +- When y value is equal ,HorizontalBarChartView only show integer [\#3806](https://github.com/danielgindi/Charts/issues/3806) +- Highlight per drag not working! [\#3805](https://github.com/danielgindi/Charts/issues/3805) +- chartTranslated is called when no translation happened [\#3803](https://github.com/danielgindi/Charts/issues/3803) +- Xcode10 real machine operation error! [\#3802](https://github.com/danielgindi/Charts/issues/3802) +- Bar Width issue after reset the data [\#3801](https://github.com/danielgindi/Charts/issues/3801) +- Performance issue: drawCircles\(context: CGContext\) in LineChart [\#3798](https://github.com/danielgindi/Charts/issues/3798) +- LineChartView Y-Aixs label'number inaccuracy [\#3794](https://github.com/danielgindi/Charts/issues/3794) +- charts在特定范围内的参考坐标精度问题 [\#3793](https://github.com/danielgindi/Charts/issues/3793) +- Change chart legend show order [\#3791](https://github.com/danielgindi/Charts/issues/3791) +- hello,I don't want to display the pie chart by zero percent. How can I do this [\#3790](https://github.com/danielgindi/Charts/issues/3790) +- how to center legend text of LineChartView? [\#3789](https://github.com/danielgindi/Charts/issues/3789) +- How to Plot only for the available x axis and leave the rest of the x axis blank? [\#3788](https://github.com/danielgindi/Charts/issues/3788) +- Custom chart marker [\#3787](https://github.com/danielgindi/Charts/issues/3787) +- How to shift xAxis values to right? [\#3785](https://github.com/danielgindi/Charts/issues/3785) +- How to disable Accessibility support? [\#3782](https://github.com/danielgindi/Charts/issues/3782) +- Feature: Add option to draw limit lines on top of data [\#3781](https://github.com/danielgindi/Charts/issues/3781) +- Legend spacing issue with LineChart and colors\[\] [\#3780](https://github.com/danielgindi/Charts/issues/3780) +- How to change value line length for each value in pieChartView [\#3776](https://github.com/danielgindi/Charts/issues/3776) +- Crash on the function isDrawingValuesAllowed [\#3772](https://github.com/danielgindi/Charts/issues/3772) +- How to let y axis line show same space when axisMinimum = 0? [\#3771](https://github.com/danielgindi/Charts/issues/3771) +- Xcode 10.1 pod install Charts open project error!!! [\#3769](https://github.com/danielgindi/Charts/issues/3769) +- Is it possible to make some gaps on a same line plot? [\#3765](https://github.com/danielgindi/Charts/issues/3765) +- Is it possible to draw custom shape on chart and handle touch on it [\#3763](https://github.com/danielgindi/Charts/issues/3763) +- Start slice automatically seleted in pie chart [\#3762](https://github.com/danielgindi/Charts/issues/3762) +- How to change color when press down on pie chart? [\#3761](https://github.com/danielgindi/Charts/issues/3761) +- notifyDataSetChanged\(\) crash when datapoint is highlighted in LineChartView [\#3759](https://github.com/danielgindi/Charts/issues/3759) +- BarChartView display half in first bar when change from group bar to bar only [\#3757](https://github.com/danielgindi/Charts/issues/3757) +- Description of Bar doesn't appear in Horizontal BarChartView [\#3756](https://github.com/danielgindi/Charts/issues/3756) +- Chart spacing between xAxis Labels [\#3755](https://github.com/danielgindi/Charts/issues/3755) +- Granularity makes my app crash because require index from zero [\#3753](https://github.com/danielgindi/Charts/issues/3753) +- this counter will make your app being crash in particular case [\#3752](https://github.com/danielgindi/Charts/issues/3752) +- Bar Chart Drawing is wrong without setting axisminimum [\#3751](https://github.com/danielgindi/Charts/issues/3751) +- Help needed - in changing the position for Piechart in SWIFT [\#3749](https://github.com/danielgindi/Charts/issues/3749) +- When using CombinedChartView, CandleChartData cannot be displayed [\#3748](https://github.com/danielgindi/Charts/issues/3748) +- Linear chart line with different thickness of direction [\#3746](https://github.com/danielgindi/Charts/issues/3746) +- I want to try a lot of line charts corresponding to the X axis is different, how can I achieve it. [\#3745](https://github.com/danielgindi/Charts/issues/3745) +- 折线图-具体时间的数据绘制进图表问题 [\#3743](https://github.com/danielgindi/Charts/issues/3743) +- Changing lineCap doesn't work when mode is not linear/stepped [\#3739](https://github.com/danielgindi/Charts/issues/3739) +- Reverse Pie Chart animation [\#3738](https://github.com/danielgindi/Charts/issues/3738) +- How to create y-axis for empty label ? [\#3735](https://github.com/danielgindi/Charts/issues/3735) +- Different colors for above and below 0 when filling a Line Chart [\#3733](https://github.com/danielgindi/Charts/issues/3733) +- How to adding multiple lines to Line Chart for swift 4.0? [\#3732](https://github.com/danielgindi/Charts/issues/3732) +- How to format y-values drawn on bar? [\#3731](https://github.com/danielgindi/Charts/issues/3731) +- how to moveViewToX and not calling setNeedsDisplay\(\) [\#3730](https://github.com/danielgindi/Charts/issues/3730) +- When using CombinedChartView, CandleChartData cannot be displayed [\#3729](https://github.com/danielgindi/Charts/issues/3729) +- Need Help. How to show labels in xAxis for GroupedBarChart? [\#3728](https://github.com/danielgindi/Charts/issues/3728) +- Force axis granularity [\#3727](https://github.com/danielgindi/Charts/issues/3727) +- Y decimal values error [\#3725](https://github.com/danielgindi/Charts/issues/3725) +- if i have 840entrys how can i set the xaxis what i want .e.g i only want to show the 0 and 840 [\#3723](https://github.com/danielgindi/Charts/issues/3723) +- if i have 840entrys how can i set the xaxis what i want .e.g i only want to show the 0 and 840 [\#3722](https://github.com/danielgindi/Charts/issues/3722) +- Align both right and left axis in the same line [\#3720](https://github.com/danielgindi/Charts/issues/3720) +- The `open var noDataTextAlignment: NSTextAlignment = .left` is missing the `@objc` so it's not exposed in Objective C. [\#3719](https://github.com/danielgindi/Charts/issues/3719) +- How to hide bottom colors & label section in Bar Chat [\#3718](https://github.com/danielgindi/Charts/issues/3718) +- Draw Line chart for non linear X-axis [\#3717](https://github.com/danielgindi/Charts/issues/3717) +- Any way to adjust the candle bar width? [\#3716](https://github.com/danielgindi/Charts/issues/3716) +- xAxis grid line in-between bar rather than center of bar [\#3713](https://github.com/danielgindi/Charts/issues/3713) +- Bubble Chart is not rendering [\#3711](https://github.com/danielgindi/Charts/issues/3711) +- Bubble Chart is not rendering [\#3710](https://github.com/danielgindi/Charts/issues/3710) +- \[Feature request\] Continue line chart beyond x-axis limits [\#3708](https://github.com/danielgindi/Charts/issues/3708) +- Use of unresolved identifier 'UIAccessibility' & Type 'UIAccessibilityTraits' \(aka 'UInt64'\) has no member 'header' [\#3707](https://github.com/danielgindi/Charts/issues/3707) +- How to draw a line chart in sections? [\#3706](https://github.com/danielgindi/Charts/issues/3706) +- \[Feature / Help\] Resize Chart based on data visibility [\#3705](https://github.com/danielgindi/Charts/issues/3705) +- \[Request / Help\] Resize Chart based on hidden / shown lines [\#3704](https://github.com/danielgindi/Charts/issues/3704) +- listening for click events in pieChartView [\#3703](https://github.com/danielgindi/Charts/issues/3703) +- How to add Strings on Left Axis in iOS-charts? [\#3702](https://github.com/danielgindi/Charts/issues/3702) +- \[Charts.BarChartDataSet setDrawIconsEnabled:\]: unrecognized selector sent to instance [\#3700](https://github.com/danielgindi/Charts/issues/3700) +- How can I set xAxis to second line? [\#3698](https://github.com/danielgindi/Charts/issues/3698) +- Add to OC project and the api is so big, How to solve this problem [\#3697](https://github.com/danielgindi/Charts/issues/3697) +- How can I call func stringForValue\(\_ value: Double, axis: AxisBase?\) -\> String [\#3696](https://github.com/danielgindi/Charts/issues/3696) +- Line chart, slide left and right to see more data? How to set it up [\#3693](https://github.com/danielgindi/Charts/issues/3693) +- Value for SWIFT\_VERSION cannot be empty. \(in target 'Charts'\) [\#3692](https://github.com/danielgindi/Charts/issues/3692) +- how to make a combine chart \(line chart + bar chart\) with leftAxis taking the top half area of the combined graph and right axis taking the bottom half [\#3690](https://github.com/danielgindi/Charts/issues/3690) +- is there any library for Gantt chart in ios swift ? please suggest me a solution..... [\#3688](https://github.com/danielgindi/Charts/issues/3688) +- Integrated to xcode10 crash [\#3687](https://github.com/danielgindi/Charts/issues/3687) +- XCode 10 app crash. [\#3686](https://github.com/danielgindi/Charts/issues/3686) +- Getting Errors in Xcode 9.2 [\#3684](https://github.com/danielgindi/Charts/issues/3684) +- How to show double vale with string in y-axis [\#3683](https://github.com/danielgindi/Charts/issues/3683) +- When I have a lot of data, how can I slide to the far right by default? [\#3682](https://github.com/danielgindi/Charts/issues/3682) +- Pie Chart - Slices are not drawn and values are overlapping [\#3679](https://github.com/danielgindi/Charts/issues/3679) +- setVisibleXRangeMaximum is behaving unexpectedly [\#3678](https://github.com/danielgindi/Charts/issues/3678) +- Getting issues after pod update. [\#3677](https://github.com/danielgindi/Charts/issues/3677) +- Pie chart and gradient [\#3674](https://github.com/danielgindi/Charts/issues/3674) +- CandleStickChartRenderer drawDataSet method does not work with CombinedChartView [\#3673](https://github.com/danielgindi/Charts/issues/3673) +- How to Hide Text? [\#3672](https://github.com/danielgindi/Charts/issues/3672) +- Memory leaks were detected also in the demo project [\#3671](https://github.com/danielgindi/Charts/issues/3671) +- Can't add two pie charts in a uiviewcontroller at same time [\#3670](https://github.com/danielgindi/Charts/issues/3670) +- ChartData ValueTextColor can not achieve a variety of colors [\#3669](https://github.com/danielgindi/Charts/issues/3669) +- PieChartView settings color is Invalid [\#3668](https://github.com/danielgindi/Charts/issues/3668) +- DrawValuesEnabled variable unreachable \(Swift 4.2\) [\#3665](https://github.com/danielgindi/Charts/issues/3665) +- Failed to verify bitcode in Charts.framework [\#3663](https://github.com/danielgindi/Charts/issues/3663) +- \[3.2.0\] Excessive Memory leaks in Swift 4.2 related to LineChartView, not present in 3.1.1 w/Swift 4 [\#3649](https://github.com/danielgindi/Charts/issues/3649) +- BarChart - xAxis Labels disappear if not a min of 2 on the screen [\#2854](https://github.com/danielgindi/Charts/issues/2854) +- 柱状图一直横向拉伸, 持续差不多 15s 就崩溃了 [\#2642](https://github.com/danielgindi/Charts/issues/2642) +- Any one try to integrate with SpriteKit/SKScene ? [\#2129](https://github.com/danielgindi/Charts/issues/2129) + +**Merged pull requests:** + +- Add Collection conformances to ChartDataSet types [\#3815](https://github.com/danielgindi/Charts/pull/3815) ([jjatie](https://github.com/jjatie)) +- Fix condition that is checked before `chartTranslated` delegate method call [\#3804](https://github.com/danielgindi/Charts/pull/3804) ([anton-filimonov](https://github.com/anton-filimonov)) +- fix \#3719 [\#3778](https://github.com/danielgindi/Charts/pull/3778) ([liuxuan30](https://github.com/liuxuan30)) +- Turned gradient components and locations into constants [\#3775](https://github.com/danielgindi/Charts/pull/3775) ([jjatie](https://github.com/jjatie)) +- add chartScaled\(\) call after double tap in BarLineChartViewBase [\#3770](https://github.com/danielgindi/Charts/pull/3770) ([artemiusmk](https://github.com/artemiusmk)) +- Fixes sharp edges on the line chart [\#3764](https://github.com/danielgindi/Charts/pull/3764) ([stokatyan](https://github.com/stokatyan)) +- Fix applying lineCap value for line chart data sets \(Fixes \#3739\) [\#3740](https://github.com/danielgindi/Charts/pull/3740) ([anton-filimonov](https://github.com/anton-filimonov)) +- Update README.md [\#3737](https://github.com/danielgindi/Charts/pull/3737) ([justinlew](https://github.com/justinlew)) +- Fix legend offset bug for horizontal bar chart \(Fixes \#3301\) [\#3736](https://github.com/danielgindi/Charts/pull/3736) ([SvenMuc](https://github.com/SvenMuc)) +- Fix wrong assignment to axisMaxLabels property [\#3721](https://github.com/danielgindi/Charts/pull/3721) ([ggirotto](https://github.com/ggirotto)) +- Add missing properties to copy\(with:\) methods [\#3715](https://github.com/danielgindi/Charts/pull/3715) ([dstranz](https://github.com/dstranz)) +- Multiple colors for valueline \(Fixes \#3480\) [\#3709](https://github.com/danielgindi/Charts/pull/3709) ([AlexeiGitH](https://github.com/AlexeiGitH)) +- Fix memory leak after rendering [\#3680](https://github.com/danielgindi/Charts/pull/3680) ([YusukeOba](https://github.com/YusukeOba)) +- fix issue \#3662 [\#3664](https://github.com/danielgindi/Charts/pull/3664) ([Michael-Du](https://github.com/Michael-Du)) +- Make NSUIAccessibilityElement initializer public. [\#3654](https://github.com/danielgindi/Charts/pull/3654) ([417-72KI](https://github.com/417-72KI)) +- improvements in barRect height calculation [\#3650](https://github.com/danielgindi/Charts/pull/3650) ([potato04](https://github.com/potato04)) +- Update document to latest format [\#3621](https://github.com/danielgindi/Charts/pull/3621) ([kemchenj](https://github.com/kemchenj)) +- Feature - ChartView Pan Ended Delegate Call [\#3612](https://github.com/danielgindi/Charts/pull/3612) ([AntonTheDev](https://github.com/AntonTheDev)) +- Axis Renderers Cleanup [\#3164](https://github.com/danielgindi/Charts/pull/3164) ([jjatie](https://github.com/jjatie)) + +## [v3.2.1](https://github.com/danielgindi/Charts/tree/v3.2.1) (2018-10-08) +[Full Changelog](https://github.com/danielgindi/Charts/compare/v3.2.0...v3.2.1) + +**Closed issues:** + +- Getting error after updating XCode to 10 from 9.4 [\#3661](https://github.com/danielgindi/Charts/issues/3661) +- Bar Chart with horizondal scroll on clicking button. [\#3660](https://github.com/danielgindi/Charts/issues/3660) +- How to change the piechart' valueLineColor and valueTextColor color individually [\#3658](https://github.com/danielgindi/Charts/issues/3658) +- Update to Swift 4.2 [\#3655](https://github.com/danielgindi/Charts/issues/3655) +- I am trying to use charts. for ios app. I am using cocoa pod for dependency setup. After setup i am trying to build the code it throwing compile errors. [\#3653](https://github.com/danielgindi/Charts/issues/3653) +- Type 'RunLoop' has no member 'Mode' [\#3652](https://github.com/danielgindi/Charts/issues/3652) +- Module compiled with Swift 4.1.2 cannot be imported by the Swift 4.2 [\#3651](https://github.com/danielgindi/Charts/issues/3651) +- Type 'RunLoop' has no member 'Mode' [\#3648](https://github.com/danielgindi/Charts/issues/3648) +- As of todays update, I am running into this issue. 'common' renamed RunLoopMode.commonModes [\#3647](https://github.com/danielgindi/Charts/issues/3647) +- Change circleHoleColor for one point [\#3646](https://github.com/danielgindi/Charts/issues/3646) +- This API is not working with Swift 4.1.. even after taking V3.2 of Charts API also.. I fixed it myself :\( [\#3645](https://github.com/danielgindi/Charts/issues/3645) +- Help building Charts Demo [\#3643](https://github.com/danielgindi/Charts/issues/3643) +- Limit line label orientation [\#3641](https://github.com/danielgindi/Charts/issues/3641) +- Is it possible to zoom into a range of values? [\#3639](https://github.com/danielgindi/Charts/issues/3639) +- Not working with SDK-Swift 4.2 [\#3635](https://github.com/danielgindi/Charts/issues/3635) +- getting the error that let is implicitly final please change from open to public in Xcode10 GM Seed [\#3634](https://github.com/danielgindi/Charts/issues/3634) +- How to optimize when the amount of data is large [\#3633](https://github.com/danielgindi/Charts/issues/3633) +- Adding mathematical function plotting [\#3632](https://github.com/danielgindi/Charts/issues/3632) +- Color shadow inside piechart [\#3631](https://github.com/danielgindi/Charts/issues/3631) +- I can not set one label on y axis. [\#3630](https://github.com/danielgindi/Charts/issues/3630) +- where is the code for draw the xAxis and yAxis indicateLine [\#3628](https://github.com/danielgindi/Charts/issues/3628) +- Is it possible to add a vertical label for Y-Axis? Or anyone working on it? [\#3627](https://github.com/danielgindi/Charts/issues/3627) +- Adding dashed lines in between bars in bar graph [\#3626](https://github.com/danielgindi/Charts/issues/3626) +- Create Line chart and/or Bar chart from String Array [\#3625](https://github.com/danielgindi/Charts/issues/3625) +- Change data if button press [\#3624](https://github.com/danielgindi/Charts/issues/3624) +- Pie Chart and Legend [\#3622](https://github.com/danielgindi/Charts/issues/3622) +- Add labels to marker or create custom marker view [\#3620](https://github.com/danielgindi/Charts/issues/3620) +- is there any way we can change the values font size for ipad in the same code? [\#3618](https://github.com/danielgindi/Charts/issues/3618) +- Reg: Display Min and Max Point in a PopUp [\#3617](https://github.com/danielgindi/Charts/issues/3617) +- Charts ScaleX problem [\#3616](https://github.com/danielgindi/Charts/issues/3616) +- CombinedChartView - EXC\_BAD\_ACCESS with doubleTapToZoomEnabled [\#3614](https://github.com/danielgindi/Charts/issues/3614) +- BarChartView How to set the fixed width and spacing? [\#3609](https://github.com/danielgindi/Charts/issues/3609) +- How can I combine two lineCharts? [\#3607](https://github.com/danielgindi/Charts/issues/3607) +- 'Charts/Charts-Swift.h' file not found [\#3603](https://github.com/danielgindi/Charts/issues/3603) +- Combined Chart with Horizontal Bar chart and a Line chart [\#3600](https://github.com/danielgindi/Charts/issues/3600) +- Design customization [\#3597](https://github.com/danielgindi/Charts/issues/3597) +- Move pie chart to specific location in the view [\#3595](https://github.com/danielgindi/Charts/issues/3595) +- Adding text data points to axis [\#3592](https://github.com/danielgindi/Charts/issues/3592) +- Performance hit [\#3585](https://github.com/danielgindi/Charts/issues/3585) +- Multiple colours for setValueTextColor and xAxis label with NSAttributedString [\#3566](https://github.com/danielgindi/Charts/issues/3566) +- Can't set a fixed width for YAxis with outside style. [\#3565](https://github.com/danielgindi/Charts/issues/3565) +- Switch from Grouped Bar chart back to normal [\#3551](https://github.com/danielgindi/Charts/issues/3551) +- X or Y axis interval of the labels [\#3547](https://github.com/danielgindi/Charts/issues/3547) +- How can I plot all Axis Value? [\#3540](https://github.com/danielgindi/Charts/issues/3540) +- When the number of numeric numbers on the Y axis does not agree, the right of the multiple charts will not be aligned. [\#3347](https://github.com/danielgindi/Charts/issues/3347) + ## [v3.2.0](https://github.com/danielgindi/Charts/tree/v3.2.0) (2018-09-17) -[Full Changelog](https://github.com/danielgindi/Charts/compare/3.1.1...v3.2.0) +[Full Changelog](https://github.com/danielgindi/Charts/compare/v3.1.1...v3.2.0) **Fixed bugs:** @@ -222,11 +495,11 @@ - Dataset logic cleanup [\#3001](https://github.com/danielgindi/Charts/pull/3001) ([jjatie](https://github.com/jjatie)) - Added value text rotation [\#2200](https://github.com/danielgindi/Charts/pull/2200) ([chinh-tran](https://github.com/chinh-tran)) -## [3.1.1](https://github.com/danielgindi/Charts/tree/3.1.1) (2018-04-02) -[Full Changelog](https://github.com/danielgindi/Charts/compare/v3.1.1...3.1.1) - ## [v3.1.1](https://github.com/danielgindi/Charts/tree/v3.1.1) (2018-04-02) -[Full Changelog](https://github.com/danielgindi/Charts/compare/3.1.0...v3.1.1) +[Full Changelog](https://github.com/danielgindi/Charts/compare/3.1.1...v3.1.1) + +## [3.1.1](https://github.com/danielgindi/Charts/tree/3.1.1) (2018-04-02) +[Full Changelog](https://github.com/danielgindi/Charts/compare/v3.1.0...3.1.1) **Fixed bugs:** @@ -286,11 +559,11 @@ - Update ILineRadarChartDataSet.swift [\#3366](https://github.com/danielgindi/Charts/pull/3366) ([Ewg777](https://github.com/Ewg777)) - Add option to disable clipping data to contentRect [\#3360](https://github.com/danielgindi/Charts/pull/3360) ([wtmoose](https://github.com/wtmoose)) -## [3.1.0](https://github.com/danielgindi/Charts/tree/3.1.0) (2018-03-22) -[Full Changelog](https://github.com/danielgindi/Charts/compare/v3.1.0...3.1.0) - ## [v3.1.0](https://github.com/danielgindi/Charts/tree/v3.1.0) (2018-03-22) -[Full Changelog](https://github.com/danielgindi/Charts/compare/v3.0.5...v3.1.0) +[Full Changelog](https://github.com/danielgindi/Charts/compare/3.1.0...v3.1.0) + +## [3.1.0](https://github.com/danielgindi/Charts/tree/3.1.0) (2018-03-22) +[Full Changelog](https://github.com/danielgindi/Charts/compare/v3.0.5...3.1.0) **Fixed bugs:** @@ -771,7 +1044,7 @@ [Full Changelog](https://github.com/danielgindi/Charts/compare/v3.0.3...3.0.3) ## [v3.0.3](https://github.com/danielgindi/Charts/tree/v3.0.3) (2017-09-08) -[Full Changelog](https://github.com/danielgindi/Charts/compare/3.0.2...v3.0.3) +[Full Changelog](https://github.com/danielgindi/Charts/compare/v3.0.2...v3.0.3) **Implemented enhancements:** @@ -1029,7 +1302,6 @@ - show tooltip on click [\#2438](https://github.com/danielgindi/Charts/issues/2438) - Got Error : “\_OBJC\_CLASS\_$\_\_TtC10ChartsDemo12XYMarkerView” in Charts [\#2437](https://github.com/danielgindi/Charts/issues/2437) - Change color label over circle [\#2436](https://github.com/danielgindi/Charts/issues/2436) -- Gradient transparency for line chart [\#2435](https://github.com/danielgindi/Charts/issues/2435) - How to set labels based on max and min value of the plot? [\#2434](https://github.com/danielgindi/Charts/issues/2434) - How to make the pie chart selected by default? [\#2431](https://github.com/danielgindi/Charts/issues/2431) - Animate 3 dataSets one by one [\#2428](https://github.com/danielgindi/Charts/issues/2428) @@ -1140,11 +1412,11 @@ - fix \#2222 move default backgroundColor to initialize\(\) [\#2228](https://github.com/danielgindi/Charts/pull/2228) ([liuxuan30](https://github.com/liuxuan30)) - Fix \#1879. Similar cut in half issue in scatter chart like others [\#1891](https://github.com/danielgindi/Charts/pull/1891) ([liuxuan30](https://github.com/liuxuan30)) -## [3.0.2](https://github.com/danielgindi/Charts/tree/3.0.2) (2017-04-02) -[Full Changelog](https://github.com/danielgindi/Charts/compare/v3.0.2...3.0.2) - ## [v3.0.2](https://github.com/danielgindi/Charts/tree/v3.0.2) (2017-04-02) -[Full Changelog](https://github.com/danielgindi/Charts/compare/v3.0.1...v3.0.2) +[Full Changelog](https://github.com/danielgindi/Charts/compare/3.0.2...v3.0.2) + +## [3.0.2](https://github.com/danielgindi/Charts/tree/3.0.2) (2017-04-02) +[Full Changelog](https://github.com/danielgindi/Charts/compare/3.0.1...3.0.2) **Implemented enhancements:** @@ -1485,11 +1757,11 @@ - Update "Usage" section of README [\#1984](https://github.com/danielgindi/Charts/pull/1984) ([elaewin](https://github.com/elaewin)) - All Charts Icons Support Swift3 \[Dub \#629, \#624, \#1261\] [\#1793](https://github.com/danielgindi/Charts/pull/1793) ([abjurato](https://github.com/abjurato)) -## [v3.0.1](https://github.com/danielgindi/Charts/tree/v3.0.1) (2016-11-20) -[Full Changelog](https://github.com/danielgindi/Charts/compare/3.0.1...v3.0.1) - ## [3.0.1](https://github.com/danielgindi/Charts/tree/3.0.1) (2016-11-20) -[Full Changelog](https://github.com/danielgindi/Charts/compare/2.3.1...3.0.1) +[Full Changelog](https://github.com/danielgindi/Charts/compare/v3.0.1...3.0.1) + +## [v3.0.1](https://github.com/danielgindi/Charts/tree/v3.0.1) (2016-11-20) +[Full Changelog](https://github.com/danielgindi/Charts/compare/v2.3.1...v3.0.1) **Closed issues:** @@ -1559,11 +1831,11 @@ - Added a check against NaN [\#1733](https://github.com/danielgindi/Charts/pull/1733) ([Selficide](https://github.com/Selficide)) -## [2.3.1](https://github.com/danielgindi/Charts/tree/2.3.1) (2016-11-04) -[Full Changelog](https://github.com/danielgindi/Charts/compare/v2.3.1...2.3.1) - ## [v2.3.1](https://github.com/danielgindi/Charts/tree/v2.3.1) (2016-11-04) -[Full Changelog](https://github.com/danielgindi/Charts/compare/v3.0.0...v2.3.1) +[Full Changelog](https://github.com/danielgindi/Charts/compare/2.3.1...v2.3.1) + +## [2.3.1](https://github.com/danielgindi/Charts/tree/2.3.1) (2016-11-04) +[Full Changelog](https://github.com/danielgindi/Charts/compare/3.0.0...2.3.1) **Fixed bugs:** @@ -1668,11 +1940,11 @@ - Updated Width Constraints - Fixes \#1770 [\#1771](https://github.com/danielgindi/Charts/pull/1771) ([SumoSimo](https://github.com/SumoSimo)) - update cocoapods [\#1684](https://github.com/danielgindi/Charts/pull/1684) ([petester42](https://github.com/petester42)) -## [v3.0.0](https://github.com/danielgindi/Charts/tree/v3.0.0) (2016-10-19) -[Full Changelog](https://github.com/danielgindi/Charts/compare/3.0.0...v3.0.0) - ## [3.0.0](https://github.com/danielgindi/Charts/tree/3.0.0) (2016-10-19) -[Full Changelog](https://github.com/danielgindi/Charts/compare/v2.3.0...3.0.0) +[Full Changelog](https://github.com/danielgindi/Charts/compare/v3.0.0...3.0.0) + +## [v3.0.0](https://github.com/danielgindi/Charts/tree/v3.0.0) (2016-10-19) +[Full Changelog](https://github.com/danielgindi/Charts/compare/2.3.0...v3.0.0) **Implemented enhancements:** @@ -1868,11 +2140,11 @@ - Attempt to make CI more stable [\#1510](https://github.com/danielgindi/Charts/pull/1510) ([petester42](https://github.com/petester42)) - Fix Cocoapods setup being broken [\#1509](https://github.com/danielgindi/Charts/pull/1509) ([petester42](https://github.com/petester42)) -## [v2.3.0](https://github.com/danielgindi/Charts/tree/v2.3.0) (2016-09-21) -[Full Changelog](https://github.com/danielgindi/Charts/compare/2.3.0...v2.3.0) - ## [2.3.0](https://github.com/danielgindi/Charts/tree/2.3.0) (2016-09-21) -[Full Changelog](https://github.com/danielgindi/Charts/compare/v2.2.5...2.3.0) +[Full Changelog](https://github.com/danielgindi/Charts/compare/v2.3.0...2.3.0) + +## [v2.3.0](https://github.com/danielgindi/Charts/tree/v2.3.0) (2016-09-21) +[Full Changelog](https://github.com/danielgindi/Charts/compare/v2.2.5...v2.3.0) **Implemented enhancements:** diff --git a/Cartfile b/Cartfile deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/Cartfile.private b/Cartfile.private index a27f21f92d..ca931038c5 100644 --- a/Cartfile.private +++ b/Cartfile.private @@ -1 +1 @@ -github "facebook/ios-snapshot-test-case" "master" +github "uber/ios-snapshot-test-case" diff --git a/Cartfile.resolved b/Cartfile.resolved index 1672a76f44..7c08e7ba55 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1 +1 @@ -github "facebook/ios-snapshot-test-case" "ed4e6a6e81bfb69a5223156e6c3d389a416cf6e3" +github "uber/ios-snapshot-test-case" "6.0.3" diff --git a/Charts.podspec b/Charts.podspec index f609330b9c..b40042a305 100644 --- a/Charts.podspec +++ b/Charts.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "Charts" - s.version = "3.2.1" + s.version = "3.3.0" s.summary = "Charts is a powerful & easy to use chart library for iOS, tvOS and OSX (and Android)" s.homepage = "https://github.com/danielgindi/Charts" s.license = { :type => "Apache License, Version 2.0", :file => "LICENSE" } @@ -10,7 +10,7 @@ Pod::Spec.new do |s| s.osx.deployment_target = "10.11" s.source = { :git => "https://github.com/danielgindi/Charts.git", :tag => "v#{s.version}" } s.default_subspec = "Core" - s.swift_version = '4.2' + s.swift_version = '5.0' s.cocoapods_version = '>= 1.5.0' s.subspec "Core" do |ss| diff --git a/Charts.xcodeproj/project.pbxproj b/Charts.xcodeproj/project.pbxproj index 693ff6767b..61309fb580 100644 --- a/Charts.xcodeproj/project.pbxproj +++ b/Charts.xcodeproj/project.pbxproj @@ -111,6 +111,7 @@ B0D28C68BB9A958DC56EB214 /* DefaultValueFormatter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 107D8F8163EE54D6D9E916B0 /* DefaultValueFormatter.swift */; }; B13C74B4FF705D7B595D01EF /* IAxisValueFormatter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0BD9DF16AF59680A3BB49452 /* IAxisValueFormatter.swift */; }; B539114951455C35BADAE3F3 /* PieChartDataSet.swift in Sources */ = {isa = PBXBuildFile; fileRef = A4FB5E3761EF8B4D1E1E1014 /* PieChartDataSet.swift */; }; + B66817462241E3CC00017CF1 /* HorizontalBarChartTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B66817452241E3CC00017CF1 /* HorizontalBarChartTests.swift */; }; B6BF9A561F91993A00E62A5D /* CombinedChartTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B6BF9A551F91993A00E62A5D /* CombinedChartTests.swift */; }; B6C9F450D937B87224D29D5C /* IFillFormatter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 818AC6B12505B7C0A53D62F9 /* IFillFormatter.swift */; }; B6DCC229615EFE706F64A37D /* LineScatterCandleRadarRenderer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 923206233CA89FD03565FF87 /* LineScatterCandleRadarRenderer.swift */; }; @@ -273,6 +274,7 @@ B137428B41C143D5115726C4 /* Description.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Description.swift; path = Source/Charts/Components/Description.swift; sourceTree = ""; }; B1BA6B21CBDF77A15848994F /* RadarChartDataSet.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = RadarChartDataSet.swift; path = Source/Charts/Data/Implementations/Standard/RadarChartDataSet.swift; sourceTree = ""; }; B44829AF0ADA583F1F0279B7 /* BubbleChartDataSet.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = BubbleChartDataSet.swift; path = Source/Charts/Data/Implementations/Standard/BubbleChartDataSet.swift; sourceTree = ""; }; + B66817452241E3CC00017CF1 /* HorizontalBarChartTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = HorizontalBarChartTests.swift; path = Tests/Charts/HorizontalBarChartTests.swift; sourceTree = ""; }; B6BF9A551F91993A00E62A5D /* CombinedChartTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = CombinedChartTests.swift; path = Tests/Charts/CombinedChartTests.swift; sourceTree = ""; }; BA157EFF2F952192C11DF937 /* AnimatedMoveViewJob.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = AnimatedMoveViewJob.swift; path = Source/Charts/Jobs/AnimatedMoveViewJob.swift; sourceTree = ""; }; BA1A58428DC4780BAB4EAADC /* CandleStickChartView.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = CandleStickChartView.swift; path = Source/Charts/Charts/CandleStickChartView.swift; sourceTree = ""; }; @@ -520,6 +522,7 @@ isa = PBXGroup; children = ( 5C3F5E1A69EC06E86505F7B1 /* BarChartTests.swift */, + B66817452241E3CC00017CF1 /* HorizontalBarChartTests.swift */, 224EFF981FBAAC4700CF9B3B /* EquatableTests.swift */, 7AB9062A28AAB9469752A954 /* ChartUtilsTests.swift */, B6BF9A551F91993A00E62A5D /* CombinedChartTests.swift */, @@ -734,7 +737,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0830; - LastUpgradeCheck = 0930; + LastUpgradeCheck = 1020; TargetAttributes = { A58A4ED274A941CA248EA921 = { LastSwiftMigration = 0900; @@ -749,6 +752,7 @@ developmentRegion = English; hasScannedForEncodings = 0; knownRegions = ( + English, en, ); mainGroup = 865A1CF149F52850CAB7F177; @@ -962,6 +966,7 @@ 8E1192F7A7152E9DA92C56A9 /* ChartUtilsTests.swift in Sources */, B6BF9A561F91993A00E62A5D /* CombinedChartTests.swift in Sources */, 2BF85BEA981B359A65E9BF67 /* LineChartTests.swift in Sources */, + B66817462241E3CC00017CF1 /* HorizontalBarChartTests.swift in Sources */, 135F11CE20425AF600D655A3 /* PieChartTests.swift in Sources */, 064989461F5C99C7006E8BB3 /* Snapshot.swift in Sources */, 224EFF991FBAAC4700CF9B3B /* EquatableTests.swift in Sources */, @@ -996,7 +1001,7 @@ GCC_NO_COMMON_BLOCKS = YES; INFOPLIST_FILE = "Source/Supporting Files/Info.plist"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; + IPHONEOS_DEPLOYMENT_TARGET = 8.4; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks"; MACOSX_DEPLOYMENT_TARGET = 10.11; MTL_ENABLE_DEBUG_INFO = YES; @@ -1007,7 +1012,7 @@ SUPPORTED_PLATFORMS = "macosx iphoneos iphonesimulator appletvos appletvsimulator"; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; TVOS_DEPLOYMENT_TARGET = 9.0; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -1030,7 +1035,7 @@ ); GCC_NO_COMMON_BLOCKS = YES; INFOPLIST_FILE = "Tests/Supporting Files/Info.plist"; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; + IPHONEOS_DEPLOYMENT_TARGET = 8.4; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; "LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; MTL_ENABLE_DEBUG_INFO = YES; @@ -1040,7 +1045,7 @@ SUPPORTED_PLATFORMS = "iphoneos iphonesimulator appletvos appletvsimulator"; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; TVOS_DEPLOYMENT_TARGET = 9.0; }; name = Debug; @@ -1049,6 +1054,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; @@ -1090,7 +1096,7 @@ GCC_WARN_UNUSED_VARIABLE = YES; SDKROOT = macosx; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2,3,4"; VALIDATE_PRODUCT = YES; }; @@ -1100,6 +1106,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; @@ -1149,7 +1156,7 @@ ONLY_ACTIVE_ARCH = YES; SDKROOT = macosx; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2,3,4"; }; name = Debug; @@ -1170,7 +1177,7 @@ GCC_NO_COMMON_BLOCKS = YES; INFOPLIST_FILE = "Source/Supporting Files/Info.plist"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; + IPHONEOS_DEPLOYMENT_TARGET = 8.4; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks"; MACOSX_DEPLOYMENT_TARGET = 10.11; MTL_ENABLE_DEBUG_INFO = NO; @@ -1180,7 +1187,7 @@ SKIP_INSTALL = YES; SUPPORTED_PLATFORMS = "macosx iphoneos iphonesimulator appletvos appletvsimulator"; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; TVOS_DEPLOYMENT_TARGET = 9.0; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -1203,7 +1210,7 @@ ); GCC_NO_COMMON_BLOCKS = YES; INFOPLIST_FILE = "Tests/Supporting Files/Info.plist"; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; + IPHONEOS_DEPLOYMENT_TARGET = 8.4; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; "LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; MTL_ENABLE_DEBUG_INFO = NO; @@ -1212,7 +1219,7 @@ SDKROOT = macosx; SUPPORTED_PLATFORMS = "iphoneos iphonesimulator appletvos appletvsimulator"; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; TVOS_DEPLOYMENT_TARGET = 9.0; }; name = Release; diff --git a/Charts.xcodeproj/xcshareddata/xcschemes/Charts.xcscheme b/Charts.xcodeproj/xcshareddata/xcschemes/Charts.xcscheme index 6029c01d57..433e05112e 100644 --- a/Charts.xcodeproj/xcshareddata/xcschemes/Charts.xcscheme +++ b/Charts.xcodeproj/xcshareddata/xcschemes/Charts.xcscheme @@ -1,6 +1,6 @@ 0) { set1 = (BarChartDataSet *)_chartView.data.dataSets[0]; - set1.values = yVals; + [set1 replaceEntries:yVals]; [_chartView.data notifyDataChanged]; [_chartView notifyDataSetChanged]; } else { - set1 = [[BarChartDataSet alloc] initWithValues:yVals label:@"DataSet"]; + set1 = [[BarChartDataSet alloc] initWithEntries:yVals label:@"DataSet"]; set1.colors = ChartColorTemplates.vordiplom; set1.drawValuesEnabled = NO; diff --git a/ChartsDemo-iOS/Objective-C/Demos/BarChartViewController.m b/ChartsDemo-iOS/Objective-C/Demos/BarChartViewController.m index 52db459e9b..5e1567c088 100644 --- a/ChartsDemo-iOS/Objective-C/Demos/BarChartViewController.m +++ b/ChartsDemo-iOS/Objective-C/Demos/BarChartViewController.m @@ -148,13 +148,13 @@ - (void)setDataCount:(int)count range:(double)range if (_chartView.data.dataSetCount > 0) { set1 = (BarChartDataSet *)_chartView.data.dataSets[0]; - set1.values = yVals; + [set1 replaceEntries: yVals]; [_chartView.data notifyDataChanged]; [_chartView notifyDataSetChanged]; } else { - set1 = [[BarChartDataSet alloc] initWithValues:yVals label:@"The year 2017"]; + set1 = [[BarChartDataSet alloc] initWithEntries:yVals label:@"The year 2017"]; [set1 setColors:ChartColorTemplates.material]; set1.drawIconsEnabled = NO; diff --git a/ChartsDemo-iOS/Objective-C/Demos/BubbleChartViewController.m b/ChartsDemo-iOS/Objective-C/Demos/BubbleChartViewController.m index 765639acfe..9d32596674 100644 --- a/ChartsDemo-iOS/Objective-C/Demos/BubbleChartViewController.m +++ b/ChartsDemo-iOS/Objective-C/Demos/BubbleChartViewController.m @@ -115,17 +115,17 @@ - (void)setDataCount:(int)count range:(double)range [yVals3 addObject:[[BubbleChartDataEntry alloc] initWithX:i y:val size:size]]; } - BubbleChartDataSet *set1 = [[BubbleChartDataSet alloc] initWithValues:yVals1 label:@"DS 1"]; + BubbleChartDataSet *set1 = [[BubbleChartDataSet alloc] initWithEntries:yVals1 label:@"DS 1"]; set1.drawIconsEnabled = NO; [set1 setColor:ChartColorTemplates.colorful[0] alpha:0.50f]; [set1 setDrawValuesEnabled:YES]; - BubbleChartDataSet *set2 = [[BubbleChartDataSet alloc] initWithValues:yVals2 label:@"DS 2"]; + BubbleChartDataSet *set2 = [[BubbleChartDataSet alloc] initWithEntries:yVals2 label:@"DS 2"]; set2.iconsOffset = CGPointMake(0, 15); [set2 setColor:ChartColorTemplates.colorful[1] alpha:0.50f]; [set2 setDrawValuesEnabled:YES]; - BubbleChartDataSet *set3 = [[BubbleChartDataSet alloc] initWithValues:yVals3 label:@"DS 3"]; + BubbleChartDataSet *set3 = [[BubbleChartDataSet alloc] initWithEntries:yVals3 label:@"DS 3"]; [set3 setColor:ChartColorTemplates.colorful[2] alpha:0.50f]; [set3 setDrawValuesEnabled:YES]; diff --git a/ChartsDemo-iOS/Objective-C/Demos/CandleStickChartViewController.m b/ChartsDemo-iOS/Objective-C/Demos/CandleStickChartViewController.m index 6e2a004dc3..25a0e73ca3 100644 --- a/ChartsDemo-iOS/Objective-C/Demos/CandleStickChartViewController.m +++ b/ChartsDemo-iOS/Objective-C/Demos/CandleStickChartViewController.m @@ -105,7 +105,7 @@ - (void)setDataCount:(int)count range:(double)range [yVals1 addObject:[[CandleChartDataEntry alloc] initWithX:i shadowH:val + high shadowL:val - low open:even ? val + open : val - open close:even ? val - close : val + close icon: [UIImage imageNamed:@"icon"]]]; } - CandleChartDataSet *set1 = [[CandleChartDataSet alloc] initWithValues:yVals1 label:@"Data Set"]; + CandleChartDataSet *set1 = [[CandleChartDataSet alloc] initWithEntries:yVals1 label:@"Data Set"]; set1.axisDependency = AxisDependencyLeft; [set1 setColor:[UIColor colorWithWhite:80/255.f alpha:1.f]]; diff --git a/ChartsDemo-iOS/Objective-C/Demos/ColoredLineChartViewController.m b/ChartsDemo-iOS/Objective-C/Demos/ColoredLineChartViewController.m index a639f6911d..520770f206 100644 --- a/ChartsDemo-iOS/Objective-C/Demos/ColoredLineChartViewController.m +++ b/ChartsDemo-iOS/Objective-C/Demos/ColoredLineChartViewController.m @@ -86,7 +86,7 @@ - (LineChartData *)dataWithCount:(int)count range:(double)range [yVals addObject:[[ChartDataEntry alloc] initWithX:i y:val]]; } - LineChartDataSet *set1 = [[LineChartDataSet alloc] initWithValues:yVals label:@"DataSet 1"]; + LineChartDataSet *set1 = [[LineChartDataSet alloc] initWithEntries:yVals label:@"DataSet 1"]; set1.lineWidth = 1.75; set1.circleRadius = 5.0; diff --git a/ChartsDemo-iOS/Objective-C/Demos/CombinedChartViewController.m b/ChartsDemo-iOS/Objective-C/Demos/CombinedChartViewController.m index 17b661712f..995c419210 100644 --- a/ChartsDemo-iOS/Objective-C/Demos/CombinedChartViewController.m +++ b/ChartsDemo-iOS/Objective-C/Demos/CombinedChartViewController.m @@ -170,7 +170,7 @@ - (LineChartData *)generateLineData [entries addObject:[[ChartDataEntry alloc] initWithX:index + 0.5 y:(arc4random_uniform(15) + 5)]]; } - LineChartDataSet *set = [[LineChartDataSet alloc] initWithValues:entries label:@"Line DataSet"]; + LineChartDataSet *set = [[LineChartDataSet alloc] initWithEntries:entries label:@"Line DataSet"]; [set setColor:[UIColor colorWithRed:240/255.f green:238/255.f blue:70/255.f alpha:1.f]]; set.lineWidth = 2.5; [set setCircleColor:[UIColor colorWithRed:240/255.f green:238/255.f blue:70/255.f alpha:1.f]]; @@ -202,13 +202,13 @@ - (BarChartData *)generateBarData [entries2 addObject:[[BarChartDataEntry alloc] initWithX:0.0 yValues:@[@(arc4random_uniform(13) + 12), @(arc4random_uniform(13) + 12)]]]; } - BarChartDataSet *set1 = [[BarChartDataSet alloc] initWithValues:entries1 label:@"Bar 1"]; + BarChartDataSet *set1 = [[BarChartDataSet alloc] initWithEntries:entries1 label:@"Bar 1"]; [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 = AxisDependencyRight; - BarChartDataSet *set2 = [[BarChartDataSet alloc] initWithValues:entries2 label:@""]; + BarChartDataSet *set2 = [[BarChartDataSet alloc] initWithEntries:entries2 label:@""]; set2.stackLabels = @[@"Stack 1", @"Stack 2"]; set2.colors = @[ [UIColor colorWithRed:61/255.f green:165/255.f blue:255/255.f alpha:1.f], @@ -243,7 +243,7 @@ - (ScatterChartData *)generateScatterData [entries addObject:[[ChartDataEntry alloc] initWithX:index + 0.25 y:(arc4random_uniform(10) + 55)]]; } - ScatterChartDataSet *set = [[ScatterChartDataSet alloc] initWithValues:entries label:@"Scatter DataSet"]; + ScatterChartDataSet *set = [[ScatterChartDataSet alloc] initWithEntries:entries label:@"Scatter DataSet"]; set.colors = ChartColorTemplates.material; set.scatterShapeSize = 4.5; [set setDrawValuesEnabled:NO]; @@ -265,7 +265,7 @@ - (CandleChartData *)generateCandleData [entries addObject:[[CandleChartDataEntry alloc] initWithX:index + 1 shadowH:90.0 shadowL:70.0 open:85.0 close:75.0]]; } - CandleChartDataSet *set = [[CandleChartDataSet alloc] initWithValues:entries label:@"Candle DataSet"]; + CandleChartDataSet *set = [[CandleChartDataSet alloc] initWithEntries:entries label:@"Candle DataSet"]; [set setColor:[UIColor colorWithRed:80/255.f green:80/255.f blue:80/255.f alpha:1.f]]; set.decreasingColor = [UIColor colorWithRed:142/255.0 green:150/255.0 blue:175/255.0 alpha:1.0]; set.shadowColor = UIColor.darkGrayColor; @@ -290,7 +290,7 @@ - (BubbleChartData *)generateBubbleData [entries addObject:[[BubbleChartDataEntry alloc] initWithX:index + 0.5 y:y size:size]]; } - BubbleChartDataSet *set = [[BubbleChartDataSet alloc] initWithValues:entries label:@"Bubble DataSet"]; + BubbleChartDataSet *set = [[BubbleChartDataSet alloc] initWithEntries:entries label:@"Bubble DataSet"]; [set setColors:ChartColorTemplates.vordiplom]; set.valueTextColor = UIColor.whiteColor; set.valueFont = [UIFont systemFontOfSize:10.f]; diff --git a/ChartsDemo-iOS/Objective-C/Demos/CubicLineChartViewController.m b/ChartsDemo-iOS/Objective-C/Demos/CubicLineChartViewController.m index e28c5cd642..0d590fbf1c 100644 --- a/ChartsDemo-iOS/Objective-C/Demos/CubicLineChartViewController.m +++ b/ChartsDemo-iOS/Objective-C/Demos/CubicLineChartViewController.m @@ -126,13 +126,13 @@ - (void)setDataCount:(int)count range:(double)range if (_chartView.data.dataSetCount > 0) { set1 = (LineChartDataSet *)_chartView.data.dataSets[0]; - set1.values = yVals1; + [set1 replaceEntries:yVals1]; [_chartView.data notifyDataChanged]; [_chartView notifyDataSetChanged]; } else { - set1 = [[LineChartDataSet alloc] initWithValues:yVals1 label:@"DataSet 1"]; + set1 = [[LineChartDataSet alloc] initWithEntries:yVals1 label:@"DataSet 1"]; set1.mode = LineChartModeCubicBezier; set1.cubicIntensity = 0.2; set1.drawCirclesEnabled = NO; diff --git a/ChartsDemo-iOS/Objective-C/Demos/HalfPieChartViewController.m b/ChartsDemo-iOS/Objective-C/Demos/HalfPieChartViewController.m index 8ea31b875b..e66840c48e 100644 --- a/ChartsDemo-iOS/Objective-C/Demos/HalfPieChartViewController.m +++ b/ChartsDemo-iOS/Objective-C/Demos/HalfPieChartViewController.m @@ -101,7 +101,7 @@ - (void)setDataCount:(int)count range:(double)range [values addObject:[[PieChartDataEntry alloc] initWithValue:(arc4random_uniform(mult) + mult / 5) label:parties[i % parties.count]]]; } - PieChartDataSet *dataSet = [[PieChartDataSet alloc] initWithValues:values label:@"Election Results"]; + PieChartDataSet *dataSet = [[PieChartDataSet alloc] initWithEntries:values label:@"Election Results"]; dataSet.sliceSpace = 3.0; dataSet.selectionShift = 5.0; diff --git a/ChartsDemo-iOS/Objective-C/Demos/HorizontalBarChartViewController.m b/ChartsDemo-iOS/Objective-C/Demos/HorizontalBarChartViewController.m index fea156a249..54899281f1 100644 --- a/ChartsDemo-iOS/Objective-C/Demos/HorizontalBarChartViewController.m +++ b/ChartsDemo-iOS/Objective-C/Demos/HorizontalBarChartViewController.m @@ -127,13 +127,13 @@ - (void)setDataCount:(int)count range:(double)range if (_chartView.data.dataSetCount > 0) { set1 = (BarChartDataSet *)_chartView.data.dataSets[0]; - set1.values = yVals; + [set1 replaceEntries:yVals]; [_chartView.data notifyDataChanged]; [_chartView notifyDataSetChanged]; } else { - set1 = [[BarChartDataSet alloc] initWithValues:yVals label:@"DataSet"]; + set1 = [[BarChartDataSet alloc] initWithEntries:yVals label:@"DataSet"]; set1.drawIconsEnabled = NO; diff --git a/ChartsDemo-iOS/Objective-C/Demos/LineChart1ViewController.m b/ChartsDemo-iOS/Objective-C/Demos/LineChart1ViewController.m index 669eb3fdd7..40297febdb 100644 --- a/ChartsDemo-iOS/Objective-C/Demos/LineChart1ViewController.m +++ b/ChartsDemo-iOS/Objective-C/Demos/LineChart1ViewController.m @@ -61,7 +61,7 @@ - (void)viewDidLoad ChartLimitLine *llXAxis = [[ChartLimitLine alloc] initWithLimit:10.0 label:@"Index 10"]; llXAxis.lineWidth = 4.0; llXAxis.lineDashLengths = @[@(10.f), @(10.f), @(0.f)]; - llXAxis.labelPosition = ChartLimitLabelPositionRightBottom; + llXAxis.labelPosition = ChartLimitLabelPositionBottomRight; llXAxis.valueFont = [UIFont systemFontOfSize:10.f]; //[_chartView.xAxis addLimitLine:llXAxis]; @@ -72,13 +72,13 @@ - (void)viewDidLoad ChartLimitLine *ll1 = [[ChartLimitLine alloc] initWithLimit:150.0 label:@"Upper Limit"]; ll1.lineWidth = 4.0; ll1.lineDashLengths = @[@5.f, @5.f]; - ll1.labelPosition = ChartLimitLabelPositionRightTop; + ll1.labelPosition = ChartLimitLabelPositionTopRight; ll1.valueFont = [UIFont systemFontOfSize:10.0]; ChartLimitLine *ll2 = [[ChartLimitLine alloc] initWithLimit:-30.0 label:@"Lower Limit"]; ll2.lineWidth = 4.0; ll2.lineDashLengths = @[@5.f, @5.f]; - ll2.labelPosition = ChartLimitLabelPositionRightBottom; + ll2.labelPosition = ChartLimitLabelPositionBottomRight; ll2.valueFont = [UIFont systemFontOfSize:10.0]; ChartYAxis *leftAxis = _chartView.leftAxis; @@ -145,13 +145,13 @@ - (void)setDataCount:(int)count range:(double)range if (_chartView.data.dataSetCount > 0) { set1 = (LineChartDataSet *)_chartView.data.dataSets[0]; - set1.values = values; + [set1 replaceEntries: values]; [_chartView.data notifyDataChanged]; [_chartView notifyDataSetChanged]; } else { - set1 = [[LineChartDataSet alloc] initWithValues:values label:@"DataSet 1"]; + set1 = [[LineChartDataSet alloc] initWithEntries:values label:@"DataSet 1"]; set1.drawIconsEnabled = NO; diff --git a/ChartsDemo-iOS/Objective-C/Demos/LineChart2ViewController.m b/ChartsDemo-iOS/Objective-C/Demos/LineChart2ViewController.m index 99e7d1ba1b..75eceadef6 100644 --- a/ChartsDemo-iOS/Objective-C/Demos/LineChart2ViewController.m +++ b/ChartsDemo-iOS/Objective-C/Demos/LineChart2ViewController.m @@ -146,15 +146,15 @@ - (void)setDataCount:(int)count range:(double)range set1 = (LineChartDataSet *)_chartView.data.dataSets[0]; set2 = (LineChartDataSet *)_chartView.data.dataSets[1]; set3 = (LineChartDataSet *)_chartView.data.dataSets[2]; - set1.values = yVals1; - set2.values = yVals2; - set3.values = yVals3; + [set1 replaceEntries:yVals1]; + [set2 replaceEntries:yVals2]; + [set3 replaceEntries:yVals3]; [_chartView.data notifyDataChanged]; [_chartView notifyDataSetChanged]; } else { - set1 = [[LineChartDataSet alloc] initWithValues:yVals1 label:@"DataSet 1"]; + set1 = [[LineChartDataSet alloc] initWithEntries:yVals1 label:@"DataSet 1"]; set1.axisDependency = AxisDependencyLeft; [set1 setColor:[UIColor colorWithRed:51/255.f green:181/255.f blue:229/255.f alpha:1.f]]; [set1 setCircleColor:UIColor.whiteColor]; @@ -165,7 +165,7 @@ - (void)setDataCount:(int)count range:(double)range set1.highlightColor = [UIColor colorWithRed:244/255.f green:117/255.f blue:117/255.f alpha:1.f]; set1.drawCircleHoleEnabled = NO; - set2 = [[LineChartDataSet alloc] initWithValues:yVals2 label:@"DataSet 2"]; + set2 = [[LineChartDataSet alloc] initWithEntries:yVals2 label:@"DataSet 2"]; set2.axisDependency = AxisDependencyRight; [set2 setColor:UIColor.redColor]; [set2 setCircleColor:UIColor.whiteColor]; @@ -176,7 +176,7 @@ - (void)setDataCount:(int)count range:(double)range set2.highlightColor = [UIColor colorWithRed:244/255.f green:117/255.f blue:117/255.f alpha:1.f]; set2.drawCircleHoleEnabled = NO; - set3 = [[LineChartDataSet alloc] initWithValues:yVals3 label:@"DataSet 3"]; + set3 = [[LineChartDataSet alloc] initWithEntries:yVals3 label:@"DataSet 3"]; set3.axisDependency = AxisDependencyRight; [set3 setColor:UIColor.yellowColor]; [set3 setCircleColor:UIColor.whiteColor]; diff --git a/ChartsDemo-iOS/Objective-C/Demos/LineChartFilledViewController.m b/ChartsDemo-iOS/Objective-C/Demos/LineChartFilledViewController.m index 6caf4ebf45..f6ec793465 100644 --- a/ChartsDemo-iOS/Objective-C/Demos/LineChartFilledViewController.m +++ b/ChartsDemo-iOS/Objective-C/Demos/LineChartFilledViewController.m @@ -105,14 +105,14 @@ - (void)setDataCount:(int)count range:(double)range { set1 = (LineChartDataSet *)_chartView.data.dataSets[0]; set2 = (LineChartDataSet *)_chartView.data.dataSets[1]; - set1.values = yVals1; - set2.values = yVals2; + [set1 replaceEntries:yVals1]; + [set2 replaceEntries:yVals2]; [_chartView.data notifyDataChanged]; [_chartView notifyDataSetChanged]; } else { - set1 = [[LineChartDataSet alloc] initWithValues:yVals1 label:@"DataSet 1"]; + set1 = [[LineChartDataSet alloc] initWithEntries:yVals1 label:@"DataSet 1"]; set1.axisDependency = AxisDependencyLeft; [set1 setColor:[UIColor colorWithRed:255/255.0 green:241/255.0 blue:46/255.0 alpha:1.0]]; set1.drawCirclesEnabled = NO; @@ -127,7 +127,7 @@ - (void)setDataCount:(int)count range:(double)range return self.chartView.leftAxis.axisMinimum; }]; - set2 = [[LineChartDataSet alloc] initWithValues:yVals2 label:@"DataSet 2"]; + set2 = [[LineChartDataSet alloc] initWithEntries:yVals2 label:@"DataSet 2"]; set2.axisDependency = AxisDependencyLeft; [set2 setColor:[UIColor colorWithRed:255/255.0 green:241/255.0 blue:46/255.0 alpha:1.0]]; set2.drawCirclesEnabled = NO; diff --git a/ChartsDemo-iOS/Objective-C/Demos/LineChartTimeViewController.m b/ChartsDemo-iOS/Objective-C/Demos/LineChartTimeViewController.m index f279248f99..06e6808f4f 100644 --- a/ChartsDemo-iOS/Objective-C/Demos/LineChartTimeViewController.m +++ b/ChartsDemo-iOS/Objective-C/Demos/LineChartTimeViewController.m @@ -126,13 +126,13 @@ - (void)setDataCount:(int)count range:(double)range if (_chartView.data.dataSetCount > 0) { set1 = (LineChartDataSet *)_chartView.data.dataSets[0]; - set1.values = values; + [set1 replaceEntries: values]; [_chartView.data notifyDataChanged]; [_chartView notifyDataSetChanged]; } else { - set1 = [[LineChartDataSet alloc] initWithValues:values label:@"DataSet 1"]; + set1 = [[LineChartDataSet alloc] initWithEntries:values label:@"DataSet 1"]; set1.axisDependency = AxisDependencyLeft; set1.valueTextColor = [UIColor colorWithRed:51/255.0 green:181/255.0 blue:229/255.0 alpha:1.0]; set1.lineWidth = 1.5; diff --git a/ChartsDemo-iOS/Objective-C/Demos/MultipleBarChartViewController.m b/ChartsDemo-iOS/Objective-C/Demos/MultipleBarChartViewController.m index 1a17776a2c..ec748b8d24 100644 --- a/ChartsDemo-iOS/Objective-C/Demos/MultipleBarChartViewController.m +++ b/ChartsDemo-iOS/Objective-C/Demos/MultipleBarChartViewController.m @@ -155,10 +155,10 @@ - (void)setDataCount:(int)count range:(double)range set2 = (BarChartDataSet *)_chartView.data.dataSets[1]; set3 = (BarChartDataSet *)_chartView.data.dataSets[2]; set4 = (BarChartDataSet *)_chartView.data.dataSets[3]; - set1.values = yVals1; - set2.values = yVals2; - set3.values = yVals3; - set4.values = yVals4; + [set1 replaceEntries:yVals1]; + [set2 replaceEntries:yVals2]; + [set3 replaceEntries:yVals3]; + [set4 replaceEntries:yVals4]; BarChartData *data = _chartView.barData; @@ -171,16 +171,16 @@ - (void)setDataCount:(int)count range:(double)range } else { - set1 = [[BarChartDataSet alloc] initWithValues:yVals1 label:@"Company A"]; + set1 = [[BarChartDataSet alloc] initWithEntries:yVals1 label:@"Company A"]; [set1 setColor:[UIColor colorWithRed:104/255.f green:241/255.f blue:175/255.f alpha:1.f]]; - set2 = [[BarChartDataSet alloc] initWithValues:yVals2 label:@"Company B"]; + set2 = [[BarChartDataSet alloc] initWithEntries:yVals2 label:@"Company B"]; [set2 setColor:[UIColor colorWithRed:164/255.f green:228/255.f blue:251/255.f alpha:1.f]]; - set3 = [[BarChartDataSet alloc] initWithValues:yVals3 label:@"Company C"]; + set3 = [[BarChartDataSet alloc] initWithEntries:yVals3 label:@"Company C"]; [set3 setColor:[UIColor colorWithRed:242/255.f green:247/255.f blue:158/255.f alpha:1.f]]; - set4 = [[BarChartDataSet alloc] initWithValues:yVals4 label:@"Company D"]; + set4 = [[BarChartDataSet alloc] initWithEntries:yVals4 label:@"Company D"]; [set4 setColor:[UIColor colorWithRed:255/255.f green:102/255.f blue:0/255.f alpha:1.f]]; NSMutableArray *dataSets = [[NSMutableArray alloc] init]; diff --git a/ChartsDemo-iOS/Objective-C/Demos/MultipleLinesChartViewController.m b/ChartsDemo-iOS/Objective-C/Demos/MultipleLinesChartViewController.m index c49f762c63..358a7e21eb 100644 --- a/ChartsDemo-iOS/Objective-C/Demos/MultipleLinesChartViewController.m +++ b/ChartsDemo-iOS/Objective-C/Demos/MultipleLinesChartViewController.m @@ -106,7 +106,7 @@ - (void)setDataCount:(int)count range:(double)range [values addObject:[[ChartDataEntry alloc] initWithX:i y:val]]; } - LineChartDataSet *d = [[LineChartDataSet alloc] initWithValues:values label:[NSString stringWithFormat:@"DataSet %d", z + 1]]; + LineChartDataSet *d = [[LineChartDataSet alloc] initWithEntries:values label:[NSString stringWithFormat:@"DataSet %d", z + 1]]; d.lineWidth = 2.5; d.circleRadius = 4.0; d.circleHoleRadius = 2.0; diff --git a/ChartsDemo-iOS/Objective-C/Demos/NegativeStackedBarChartViewController.m b/ChartsDemo-iOS/Objective-C/Demos/NegativeStackedBarChartViewController.m index 0e2703a83d..b87ef62a13 100644 --- a/ChartsDemo-iOS/Objective-C/Demos/NegativeStackedBarChartViewController.m +++ b/ChartsDemo-iOS/Objective-C/Demos/NegativeStackedBarChartViewController.m @@ -124,7 +124,7 @@ - (void)setChartData if (_chartView.data.dataSetCount > 0) { set = (BarChartDataSet *)_chartView.data.dataSets[0]; - set.values = yValues; + [set replaceEntries: yValues]; [_chartView.data notifyDataChanged]; [_chartView notifyDataSetChanged]; } @@ -137,7 +137,7 @@ - (void)setChartData customFormatter.minimumSignificantDigits = 1; customFormatter.minimumFractionDigits = 1; - set = [[BarChartDataSet alloc] initWithValues:yValues label:@"Age Distribution"]; + set = [[BarChartDataSet alloc] initWithEntries:yValues label:@"Age Distribution"]; set.drawIconsEnabled = NO; diff --git a/ChartsDemo-iOS/Objective-C/Demos/PieChartViewController.m b/ChartsDemo-iOS/Objective-C/Demos/PieChartViewController.m index 5197fcea60..5bc3a9d665 100644 --- a/ChartsDemo-iOS/Objective-C/Demos/PieChartViewController.m +++ b/ChartsDemo-iOS/Objective-C/Demos/PieChartViewController.m @@ -97,7 +97,7 @@ - (void)setDataCount:(int)count range:(double)range [values addObject:[[PieChartDataEntry alloc] initWithValue:(arc4random_uniform(mult) + mult / 5) label:parties[i % parties.count] icon: [UIImage imageNamed:@"icon"]]]; } - PieChartDataSet *dataSet = [[PieChartDataSet alloc] initWithValues:values label:@"Election Results"]; + PieChartDataSet *dataSet = [[PieChartDataSet alloc] initWithEntries:values label:@"Election Results"]; dataSet.drawIconsEnabled = NO; diff --git a/ChartsDemo-iOS/Objective-C/Demos/PiePolylineChartViewController.m b/ChartsDemo-iOS/Objective-C/Demos/PiePolylineChartViewController.m index 98414e0d80..81f092e9be 100644 --- a/ChartsDemo-iOS/Objective-C/Demos/PiePolylineChartViewController.m +++ b/ChartsDemo-iOS/Objective-C/Demos/PiePolylineChartViewController.m @@ -82,7 +82,7 @@ - (void)setDataCount:(int)count range:(double)range [entries addObject:[[PieChartDataEntry alloc] initWithValue:(arc4random_uniform(mult) + mult / 5) label:parties[i % parties.count]]]; } - PieChartDataSet *dataSet = [[PieChartDataSet alloc] initWithValues:entries label:@"Election Results"]; + PieChartDataSet *dataSet = [[PieChartDataSet alloc] initWithEntries:entries label:@"Election Results"]; dataSet.sliceSpace = 2.0; // add a lot of colors diff --git a/ChartsDemo-iOS/Objective-C/Demos/PositiveNegativeBarChartViewController.m b/ChartsDemo-iOS/Objective-C/Demos/PositiveNegativeBarChartViewController.m index febad6bbd1..2440fe9e1a 100644 --- a/ChartsDemo-iOS/Objective-C/Demos/PositiveNegativeBarChartViewController.m +++ b/ChartsDemo-iOS/Objective-C/Demos/PositiveNegativeBarChartViewController.m @@ -149,7 +149,7 @@ - (void)setChartData } } - BarChartDataSet *set = set = [[BarChartDataSet alloc] initWithValues:values label:@"Values"]; + BarChartDataSet *set = set = [[BarChartDataSet alloc] initWithEntries:values label:@"Values"]; set.colors = colors; set.valueColors = colors; diff --git a/ChartsDemo-iOS/Objective-C/Demos/RadarChartViewController.m b/ChartsDemo-iOS/Objective-C/Demos/RadarChartViewController.m index 857ea82dca..24cfea5b58 100644 --- a/ChartsDemo-iOS/Objective-C/Demos/RadarChartViewController.m +++ b/ChartsDemo-iOS/Objective-C/Demos/RadarChartViewController.m @@ -151,7 +151,7 @@ - (void)setChartData [entries2 addObject:[[RadarChartDataEntry alloc] initWithValue:(arc4random_uniform(mult) + min)]]; } - RadarChartDataSet *set1 = [[RadarChartDataSet alloc] initWithValues:entries1 label:@"Last Week"]; + RadarChartDataSet *set1 = [[RadarChartDataSet alloc] initWithEntries:entries1 label:@"Last Week"]; [set1 setColor:[UIColor colorWithRed:103/255.0 green:110/255.0 blue:129/255.0 alpha:1.0]]; set1.fillColor = [UIColor colorWithRed:103/255.0 green:110/255.0 blue:129/255.0 alpha:1.0]; set1.drawFilledEnabled = YES; @@ -160,7 +160,7 @@ - (void)setChartData set1.drawHighlightCircleEnabled = YES; [set1 setDrawHighlightIndicators:NO]; - RadarChartDataSet *set2 = [[RadarChartDataSet alloc] initWithValues:entries2 label:@"This Week"]; + RadarChartDataSet *set2 = [[RadarChartDataSet alloc] initWithEntries:entries2 label:@"This Week"]; [set2 setColor:[UIColor colorWithRed:121/255.0 green:162/255.0 blue:175/255.0 alpha:1.0]]; set2.fillColor = [UIColor colorWithRed:121/255.0 green:162/255.0 blue:175/255.0 alpha:1.0]; set2.drawFilledEnabled = YES; diff --git a/ChartsDemo-iOS/Objective-C/Demos/ScatterChartViewController.m b/ChartsDemo-iOS/Objective-C/Demos/ScatterChartViewController.m index 1434995699..19a158f640 100644 --- a/ChartsDemo-iOS/Objective-C/Demos/ScatterChartViewController.m +++ b/ChartsDemo-iOS/Objective-C/Demos/ScatterChartViewController.m @@ -110,15 +110,15 @@ - (void)setDataCount:(int)count range:(double)range [yVals3 addObject:[[ChartDataEntry alloc] initWithX:(double)i + 0.66 y:val]]; } - ScatterChartDataSet *set1 = [[ScatterChartDataSet alloc] initWithValues:yVals1 label:@"DS 1"]; + ScatterChartDataSet *set1 = [[ScatterChartDataSet alloc] initWithEntries:yVals1 label:@"DS 1"]; [set1 setScatterShape:ScatterShapeSquare]; [set1 setColor:ChartColorTemplates.colorful[0]]; - ScatterChartDataSet *set2 = [[ScatterChartDataSet alloc] initWithValues:yVals2 label:@"DS 2"]; + ScatterChartDataSet *set2 = [[ScatterChartDataSet alloc] initWithEntries:yVals2 label:@"DS 2"]; [set2 setScatterShape:ScatterShapeCircle]; set2.scatterShapeHoleColor = ChartColorTemplates.colorful[3]; set2.scatterShapeHoleRadius = 3.5f; [set2 setColor:ChartColorTemplates.colorful[1]]; - ScatterChartDataSet *set3 = [[ScatterChartDataSet alloc] initWithValues:yVals3 label:@"DS 3"]; + ScatterChartDataSet *set3 = [[ScatterChartDataSet alloc] initWithEntries:yVals3 label:@"DS 3"]; [set3 setScatterShape:ScatterShapeCross]; [set3 setColor:ChartColorTemplates.colorful[2]]; diff --git a/ChartsDemo-iOS/Objective-C/Demos/SinusBarChartViewController.m b/ChartsDemo-iOS/Objective-C/Demos/SinusBarChartViewController.m index c945986a36..e64bf3388b 100644 --- a/ChartsDemo-iOS/Objective-C/Demos/SinusBarChartViewController.m +++ b/ChartsDemo-iOS/Objective-C/Demos/SinusBarChartViewController.m @@ -118,13 +118,13 @@ - (void)setDataCount:(int)count if (_chartView.data.dataSetCount > 0) { set = (BarChartDataSet *)_chartView.data.dataSets[0]; - set.values = entries; + [set replaceEntries: entries]; [_chartView.data notifyDataChanged]; [_chartView notifyDataSetChanged]; } else { - set = [[BarChartDataSet alloc] initWithValues:entries label:@"Sinus Function"]; + set = [[BarChartDataSet alloc] initWithEntries:entries label:@"Sinus Function"]; [set setColor:[UIColor colorWithRed:240/255.f green:120/255.f blue:124/255.f alpha:1.f]]; BarChartData *data = [[BarChartData alloc] initWithDataSet:set]; diff --git a/ChartsDemo-iOS/Objective-C/Demos/StackedBarChartViewController.m b/ChartsDemo-iOS/Objective-C/Demos/StackedBarChartViewController.m index 0a572b4cf8..69fb1053bf 100644 --- a/ChartsDemo-iOS/Objective-C/Demos/StackedBarChartViewController.m +++ b/ChartsDemo-iOS/Objective-C/Demos/StackedBarChartViewController.m @@ -119,13 +119,13 @@ - (void)setDataCount:(int)count range:(double)range if (_chartView.data.dataSetCount > 0) { set1 = (BarChartDataSet *)_chartView.data.dataSets[0]; - set1.values = yVals; + [set1 replaceEntries: yVals]; [_chartView.data notifyDataChanged]; [_chartView notifyDataSetChanged]; } else { - set1 = [[BarChartDataSet alloc] initWithValues:yVals label:@"Statistics Vienna 2014"]; + set1 = [[BarChartDataSet alloc] initWithEntries:yVals label:@"Statistics Vienna 2014"]; set1.drawIconsEnabled = NO; diff --git a/ChartsDemo-iOS/Swift/Components/BalloonMarker.swift b/ChartsDemo-iOS/Swift/Components/BalloonMarker.swift index a304c0c808..3a66e1cb6a 100644 --- a/ChartsDemo-iOS/Swift/Components/BalloonMarker.swift +++ b/ChartsDemo-iOS/Swift/Components/BalloonMarker.swift @@ -24,7 +24,7 @@ open class BalloonMarker: MarkerImage fileprivate var label: String? fileprivate var _labelSize: CGSize = CGSize() fileprivate var _paragraphStyle: NSMutableParagraphStyle? - fileprivate var _drawAttributes = [NSAttributedString.Key : AnyObject]() + fileprivate var _drawAttributes = [NSAttributedString.Key : Any]() public init(color: UIColor, font: UIFont, textColor: UIColor, insets: UIEdgeInsets) { diff --git a/ChartsDemo-iOS/Swift/Demos/AnotherBarChartViewController.swift b/ChartsDemo-iOS/Swift/Demos/AnotherBarChartViewController.swift index 38891b0c89..abfe17ef3c 100644 --- a/ChartsDemo-iOS/Swift/Demos/AnotherBarChartViewController.swift +++ b/ChartsDemo-iOS/Swift/Demos/AnotherBarChartViewController.swift @@ -70,11 +70,11 @@ class AnotherBarChartViewController: DemoBaseViewController { var set1: BarChartDataSet! = nil if let set = chartView.data?.dataSets.first as? BarChartDataSet { set1 = set - set1?.values = yVals + set1?.replaceEntries(yVals) chartView.data?.notifyDataChanged() chartView.notifyDataSetChanged() } else { - set1 = BarChartDataSet(values: yVals, label: "Data Set") + set1 = BarChartDataSet(entries: yVals, label: "Data Set") set1.colors = ChartColorTemplates.vordiplom() set1.drawValuesEnabled = false diff --git a/ChartsDemo-iOS/Swift/Demos/BarChartViewController.swift b/ChartsDemo-iOS/Swift/Demos/BarChartViewController.swift index a9a629120a..02fc03034a 100644 --- a/ChartsDemo-iOS/Swift/Demos/BarChartViewController.swift +++ b/ChartsDemo-iOS/Swift/Demos/BarChartViewController.swift @@ -121,11 +121,11 @@ class BarChartViewController: DemoBaseViewController { var set1: BarChartDataSet! = nil if let set = chartView.data?.dataSets.first as? BarChartDataSet { set1 = set - set1.values = yVals + set1.replaceEntries(yVals) chartView.data?.notifyDataChanged() chartView.notifyDataSetChanged() } else { - set1 = BarChartDataSet(values: yVals, label: "The year 2017") + set1 = BarChartDataSet(entries: yVals, label: "The year 2017") set1.colors = ChartColorTemplates.material() set1.drawValuesEnabled = false diff --git a/ChartsDemo-iOS/Swift/Demos/BubbleChartViewController.swift b/ChartsDemo-iOS/Swift/Demos/BubbleChartViewController.swift index 61d944b735..b53576fc79 100644 --- a/ChartsDemo-iOS/Swift/Demos/BubbleChartViewController.swift +++ b/ChartsDemo-iOS/Swift/Demos/BubbleChartViewController.swift @@ -89,18 +89,18 @@ class BubbleChartViewController: DemoBaseViewController { return BubbleChartDataEntry(x: Double(i), y: val, size: size) } - let set1 = BubbleChartDataSet(values: yVals1, label: "DS 1") + let set1 = BubbleChartDataSet(entries: yVals1, label: "DS 1") set1.drawIconsEnabled = false set1.setColor(ChartColorTemplates.colorful()[0], alpha: 0.5) set1.drawValuesEnabled = true - let set2 = BubbleChartDataSet(values: yVals2, label: "DS 2") + let set2 = BubbleChartDataSet(entries: yVals2, label: "DS 2") set2.drawIconsEnabled = false set2.iconsOffset = CGPoint(x: 0, y: 15) set2.setColor(ChartColorTemplates.colorful()[1], alpha: 0.5) set2.drawValuesEnabled = true - let set3 = BubbleChartDataSet(values: yVals3, label: "DS 3") + let set3 = BubbleChartDataSet(entries: yVals3, label: "DS 3") set3.setColor(ChartColorTemplates.colorful()[2], alpha: 0.5) set3.drawValuesEnabled = true diff --git a/ChartsDemo-iOS/Swift/Demos/CandleStickChartViewController.swift b/ChartsDemo-iOS/Swift/Demos/CandleStickChartViewController.swift index ae2fcc6a89..d8fd334ca0 100644 --- a/ChartsDemo-iOS/Swift/Demos/CandleStickChartViewController.swift +++ b/ChartsDemo-iOS/Swift/Demos/CandleStickChartViewController.swift @@ -87,7 +87,7 @@ class CandleStickChartViewController: DemoBaseViewController { return CandleChartDataEntry(x: Double(i), shadowH: val + high, shadowL: val - low, open: even ? val + open : val - open, close: even ? val - close : val + close, icon: UIImage(named: "icon")!) } - let set1 = CandleChartDataSet(values: yVals1, label: "Data Set") + let set1 = CandleChartDataSet(entries: yVals1, label: "Data Set") set1.axisDependency = .left set1.setColor(UIColor(white: 80/255, alpha: 1)) set1.drawIconsEnabled = false diff --git a/ChartsDemo-iOS/Swift/Demos/ColoredLineChartViewController.swift b/ChartsDemo-iOS/Swift/Demos/ColoredLineChartViewController.swift index a5309ea707..a2e105995e 100644 --- a/ChartsDemo-iOS/Swift/Demos/ColoredLineChartViewController.swift +++ b/ChartsDemo-iOS/Swift/Demos/ColoredLineChartViewController.swift @@ -62,7 +62,7 @@ class ColoredLineChartViewController: DemoBaseViewController { return ChartDataEntry(x: Double(i), y: val) } - let set1 = LineChartDataSet(values: yVals, label: "DataSet 1") + let set1 = LineChartDataSet(entries: yVals, label: "DataSet 1") set1.lineWidth = 1.75 set1.circleRadius = 5.0 diff --git a/ChartsDemo-iOS/Swift/Demos/CombinedChartViewController.swift b/ChartsDemo-iOS/Swift/Demos/CombinedChartViewController.swift index d3162293a7..e78aadaa96 100644 --- a/ChartsDemo-iOS/Swift/Demos/CombinedChartViewController.swift +++ b/ChartsDemo-iOS/Swift/Demos/CombinedChartViewController.swift @@ -126,7 +126,7 @@ class CombinedChartViewController: DemoBaseViewController { return ChartDataEntry(x: Double(i) + 0.5, y: Double(arc4random_uniform(15) + 5)) } - let set = LineChartDataSet(values: entries, label: "Line DataSet") + let set = LineChartDataSet(entries: entries, label: "Line DataSet") set.setColor(UIColor(red: 240/255, green: 238/255, blue: 70/255, alpha: 1)) set.lineWidth = 2.5 set.setCircleColor(UIColor(red: 240/255, green: 238/255, blue: 70/255, alpha: 1)) @@ -151,13 +151,13 @@ class CombinedChartViewController: DemoBaseViewController { return BarChartDataEntry(x: 0, yValues: [Double(arc4random_uniform(13) + 12), Double(arc4random_uniform(13) + 12)]) } - let set1 = BarChartDataSet(values: entries1, label: "Bar 1") + let set1 = BarChartDataSet(entries: entries1, label: "Bar 1") set1.setColor(UIColor(red: 60/255, green: 220/255, blue: 78/255, alpha: 1)) set1.valueTextColor = UIColor(red: 60/255, green: 220/255, blue: 78/255, alpha: 1) set1.valueFont = .systemFont(ofSize: 10) set1.axisDependency = .left - let set2 = BarChartDataSet(values: entries2, label: "") + let set2 = BarChartDataSet(entries: entries2, label: "") set2.stackLabels = ["Stack 1", "Stack 2"] set2.colors = [UIColor(red: 61/255, green: 165/255, blue: 255/255, alpha: 1), UIColor(red: 23/255, green: 197/255, blue: 255/255, alpha: 1) @@ -185,7 +185,7 @@ class CombinedChartViewController: DemoBaseViewController { return ChartDataEntry(x: i+0.25, y: Double(arc4random_uniform(10) + 55)) } - let set = ScatterChartDataSet(values: entries, label: "Scatter DataSet") + let set = ScatterChartDataSet(entries: entries, label: "Scatter DataSet") set.colors = ChartColorTemplates.material() set.scatterShapeSize = 4.5 set.drawValuesEnabled = false @@ -199,7 +199,7 @@ class CombinedChartViewController: DemoBaseViewController { return CandleChartDataEntry(x: Double(i+1), shadowH: 90, shadowL: 70, open: 85, close: 75) } - let set = CandleChartDataSet(values: entries, label: "Candle DataSet") + let set = CandleChartDataSet(entries: entries, label: "Candle DataSet") set.setColor(UIColor(red: 80/255, green: 80/255, blue: 80/255, alpha: 1)) set.decreasingColor = UIColor(red: 142/255, green: 150/255, blue: 175/255, alpha: 1) set.shadowColor = .darkGray @@ -216,7 +216,7 @@ class CombinedChartViewController: DemoBaseViewController { size: CGFloat(arc4random_uniform(50) + 105)) } - let set = BubbleChartDataSet(values: entries, label: "Bubble DataSet") + let set = BubbleChartDataSet(entries: entries, label: "Bubble DataSet") set.setColors(ChartColorTemplates.vordiplom(), alpha: 1) set.valueTextColor = .white set.valueFont = .systemFont(ofSize: 10) diff --git a/ChartsDemo-iOS/Swift/Demos/CubicLineChartViewController.swift b/ChartsDemo-iOS/Swift/Demos/CubicLineChartViewController.swift index 627d13d08d..257be284f1 100644 --- a/ChartsDemo-iOS/Swift/Demos/CubicLineChartViewController.swift +++ b/ChartsDemo-iOS/Swift/Demos/CubicLineChartViewController.swift @@ -89,7 +89,7 @@ class CubicLineChartViewController: DemoBaseViewController { return ChartDataEntry(x: Double(i), y: val) } - let set1 = LineChartDataSet(values: yVals1, label: "DataSet 1") + let set1 = LineChartDataSet(entries: yVals1, label: "DataSet 1") set1.mode = .cubicBezier set1.drawCirclesEnabled = false set1.lineWidth = 1.8 diff --git a/ChartsDemo-iOS/Swift/Demos/HalfPieChartViewController.swift b/ChartsDemo-iOS/Swift/Demos/HalfPieChartViewController.swift index f820f53dae..541aa6080c 100644 --- a/ChartsDemo-iOS/Swift/Demos/HalfPieChartViewController.swift +++ b/ChartsDemo-iOS/Swift/Demos/HalfPieChartViewController.swift @@ -80,7 +80,7 @@ class HalfPieChartViewController: DemoBaseViewController { label: parties[i % parties.count]) } - let set = PieChartDataSet(values: entries, label: "Election Results") + let set = PieChartDataSet(entries: entries, label: "Election Results") set.sliceSpace = 3 set.selectionShift = 5 set.colors = ChartColorTemplates.material() diff --git a/ChartsDemo-iOS/Swift/Demos/HorizontalBarChartViewController.swift b/ChartsDemo-iOS/Swift/Demos/HorizontalBarChartViewController.swift index 2dbcab9491..850a6b6eab 100644 --- a/ChartsDemo-iOS/Swift/Demos/HorizontalBarChartViewController.swift +++ b/ChartsDemo-iOS/Swift/Demos/HorizontalBarChartViewController.swift @@ -100,7 +100,7 @@ class HorizontalBarChartViewController: DemoBaseViewController { return BarChartDataEntry(x: Double(i)*spaceForBar, y: val, icon: #imageLiteral(resourceName: "icon")) } - let set1 = BarChartDataSet(values: yVals, label: "DataSet") + let set1 = BarChartDataSet(entries: yVals, label: "DataSet") set1.drawIconsEnabled = false let data = BarChartData(dataSet: set1) diff --git a/ChartsDemo-iOS/Swift/Demos/LineChart1ViewController.swift b/ChartsDemo-iOS/Swift/Demos/LineChart1ViewController.swift index d017f896d5..8dbd51d5e7 100644 --- a/ChartsDemo-iOS/Swift/Demos/LineChart1ViewController.swift +++ b/ChartsDemo-iOS/Swift/Demos/LineChart1ViewController.swift @@ -50,7 +50,7 @@ class LineChart1ViewController: DemoBaseViewController { let llXAxis = ChartLimitLine(limit: 10, label: "Index 10") llXAxis.lineWidth = 4 llXAxis.lineDashLengths = [10, 10, 0] - llXAxis.labelPosition = .rightBottom + llXAxis.labelPosition = .bottomRight llXAxis.valueFont = .systemFont(ofSize: 10) chartView.xAxis.gridLineDashLengths = [10, 10] @@ -59,13 +59,13 @@ class LineChart1ViewController: DemoBaseViewController { let ll1 = ChartLimitLine(limit: 150, label: "Upper Limit") ll1.lineWidth = 4 ll1.lineDashLengths = [5, 5] - ll1.labelPosition = .rightTop + ll1.labelPosition = .topRight ll1.valueFont = .systemFont(ofSize: 10) let ll2 = ChartLimitLine(limit: -30, label: "Lower Limit") ll2.lineWidth = 4 ll2.lineDashLengths = [5,5] - ll2.labelPosition = .rightBottom + ll2.labelPosition = .bottomRight ll2.valueFont = .systemFont(ofSize: 10) let leftAxis = chartView.leftAxis @@ -119,7 +119,7 @@ class LineChart1ViewController: DemoBaseViewController { return ChartDataEntry(x: Double(i), y: val, icon: #imageLiteral(resourceName: "icon")) } - let set1 = LineChartDataSet(values: values, label: "DataSet 1") + let set1 = LineChartDataSet(entries: values, label: "DataSet 1") set1.drawIconsEnabled = false set1.lineDashLengths = [5, 2.5] diff --git a/ChartsDemo-iOS/Swift/Demos/LineChart2ViewController.swift b/ChartsDemo-iOS/Swift/Demos/LineChart2ViewController.swift index 564d50f66d..dc94f6c65b 100644 --- a/ChartsDemo-iOS/Swift/Demos/LineChart2ViewController.swift +++ b/ChartsDemo-iOS/Swift/Demos/LineChart2ViewController.swift @@ -102,7 +102,7 @@ class LineChart2ViewController: DemoBaseViewController { return ChartDataEntry(x: Double(i), y: val) } - let set1 = LineChartDataSet(values: yVals1, label: "DataSet 1") + let set1 = LineChartDataSet(entries: yVals1, label: "DataSet 1") set1.axisDependency = .left set1.setColor(UIColor(red: 51/255, green: 181/255, blue: 229/255, alpha: 1)) set1.setCircleColor(.white) @@ -113,7 +113,7 @@ class LineChart2ViewController: DemoBaseViewController { set1.highlightColor = UIColor(red: 244/255, green: 117/255, blue: 117/255, alpha: 1) set1.drawCircleHoleEnabled = false - let set2 = LineChartDataSet(values: yVals2, label: "DataSet 2") + let set2 = LineChartDataSet(entries: yVals2, label: "DataSet 2") set2.axisDependency = .right set2.setColor(.red) set2.setCircleColor(.white) @@ -124,7 +124,7 @@ class LineChart2ViewController: DemoBaseViewController { set2.highlightColor = UIColor(red: 244/255, green: 117/255, blue: 117/255, alpha: 1) set2.drawCircleHoleEnabled = false - let set3 = LineChartDataSet(values: yVals3, label: "DataSet 3") + let set3 = LineChartDataSet(entries: yVals3, label: "DataSet 3") set3.axisDependency = .right set3.setColor(.yellow) set3.setCircleColor(.white) diff --git a/ChartsDemo-iOS/Swift/Demos/LineChartFilledViewController.swift b/ChartsDemo-iOS/Swift/Demos/LineChartFilledViewController.swift index 11726e4e4f..7c515c352b 100644 --- a/ChartsDemo-iOS/Swift/Demos/LineChartFilledViewController.swift +++ b/ChartsDemo-iOS/Swift/Demos/LineChartFilledViewController.swift @@ -72,7 +72,7 @@ class LineChartFilledViewController: DemoBaseViewController { return ChartDataEntry(x: Double(i), y: val) } - let set1 = LineChartDataSet(values: yVals1, label: "DataSet 1") + let set1 = LineChartDataSet(entries: yVals1, label: "DataSet 1") set1.axisDependency = .left set1.setColor(UIColor(red: 255/255, green: 241/255, blue: 46/255, alpha: 1)) set1.drawCirclesEnabled = false @@ -87,7 +87,7 @@ class LineChartFilledViewController: DemoBaseViewController { return CGFloat(self.chartView.leftAxis.axisMinimum) } - let set2 = LineChartDataSet(values: yVals2, label: "DataSet 2") + let set2 = LineChartDataSet(entries: yVals2, label: "DataSet 2") set2.axisDependency = .left set2.setColor(UIColor(red: 255/255, green: 241/255, blue: 46/255, alpha: 1)) set2.drawCirclesEnabled = false diff --git a/ChartsDemo-iOS/Swift/Demos/LineChartTimeViewController.swift b/ChartsDemo-iOS/Swift/Demos/LineChartTimeViewController.swift index 0ab688ec60..92258e15db 100644 --- a/ChartsDemo-iOS/Swift/Demos/LineChartTimeViewController.swift +++ b/ChartsDemo-iOS/Swift/Demos/LineChartTimeViewController.swift @@ -99,7 +99,7 @@ class LineChartTimeViewController: DemoBaseViewController { return ChartDataEntry(x: x, y: Double(y)) } - let set1 = LineChartDataSet(values: values, label: "DataSet 1") + let set1 = LineChartDataSet(entries: values, label: "DataSet 1") set1.axisDependency = .left set1.setColor(UIColor(red: 51/255, green: 181/255, blue: 229/255, alpha: 1)) set1.lineWidth = 1.5 diff --git a/ChartsDemo-iOS/Swift/Demos/MultipleBarChartViewController.swift b/ChartsDemo-iOS/Swift/Demos/MultipleBarChartViewController.swift index 93c9f4654b..26d806d5e2 100644 --- a/ChartsDemo-iOS/Swift/Demos/MultipleBarChartViewController.swift +++ b/ChartsDemo-iOS/Swift/Demos/MultipleBarChartViewController.swift @@ -107,16 +107,16 @@ class MultipleBarChartViewController: DemoBaseViewController { let yVals3 = (startYear ..< endYear).map(block) let yVals4 = (startYear ..< endYear).map(block) - let set1 = BarChartDataSet(values: yVals1, label: "Company A") + let set1 = BarChartDataSet(entries: yVals1, label: "Company A") set1.setColor(UIColor(red: 104/255, green: 241/255, blue: 175/255, alpha: 1)) - let set2 = BarChartDataSet(values: yVals2, label: "Company B") + let set2 = BarChartDataSet(entries: yVals2, label: "Company B") set2.setColor(UIColor(red: 164/255, green: 228/255, blue: 251/255, alpha: 1)) - let set3 = BarChartDataSet(values: yVals3, label: "Company C") + let set3 = BarChartDataSet(entries: yVals3, label: "Company C") set3.setColor(UIColor(red: 242/255, green: 247/255, blue: 158/255, alpha: 1)) - let set4 = BarChartDataSet(values: yVals4, label: "Company D") + let set4 = BarChartDataSet(entries: yVals4, label: "Company D") set4.setColor(UIColor(red: 255/255, green: 102/255, blue: 0/255, alpha: 1)) let data = BarChartData(dataSets: [set1, set2, set3, set4]) diff --git a/ChartsDemo-iOS/Swift/Demos/MultipleLinesChartViewController.swift b/ChartsDemo-iOS/Swift/Demos/MultipleLinesChartViewController.swift index 4b11f73d28..78a969c698 100644 --- a/ChartsDemo-iOS/Swift/Demos/MultipleLinesChartViewController.swift +++ b/ChartsDemo-iOS/Swift/Demos/MultipleLinesChartViewController.swift @@ -78,7 +78,7 @@ class MultipleLinesChartViewController: DemoBaseViewController { } let dataSets = (0..<3).map { i -> LineChartDataSet in let yVals = (0.. 0 ? red : green } - let set = BarChartDataSet(values: yVals, label: "Values") + let set = BarChartDataSet(entries: yVals, label: "Values") set.colors = colors set.valueColors = colors diff --git a/ChartsDemo-iOS/Swift/Demos/RadarChartViewController.swift b/ChartsDemo-iOS/Swift/Demos/RadarChartViewController.swift index ffd810749d..c46736f98d 100644 --- a/ChartsDemo-iOS/Swift/Demos/RadarChartViewController.swift +++ b/ChartsDemo-iOS/Swift/Demos/RadarChartViewController.swift @@ -124,7 +124,7 @@ class RadarChartViewController: DemoBaseViewController { let entries1 = (0.. 0.7) minitest (~> 5.1) thread_safe (~> 0.3, >= 0.3.4) @@ -11,12 +11,12 @@ GEM public_suffix (>= 2.0.2, < 4.0) atomos (0.1.3) claide (1.0.2) - cocoapods (1.6.0.beta.1) + cocoapods (1.7.0.beta.3) activesupport (>= 4.0.2, < 5) claide (>= 1.0.2, < 2.0) - cocoapods-core (= 1.6.0.beta.1) - cocoapods-deintegrate (>= 1.0.2, < 2.0) - cocoapods-downloader (>= 1.2.1, < 2.0) + cocoapods-core (= 1.7.0.beta.3) + cocoapods-deintegrate (>= 1.0.3, < 2.0) + cocoapods-downloader (>= 1.2.2, < 2.0) cocoapods-plugins (>= 1.0.0, < 2.0) cocoapods-search (>= 1.0.0, < 2.0) cocoapods-stats (>= 1.0.0, < 2.0) @@ -24,34 +24,34 @@ GEM cocoapods-try (>= 1.1.0, < 2.0) colored2 (~> 3.1) escape (~> 0.0.4) - fourflusher (~> 2.0.1) + fourflusher (>= 2.2.0, < 3.0) gh_inspector (~> 1.0) molinillo (~> 0.6.6) nap (~> 1.0) - ruby-macho (~> 1.2) - xcodeproj (>= 1.6.0, < 2.0) - cocoapods-core (1.6.0.beta.1) + ruby-macho (~> 1.4) + xcodeproj (>= 1.8.2, < 2.0) + cocoapods-core (1.7.0.beta.3) activesupport (>= 4.0.2, < 6) fuzzy_match (~> 2.0.4) nap (~> 1.0) - cocoapods-deintegrate (1.0.2) - cocoapods-downloader (1.2.1) + cocoapods-deintegrate (1.0.4) + cocoapods-downloader (1.2.2) cocoapods-plugins (1.0.0) nap cocoapods-search (1.0.0) - cocoapods-stats (1.0.0) + cocoapods-stats (1.1.0) cocoapods-trunk (1.3.1) nap (>= 0.8, < 2.0) netrc (~> 0.11) cocoapods-try (1.1.0) colored2 (3.1.2) - concurrent-ruby (1.0.5) + concurrent-ruby (1.1.5) escape (0.0.4) - faraday (0.15.3) + faraday (0.15.4) multipart-post (>= 1.2, < 3) faraday-http-cache (2.0.0) faraday (~> 0.8) - fourflusher (2.0.1) + fourflusher (2.2.0) fuzzy_match (2.0.4) gh_inspector (1.1.3) github_changelog_generator (1.14.3) @@ -71,21 +71,21 @@ GEM nanaimo (0.2.6) nap (1.1.0) netrc (0.11.0) - octokit (4.12.0) + octokit (4.14.0) sawyer (~> 0.8.0, >= 0.5.3) public_suffix (3.0.3) rainbow (3.0.0) - rake (12.3.1) + rake (12.3.2) retriable (2.1.0) rouge (2.0.7) - ruby-macho (1.3.1) + ruby-macho (1.4.0) sawyer (0.8.1) addressable (>= 2.3.5, < 2.6) faraday (~> 0.8, < 1.0) thread_safe (0.3.6) tzinfo (1.2.5) thread_safe (~> 0.1) - xcodeproj (1.6.0) + xcodeproj (1.8.2) CFPropertyList (>= 2.3.3, < 4.0) atomos (~> 0.1.3) claide (>= 1.0.2, < 2.0) @@ -104,4 +104,4 @@ DEPENDENCIES xcpretty BUNDLED WITH - 1.16.3 + 1.16.6 diff --git a/Package.swift b/Package.swift index cbc04b9cf9..6796c8899b 100644 --- a/Package.swift +++ b/Package.swift @@ -11,5 +11,5 @@ let package = Package( targets: [ .target(name: "Charts", dependencies: []) ], - swiftLanguageVersions: [4] + swiftLanguageVersions: [5] ) diff --git a/README.md b/README.md index a74ce0a2c4..89d92c813f 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -**Version 3.2.1**, synced to [MPAndroidChart #f6a398b](https://github.com/PhilJay/MPAndroidChart/commit/f6a398b) +**Version 3.3.0**, synced to [MPAndroidChart #f6a398b](https://github.com/PhilJay/MPAndroidChart/commit/f6a398b) ![alt tag](https://raw.github.com/danielgindi/Charts/master/Assets/feature_graphic.png) ![Supported Platforms](https://img.shields.io/cocoapods/p/Charts.svg) [![Releases](https://img.shields.io/github/release/danielgindi/Charts.svg)](https://github.com/danielgindi/Charts/releases) [![Latest pod release](https://img.shields.io/cocoapods/v/Charts.svg)](http://cocoapods.org/pods/charts) [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) [![Build Status](https://travis-ci.org/danielgindi/Charts.svg?branch=master)](https://travis-ci.org/danielgindi/Charts) [![codecov](https://codecov.io/gh/danielgindi/Charts/branch/master/graph/badge.svg)](https://codecov.io/gh/danielgindi/Charts) @@ -6,14 +6,14 @@ ### Just a heads up: Charts 3.0 has some breaking changes. Please read [the release/migration notes](https://github.com/danielgindi/Charts/releases/tag/v3.0.0). ### Another heads up: ChartsRealm is now in a [separate repo](https://github.com/danielgindi/ChartsRealm). Pods is also now `Charts` and `ChartsRealm`, instead of ~`Charts/Core`~ and ~`Charts/Realm`~ -### One more heads up: As Swift evolves, if you are not using latest Swift compiler, you shouldn't check out master branch. Instead, you should go to release page and pick up whatever suits you. +### One more heads up: As Swift evolves, if you are not using the latest Swift compiler, you shouldn't check out the master branch. Instead, you should go to the release page and pick up whatever suits you. -* Xcode 10.0 / Swift 4.2 (master branch) +* Xcode 10.2 / Swift 5.0 (master branch) * iOS >= 8.0 (Use as an **Embedded** Framework) * tvOS >= 9.0 * macOS >= 10.11 -Okay so there's this beautiful library called [MPAndroidChart](https://github.com/PhilJay/MPAndroidChart) by [Philipp Jahoda](https://www.linkedin.com/in/philippjahoda) which has become very popular amongst Android developers, and in the meanwhile there's no decent charting solution for iOS. +Okay so there's this beautiful library called [MPAndroidChart](https://github.com/PhilJay/MPAndroidChart) by [Philipp Jahoda](https://www.linkedin.com/in/philippjahoda) which has become very popular amongst Android developers, but there was no decent solution to create charts for iOS. I've chosen to write it in `Swift` as it can be highly optimized by the compiler, and can be used in both `Swift` and `ObjC` project. The demo project is written in `ObjC` to demonstrate how it works. @@ -26,7 +26,7 @@ I've chosen to write it in `Swift` as it can be highly optimized by the compiler * Make sure you are running a supported version of Xcode. * Usually it is specified here a few lines above. * In most cases it will be the latest Xcode version. -* Make sure that your project supports Swift 3.0 +* Make sure that your project supports Swift 5.0 * Optional: Run `carthage checkout` in the project folder, to fetch dependencies (i.e testing dependencies). * If you don't have Carthage - you can get it [here](https://github.com/Carthage/Carthage/releases). @@ -79,8 +79,8 @@ For [Realm](https://realm.io/) support, please add `pod 'ChartsRealm'` too. Charts now include Carthage prebuilt binaries. ```carthage -github "danielgindi/Charts" == 3.2.1 -github "danielgindi/Charts" ~> 3.2.1 +github "danielgindi/Charts" == 3.3.0 +github "danielgindi/Charts" ~> 3.3.0 ``` In order to build the binaries for a new release, use `carthage build --no-skip-current && carthage archive Charts`. diff --git a/Source/Charts/Animation/Animator.swift b/Source/Charts/Animation/Animator.swift index 0b4d725ccf..b94b21f496 100644 --- a/Source/Charts/Animation/Animator.swift +++ b/Source/Charts/Animation/Animator.swift @@ -12,10 +12,6 @@ import Foundation import CoreGraphics -#if !os(OSX) - import UIKit -#endif - @objc(ChartAnimatorDelegate) public protocol AnimatorDelegate { @@ -136,10 +132,12 @@ open class Animator: NSObject /// Animates the drawing / rendering of the chart on both x- and y-axis with the specified animation time. /// If `animate(...)` is called, no further calling of `invalidate()` is necessary to refresh the chart. - /// - parameter xAxisDuration: duration for animating the x axis - /// - parameter yAxisDuration: duration for animating the y axis - /// - parameter easingX: an easing function for the animation on the x axis - /// - parameter easingY: an easing function for the animation on the y axis + /// + /// - Parameters: + /// - xAxisDuration: duration for animating the x axis + /// - yAxisDuration: duration for animating the y axis + /// - easingX: an easing function for the animation on the x axis + /// - easingY: an easing function for the animation on the y axis @objc open func animate(xAxisDuration: TimeInterval, yAxisDuration: TimeInterval, easingX: ChartEasingFunctionBlock?, easingY: ChartEasingFunctionBlock?) { stop() @@ -169,10 +167,12 @@ open class Animator: NSObject /// Animates the drawing / rendering of the chart on both x- and y-axis with the specified animation time. /// If `animate(...)` is called, no further calling of `invalidate()` is necessary to refresh the chart. - /// - parameter xAxisDuration: duration for animating the x axis - /// - parameter yAxisDuration: duration for animating the y axis - /// - parameter easingOptionX: the easing function for the animation on the x axis - /// - parameter easingOptionY: the easing function for the animation on the y axis + /// + /// - Parameters: + /// - xAxisDuration: duration for animating the x axis + /// - yAxisDuration: duration for animating the y axis + /// - easingOptionX: the easing function for the animation on the x axis + /// - easingOptionY: the easing function for the animation on the y axis @objc open func animate(xAxisDuration: TimeInterval, yAxisDuration: TimeInterval, easingOptionX: ChartEasingOption, easingOptionY: ChartEasingOption) { animate(xAxisDuration: xAxisDuration, yAxisDuration: yAxisDuration, easingX: easingFunctionFromOption(easingOptionX), easingY: easingFunctionFromOption(easingOptionY)) @@ -180,9 +180,11 @@ open class Animator: NSObject /// Animates the drawing / rendering of the chart on both x- and y-axis with the specified animation time. /// If `animate(...)` is called, no further calling of `invalidate()` is necessary to refresh the chart. - /// - parameter xAxisDuration: duration for animating the x axis - /// - parameter yAxisDuration: duration for animating the y axis - /// - parameter easing: an easing function for the animation + /// + /// - Parameters: + /// - xAxisDuration: duration for animating the x axis + /// - yAxisDuration: duration for animating the y axis + /// - easing: an easing function for the animation @objc open func animate(xAxisDuration: TimeInterval, yAxisDuration: TimeInterval, easing: ChartEasingFunctionBlock?) { animate(xAxisDuration: xAxisDuration, yAxisDuration: yAxisDuration, easingX: easing, easingY: easing) @@ -190,9 +192,11 @@ open class Animator: NSObject /// Animates the drawing / rendering of the chart on both x- and y-axis with the specified animation time. /// If `animate(...)` is called, no further calling of `invalidate()` is necessary to refresh the chart. - /// - parameter xAxisDuration: duration for animating the x axis - /// - parameter yAxisDuration: duration for animating the y axis - /// - parameter easingOption: the easing function for the animation + /// + /// - Parameters: + /// - xAxisDuration: duration for animating the x axis + /// - yAxisDuration: duration for animating the y axis + /// - easingOption: the easing function for the animation @objc open func animate(xAxisDuration: TimeInterval, yAxisDuration: TimeInterval, easingOption: ChartEasingOption = .easeInOutSine) { animate(xAxisDuration: xAxisDuration, yAxisDuration: yAxisDuration, easing: easingFunctionFromOption(easingOption)) @@ -200,8 +204,10 @@ open class Animator: NSObject /// Animates the drawing / rendering of the chart the x-axis with the specified animation time. /// If `animate(...)` is called, no further calling of `invalidate()` is necessary to refresh the chart. - /// - parameter xAxisDuration: duration for animating the x axis - /// - parameter easing: an easing function for the animation + /// + /// - Parameters: + /// - xAxisDuration: duration for animating the x axis + /// - easing: an easing function for the animation @objc open func animate(xAxisDuration: TimeInterval, easing: ChartEasingFunctionBlock?) { _startTimeX = CACurrentMediaTime() @@ -225,8 +231,10 @@ open class Animator: NSObject /// Animates the drawing / rendering of the chart the x-axis with the specified animation time. /// If `animate(...)` is called, no further calling of `invalidate()` is necessary to refresh the chart. - /// - parameter xAxisDuration: duration for animating the x axis - /// - parameter easingOption: the easing function for the animation + /// + /// - Parameters: + /// - xAxisDuration: duration for animating the x axis + /// - easingOption: the easing function for the animation @objc open func animate(xAxisDuration: TimeInterval, easingOption: ChartEasingOption = .easeInOutSine) { animate(xAxisDuration: xAxisDuration, easing: easingFunctionFromOption(easingOption)) @@ -234,8 +242,10 @@ open class Animator: NSObject /// Animates the drawing / rendering of the chart the y-axis with the specified animation time. /// If `animate(...)` is called, no further calling of `invalidate()` is necessary to refresh the chart. - /// - parameter yAxisDuration: duration for animating the y axis - /// - parameter easing: an easing function for the animation + /// + /// - Parameters: + /// - yAxisDuration: duration for animating the y axis + /// - easing: an easing function for the animation @objc open func animate(yAxisDuration: TimeInterval, easing: ChartEasingFunctionBlock?) { _startTimeY = CACurrentMediaTime() @@ -259,8 +269,10 @@ open class Animator: NSObject /// Animates the drawing / rendering of the chart the y-axis with the specified animation time. /// If `animate(...)` is called, no further calling of `invalidate()` is necessary to refresh the chart. - /// - parameter yAxisDuration: duration for animating the y axis - /// - parameter easingOption: the easing function for the animation + /// + /// - Parameters: + /// - yAxisDuration: duration for animating the y axis + /// - easingOption: the easing function for the animation @objc open func animate(yAxisDuration: TimeInterval, easingOption: ChartEasingOption = .easeInOutSine) { animate(yAxisDuration: yAxisDuration, easing: easingFunctionFromOption(easingOption)) diff --git a/Source/Charts/Charts/BarChartView.swift b/Source/Charts/Charts/BarChartView.swift index ec4c019f1f..4f9aaa0bc9 100644 --- a/Source/Charts/Charts/BarChartView.swift +++ b/Source/Charts/Charts/BarChartView.swift @@ -58,7 +58,7 @@ open class BarChartView: BarLineChartViewBase, BarChartDataProvider max: data.getYMax(axis: .right)) } - /// - returns: The Highlight object (contains x-index and DataSet index) of the selected value at the given touch point inside the BarChart. + /// - Returns: The Highlight object (contains x-index and DataSet index) of the selected value at the given touch point inside the BarChart. open override func getHighlightByTouchPoint(_ pt: CGPoint) -> Highlight? { if _data === nil @@ -82,7 +82,7 @@ open class BarChartView: BarLineChartViewBase, BarChartDataProvider axis: h.axis) } - /// - returns: The bounding box of the specified Entry in the specified DataSet. Returns null if the Entry could not be found in the charts data. + /// - Returns: The bounding box of the specified Entry in the specified DataSet. Returns null if the Entry could not be found in the charts data. @objc open func getBarBounds(entry e: BarChartDataEntry) -> CGRect { guard let @@ -111,9 +111,10 @@ open class BarChartView: BarLineChartViewBase, BarChartDataProvider /// Previously set x-values of entries will be overwritten. Leaves space between bars and groups as specified by the parameters. /// Calls `notifyDataSetChanged()` afterwards. /// - /// - parameter fromX: the starting point on the x-axis where the grouping should begin - /// - parameter groupSpace: the space between groups of bars in values (not pixels) e.g. 0.8f for bar width 1f - /// - parameter barSpace: the space between individual bars in values (not pixels) e.g. 0.1f for bar width 1f + /// - Parameters: + /// - fromX: the starting point on the x-axis where the grouping should begin + /// - groupSpace: the space between groups of bars in values (not pixels) e.g. 0.8f for bar width 1f + /// - barSpace: the space between individual bars in values (not pixels) e.g. 0.1f for bar width 1f @objc open func groupBars(fromX: Double, groupSpace: Double, barSpace: Double) { guard let barData = self.barData @@ -128,9 +129,11 @@ open class BarChartView: BarLineChartViewBase, BarChartDataProvider } /// Highlights the value at the given x-value in the given DataSet. Provide -1 as the dataSetIndex to undo all highlighting. - /// - parameter x: - /// - parameter dataSetIndex: - /// - parameter stackIndex: the index inside the stack - only relevant for stacked entries + /// + /// - Parameters: + /// - x: + /// - dataSetIndex: + /// - stackIndex: the index inside the stack - only relevant for stacked entries @objc open func highlightValue(x: Double, dataSetIndex: Int, stackIndex: Int) { highlightValue(Highlight(x: x, dataSetIndex: dataSetIndex, stackIndex: stackIndex)) @@ -168,16 +171,16 @@ open class BarChartView: BarLineChartViewBase, BarChartDataProvider /// If enabled, highlighting operations will highlight the whole bar, even if only a single stack entry was tapped. @objc open var highlightFullBarEnabled: Bool = false - /// - returns: `true` the highlight is be full-bar oriented, `false` ifsingle-value + /// `true` the highlight is be full-bar oriented, `false` ifsingle-value open var isHighlightFullBarEnabled: Bool { return highlightFullBarEnabled } // MARK: - BarChartDataProvider open var barData: BarChartData? { return _data as? BarChartData } - /// - returns: `true` if drawing values above bars is enabled, `false` ifnot + /// `true` if drawing values above bars is enabled, `false` ifnot open var isDrawValueAboveBarEnabled: Bool { return drawValueAboveBarEnabled } - /// - returns: `true` if drawing shadows (maxvalue) for each bar is enabled, `false` ifnot + /// `true` if drawing shadows (maxvalue) for each bar is enabled, `false` ifnot open var isDrawBarShadowEnabled: Bool { return drawBarShadowEnabled } } diff --git a/Source/Charts/Charts/BarLineChartViewBase.swift b/Source/Charts/Charts/BarLineChartViewBase.swift index b169f18295..95a9e98810 100644 --- a/Source/Charts/Charts/BarLineChartViewBase.swift +++ b/Source/Charts/Charts/BarLineChartViewBase.swift @@ -12,10 +12,6 @@ import Foundation import CoreGraphics -#if !os(OSX) - import UIKit -#endif - /// Base-class of LineChart, BarChart, ScatterChart and CandleStickChart. open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartDataProvider, NSUIGestureRecognizerDelegate { @@ -134,10 +130,10 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD _panGestureRecognizer.isEnabled = _dragXEnabled || _dragYEnabled #if !os(tvOS) - _pinchGestureRecognizer = NSUIPinchGestureRecognizer(target: self, action: #selector(BarLineChartViewBase.pinchGestureRecognized(_:))) - _pinchGestureRecognizer.delegate = self - self.addGestureRecognizer(_pinchGestureRecognizer) - _pinchGestureRecognizer.isEnabled = _pinchZoomEnabled || _scaleXEnabled || _scaleYEnabled + _pinchGestureRecognizer = NSUIPinchGestureRecognizer(target: self, action: #selector(BarLineChartViewBase.pinchGestureRecognized(_:))) + _pinchGestureRecognizer.delegate = self + self.addGestureRecognizer(_pinchGestureRecognizer) + _pinchGestureRecognizer.isEnabled = _pinchZoomEnabled || _scaleXEnabled || _scaleYEnabled #endif } @@ -625,8 +621,12 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD { location.y = -(self.bounds.size.height - location.y - _viewPortHandler.offsetBottom) } - - self.zoom(scaleX: isScaleXEnabled ? 1.4 : 1.0, scaleY: isScaleYEnabled ? 1.4 : 1.0, x: location.x, y: location.y) + + let scaleX: CGFloat = isScaleXEnabled ? 1.4 : 1.0 + let scaleY: CGFloat = isScaleYEnabled ? 1.4 : 1.0 + + self.zoom(scaleX: scaleX, scaleY: scaleY, x: location.x, y: location.y) + delegate?.chartScaled?(self, scaleX: scaleX, scaleY: scaleY) } } } @@ -838,6 +838,8 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD _outerScrollView?.nsuiIsScrollEnabled = true _outerScrollView = nil } + + delegate?.chartViewDidEndPanning?(self) } } @@ -864,7 +866,7 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD matrix = _viewPortHandler.refresh(newMatrix: matrix, chart: self, invalidate: true) - if delegate !== nil + if matrix != originalMatrix { delegate?.chartTranslated?(self, dX: translation.x, dY: translation.y) } @@ -938,13 +940,13 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD else { #if !os(tvOS) - if gestureRecognizer == _pinchGestureRecognizer + if gestureRecognizer == _pinchGestureRecognizer + { + if _data === nil || (!_pinchZoomEnabled && !_scaleXEnabled && !_scaleYEnabled) { - if _data === nil || (!_pinchZoomEnabled && !_scaleXEnabled && !_scaleYEnabled) - { - return false - } + return false } + } #endif } @@ -973,11 +975,11 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD open func gestureRecognizer(_ gestureRecognizer: NSUIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: NSUIGestureRecognizer) -> Bool { #if !os(tvOS) - if ((gestureRecognizer is NSUIPinchGestureRecognizer && otherGestureRecognizer is NSUIPanGestureRecognizer) || - (gestureRecognizer is NSUIPanGestureRecognizer && otherGestureRecognizer is NSUIPinchGestureRecognizer)) - { - return true - } + if ((gestureRecognizer is NSUIPinchGestureRecognizer && otherGestureRecognizer is NSUIPanGestureRecognizer) || + (gestureRecognizer is NSUIPanGestureRecognizer && otherGestureRecognizer is NSUIPinchGestureRecognizer)) + { + return true + } #endif if gestureRecognizer is NSUIPanGestureRecognizer, @@ -1062,10 +1064,11 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD /// Zooms in or out by the given scale factor. x and y are the coordinates /// (in pixels) of the zoom center. /// - /// - parameter scaleX: if < 1 --> zoom out, if > 1 --> zoom in - /// - parameter scaleY: if < 1 --> zoom out, if > 1 --> zoom in - /// - parameter x: - /// - parameter y: + /// - Parameters: + /// - scaleX: if < 1 --> zoom out, if > 1 --> zoom in + /// - scaleY: if < 1 --> zoom out, if > 1 --> zoom in + /// - x: + /// - y: @objc open func zoom( scaleX: CGFloat, scaleY: CGFloat, @@ -1083,11 +1086,12 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD /// Zooms in or out by the given scale factor. /// x and y are the values (**not pixels**) of the zoom center. /// - /// - parameter scaleX: if < 1 --> zoom out, if > 1 --> zoom in - /// - parameter scaleY: if < 1 --> zoom out, if > 1 --> zoom in - /// - parameter xValue: - /// - parameter yValue: - /// - parameter axis: + /// - Parameters: + /// - scaleX: if < 1 --> zoom out, if > 1 --> zoom in + /// - scaleY: if < 1 --> zoom out, if > 1 --> zoom in + /// - xValue: + /// - yValue: + /// - axis: @objc open func zoom( scaleX: CGFloat, scaleY: CGFloat, @@ -1109,11 +1113,12 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD /// Zooms to the center of the chart with the given scale factor. /// - /// - parameter scaleX: if < 1 --> zoom out, if > 1 --> zoom in - /// - parameter scaleY: if < 1 --> zoom out, if > 1 --> zoom in - /// - parameter xValue: - /// - parameter yValue: - /// - parameter axis: + /// - Parameters: + /// - scaleX: if < 1 --> zoom out, if > 1 --> zoom in + /// - scaleY: if < 1 --> zoom out, if > 1 --> zoom in + /// - xValue: + /// - yValue: + /// - axis: @objc open func zoomToCenter( scaleX: CGFloat, scaleY: CGFloat) @@ -1129,13 +1134,14 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD /// Zooms by the specified scale factor to the specified values on the specified axis. /// - /// - parameter scaleX: - /// - parameter scaleY: - /// - parameter xValue: - /// - parameter yValue: - /// - parameter axis: which axis should be used as a reference for the y-axis - /// - parameter duration: the duration of the animation in seconds - /// - parameter easing: + /// - Parameters: + /// - scaleX: + /// - scaleY: + /// - xValue: + /// - yValue: + /// - axis: which axis should be used as a reference for the y-axis + /// - duration: the duration of the animation in seconds + /// - easing: @objc open func zoomAndCenterViewAnimated( scaleX: CGFloat, scaleY: CGFloat, @@ -1171,13 +1177,14 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD /// Zooms by the specified scale factor to the specified values on the specified axis. /// - /// - parameter scaleX: - /// - parameter scaleY: - /// - parameter xValue: - /// - parameter yValue: - /// - parameter axis: which axis should be used as a reference for the y-axis - /// - parameter duration: the duration of the animation in seconds - /// - parameter easing: + /// - Parameters: + /// - scaleX: + /// - scaleY: + /// - xValue: + /// - yValue: + /// - axis: which axis should be used as a reference for the y-axis + /// - duration: the duration of the animation in seconds + /// - easing: @objc open func zoomAndCenterViewAnimated( scaleX: CGFloat, scaleY: CGFloat, @@ -1192,13 +1199,14 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD /// Zooms by the specified scale factor to the specified values on the specified axis. /// - /// - parameter scaleX: - /// - parameter scaleY: - /// - parameter xValue: - /// - parameter yValue: - /// - parameter axis: which axis should be used as a reference for the y-axis - /// - parameter duration: the duration of the animation in seconds - /// - parameter easing: + /// - Parameters: + /// - scaleX: + /// - scaleY: + /// - xValue: + /// - yValue: + /// - axis: which axis should be used as a reference for the y-axis + /// - duration: the duration of the animation in seconds + /// - easing: @objc open func zoomAndCenterViewAnimated( scaleX: CGFloat, scaleY: CGFloat, @@ -1271,8 +1279,9 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD /// Sets the size of the area (range on the y-axis) that should be maximum visible at once. /// - /// - parameter yRange: - /// - parameter axis: - the axis for which this limit should apply + /// - Parameters: + /// - yRange: + /// - axis: - the axis for which this limit should apply @objc open func setVisibleYRangeMaximum(_ maxYRange: Double, axis: YAxis.AxisDependency) { let yScale = getAxisRange(axis: axis) / maxYRange @@ -1281,8 +1290,9 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD /// Sets the size of the area (range on the y-axis) that should be minimum visible at once, no further zooming in possible. /// - /// - parameter yRange: - /// - parameter axis: - the axis for which this limit should apply + /// - Parameters: + /// - yRange: + /// - axis: - the axis for which this limit should apply @objc open func setVisibleYRangeMinimum(_ minYRange: Double, axis: YAxis.AxisDependency) { let yScale = getAxisRange(axis: axis) / minYRange @@ -1291,9 +1301,10 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD /// Limits the maximum and minimum y range that can be visible by pinching and zooming. /// - /// - parameter minYRange: - /// - parameter maxYRange: - /// - parameter axis: + /// - Parameters: + /// - minYRange: + /// - maxYRange: + /// - axis: @objc open func setVisibleYRange(minYRange: Double, maxYRange: Double, axis: YAxis.AxisDependency) { let minScale = getAxisRange(axis: axis) / minYRange @@ -1318,8 +1329,9 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD /// Centers the viewport to the specified y-value on the y-axis. /// This also refreshes the chart by calling setNeedsDisplay(). /// - /// - parameter yValue: - /// - parameter axis: - which axis should be used as a reference for the y-axis + /// - Parameters: + /// - yValue: + /// - axis: - which axis should be used as a reference for the y-axis @objc open func moveViewToY(_ yValue: Double, axis: YAxis.AxisDependency) { let yInView = getAxisRange(axis: axis) / Double(_viewPortHandler.scaleY) @@ -1337,9 +1349,10 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD /// This will move the left side of the current viewport to the specified x-value on the x-axis, and center the viewport to the specified y-value on the y-axis. /// This also refreshes the chart by calling setNeedsDisplay(). /// - /// - parameter xValue: - /// - parameter yValue: - /// - parameter axis: - which axis should be used as a reference for the y-axis + /// - Parameters: + /// - xValue: + /// - yValue: + /// - axis: - which axis should be used as a reference for the y-axis @objc open func moveViewTo(xValue: Double, yValue: Double, axis: YAxis.AxisDependency) { let yInView = getAxisRange(axis: axis) / Double(_viewPortHandler.scaleY) @@ -1357,11 +1370,12 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD /// This will move the left side of the current viewport to the specified x-position and center the viewport to the specified y-position animated. /// This also refreshes the chart by calling setNeedsDisplay(). /// - /// - parameter xValue: - /// - parameter yValue: - /// - parameter axis: which axis should be used as a reference for the y-axis - /// - parameter duration: the duration of the animation in seconds - /// - parameter easing: + /// - Parameters: + /// - xValue: + /// - yValue: + /// - axis: which axis should be used as a reference for the y-axis + /// - duration: the duration of the animation in seconds + /// - easing: @objc open func moveViewToAnimated( xValue: Double, yValue: Double, @@ -1392,11 +1406,12 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD /// This will move the left side of the current viewport to the specified x-position and center the viewport to the specified y-position animated. /// This also refreshes the chart by calling setNeedsDisplay(). /// - /// - parameter xValue: - /// - parameter yValue: - /// - parameter axis: which axis should be used as a reference for the y-axis - /// - parameter duration: the duration of the animation in seconds - /// - parameter easing: + /// - Parameters: + /// - xValue: + /// - yValue: + /// - axis: which axis should be used as a reference for the y-axis + /// - duration: the duration of the animation in seconds + /// - easing: @objc open func moveViewToAnimated( xValue: Double, yValue: Double, @@ -1410,11 +1425,12 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD /// This will move the left side of the current viewport to the specified x-position and center the viewport to the specified y-position animated. /// This also refreshes the chart by calling setNeedsDisplay(). /// - /// - parameter xValue: - /// - parameter yValue: - /// - parameter axis: which axis should be used as a reference for the y-axis - /// - parameter duration: the duration of the animation in seconds - /// - parameter easing: + /// - Parameters: + /// - xValue: + /// - yValue: + /// - axis: which axis should be used as a reference for the y-axis + /// - duration: the duration of the animation in seconds + /// - easing: @objc open func moveViewToAnimated( xValue: Double, yValue: Double, @@ -1427,9 +1443,10 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD /// This will move the center of the current viewport to the specified x-value and y-value. /// This also refreshes the chart by calling setNeedsDisplay(). /// - /// - parameter xValue: - /// - parameter yValue: - /// - parameter axis: - which axis should be used as a reference for the y-axis + /// - Parameters: + /// - xValue: + /// - yValue: + /// - axis: - which axis should be used as a reference for the y-axis @objc open func centerViewTo( xValue: Double, yValue: Double, @@ -1450,11 +1467,12 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD /// This will move the center of the current viewport to the specified x-value and y-value animated. /// - /// - parameter xValue: - /// - parameter yValue: - /// - parameter axis: which axis should be used as a reference for the y-axis - /// - parameter duration: the duration of the animation in seconds - /// - parameter easing: + /// - Parameters: + /// - xValue: + /// - yValue: + /// - axis: which axis should be used as a reference for the y-axis + /// - duration: the duration of the animation in seconds + /// - easing: @objc open func centerViewToAnimated( xValue: Double, yValue: Double, @@ -1485,11 +1503,12 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD /// This will move the center of the current viewport to the specified x-value and y-value animated. /// - /// - parameter xValue: - /// - parameter yValue: - /// - parameter axis: which axis should be used as a reference for the y-axis - /// - parameter duration: the duration of the animation in seconds - /// - parameter easing: + /// - Parameters: + /// - xValue: + /// - yValue: + /// - axis: which axis should be used as a reference for the y-axis + /// - duration: the duration of the animation in seconds + /// - easing: @objc open func centerViewToAnimated( xValue: Double, yValue: Double, @@ -1502,11 +1521,12 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD /// This will move the center of the current viewport to the specified x-value and y-value animated. /// - /// - parameter xValue: - /// - parameter yValue: - /// - parameter axis: which axis should be used as a reference for the y-axis - /// - parameter duration: the duration of the animation in seconds - /// - parameter easing: + /// - Parameters: + /// - xValue: + /// - yValue: + /// - axis: which axis should be used as a reference for the y-axis + /// - duration: the duration of the animation in seconds + /// - easing: @objc open func centerViewToAnimated( xValue: Double, yValue: Double, @@ -1545,7 +1565,7 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD // MARK: - Accessors - /// - returns: The range of the specified axis. + /// - Returns: The range of the specified axis. @objc open func getAxisRange(axis: YAxis.AxisDependency) -> Double { if axis == .left @@ -1558,7 +1578,7 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD } } - /// - returns: The position (in pixels) the provided Entry has inside the chart view + /// - Returns: The position (in pixels) the provided Entry has inside the chart view @objc open func getPosition(entry e: ChartDataEntry, axis: YAxis.AxisDependency) -> CGPoint { var vals = CGPoint(x: CGFloat(e.x), y: CGFloat(e.y)) @@ -1622,7 +1642,7 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD _scaleXEnabled = enabled _scaleYEnabled = enabled #if !os(tvOS) - _pinchGestureRecognizer.isEnabled = _pinchZoomEnabled || _scaleXEnabled || _scaleYEnabled + _pinchGestureRecognizer.isEnabled = _pinchZoomEnabled || _scaleXEnabled || _scaleYEnabled #endif } } @@ -1639,7 +1659,7 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD { _scaleXEnabled = newValue #if !os(tvOS) - _pinchGestureRecognizer.isEnabled = _pinchZoomEnabled || _scaleXEnabled || _scaleYEnabled + _pinchGestureRecognizer.isEnabled = _pinchZoomEnabled || _scaleXEnabled || _scaleYEnabled #endif } } @@ -1657,7 +1677,7 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD { _scaleYEnabled = newValue #if !os(tvOS) - _pinchGestureRecognizer.isEnabled = _pinchZoomEnabled || _scaleXEnabled || _scaleYEnabled + _pinchGestureRecognizer.isEnabled = _pinchZoomEnabled || _scaleXEnabled || _scaleYEnabled #endif } } @@ -1684,7 +1704,7 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD } /// **default**: true - /// - returns: `true` if zooming via double-tap is enabled `false` ifnot. + /// `true` if zooming via double-tap is enabled `false` ifnot. @objc open var isDoubleTapToZoomEnabled: Bool { return doubleTapToZoomEnabled @@ -1703,20 +1723,20 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD } /// **default**: true - /// - returns: `true` if drawing the grid background is enabled, `false` ifnot. + /// `true` if drawing the grid background is enabled, `false` ifnot. @objc open var isDrawGridBackgroundEnabled: Bool { return drawGridBackgroundEnabled } /// **default**: false - /// - returns: `true` if drawing the borders rectangle is enabled, `false` ifnot. + /// `true` if drawing the borders rectangle is enabled, `false` ifnot. @objc open var isDrawBordersEnabled: Bool { return drawBordersEnabled } - /// - returns: The x and y values in the chart at the given touch point + /// - Returns: The x and y values in the chart at the given touch point /// (encapsulated in a `CGPoint`). This method transforms pixel coordinates to /// coordinates / values in the chart. This is the opposite method to /// `getPixelsForValues(...)`. @@ -1732,7 +1752,7 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD return getTransformer(forAxis: axis).pixelForValues(x: x, y: y) } - /// - returns: The Entry object displayed at the touched position of the chart + /// - Returns: The Entry object displayed at the touched position of the chart @objc open func getEntryByTouchPoint(point pt: CGPoint) -> ChartDataEntry! { if let h = getHighlightByTouchPoint(pt) @@ -1742,7 +1762,7 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD return nil } - /// - returns: The DataSet object displayed at the touched position of the chart + /// - Returns: The DataSet object displayed at the touched position of the chart @objc open func getDataSetByTouchPoint(point pt: CGPoint) -> IBarLineScatterCandleBubbleChartDataSet? { let h = getHighlightByTouchPoint(pt) @@ -1753,7 +1773,7 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD return nil } - /// - returns: The current x-scale factor + /// The current x-scale factor @objc open var scaleX: CGFloat { if _viewPortHandler === nil @@ -1763,7 +1783,7 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD return _viewPortHandler.scaleX } - /// - returns: The current y-scale factor + /// The current y-scale factor @objc open var scaleY: CGFloat { if _viewPortHandler === nil @@ -1776,7 +1796,7 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD /// if the chart is fully zoomed out, return true @objc open var isFullyZoomedOut: Bool { return _viewPortHandler.isFullyZoomedOut } - /// - returns: The y-axis object to the corresponding AxisDependency. In the + /// - Returns: The y-axis object to the corresponding AxisDependency. In the /// horizontal bar-chart, LEFT == top, RIGHT == BOTTOM @objc open func getAxis(_ axis: YAxis.AxisDependency) -> YAxis { @@ -1803,14 +1823,14 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD { _pinchZoomEnabled = newValue #if !os(tvOS) - _pinchGestureRecognizer.isEnabled = _pinchZoomEnabled || _scaleXEnabled || _scaleYEnabled + _pinchGestureRecognizer.isEnabled = _pinchZoomEnabled || _scaleXEnabled || _scaleYEnabled #endif } } } /// **default**: false - /// - returns: `true` if pinch-zoom is enabled, `false` ifnot + /// `true` if pinch-zoom is enabled, `false` ifnot @objc open var isPinchZoomEnabled: Bool { return pinchZoomEnabled } /// Set an offset in dp that allows the user to drag the chart over it's @@ -1827,7 +1847,7 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD _viewPortHandler.setDragOffsetY(offset) } - /// - returns: `true` if both drag offsets (x and y) are zero or smaller. + /// `true` if both drag offsets (x and y) are zero or smaller. @objc open var hasNoDragOffset: Bool { return _viewPortHandler.hasNoDragOffset } open override var chartYMax: Double @@ -1840,7 +1860,7 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD return min(leftAxis._axisMinimum, rightAxis._axisMinimum) } - /// - returns: `true` if either the left or the right or both axes are inverted. + /// `true` if either the left or the right or both axes are inverted. @objc open var isAnyAxisInverted: Bool { return leftAxis.isInverted || rightAxis.isInverted @@ -1855,7 +1875,7 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD } /// **default**: false - /// - returns: `true` if auto scaling on the y axis is enabled. + /// `true` if auto scaling on the y axis is enabled. @objc open var isAutoScaleMinMaxEnabled : Bool { return autoScaleMinMaxEnabled } /// Sets a minimum width to the specified y axis. @@ -1872,7 +1892,8 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD } /// **default**: 0.0 - /// - returns: The (custom) minimum width of the specified Y axis. + /// + /// - Returns: The (custom) minimum width of the specified Y axis. @objc open func getYAxisMinWidth(_ axis: YAxis.AxisDependency) -> CGFloat { if axis == .left @@ -1901,7 +1922,8 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD /// Zero (0.0) means there's no maximum width /// /// **default**: 0.0 (no maximum specified) - /// - returns: The (custom) maximum width of the specified Y axis. + /// + /// - Returns: The (custom) maximum width of the specified Y axis. @objc open func getYAxisMaxWidth(_ axis: YAxis.AxisDependency) -> CGFloat { if axis == .left @@ -1914,7 +1936,7 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD } } - /// - returns the width of the specified y axis. + /// - Returns the width of the specified y axis. @objc open func getYAxisWidth(_ axis: YAxis.AxisDependency) -> CGFloat { if axis == .left @@ -1929,7 +1951,7 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD // MARK: - BarLineScatterCandleBubbleChartDataProvider - /// - returns: The Transformer class that contains all matrices and is + /// - Returns: The Transformer class that contains all matrices and is /// responsible for transforming values into pixels on the screen and /// backwards. open func getTransformer(forAxis axis: YAxis.AxisDependency) -> Transformer @@ -1962,7 +1984,7 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD return getAxis(axis).isInverted } - /// - returns: The lowest x-index (value on the x-axis) that is still visible on he chart. + /// The lowest x-index (value on the x-axis) that is still visible on he chart. open var lowestVisibleX: Double { var pt = CGPoint( @@ -1974,7 +1996,7 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD return max(xAxis._axisMinimum, Double(pt.x)) } - /// - returns: The highest x-index (value on the x-axis) that is still visible on the chart. + /// The highest x-index (value on the x-axis) that is still visible on the chart. open var highestVisibleX: Double { var pt = CGPoint( diff --git a/Source/Charts/Charts/ChartViewBase.swift b/Source/Charts/Charts/ChartViewBase.swift index 29ab832760..0b58b26335 100644 --- a/Source/Charts/Charts/ChartViewBase.swift +++ b/Source/Charts/Charts/ChartViewBase.swift @@ -13,18 +13,19 @@ import Foundation import CoreGraphics -#if !os(OSX) - import UIKit -#endif - @objc public protocol ChartViewDelegate { /// Called when a value has been selected inside the chart. - /// - parameter entry: The selected Entry. - /// - parameter highlight: The corresponding highlight object that contains information about the highlighted position such as dataSetIndex etc. + /// + /// - Parameters: + /// - entry: The selected Entry. + /// - highlight: The corresponding highlight object that contains information about the highlighted position such as dataSetIndex etc. @objc optional func chartValueSelected(_ chartView: ChartViewBase, entry: ChartDataEntry, highlight: Highlight) + /// Called when a user stops panning between values on the chart + @objc optional func chartViewDidEndPanning(_ chartView: ChartViewBase) + // Called when nothing has been selected or an "un-select" has been made. @objc optional func chartValueNothingSelected(_ chartView: ChartViewBase) @@ -33,13 +34,16 @@ public protocol ChartViewDelegate // Callbacks when the chart is moved / translated via drag gesture. @objc optional func chartTranslated(_ chartView: ChartViewBase, dX: CGFloat, dY: CGFloat) + + // Callbacks when Animator stops animating + @objc optional func chartView(_ chartView: ChartViewBase, animatorDidStop animator: Animator) } open class ChartViewBase: NSUIView, ChartDataProvider, AnimatorDelegate { // MARK: - Properties - /// - returns: The object representing all x-labels, this method can be used to + /// - Returns: The object representing all x-labels, this method can be used to /// acquire the XAxis object and modify it (e.g. change the position of the /// labels) @objc open var xAxis: XAxis @@ -83,13 +87,13 @@ open class ChartViewBase: NSUIView, ChartDataProvider, AnimatorDelegate @objc open var noDataText = "No chart data available." /// Font to be used for the no data text. - @objc open var noDataFont: NSUIFont! = NSUIFont(name: "HelveticaNeue", size: 12.0) + @objc open var noDataFont = NSUIFont.systemFont(ofSize: 12) /// color of the no data text @objc open var noDataTextColor: NSUIColor = NSUIColor.black /// alignment of the no data text - open var noDataTextAlignment: NSTextAlignment = .left + @objc open var noDataTextAlignment: NSTextAlignment = .left internal var _legendRenderer: LegendRenderer! @@ -114,7 +118,7 @@ open class ChartViewBase: NSUIView, ChartDataProvider, AnimatorDelegate /// (use the `marker` property to specify a marker) @objc open var drawMarkers = true - /// - returns: `true` if drawing the marker is enabled when tapping on values + /// - Returns: `true` if drawing the marker is enabled when tapping on values /// (use the `marker` property to specify a marker) @objc open var isDrawMarkersEnabled: Bool { return drawMarkers } @@ -166,7 +170,7 @@ open class ChartViewBase: NSUIView, ChartDataProvider, AnimatorDelegate internal func initialize() { #if os(iOS) - self.backgroundColor = NSUIColor.clear + self.backgroundColor = NSUIColor.clear #endif _animator = Animator() @@ -239,7 +243,7 @@ open class ChartViewBase: NSUIView, ChartDataProvider, AnimatorDelegate setNeedsDisplay() } - /// - returns: `true` if the chart is empty (meaning it's data object is either null or contains no entries). + /// - Returns: `true` if the chart is empty (meaning it's data object is either null or contains no entries). @objc open func isEmpty() -> Bool { guard let data = _data else { return true } @@ -375,7 +379,7 @@ open class ChartViewBase: NSUIView, ChartDataProvider, AnimatorDelegate // MARK: - Highlighting - /// - returns: The array of currently highlighted values. This might an empty if nothing is highlighted. + /// The array of currently highlighted values. This might an empty if nothing is highlighted. @objc open var highlighted: [Highlight] { return _indicesToHighlight @@ -390,17 +394,18 @@ open class ChartViewBase: NSUIView, ChartDataProvider, AnimatorDelegate set { _highlightPerTapEnabled = newValue } } - /// - returns: `true` if values can be highlighted via tap gesture, `false` ifnot. + /// `true` if values can be highlighted via tap gesture, `false` ifnot. @objc open var isHighLightPerTapEnabled: Bool { return highlightPerTapEnabled } /// Checks if the highlight array is null, has a length of zero or if the first object is null. - /// - returns: `true` if there are values to highlight, `false` ifthere are no values to highlight. + /// + /// - Returns: `true` if there are values to highlight, `false` ifthere are no values to highlight. @objc open func valuesToHighlight() -> Bool { - return _indicesToHighlight.count > 0 + return !_indicesToHighlight.isEmpty } /// Highlights the values at the given indices in the given DataSets. Provide @@ -428,9 +433,11 @@ open class ChartViewBase: NSUIView, ChartDataProvider, AnimatorDelegate /// Highlights any y-value at the given x-value in the given DataSet. /// Provide -1 as the dataSetIndex to undo all highlighting. /// This method will call the delegate. - /// - parameter x: The x-value to highlight - /// - parameter dataSetIndex: The dataset index to search in - /// - parameter dataIndex: The data index to search in (only used in CombinedChartView currently) + /// + /// - Parameters: + /// - x: The x-value to highlight + /// - dataSetIndex: The dataset index to search in + /// - dataIndex: The data index to search in (only used in CombinedChartView currently) @objc open func highlightValue(x: Double, dataSetIndex: Int, dataIndex: Int = -1) { highlightValue(x: x, dataSetIndex: dataSetIndex, dataIndex: dataIndex, callDelegate: true) @@ -439,10 +446,12 @@ open class ChartViewBase: NSUIView, ChartDataProvider, AnimatorDelegate /// Highlights the value at the given x-value and y-value in the given DataSet. /// Provide -1 as the dataSetIndex to undo all highlighting. /// This method will call the delegate. - /// - parameter x: The x-value to highlight - /// - parameter y: The y-value to highlight. Supply `NaN` for "any" - /// - parameter dataSetIndex: The dataset index to search in - /// - parameter dataIndex: The data index to search in (only used in CombinedChartView currently) + /// + /// - Parameters: + /// - x: The x-value to highlight + /// - y: The y-value to highlight. Supply `NaN` for "any" + /// - dataSetIndex: The dataset index to search in + /// - dataIndex: The data index to search in (only used in CombinedChartView currently) @objc open func highlightValue(x: Double, y: Double, dataSetIndex: Int, dataIndex: Int = -1) { highlightValue(x: x, y: y, dataSetIndex: dataSetIndex, dataIndex: dataIndex, callDelegate: true) @@ -450,10 +459,12 @@ open class ChartViewBase: NSUIView, ChartDataProvider, AnimatorDelegate /// Highlights any y-value at the given x-value in the given DataSet. /// Provide -1 as the dataSetIndex to undo all highlighting. - /// - parameter x: The x-value to highlight - /// - parameter dataSetIndex: The dataset index to search in - /// - parameter dataIndex: The data index to search in (only used in CombinedChartView currently) - /// - parameter callDelegate: Should the delegate be called for this change + /// + /// - Parameters: + /// - x: The x-value to highlight + /// - dataSetIndex: The dataset index to search in + /// - dataIndex: The data index to search in (only used in CombinedChartView currently) + /// - callDelegate: Should the delegate be called for this change @objc open func highlightValue(x: Double, dataSetIndex: Int, dataIndex: Int = -1, callDelegate: Bool) { highlightValue(x: x, y: .nan, dataSetIndex: dataSetIndex, dataIndex: dataIndex, callDelegate: callDelegate) @@ -461,11 +472,13 @@ open class ChartViewBase: NSUIView, ChartDataProvider, AnimatorDelegate /// Highlights the value at the given x-value and y-value in the given DataSet. /// Provide -1 as the dataSetIndex to undo all highlighting. - /// - parameter x: The x-value to highlight - /// - parameter y: The y-value to highlight. Supply `NaN` for "any" - /// - parameter dataSetIndex: The dataset index to search in - /// - parameter dataIndex: The data index to search in (only used in CombinedChartView currently) - /// - parameter callDelegate: Should the delegate be called for this change + /// + /// - Parameters: + /// - x: The x-value to highlight + /// - y: The y-value to highlight. Supply `NaN` for "any" + /// - dataSetIndex: The dataset index to search in + /// - dataIndex: The data index to search in (only used in CombinedChartView currently) + /// - callDelegate: Should the delegate be called for this change @objc open func highlightValue(x: Double, y: Double, dataSetIndex: Int, dataIndex: Int = -1, callDelegate: Bool) { guard let data = _data else @@ -486,7 +499,9 @@ open class ChartViewBase: NSUIView, ChartDataProvider, AnimatorDelegate /// Highlights the values represented by the provided Highlight object /// This method *will not* call the delegate. - /// - parameter highlight: contains information about which entry should be highlighted + /// + /// - Parameters: + /// - highlight: contains information about which entry should be highlighted @objc open func highlightValue(_ highlight: Highlight?) { highlightValue(highlight, callDelegate: false) @@ -535,7 +550,7 @@ open class ChartViewBase: NSUIView, ChartDataProvider, AnimatorDelegate setNeedsDisplay() } - /// - returns: The Highlight object (contains x-index and DataSet index) of the + /// - Returns: The Highlight object (contains x-index and DataSet index) of the /// selected value at the given touch point inside the Line-, Scatter-, or /// CandleStick-Chart. @objc open func getHighlightByTouchPoint(_ pt: CGPoint) -> Highlight? @@ -595,7 +610,7 @@ open class ChartViewBase: NSUIView, ChartDataProvider, AnimatorDelegate } } - /// - returns: The actual position in pixels of the MarkerView for the given Entry in the given DataSet. + /// - Returns: The actual position in pixels of the MarkerView for the given Entry in the given DataSet. @objc open func getMarkerPosition(highlight: Highlight) -> CGPoint { return CGPoint(x: highlight.drawX, y: highlight.drawY) @@ -603,7 +618,7 @@ open class ChartViewBase: NSUIView, ChartDataProvider, AnimatorDelegate // MARK: - Animation - /// - returns: The animator responsible for animating chart values. + /// The animator responsible for animating chart values. @objc open var chartAnimator: Animator! { return _animator @@ -611,10 +626,12 @@ open class ChartViewBase: NSUIView, ChartDataProvider, AnimatorDelegate /// Animates the drawing / rendering of the chart on both x- and y-axis with the specified animation time. /// If `animate(...)` is called, no further calling of `invalidate()` is necessary to refresh the chart. - /// - parameter xAxisDuration: duration for animating the x axis - /// - parameter yAxisDuration: duration for animating the y axis - /// - parameter easingX: an easing function for the animation on the x axis - /// - parameter easingY: an easing function for the animation on the y axis + /// + /// - Parameters: + /// - xAxisDuration: duration for animating the x axis + /// - yAxisDuration: duration for animating the y axis + /// - easingX: an easing function for the animation on the x axis + /// - easingY: an easing function for the animation on the y axis @objc open func animate(xAxisDuration: TimeInterval, yAxisDuration: TimeInterval, easingX: ChartEasingFunctionBlock?, easingY: ChartEasingFunctionBlock?) { _animator.animate(xAxisDuration: xAxisDuration, yAxisDuration: yAxisDuration, easingX: easingX, easingY: easingY) @@ -622,10 +639,12 @@ open class ChartViewBase: NSUIView, ChartDataProvider, AnimatorDelegate /// Animates the drawing / rendering of the chart on both x- and y-axis with the specified animation time. /// If `animate(...)` is called, no further calling of `invalidate()` is necessary to refresh the chart. - /// - parameter xAxisDuration: duration for animating the x axis - /// - parameter yAxisDuration: duration for animating the y axis - /// - parameter easingOptionX: the easing function for the animation on the x axis - /// - parameter easingOptionY: the easing function for the animation on the y axis + /// + /// - Parameters: + /// - xAxisDuration: duration for animating the x axis + /// - yAxisDuration: duration for animating the y axis + /// - easingOptionX: the easing function for the animation on the x axis + /// - easingOptionY: the easing function for the animation on the y axis @objc open func animate(xAxisDuration: TimeInterval, yAxisDuration: TimeInterval, easingOptionX: ChartEasingOption, easingOptionY: ChartEasingOption) { _animator.animate(xAxisDuration: xAxisDuration, yAxisDuration: yAxisDuration, easingOptionX: easingOptionX, easingOptionY: easingOptionY) @@ -633,9 +652,11 @@ open class ChartViewBase: NSUIView, ChartDataProvider, AnimatorDelegate /// Animates the drawing / rendering of the chart on both x- and y-axis with the specified animation time. /// If `animate(...)` is called, no further calling of `invalidate()` is necessary to refresh the chart. - /// - parameter xAxisDuration: duration for animating the x axis - /// - parameter yAxisDuration: duration for animating the y axis - /// - parameter easing: an easing function for the animation + /// + /// - Parameters: + /// - xAxisDuration: duration for animating the x axis + /// - yAxisDuration: duration for animating the y axis + /// - easing: an easing function for the animation @objc open func animate(xAxisDuration: TimeInterval, yAxisDuration: TimeInterval, easing: ChartEasingFunctionBlock?) { _animator.animate(xAxisDuration: xAxisDuration, yAxisDuration: yAxisDuration, easing: easing) @@ -643,9 +664,11 @@ open class ChartViewBase: NSUIView, ChartDataProvider, AnimatorDelegate /// Animates the drawing / rendering of the chart on both x- and y-axis with the specified animation time. /// If `animate(...)` is called, no further calling of `invalidate()` is necessary to refresh the chart. - /// - parameter xAxisDuration: duration for animating the x axis - /// - parameter yAxisDuration: duration for animating the y axis - /// - parameter easingOption: the easing function for the animation + /// + /// - Parameters: + /// - xAxisDuration: duration for animating the x axis + /// - yAxisDuration: duration for animating the y axis + /// - easingOption: the easing function for the animation @objc open func animate(xAxisDuration: TimeInterval, yAxisDuration: TimeInterval, easingOption: ChartEasingOption) { _animator.animate(xAxisDuration: xAxisDuration, yAxisDuration: yAxisDuration, easingOption: easingOption) @@ -653,8 +676,10 @@ open class ChartViewBase: NSUIView, ChartDataProvider, AnimatorDelegate /// Animates the drawing / rendering of the chart on both x- and y-axis with the specified animation time. /// If `animate(...)` is called, no further calling of `invalidate()` is necessary to refresh the chart. - /// - parameter xAxisDuration: duration for animating the x axis - /// - parameter yAxisDuration: duration for animating the y axis + /// + /// - Parameters: + /// - xAxisDuration: duration for animating the x axis + /// - yAxisDuration: duration for animating the y axis @objc open func animate(xAxisDuration: TimeInterval, yAxisDuration: TimeInterval) { _animator.animate(xAxisDuration: xAxisDuration, yAxisDuration: yAxisDuration) @@ -662,8 +687,10 @@ open class ChartViewBase: NSUIView, ChartDataProvider, AnimatorDelegate /// Animates the drawing / rendering of the chart the x-axis with the specified animation time. /// If `animate(...)` is called, no further calling of `invalidate()` is necessary to refresh the chart. - /// - parameter xAxisDuration: duration for animating the x axis - /// - parameter easing: an easing function for the animation + /// + /// - Parameters: + /// - xAxisDuration: duration for animating the x axis + /// - easing: an easing function for the animation @objc open func animate(xAxisDuration: TimeInterval, easing: ChartEasingFunctionBlock?) { _animator.animate(xAxisDuration: xAxisDuration, easing: easing) @@ -671,8 +698,10 @@ open class ChartViewBase: NSUIView, ChartDataProvider, AnimatorDelegate /// Animates the drawing / rendering of the chart the x-axis with the specified animation time. /// If `animate(...)` is called, no further calling of `invalidate()` is necessary to refresh the chart. - /// - parameter xAxisDuration: duration for animating the x axis - /// - parameter easingOption: the easing function for the animation + /// + /// - Parameters: + /// - xAxisDuration: duration for animating the x axis + /// - easingOption: the easing function for the animation @objc open func animate(xAxisDuration: TimeInterval, easingOption: ChartEasingOption) { _animator.animate(xAxisDuration: xAxisDuration, easingOption: easingOption) @@ -680,7 +709,9 @@ open class ChartViewBase: NSUIView, ChartDataProvider, AnimatorDelegate /// Animates the drawing / rendering of the chart the x-axis with the specified animation time. /// If `animate(...)` is called, no further calling of `invalidate()` is necessary to refresh the chart. - /// - parameter xAxisDuration: duration for animating the x axis + /// + /// - Parameters: + /// - xAxisDuration: duration for animating the x axis @objc open func animate(xAxisDuration: TimeInterval) { _animator.animate(xAxisDuration: xAxisDuration) @@ -688,8 +719,10 @@ open class ChartViewBase: NSUIView, ChartDataProvider, AnimatorDelegate /// Animates the drawing / rendering of the chart the y-axis with the specified animation time. /// If `animate(...)` is called, no further calling of `invalidate()` is necessary to refresh the chart. - /// - parameter yAxisDuration: duration for animating the y axis - /// - parameter easing: an easing function for the animation + /// + /// - Parameters: + /// - yAxisDuration: duration for animating the y axis + /// - easing: an easing function for the animation @objc open func animate(yAxisDuration: TimeInterval, easing: ChartEasingFunctionBlock?) { _animator.animate(yAxisDuration: yAxisDuration, easing: easing) @@ -697,8 +730,10 @@ open class ChartViewBase: NSUIView, ChartDataProvider, AnimatorDelegate /// Animates the drawing / rendering of the chart the y-axis with the specified animation time. /// If `animate(...)` is called, no further calling of `invalidate()` is necessary to refresh the chart. - /// - parameter yAxisDuration: duration for animating the y axis - /// - parameter easingOption: the easing function for the animation + /// + /// - Parameters: + /// - yAxisDuration: duration for animating the y axis + /// - easingOption: the easing function for the animation @objc open func animate(yAxisDuration: TimeInterval, easingOption: ChartEasingOption) { _animator.animate(yAxisDuration: yAxisDuration, easingOption: easingOption) @@ -706,7 +741,9 @@ open class ChartViewBase: NSUIView, ChartDataProvider, AnimatorDelegate /// Animates the drawing / rendering of the chart the y-axis with the specified animation time. /// If `animate(...)` is called, no further calling of `invalidate()` is necessary to refresh the chart. - /// - parameter yAxisDuration: duration for animating the y axis + /// + /// - Parameters: + /// - yAxisDuration: duration for animating the y axis @objc open func animate(yAxisDuration: TimeInterval) { _animator.animate(yAxisDuration: yAxisDuration) @@ -714,13 +751,13 @@ open class ChartViewBase: NSUIView, ChartDataProvider, AnimatorDelegate // MARK: - Accessors - /// - returns: The current y-max value across all DataSets + /// The current y-max value across all DataSets open var chartYMax: Double { return _data?.yMax ?? 0.0 } - /// - returns: The current y-min value across all DataSets + /// The current y-min value across all DataSets open var chartYMin: Double { return _data?.yMin ?? 0.0 @@ -741,47 +778,46 @@ open class ChartViewBase: NSUIView, ChartDataProvider, AnimatorDelegate return _xAxis.axisRange } - /// * - /// - note: (Equivalent of getCenter() in MPAndroidChart, as center is already a standard in iOS that returns the center point relative to superview, and MPAndroidChart returns relative to self)* - /// - returns: The center point of the chart (the whole View) in pixels. + /// - Note: (Equivalent of getCenter() in MPAndroidChart, as center is already a standard in iOS that returns the center point relative to superview, and MPAndroidChart returns relative to self)* + /// The center point of the chart (the whole View) in pixels. @objc open var midPoint: CGPoint { let bounds = self.bounds return CGPoint(x: bounds.origin.x + bounds.size.width / 2.0, y: bounds.origin.y + bounds.size.height / 2.0) } - /// - returns: The center of the chart taking offsets under consideration. (returns the center of the content rectangle) + /// The center of the chart taking offsets under consideration. (returns the center of the content rectangle) open var centerOffsets: CGPoint { return _viewPortHandler.contentCenter } - /// - returns: The Legend object of the chart. This method can be used to get an instance of the legend in order to customize the automatically generated Legend. + /// The Legend object of the chart. This method can be used to get an instance of the legend in order to customize the automatically generated Legend. @objc open var legend: Legend { return _legend } - /// - returns: The renderer object responsible for rendering / drawing the Legend. + /// The renderer object responsible for rendering / drawing the Legend. @objc open var legendRenderer: LegendRenderer! { return _legendRenderer } - /// - returns: The rectangle that defines the borders of the chart-value surface (into which the actual values are drawn). + /// The rectangle that defines the borders of the chart-value surface (into which the actual values are drawn). @objc open var contentRect: CGRect { return _viewPortHandler.contentRect } - /// - returns: The ViewPortHandler of the chart that is responsible for the + /// - Returns: The ViewPortHandler of the chart that is responsible for the /// content area of the chart and its offsets and dimensions. @objc open var viewPortHandler: ViewPortHandler! { return _viewPortHandler } - /// - returns: The bitmap that represents the chart. + /// - Returns: The bitmap that represents the chart. @objc open func getChartImage(transparent: Bool) -> NSUIImage? { NSUIGraphicsBeginImageContextWithOptions(bounds.size, isOpaque || !transparent, NSUIMainScreen()?.nsuiScale ?? 1.0) @@ -824,11 +860,11 @@ open class ChartViewBase: NSUIView, ChartDataProvider, AnimatorDelegate /// the SD card chart is saved as a PNG image, example: /// saveToPath("myfilename", "foldername1/foldername2") /// - /// - parameter to: path to the image to save - /// - parameter format: the format to save - /// - parameter compressionQuality: compression quality for lossless formats (JPEG) - /// - /// - returns: `true` if the image was saved successfully + /// - Parameters: + /// - to: path to the image to save + /// - format: the format to save + /// - compressionQuality: compression quality for lossless formats (JPEG) + /// - Returns: `true` if the image was saved successfully open func save(to path: String, format: ImageFormat, compressionQuality: Double) -> Bool { guard let image = getChartImage(transparent: format != .jpeg) else { return false } @@ -884,7 +920,7 @@ open class ChartViewBase: NSUIView, ChartDataProvider, AnimatorDelegate @objc open func removeViewportJob(_ job: ViewPortJob) { - if let index = _viewportJobs.index(where: { $0 === job }) + if let index = _viewportJobs.firstIndex(where: { $0 === job }) { _viewportJobs.remove(at: index) } @@ -908,7 +944,7 @@ open class ChartViewBase: NSUIView, ChartDataProvider, AnimatorDelegate } /// **default**: true - /// - returns: `true` if chart continues to scroll after touch up, `false` ifnot. + /// `true` if chart continues to scroll after touch up, `false` ifnot. @objc open var isDragDecelerationEnabled: Bool { return dragDecelerationEnabled @@ -959,7 +995,7 @@ open class ChartViewBase: NSUIView, ChartDataProvider, AnimatorDelegate open func animatorStopped(_ chartAnimator: Animator) { - + delegate?.chartView?(self, animatorDidStop: chartAnimator) } // MARK: - Touches diff --git a/Source/Charts/Charts/CombinedChartView.swift b/Source/Charts/Charts/CombinedChartView.swift index e1b13b495e..47eebd6c78 100644 --- a/Source/Charts/Charts/CombinedChartView.swift +++ b/Source/Charts/Charts/CombinedChartView.swift @@ -76,7 +76,7 @@ open class CombinedChartView: BarLineChartViewBase, CombinedChartDataProvider } } - /// - returns: The Highlight object (contains x-index and DataSet index) of the selected value at the given touch point inside the CombinedChart. + /// - Returns: The Highlight object (contains x-index and DataSet index) of the selected value at the given touch point inside the CombinedChart. open override func getHighlightByTouchPoint(_ pt: CGPoint) -> Highlight? { if _data === nil @@ -176,10 +176,10 @@ open class CombinedChartView: BarLineChartViewBase, CombinedChartDataProvider set { (renderer as! CombinedChartRenderer).drawBarShadowEnabled = newValue } } - /// - returns: `true` if drawing values above bars is enabled, `false` ifnot + /// `true` if drawing values above bars is enabled, `false` ifnot open var isDrawValueAboveBarEnabled: Bool { return (renderer as! CombinedChartRenderer).drawValueAboveBarEnabled } - /// - returns: `true` if drawing shadows (maxvalue) for each bar is enabled, `false` ifnot + /// `true` if drawing shadows (maxvalue) for each bar is enabled, `false` ifnot open var isDrawBarShadowEnabled: Bool { return (renderer as! CombinedChartRenderer).drawBarShadowEnabled } /// the order in which the provided data objects should be drawn. @@ -200,7 +200,7 @@ open class CombinedChartView: BarLineChartViewBase, CombinedChartDataProvider /// Set this to `true` to make the highlight operation full-bar oriented, `false` to make it highlight single values @objc open var highlightFullBarEnabled: Bool = false - /// - returns: `true` the highlight is be full-bar oriented, `false` ifsingle-value + /// `true` the highlight is be full-bar oriented, `false` ifsingle-value open var isHighlightFullBarEnabled: Bool { return highlightFullBarEnabled } // MARK: - ChartViewBase diff --git a/Source/Charts/Charts/HorizontalBarChartView.swift b/Source/Charts/Charts/HorizontalBarChartView.swift index 1c897afc9d..23f5b1675c 100644 --- a/Source/Charts/Charts/HorizontalBarChartView.swift +++ b/Source/Charts/Charts/HorizontalBarChartView.swift @@ -12,10 +12,6 @@ import Foundation import CoreGraphics -#if !os(OSX) - import UIKit -#endif - /// BarChart with horizontal bar orientation. In this implementation, x- and y-axis are switched. open class HorizontalBarChartView: BarChartView { @@ -39,7 +35,7 @@ open class HorizontalBarChartView: BarChartView guard let legend = _legend, legend.isEnabled, - legend.drawInside + !legend.drawInside else { return } // setup offsets for legend @@ -257,7 +253,7 @@ open class HorizontalBarChartView: BarChartView return self.highlighter?.getHighlight(x: pt.y, y: pt.x) } - /// - returns: The lowest x-index (value on the x-axis) that is still visible on he chart. + /// The lowest x-index (value on the x-axis) that is still visible on he chart. open override var lowestVisibleX: Double { var pt = CGPoint( @@ -269,7 +265,7 @@ open class HorizontalBarChartView: BarChartView return max(xAxis._axisMinimum, Double(pt.y)) } - /// - returns: The highest x-index (value on the x-axis) that is still visible on the chart. + /// The highest x-index (value on the x-axis) that is still visible on the chart. open override var highestVisibleX: Double { var pt = CGPoint( diff --git a/Source/Charts/Charts/PieChartView.swift b/Source/Charts/Charts/PieChartView.swift index 58335c5b69..1010434f9f 100644 --- a/Source/Charts/Charts/PieChartView.swift +++ b/Source/Charts/Charts/PieChartView.swift @@ -12,10 +12,6 @@ import Foundation import CoreGraphics -#if !os(OSX) - import UIKit -#endif - /// View that represents a pie chart. Draws cake like slices. open class PieChartView: PieRadarChartViewBase { @@ -195,17 +191,12 @@ 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.dataSets { - let set = dataSets[i] - let entryCount = set.entryCount - - for j in 0 ..< entryCount + for j in 0 ..< set.entryCount { guard let e = set.entryForIndex(j) else { continue } @@ -228,22 +219,7 @@ open class PieChartView: PieRadarChartViewBase /// Checks if the given index is set to be highlighted. @objc open func needsHighlight(index: Int) -> Bool { - // no highlight - if !valuesToHighlight() - { - return false - } - - for i in 0 ..< _indicesToHighlight.count - { - // check if the xvalue for the given dataset needs highlight - if Int(_indicesToHighlight[i].x) == index - { - return true - } - } - - return false + return _indicesToHighlight.contains { Int($0.x) == index } } /// calculates the needed angle for a given value @@ -263,39 +239,25 @@ open class PieChartView: PieRadarChartViewBase { fatalError("PieChart has no XAxis") } - + open override func indexForAngle(_ angle: CGFloat) -> Int { + // TODO: Return nil instead of -1 // take the current angle of the chart into consideration let a = (angle - self.rotationAngle).normalizedAngle - for i in 0 ..< _absoluteAngles.count - { - if _absoluteAngles[i] > a - { - return i - } - } - - return -1 // return -1 if no index found + return _absoluteAngles.firstIndex { $0 > a } ?? -1 } - /// - returns: The index of the DataSet this x-index belongs to. + /// - Returns: The index of the DataSet this x-index belongs to. @objc open func dataSetIndexForIndex(_ xValue: Double) -> Int { - var dataSets = _data?.dataSets ?? [] - - for i in 0 ..< dataSets.count - { - if (dataSets[i].entryForXValue(xValue, closestToY: Double.nan) !== nil) - { - return i - } - } - - return -1 + // TODO: Return nil instead of -1 + return _data?.dataSets.firstIndex { + $0.entryForXValue(xValue, closestToY: .nan) != nil + } ?? -1 } - /// - returns: An integer array of all the different angles the chart slices + /// - Returns: An integer array of all the different angles the chart slices /// have the angles in the returned array determine how much space (of 360°) /// each slice takes @objc open var drawAngles: [CGFloat] @@ -303,7 +265,7 @@ open class PieChartView: PieRadarChartViewBase return _drawAngles } - /// - returns: The absolute angles of the different chart slices (where the + /// - Returns: The absolute angles of the different chart slices (where the /// slices end) @objc open var absoluteAngles: [CGFloat] { @@ -312,7 +274,7 @@ open class PieChartView: PieRadarChartViewBase /// The color for the hole that is drawn in the center of the PieChart (if enabled). /// - /// - note: Use holeTransparent with holeColor = nil to make the hole transparent.* + /// - Note: Use holeTransparent with holeColor = nil to make the hole transparent.* @objc open var holeColor: NSUIColor? { get @@ -342,7 +304,7 @@ open class PieChartView: PieRadarChartViewBase } } - /// - returns: `true` if the inner tips of the slices are visible behind the hole, `false` if not. + /// `true` if the inner tips of the slices are visible behind the hole, `false` if not. @objc open var isDrawSlicesUnderHoleEnabled: Bool { return drawSlicesUnderHoleEnabled @@ -362,7 +324,7 @@ open class PieChartView: PieRadarChartViewBase } } - /// - returns: `true` if the hole in the center of the pie-chart is set to be visible, `false` ifnot + /// `true` if the hole in the center of the pie-chart is set to be visible, `false` ifnot @objc open var isDrawHoleEnabled: Bool { get @@ -387,20 +349,15 @@ open class PieChartView: PieRadarChartViewBase } else { - #if os(OSX) - let paragraphStyle = NSParagraphStyle.default.mutableCopy() as! NSMutableParagraphStyle - paragraphStyle.lineBreakMode = NSLineBreakMode.byTruncatingTail - #else - let paragraphStyle = NSParagraphStyle.default.mutableCopy() as! NSMutableParagraphStyle - paragraphStyle.lineBreakMode = NSLineBreakMode.byTruncatingTail - #endif + let paragraphStyle = NSParagraphStyle.default.mutableCopy() as! NSMutableParagraphStyle + paragraphStyle.lineBreakMode = .byTruncatingTail paragraphStyle.alignment = .center attrString = NSMutableAttributedString(string: newValue!) attrString?.setAttributes([ - NSAttributedString.Key.foregroundColor: NSUIColor.black, - NSAttributedString.Key.font: NSUIFont.systemFont(ofSize: 12.0), - NSAttributedString.Key.paragraphStyle: paragraphStyle + .foregroundColor: NSUIColor.black, + .font: NSUIFont.systemFont(ofSize: 12.0), + .paragraphStyle: paragraphStyle ], range: NSMakeRange(0, attrString!.length)) } self.centerAttributedText = attrString @@ -449,7 +406,7 @@ open class PieChartView: PieRadarChartViewBase } } - /// - returns: `true` if drawing the center text is enabled + /// `true` if drawing the center text is enabled @objc open var isDrawCenterTextEnabled: Bool { get @@ -473,13 +430,13 @@ open class PieChartView: PieRadarChartViewBase return _circleBox.width / 2.0 } - /// - returns: The circlebox, the boundingbox of the pie-chart slices + /// The circlebox, the boundingbox of the pie-chart slices @objc open var circleBox: CGRect { return _circleBox } - /// - returns: The center of the circlebox + /// The center of the circlebox @objc open var centerCircleBox: CGPoint { return CGPoint(x: _circleBox.midX, y: _circleBox.midY) @@ -569,7 +526,7 @@ open class PieChartView: PieRadarChartViewBase } } - /// - returns: `true` if drawing entry labels is enabled, `false` ifnot + /// `true` if drawing entry labels is enabled, `false` ifnot @objc open var isDrawEntryLabelsEnabled: Bool { get @@ -592,7 +549,7 @@ open class PieChartView: PieRadarChartViewBase } } - /// - returns: `true` if drawing x-values is enabled, `false` ifnot + /// `true` if drawing x-values is enabled, `false` ifnot @objc open var isUsePercentValuesEnabled: Bool { get diff --git a/Source/Charts/Charts/PieRadarChartViewBase.swift b/Source/Charts/Charts/PieRadarChartViewBase.swift old mode 100755 new mode 100644 index c6de8ce7c7..bbdc8d826f --- a/Source/Charts/Charts/PieRadarChartViewBase.swift +++ b/Source/Charts/Charts/PieRadarChartViewBase.swift @@ -12,10 +12,6 @@ import Foundation import CoreGraphics -#if !os(OSX) - import UIKit -#endif - /// Base class of PieChartView and RadarChartView. open class PieRadarChartViewBase: ChartViewBase { @@ -63,9 +59,9 @@ open class PieRadarChartViewBase: ChartViewBase self.addGestureRecognizer(_tapGestureRecognizer) #if !os(tvOS) - _rotationGestureRecognizer = NSUIRotationGestureRecognizer(target: self, action: #selector(rotationGestureRecognized(_:))) - self.addGestureRecognizer(_rotationGestureRecognizer) - _rotationGestureRecognizer.isEnabled = rotationWithTwoFingers + _rotationGestureRecognizer = NSUIRotationGestureRecognizer(target: self, action: #selector(rotationGestureRecognized(_:))) + self.addGestureRecognizer(_rotationGestureRecognizer) + _rotationGestureRecognizer.isEnabled = rotationWithTwoFingers #endif } @@ -244,7 +240,7 @@ open class PieRadarChartViewBase: ChartViewBase _viewPortHandler.restrainViewPort(offsetLeft: offsetLeft, offsetTop: offsetTop, offsetRight: offsetRight, offsetBottom: offsetBottom) } - /// - returns: The angle relative to the chart center for the given point on the chart in degrees. + /// - Returns: The angle relative to the chart center for the given point on the chart in degrees. /// The angle is always between 0 and 360°, 0° is NORTH, 90° is EAST, ... @objc open func angleForPoint(x: CGFloat, y: CGFloat) -> CGFloat { @@ -282,7 +278,7 @@ open class PieRadarChartViewBase: ChartViewBase y: center.y + dist * sin(angle.DEG2RAD)) } - /// - returns: The distance of a certain point on the chart to the center of the chart. + /// - Returns: The distance of a certain point on the chart to the center of the chart. @objc open func distanceToCenter(x: CGFloat, y: CGFloat) -> CGFloat { let c = self.centerOffsets @@ -316,7 +312,7 @@ open class PieRadarChartViewBase: ChartViewBase return dist } - /// - returns: The xIndex for the given angle around the center of the chart. + /// - Returns: The xIndex for the given angle around the center of the chart. /// -1 if not found / outofbounds. @objc open func indexForAngle(_ angle: CGFloat) -> Int { @@ -326,7 +322,7 @@ open class PieRadarChartViewBase: ChartViewBase /// current rotation angle of the pie chart /// /// **default**: 270 --> top (NORTH) - /// - returns: Will always return a normalized value, which will be between 0.0 < 360.0 + /// Will always return a normalized value, which will be between 0.0 < 360.0 @objc open var rotationAngle: CGFloat { get @@ -348,7 +344,7 @@ open class PieRadarChartViewBase: ChartViewBase return _rawRotationAngle } - /// - returns: The diameter of the pie- or radar-chart + /// The diameter of the pie- or radar-chart @objc open var diameter: CGFloat { var content = _viewPortHandler.contentRect @@ -359,19 +355,19 @@ open class PieRadarChartViewBase: ChartViewBase return min(content.width, content.height) } - /// - returns: The radius of the chart in pixels. + /// The radius of the chart in pixels. @objc open var radius: CGFloat { fatalError("radius cannot be called on PieRadarChartViewBase") } - /// - returns: The required offset for the chart legend. + /// The required offset for the chart legend. internal var requiredLegendOffset: CGFloat { fatalError("requiredLegendOffset cannot be called on PieRadarChartViewBase") } - /// - returns: The base offset needed for the chart without calculating the + /// - Returns: The base offset needed for the chart without calculating the /// legend size. internal var requiredBaseOffset: CGFloat { @@ -407,7 +403,7 @@ open class PieRadarChartViewBase: ChartViewBase { _rotationWithTwoFingers = newValue #if !os(tvOS) - _rotationGestureRecognizer.isEnabled = _rotationWithTwoFingers + _rotationGestureRecognizer.isEnabled = _rotationWithTwoFingers #endif } } @@ -475,7 +471,7 @@ open class PieRadarChartViewBase: ChartViewBase var angle: CGFloat } - private var _velocitySamples = [AngularVelocitySample]() + private var velocitySamples = [AngularVelocitySample]() private var _decelerationLastTime: TimeInterval = 0.0 private var _decelerationDisplayLink: NSUIDisplayLink! @@ -663,70 +659,52 @@ open class PieRadarChartViewBase: ChartViewBase private func resetVelocity() { - _velocitySamples.removeAll(keepingCapacity: false) + velocitySamples.removeAll(keepingCapacity: false) } private func sampleVelocity(touchLocation: CGPoint) { - let currentTime = CACurrentMediaTime() - - _velocitySamples.append(AngularVelocitySample(time: currentTime, angle: angleForPoint(x: touchLocation.x, y: touchLocation.y))) - + let currentSample: AngularVelocitySample = { + let time = CACurrentMediaTime() + let angle = angleForPoint(x: touchLocation.x, y: touchLocation.y) + return AngularVelocitySample(time: time, angle: angle) + }() + // Remove samples older than our sample time - 1 seconds - var i = 0, count = _velocitySamples.count - while (i < count - 2) - { - if currentTime - _velocitySamples[i].time > 1.0 - { - _velocitySamples.remove(at: 0) - i -= 1 - count -= 1 - } - else - { - break - } - - i += 1 + // while keeping at least one samples + let index = velocitySamples + .dropLast() + .lastIndex { $0.time < currentSample.time - 1 } + if let index = index { + velocitySamples.remove(at: index) } + velocitySamples.append(currentSample) } - + private func calculateVelocity() -> CGFloat { - if _velocitySamples.isEmpty - { - return 0.0 - } - - var firstSample = _velocitySamples[0] - var lastSample = _velocitySamples[_velocitySamples.count - 1] - + guard var firstSample = velocitySamples.first, + var lastSample = velocitySamples.last + else { return 0 } + // Look for a sample that's closest to the latest sample, but not the same, so we can deduce the direction - var beforeLastSample = firstSample - for i in stride(from: (_velocitySamples.count - 1), through: 0, by: -1) - { - beforeLastSample = _velocitySamples[i] - if beforeLastSample.angle != lastSample.angle - { - break - } - } - + let beforeLastSample = velocitySamples.last { $0.angle != lastSample.angle } + ?? firstSample + // Calculate the sampling time - var timeDelta = lastSample.time - firstSample.time - if timeDelta == 0.0 - { - timeDelta = 0.1 - } - + let timeDelta: CGFloat = { + let delta = CGFloat(lastSample.time - firstSample.time) + return delta == 0 ? 0.1 : delta + }() + // Calculate clockwise/ccw by choosing two values that should be closest to each other, // so if the angles are two far from each other we know they are inverted "for sure" - var clockwise = lastSample.angle >= beforeLastSample.angle - if (abs(lastSample.angle - beforeLastSample.angle) > 270.0) - { - clockwise = !clockwise - } - + let isClockwise: Bool = { + let isClockwise = lastSample.angle >= beforeLastSample.angle + let isInverted = abs(lastSample.angle - beforeLastSample.angle) > 270.0 + return isInverted ? !isClockwise : isClockwise + }() + // Now if the "gesture" is over a too big of an angle - then we know the angles are inverted, and we need to move them closer to each other from both sides of the 360.0 wrapping point if lastSample.angle - firstSample.angle > 180.0 { @@ -736,19 +714,12 @@ open class PieRadarChartViewBase: ChartViewBase { lastSample.angle += 360.0 } - + // The velocity - var velocity = abs((lastSample.angle - firstSample.angle) / CGFloat(timeDelta)) - - // Direction? - if !clockwise - { - velocity = -velocity - } - - return velocity + let velocity = abs((lastSample.angle - firstSample.angle) / timeDelta) + return isClockwise ? velocity : -velocity } - + /// sets the starting angle of the rotation, this is only used by the touch listener, x and y is the touch position private func setGestureStartAngle(x: CGFloat, y: CGFloat) { @@ -791,7 +762,7 @@ open class PieRadarChartViewBase: ChartViewBase } } - /// - returns: The distance between two points + /// - Returns: The distance between two points private func distance(eventX: CGFloat, startX: CGFloat, eventY: CGFloat, startY: CGFloat) -> CGFloat { let dx = eventX - startX @@ -799,7 +770,7 @@ open class PieRadarChartViewBase: ChartViewBase return sqrt(dx * dx + dy * dy) } - /// - returns: The distance between two points + /// - Returns: The distance between two points private func distance(from: CGPoint, to: CGPoint) -> CGFloat { let dx = from.x - to.x diff --git a/Source/Charts/Charts/RadarChartView.swift b/Source/Charts/Charts/RadarChartView.swift index 745c933bf1..85892bff3f 100644 --- a/Source/Charts/Charts/RadarChartView.swift +++ b/Source/Charts/Charts/RadarChartView.swift @@ -146,7 +146,7 @@ open class RadarChartView: PieRadarChartViewBase drawMarkers(context: context) } - /// - returns: The factor that is needed to transform values into pixels. + /// The factor that is needed to transform values into pixels. @objc open var factor: CGFloat { let content = _viewPortHandler.contentRect @@ -154,7 +154,7 @@ open class RadarChartView: PieRadarChartViewBase / CGFloat(_yAxis.axisRange) } - /// - returns: The angle that each slice in the radar chart occupies. + /// The angle that each slice in the radar chart occupies. @objc open var sliceAngle: CGFloat { return 360.0 / CGFloat(_data?.maxEntryCountSet?.entryCount ?? 0) @@ -168,24 +168,12 @@ open class RadarChartView: PieRadarChartViewBase let sliceAngle = self.sliceAngle let max = _data?.maxEntryCountSet?.entryCount ?? 0 - - var index = 0 - - for i in 0.. a - { - index = i - break - } - } - - return index + return (0.. a + } ?? max } - /// - returns: The object that represents all y-labels of the RadarChart. + /// The object that represents all y-labels of the RadarChart. @objc open var yAxis: YAxis { return _yAxis @@ -221,12 +209,12 @@ open class RadarChartView: PieRadarChartViewBase return min(content.width / 2.0, content.height / 2.0) } - /// - returns: The maximum value this chart can display on it's y-axis. + /// The maximum value this chart can display on it's y-axis. open override var chartYMax: Double { return _yAxis._axisMaximum } - /// - returns: The minimum value this chart can display on it's y-axis. + /// The minimum value this chart can display on it's y-axis. open override var chartYMin: Double { return _yAxis._axisMinimum } - /// - returns: The range of y-values this chart can display. + /// The range of y-values this chart can display. @objc open var yRange: Double { return _yAxis.axisRange } } diff --git a/Source/Charts/Components/AxisBase.swift b/Source/Charts/Components/AxisBase.swift index ee32230d47..144e69bf6b 100644 --- a/Source/Charts/Components/AxisBase.swift +++ b/Source/Charts/Components/AxisBase.swift @@ -147,7 +147,7 @@ open class AxisBase: ComponentBase return longest } - /// - returns: The formatted label at the specified index. This will either use the auto-formatter or the custom formatter (if one is set). + /// - Returns: The formatted label at the specified index. This will either use the auto-formatter or the custom formatter (if one is set). @objc open func getFormattedLabel(_ index: Int) -> String { if index < 0 || index >= entries.count @@ -229,7 +229,7 @@ open class AxisBase: ComponentBase /// The maximum number of labels on the axis @objc open var axisMaxLabels = Int(25) { - didSet { axisMinLabels = axisMaxLabels > 0 ? axisMaxLabels : oldValue } + didSet { axisMaxLabels = axisMaxLabels > 0 ? axisMaxLabels : oldValue } } /// the number of label entries the axis should have @@ -258,7 +258,7 @@ open class AxisBase: ComponentBase forceLabelsEnabled = force } - /// - returns: `true` if focing the y-label count is enabled. Default: false + /// `true` if focing the y-label count is enabled. Default: false @objc open var isForceLabelsEnabled: Bool { return forceLabelsEnabled } /// Adds a new ChartLimitLine to this axis. @@ -270,14 +270,8 @@ open class AxisBase: ComponentBase /// Removes the specified ChartLimitLine from the axis. @objc open func removeLimitLine(_ line: ChartLimitLine) { - for i in 0 ..< _limitLines.count - { - if _limitLines[i] === line - { - _limitLines.remove(at: i) - return - } - } + guard let i = _limitLines.firstIndex(of: line) else { return } + _limitLines.remove(at: i) } /// Removes all LimitLines from the axis. @@ -286,7 +280,7 @@ open class AxisBase: ComponentBase _limitLines.removeAll(keepingCapacity: false) } - /// - returns: The LimitLines of this axis. + /// The LimitLines of this axis. @objc open var limitLines : [ChartLimitLine] { return _limitLines @@ -345,8 +339,10 @@ open class AxisBase: ComponentBase } /// Calculates the minimum, maximum and range values of the YAxis with the given minimum and maximum values from the chart data. - /// - parameter dataMin: the y-min value according to chart data - /// - parameter dataMax: the y-max value according to chart + /// + /// - Parameters: + /// - dataMin: the y-min value according to chart data + /// - dataMax: the y-max value according to chart @objc open func calculate(min dataMin: Double, max dataMax: Double) { // if custom, use value as is, else use data value diff --git a/Source/Charts/Components/ChartLimitLine.swift b/Source/Charts/Components/ChartLimitLine.swift index e6682e3a33..41a2fe07b9 100644 --- a/Source/Charts/Components/ChartLimitLine.swift +++ b/Source/Charts/Components/ChartLimitLine.swift @@ -20,10 +20,10 @@ open class ChartLimitLine: ComponentBase @objc(ChartLimitLabelPosition) public enum LabelPosition: Int { - case leftTop - case leftBottom - case rightTop - case rightBottom + case topLeft + case topRight + case bottomLeft + case bottomRight } /// limit / maximum (the y-value or xIndex) @@ -39,7 +39,7 @@ open class ChartLimitLine: ComponentBase @objc open var drawLabelEnabled = true @objc open var label = "" - @objc open var labelPosition = LabelPosition.rightTop + @objc open var labelPosition = LabelPosition.topRight public override init() { diff --git a/Source/Charts/Components/Description.swift b/Source/Charts/Components/Description.swift index a063499e4f..84990885ad 100644 --- a/Source/Charts/Components/Description.swift +++ b/Source/Charts/Components/Description.swift @@ -12,22 +12,18 @@ import Foundation import CoreGraphics -#if !os(OSX) - import UIKit -#endif - @objc(ChartDescription) open class Description: ComponentBase { public override init() { #if os(tvOS) - // 23 is the smallest recommended font size on the TV - font = NSUIFont.systemFont(ofSize: 23) + // 23 is the smallest recommended font size on the TV + font = .systemFont(ofSize: 23) #elseif os(OSX) - font = NSUIFont.systemFont(ofSize: NSUIFont.systemFontSize) + font = .systemFont(ofSize: NSUIFont.systemFontSize) #else - font = NSUIFont.systemFont(ofSize: 8.0) + font = .systemFont(ofSize: 8.0) #endif super.init() diff --git a/Source/Charts/Components/IMarker.swift b/Source/Charts/Components/IMarker.swift index 59abfad7bb..a4b7526098 100644 --- a/Source/Charts/Components/IMarker.swift +++ b/Source/Charts/Components/IMarker.swift @@ -15,24 +15,23 @@ import CoreGraphics @objc(IChartMarker) public protocol IMarker: class { - /// - returns: The desired (general) offset you wish the IMarker to have on the x-axis. - /// + /// - Returns: The desired (general) offset you wish the IMarker to have on the x-axis. /// By returning x: -(width / 2) you will center the IMarker horizontally. - /// /// By returning y: -(height / 2) you will center the IMarker vertically. var offset: CGPoint { get } - /// - returns: The offset for drawing at the specific `point`. + /// - Parameters: + /// - point: This is the point at which the marker wants to be drawn. You can adjust the offset conditionally based on this argument. + /// - Returns: The offset for drawing at the specific `point`. /// This allows conditional adjusting of the Marker position. /// If you have no adjustments to make, return self.offset(). - /// - /// - parameter point: This is the point at which the marker wants to be drawn. You can adjust the offset conditionally based on this argument. func offsetForDrawing(atPoint: CGPoint) -> CGPoint /// This method enables a custom IMarker to update it's content every time the IMarker is redrawn according to the data entry it points to. /// - /// - parameter entry: The Entry the IMarker belongs to. This can also be any subclass of Entry, like BarEntry or CandleEntry, simply cast it at runtime. - /// - parameter highlight: The highlight object contains information about the highlighted value such as it's dataset-index, the selected range or stack-index (only stacked bar entries). + /// - Parameters: + /// - entry: The Entry the IMarker belongs to. This can also be any subclass of Entry, like BarEntry or CandleEntry, simply cast it at runtime. + /// - highlight: The highlight object contains information about the highlighted value such as it's dataset-index, the selected range or stack-index (only stacked bar entries). func refreshContent(entry: ChartDataEntry, highlight: Highlight) /// Draws the IMarker on the given position on the given context diff --git a/Source/Charts/Components/Legend.swift b/Source/Charts/Components/Legend.swift index 68e9e9e283..f50676ef3d 100644 --- a/Source/Charts/Components/Legend.swift +++ b/Source/Charts/Components/Legend.swift @@ -12,10 +12,6 @@ import Foundation import CoreGraphics -#if !os(OSX) - import UIKit -#endif - @objc(ChartLegend) open class Legend: ComponentBase { @@ -271,11 +267,7 @@ open class Legend: ComponentBase } width += size.width - - if i < entryCount - 1 - { - maxHeight += labelLineHeight + yEntrySpace - } + maxHeight += labelLineHeight + yEntrySpace } else { @@ -420,7 +412,7 @@ open class Legend: ComponentBase } /// **default**: false (automatic legend) - /// - returns: `true` if a custom legend entries has been set + /// `true` if a custom legend entries has been set @objc open var isLegendCustom: Bool { return _isLegendCustom diff --git a/Source/Charts/Components/LegendEntry.swift b/Source/Charts/Components/LegendEntry.swift index 88ed2e115c..5868137ef9 100644 --- a/Source/Charts/Components/LegendEntry.swift +++ b/Source/Charts/Components/LegendEntry.swift @@ -12,10 +12,6 @@ import Foundation import CoreGraphics -#if !os(OSX) - import UIKit -#endif - @objc(ChartLegendEntry) open class LegendEntry: NSObject { @@ -24,14 +20,15 @@ open class LegendEntry: NSObject super.init() } - /// - parameter label: The legend entry text. + /// - Parameters: + /// - label: The legend entry text. /// A `nil` label will start a group. - /// - parameter form: The form to draw for this entry. - /// - parameter formSize: Set to NaN to use the legend's default. - /// - parameter formLineWidth: Set to NaN to use the legend's default. - /// - parameter formLineDashPhase: Line dash configuration. - /// - parameter formLineDashLengths: Line dash configurationas NaN to use the legend's default. - /// - parameter formColor: The color for drawing the form. + /// - form: The form to draw for this entry. + /// - formSize: Set to NaN to use the legend's default. + /// - formLineWidth: Set to NaN to use the legend's default. + /// - formLineDashPhase: Line dash configuration. + /// - formLineDashLengths: Line dash configurationas NaN to use the legend's default. + /// - formColor: The color for drawing the form. @objc public init(label: String?, form: Legend.Form, formSize: CGFloat, diff --git a/Source/Charts/Components/MarkerImage.swift b/Source/Charts/Components/MarkerImage.swift index 14e4dcfc86..341b1186c0 100644 --- a/Source/Charts/Components/MarkerImage.swift +++ b/Source/Charts/Components/MarkerImage.swift @@ -12,10 +12,6 @@ import Foundation import CoreGraphics -#if !os(OSX) - import UIKit -#endif - @objc(ChartMarkerImage) open class MarkerImage: NSObject, IMarker { diff --git a/Source/Charts/Components/MarkerView.swift b/Source/Charts/Components/MarkerView.swift index 094f4e2e9d..e4d682ce84 100644 --- a/Source/Charts/Components/MarkerView.swift +++ b/Source/Charts/Components/MarkerView.swift @@ -12,10 +12,6 @@ import Foundation import CoreGraphics -#if !os(OSX) - import UIKit -#endif - @objc(ChartMarkerView) open class MarkerView: NSUIView, IMarker { @@ -75,24 +71,24 @@ open class MarkerView: NSUIView, IMarker open class func viewFromXib(in bundle: Bundle = .main) -> MarkerView? { #if !os(OSX) - return bundle.loadNibNamed( - String(describing: self), - owner: nil, - options: nil)?[0] as? MarkerView + return bundle.loadNibNamed( + String(describing: self), + owner: nil, + options: nil)?[0] as? MarkerView #else - - var loadedObjects = NSArray() - let loadedObjectsPointer = AutoreleasingUnsafeMutablePointer(&loadedObjects) - - if bundle.loadNibNamed( - NSNib.Name(String(describing: self)), - owner: nil, - topLevelObjects: loadedObjectsPointer) - { - return loadedObjects[0] as? MarkerView - } - - return nil + + var loadedObjects = NSArray() + let loadedObjectsPointer = AutoreleasingUnsafeMutablePointer(&loadedObjects) + + if bundle.loadNibNamed( + NSNib.Name(String(describing: self)), + owner: nil, + topLevelObjects: loadedObjectsPointer) + { + return loadedObjects[0] as? MarkerView + } + + return nil #endif } diff --git a/Source/Charts/Components/XAxis.swift b/Source/Charts/Components/XAxis.swift index 1031bbb0e7..77dbbd6974 100644 --- a/Source/Charts/Components/XAxis.swift +++ b/Source/Charts/Components/XAxis.swift @@ -49,10 +49,10 @@ open class XAxis: AxisBase /// if set to true, word wrapping the labels will be enabled. /// word wrapping is done using `(value width * labelRotatedWidth)` /// - /// - note: currently supports all charts except pie/radar/horizontal-bar* + /// - Note: currently supports all charts except pie/radar/horizontal-bar* @objc open var wordWrapEnabled = false - /// - returns: `true` if word wrapping the labels is enabled + /// `true` if word wrapping the labels is enabled @objc open var isWordWrapEnabled: Bool { return wordWrapEnabled } /// the width for wrapping the labels, as percentage out of one value width. diff --git a/Source/Charts/Components/YAxis.swift b/Source/Charts/Components/YAxis.swift index 4729c1843d..01e41b51af 100644 --- a/Source/Charts/Components/YAxis.swift +++ b/Source/Charts/Components/YAxis.swift @@ -12,10 +12,6 @@ import Foundation import CoreGraphics -#if !os(OSX) - import UIKit -#endif - /// Class representing the y-axis labels settings and its entries. /// Be aware that not all features the YLabels class provides are suitable for the RadarChart. @@ -129,7 +125,7 @@ open class YAxis: AxisBase return requiredSize().height } - /// - returns: `true` if this axis needs horizontal offset, `false` ifno offset is needed. + /// `true` if this axis needs horizontal offset, `false` ifno offset is needed. @objc open var needsOffset: Bool { if isEnabled && isDrawLabelsEnabled && labelPosition == .outsideChart @@ -150,6 +146,23 @@ open class YAxis: AxisBase var min = _customAxisMin ? _axisMinimum : dataMin var max = _customAxisMax ? _axisMaximum : dataMax + // Make sure max is greater than min + // Discussion: https://github.com/danielgindi/Charts/pull/3650#discussion_r221409991 + if min > max + { + switch(_customAxisMax, _customAxisMin) + { + case(true, true): + (min, max) = (max, min) + case(true, false): + min = max < 0 ? max * 1.5 : max * 0.5 + case(false, true): + max = min < 0 ? min * 0.5 : min * 1.5 + case(false, false): + break + } + } + // temporary range (before calculations) let range = abs(max - min) diff --git a/Source/Charts/Data/Implementations/ChartBaseDataSet.swift b/Source/Charts/Data/Implementations/ChartBaseDataSet.swift index b78867679e..b331405b05 100644 --- a/Source/Charts/Data/Implementations/ChartBaseDataSet.swift +++ b/Source/Charts/Data/Implementations/ChartBaseDataSet.swift @@ -13,7 +13,7 @@ import Foundation import CoreGraphics -open class ChartBaseDataSet: NSObject, IChartDataSet +open class ChartBaseDataSet: NSObject, IChartDataSet, NSCopying { public required override init() { @@ -198,7 +198,7 @@ open class ChartBaseDataSet: NSObject, IChartDataSet /// The axis this DataSet should be plotted against. open var axisDependency = YAxis.AxisDependency.left - /// - returns: The color at the given index of the DataSet's color array. + /// - Returns: The color at the given index of the DataSet's color array. /// This prevents out-of-bounds by performing a modulus on the color index, so colours will repeat themselves. open func color(atIndex index: Int) -> NSUIColor { @@ -217,7 +217,9 @@ open class ChartBaseDataSet: NSObject, IChartDataSet } /// Adds a new color to the colors array of the DataSet. - /// - parameter color: the color to add + /// + /// - Parameters: + /// - color: the color to add open func addColor(_ color: NSUIColor) { colors.append(color) @@ -225,7 +227,9 @@ open class ChartBaseDataSet: NSObject, IChartDataSet /// Sets the one and **only** color that should be used for this DataSet. /// Internally, this recreates the colors array and adds the specified color. - /// - parameter color: the color to set + /// + /// - Parameters: + /// - color: the color to set open func setColor(_ color: NSUIColor) { colors.removeAll(keepingCapacity: false) @@ -233,31 +237,30 @@ open class ChartBaseDataSet: NSObject, IChartDataSet } /// Sets colors to a single color a specific alpha value. - /// - parameter color: the color to set - /// - parameter alpha: alpha to apply to the set `color` + /// + /// - Parameters: + /// - color: the color to set + /// - alpha: alpha to apply to the set `color` @objc open func setColor(_ color: NSUIColor, alpha: CGFloat) { setColor(color.withAlphaComponent(alpha)) } /// Sets colors with a specific alpha value. - /// - parameter colors: the colors to set - /// - parameter alpha: alpha to apply to the set `colors` + /// + /// - Parameters: + /// - colors: the colors to set + /// - alpha: alpha to apply to the set `colors` @objc open func setColors(_ colors: [NSUIColor], alpha: CGFloat) { - var colorsWithAlpha = colors - - for i in 0 ..< colorsWithAlpha.count - { - colorsWithAlpha[i] = colorsWithAlpha[i] .withAlphaComponent(alpha) - } - - self.colors = colorsWithAlpha + self.colors = colors.map { $0.withAlphaComponent(alpha) } } /// Sets colors with a specific alpha value. - /// - parameter colors: the colors to set - /// - parameter alpha: alpha to apply to the set `colors` + /// + /// - Parameters: + /// - colors: the colors to set + /// - alpha: alpha to apply to the set `colors` open func setColors(_ colors: NSUIColor...) { self.colors = colors @@ -266,7 +269,7 @@ open class ChartBaseDataSet: NSObject, IChartDataSet /// if true, value highlighting is enabled open var highlightEnabled = true - /// - returns: `true` if value highlighting is enabled for this dataset + /// `true` if value highlighting is enabled for this dataset open var isHighlightEnabled: Bool { return highlightEnabled } /// Custom formatter that is used instead of the auto-formatter if set @@ -313,7 +316,7 @@ open class ChartBaseDataSet: NSObject, IChartDataSet } } - /// - returns: The color at the specified index that is used for drawing the values inside the chart. Uses modulus internally. + /// - Returns: The color at the specified index that is used for drawing the values inside the chart. Uses modulus internally. open func valueTextColorAt(_ index: Int) -> NSUIColor { var index = index @@ -354,10 +357,10 @@ open class ChartBaseDataSet: NSObject, IChartDataSet /// Set this to true to draw y-values on the chart. /// - /// - note: For bar and line charts: if `maxVisibleCount` is reached, no values will be drawn even if this is enabled. + /// - Note: For bar and line charts: if `maxVisibleCount` is reached, no values will be drawn even if this is enabled. open var drawValuesEnabled = true - /// - returns: `true` if y-value drawing is enabled, `false` ifnot + /// `true` if y-value drawing is enabled, `false` ifnot open var isDrawValuesEnabled: Bool { return drawValuesEnabled @@ -365,7 +368,7 @@ open class ChartBaseDataSet: NSObject, IChartDataSet /// Set this to true to draw y-icons on the chart. /// - /// - note: For bar and line charts: if `maxVisibleCount` is reached, no icons will be drawn even if this is enabled. + /// - Note: For bar and line charts: if `maxVisibleCount` is reached, no icons will be drawn even if this is enabled. open var drawIconsEnabled = true /// Returns true if y-icon drawing is enabled, false if not @@ -384,7 +387,7 @@ open class ChartBaseDataSet: NSObject, IChartDataSet /// Set the visibility of this DataSet. If not visible, the DataSet will not be drawn to the chart upon refreshing it. open var visible = true - /// - returns: `true` if this DataSet is visible inside the chart, or `false` ifit is currently hidden. + /// `true` if this DataSet is visible inside the chart, or `false` ifit is currently hidden. open var isVisible: Bool { return visible @@ -399,25 +402,33 @@ open class ChartBaseDataSet: NSObject, IChartDataSet open override var debugDescription: String { - var desc = description + ":" - - for i in 0 ..< self.entryCount - { - desc += "\n" + (self.entryForIndex(i)?.description ?? "") + return (0.. AnyObject + open func copy(with zone: NSZone? = nil) -> Any { let copy = type(of: self).init() copy.colors = colors copy.valueColors = valueColors copy.label = label + copy.axisDependency = axisDependency + copy.highlightEnabled = highlightEnabled + copy._valueFormatter = _valueFormatter + copy.valueFont = valueFont + copy.form = form + copy.formSize = formSize + copy.formLineWidth = formLineWidth + copy.formLineDashPhase = formLineDashPhase + copy.formLineDashLengths = formLineDashLengths + copy.drawValuesEnabled = drawValuesEnabled + copy.drawValuesEnabled = drawValuesEnabled + copy.iconsOffset = iconsOffset + copy.visible = visible return copy } diff --git a/Source/Charts/Data/Implementations/Standard/BarChartData.swift b/Source/Charts/Data/Implementations/Standard/BarChartData.swift index 0317fc8a6b..6697c32cf2 100644 --- a/Source/Charts/Data/Implementations/Standard/BarChartData.swift +++ b/Source/Charts/Data/Implementations/Standard/BarChartData.swift @@ -33,9 +33,10 @@ open class BarChartData: BarLineScatterCandleBubbleChartData /// Previously set x-values of entries will be overwritten. Leaves space between bars and groups as specified by the parameters. /// Do not forget to call notifyDataSetChanged() on your BarChart object after calling this method. /// - /// - parameter the starting point on the x-axis where the grouping should begin - /// - parameter groupSpace: The space between groups of bars in values (not pixels) e.g. 0.8f for bar width 1f - /// - parameter barSpace: The space between individual bars in values (not pixels) e.g. 0.1f for bar width 1f + /// - Parameters: + /// - fromX: the starting point on the x-axis where the grouping should begin + /// - groupSpace: The space between groups of bars in values (not pixels) e.g. 0.8f for bar width 1f + /// - barSpace: The space between individual bars in values (not pixels) e.g. 0.1f for bar width 1f @objc open func groupBars(fromX: Double, groupSpace: Double, barSpace: Double) { let setCount = _dataSets.count @@ -95,8 +96,9 @@ open class BarChartData: BarLineScatterCandleBubbleChartData /// In case of grouped bars, this method returns the space an individual group of bar needs on the x-axis. /// - /// - parameter groupSpace: - /// - parameter barSpace: + /// - Parameters: + /// - groupSpace: + /// - barSpace: @objc open func groupWidth(groupSpace: Double, barSpace: Double) -> Double { return Double(_dataSets.count) * (self.barWidth + barSpace) + groupSpace diff --git a/Source/Charts/Data/Implementations/Standard/BarChartDataEntry.swift b/Source/Charts/Data/Implementations/Standard/BarChartDataEntry.swift index 5c60dabb6e..31c51b0f86 100644 --- a/Source/Charts/Data/Implementations/Standard/BarChartDataEntry.swift +++ b/Source/Charts/Data/Implementations/Standard/BarChartDataEntry.swift @@ -37,21 +37,25 @@ open class BarChartDataEntry: ChartDataEntry } /// Constructor for normal bars (not stacked). - public override init(x: Double, y: Double, data: AnyObject?) + public convenience init(x: Double, y: Double, data: Any?) { - super.init(x: x, y: y, data: data) + self.init(x: x, y: y) + self.data = data } /// Constructor for normal bars (not stacked). - public override init(x: Double, y: Double, icon: NSUIImage?) + public convenience init(x: Double, y: Double, icon: NSUIImage?) { - super.init(x: x, y: y, icon: icon) + self.init(x: x, y: y) + self.icon = icon } /// Constructor for normal bars (not stacked). - public override init(x: Double, y: Double, icon: NSUIImage?, data: AnyObject?) + public convenience init(x: Double, y: Double, icon: NSUIImage?, data: Any?) { - super.init(x: x, y: y, icon: icon, data: data) + self.init(x: x, y: y) + self.icon = icon + self.data = data } /// Constructor for stacked bar entries. @@ -62,32 +66,27 @@ open class BarChartDataEntry: ChartDataEntry calcPosNegSum() calcRanges() } - + /// Constructor for stacked bar entries. One data object for whole stack - @objc public init(x: Double, yValues: [Double], data: AnyObject?) + @objc public convenience init(x: Double, yValues: [Double], icon: NSUIImage?) { - super.init(x: x, y: BarChartDataEntry.calcSum(values: yValues), data: data) - self._yVals = yValues - calcPosNegSum() - calcRanges() + self.init(x: x, yValues: yValues) + self.icon = icon } - + /// Constructor for stacked bar entries. One data object for whole stack - @objc public init(x: Double, yValues: [Double], icon: NSUIImage?, data: AnyObject?) + @objc public convenience init(x: Double, yValues: [Double], data: Any?) { - super.init(x: x, y: BarChartDataEntry.calcSum(values: yValues), icon: icon, data: data) - self._yVals = yValues - calcPosNegSum() - calcRanges() + self.init(x: x, yValues: yValues) + self.data = data } - + /// Constructor for stacked bar entries. One data object for whole stack - @objc public init(x: Double, yValues: [Double], icon: NSUIImage?) + @objc public convenience init(x: Double, yValues: [Double], icon: NSUIImage?, data: Any?) { - super.init(x: x, y: BarChartDataEntry.calcSum(values: yValues), icon: icon) - self._yVals = yValues - calcPosNegSum() - calcRanges() + self.init(x: x, yValues: yValues) + self.icon = icon + self.data = data } @objc open func sumBelow(stackIndex :Int) -> Double @@ -109,13 +108,13 @@ open class BarChartDataEntry: ChartDataEntry return remainder } - /// - returns: The sum of all negative values this entry (if stacked) contains. (this is a positive number) + /// The sum of all negative values this entry (if stacked) contains. (this is a positive number) @objc open var negativeSum: Double { return _negativeSum } - /// - returns: The sum of all positive values this entry (if stacked) contains. + /// The sum of all positive values this entry (if stacked) contains. @objc open var positiveSum: Double { return _positiveSum @@ -123,69 +122,51 @@ open class BarChartDataEntry: ChartDataEntry @objc open func calcPosNegSum() { - guard let _yVals = _yVals else - { - _positiveSum = 0.0 - _negativeSum = 0.0 - return - } - - var sumNeg: Double = 0.0 - var sumPos: Double = 0.0 - - for f in _yVals - { - if f < 0.0 + (_negativeSum, _positiveSum) = _yVals?.reduce(into: (0,0)) { (result, y) in + if y < 0 { - sumNeg += -f + result.0 += -y } else { - sumPos += f + result.1 += y } - } - - _negativeSum = sumNeg - _positiveSum = sumPos + } ?? (0,0) } /// Splits up the stack-values of the given bar-entry into Range objects. - /// - parameter entry: - /// - returns: + /// + /// - Parameters: + /// - entry: + /// - Returns: @objc open func calcRanges() { - let values = yValues - if values?.isEmpty != false - { - return - } - + guard let values = yValues, !values.isEmpty else { return } + if _ranges == nil { _ranges = [Range]() } else { - _ranges?.removeAll() + _ranges!.removeAll() } - _ranges?.reserveCapacity(values!.count) + _ranges!.reserveCapacity(values.count) var negRemain = -negativeSum var posRemain: Double = 0.0 - for i in 0 ..< values!.count + for value in values { - let value = values![i] - if value < 0 { - _ranges?.append(Range(from: negRemain, to: negRemain - value)) + _ranges!.append(Range(from: negRemain, to: negRemain - value)) negRemain -= value } else { - _ranges?.append(Range(from: posRemain, to: posRemain + value)) + _ranges!.append(Range(from: posRemain, to: posRemain + value)) posRemain += value } } @@ -209,7 +190,7 @@ open class BarChartDataEntry: ChartDataEntry } } - /// - returns: The ranges of the individual stack-entries. Will return null if this entry is not stacked. + /// The ranges of the individual stack-entries. Will return null if this entry is not stacked. @objc open var ranges: [Range]? { return _ranges @@ -217,19 +198,21 @@ open class BarChartDataEntry: ChartDataEntry // MARK: NSCopying - open override func copyWithZone(_ zone: NSZone?) -> AnyObject + open override func copy(with zone: NSZone? = nil) -> Any { - let copy = super.copyWithZone(zone) as! BarChartDataEntry + let copy = super.copy(with: zone) as! BarChartDataEntry copy._yVals = _yVals copy.y = y copy._negativeSum = _negativeSum + copy._positiveSum = _positiveSum return copy } /// Calculates the sum across all values of the given stack. /// - /// - parameter vals: - /// - returns: + /// - Parameters: + /// - vals: + /// - Returns: private static func calcSum(values: [Double]?) -> Double { guard let values = values diff --git a/Source/Charts/Data/Implementations/Standard/BarChartDataSet.swift b/Source/Charts/Data/Implementations/Standard/BarChartDataSet.swift index 1bdca1b0f8..2478aeccf8 100644 --- a/Source/Charts/Data/Implementations/Standard/BarChartDataSet.swift +++ b/Source/Charts/Data/Implementations/Standard/BarChartDataSet.swift @@ -19,8 +19,8 @@ open class BarChartDataSet: BarLineScatterCandleBubbleChartDataSet, IBarChartDat { self.highlightColor = NSUIColor.black - self.calcStackSize(entries: values as! [BarChartDataEntry]) - self.calcEntryCountIncludingStacks(entries: values as! [BarChartDataEntry]) + self.calcStackSize(entries: entries as! [BarChartDataEntry]) + self.calcEntryCountIncludingStacks(entries: entries as! [BarChartDataEntry]) } public required init() @@ -29,9 +29,9 @@ open class BarChartDataSet: BarLineScatterCandleBubbleChartDataSet, IBarChartDat initialize() } - public override init(values: [ChartDataEntry]?, label: String?) + public override init(entries: [ChartDataEntry]?, label: String?) { - super.init(values: values, label: label) + super.init(entries: entries, label: label) initialize() } @@ -114,19 +114,19 @@ open class BarChartDataSet: BarLineScatterCandleBubbleChartDataSet, IBarChartDat } } - /// - returns: The maximum number of bars that can be stacked upon another in this DataSet. + /// The maximum number of bars that can be stacked upon another in this DataSet. open var stackSize: Int { return _stackSize } - /// - returns: `true` if this DataSet is stacked (stacksize > 1) or not. + /// `true` if this DataSet is stacked (stacksize > 1) or not. open var isStacked: Bool { return _stackSize > 1 ? true : false } - /// - returns: The overall entry count, including counting each stack-value individually + /// The overall entry count, including counting each stack-value individually @objc open var entryCountStacks: Int { return _entryCountStacks @@ -151,14 +151,16 @@ open class BarChartDataSet: BarLineScatterCandleBubbleChartDataSet, IBarChartDat // MARK: - NSCopying - open override func copyWithZone(_ zone: NSZone?) -> AnyObject + open override func copy(with zone: NSZone? = nil) -> Any { - let copy = super.copyWithZone(zone) as! BarChartDataSet + let copy = super.copy(with: zone) as! BarChartDataSet copy._stackSize = _stackSize copy._entryCountStacks = _entryCountStacks copy.stackLabels = stackLabels copy.barShadowColor = barShadowColor + copy.barBorderWidth = barBorderWidth + copy.barBorderColor = barBorderColor copy.highlightAlpha = highlightAlpha return copy } diff --git a/Source/Charts/Data/Implementations/Standard/BarLineScatterCandleBubbleChartDataSet.swift b/Source/Charts/Data/Implementations/Standard/BarLineScatterCandleBubbleChartDataSet.swift index 02b942f479..91382515a8 100644 --- a/Source/Charts/Data/Implementations/Standard/BarLineScatterCandleBubbleChartDataSet.swift +++ b/Source/Charts/Data/Implementations/Standard/BarLineScatterCandleBubbleChartDataSet.swift @@ -26,9 +26,9 @@ open class BarLineScatterCandleBubbleChartDataSet: ChartDataSet, IBarLineScatter // MARK: - NSCopying - open override func copyWithZone(_ zone: NSZone?) -> AnyObject + open override func copy(with zone: NSZone? = nil) -> Any { - let copy = super.copyWithZone(zone) as! BarLineScatterCandleBubbleChartDataSet + let copy = super.copy(with: zone) as! BarLineScatterCandleBubbleChartDataSet copy.highlightColor = highlightColor copy.highlightLineWidth = highlightLineWidth copy.highlightLineDashPhase = highlightLineDashPhase diff --git a/Source/Charts/Data/Implementations/Standard/BubbleChartDataEntry.swift b/Source/Charts/Data/Implementations/Standard/BubbleChartDataEntry.swift index 7f412d7397..01f9fc968d 100644 --- a/Source/Charts/Data/Implementations/Standard/BubbleChartDataEntry.swift +++ b/Source/Charts/Data/Implementations/Standard/BubbleChartDataEntry.swift @@ -22,9 +22,10 @@ open class BubbleChartDataEntry: ChartDataEntry super.init() } - /// - parameter x: The index on the x-axis. - /// - parameter y: The value on the y-axis. - /// - parameter size: The size of the bubble. + /// - Parameters: + /// - x: The index on the x-axis. + /// - y: The value on the y-axis. + /// - size: The size of the bubble. @objc public init(x: Double, y: Double, size: CGFloat) { super.init(x: x, y: y) @@ -32,45 +33,46 @@ open class BubbleChartDataEntry: ChartDataEntry self.size = size } - /// - parameter x: The index on the x-axis. - /// - parameter y: The value on the y-axis. - /// - parameter size: The size of the bubble. - /// - parameter data: Spot for additional data this Entry represents. - @objc public init(x: Double, y: Double, size: CGFloat, data: AnyObject?) + /// - Parameters: + /// - x: The index on the x-axis. + /// - y: The value on the y-axis. + /// - size: The size of the bubble. + /// - data: Spot for additional data this Entry represents. + @objc public convenience init(x: Double, y: Double, size: CGFloat, data: Any?) { - super.init(x: x, y: y, data: data) - - self.size = size + self.init(x: x, y: y, size: size) + self.data = data } - /// - parameter x: The index on the x-axis. - /// - parameter y: The value on the y-axis. - /// - parameter size: The size of the bubble. - /// - parameter icon: icon image - @objc public init(x: Double, y: Double, size: CGFloat, icon: NSUIImage?) + /// - Parameters: + /// - x: The index on the x-axis. + /// - y: The value on the y-axis. + /// - size: The size of the bubble. + /// - icon: icon image + @objc public convenience init(x: Double, y: Double, size: CGFloat, icon: NSUIImage?) { - super.init(x: x, y: y, icon: icon) - - self.size = size + self.init(x: x, y: y, size: size) + self.icon = icon } - /// - parameter x: The index on the x-axis. - /// - parameter y: The value on the y-axis. - /// - parameter size: The size of the bubble. - /// - parameter icon: icon image - /// - parameter data: Spot for additional data this Entry represents. - @objc public init(x: Double, y: Double, size: CGFloat, icon: NSUIImage?, data: AnyObject?) + /// - Parameters: + /// - x: The index on the x-axis. + /// - y: The value on the y-axis. + /// - size: The size of the bubble. + /// - icon: icon image + /// - data: Spot for additional data this Entry represents. + @objc public convenience init(x: Double, y: Double, size: CGFloat, icon: NSUIImage?, data: Any?) { - super.init(x: x, y: y, icon: icon, data: data) - - self.size = size + self.init(x: x, y: y, size: size) + self.icon = icon + self.data = data } // MARK: NSCopying - open override func copyWithZone(_ zone: NSZone?) -> AnyObject + open override func copy(with zone: NSZone? = nil) -> Any { - let copy = super.copyWithZone(zone) as! BubbleChartDataEntry + let copy = super.copy(with: zone) as! BubbleChartDataEntry copy.size = size return copy } diff --git a/Source/Charts/Data/Implementations/Standard/BubbleChartDataSet.swift b/Source/Charts/Data/Implementations/Standard/BubbleChartDataSet.swift index cdc3567e69..775fafb8bd 100644 --- a/Source/Charts/Data/Implementations/Standard/BubbleChartDataSet.swift +++ b/Source/Charts/Data/Implementations/Standard/BubbleChartDataSet.swift @@ -45,12 +45,13 @@ open class BubbleChartDataSet: BarLineScatterCandleBubbleChartDataSet, IBubbleCh // MARK: - NSCopying - open override func copyWithZone(_ zone: NSZone?) -> AnyObject + open override func copy(with zone: NSZone? = nil) -> Any { - let copy = super.copyWithZone(zone) as! BubbleChartDataSet + let copy = super.copy(with: zone) as! BubbleChartDataSet copy._xMin = _xMin copy._xMax = _xMax copy._maxSize = _maxSize + copy.normalizeSizeEnabled = normalizeSizeEnabled copy.highlightCircleWidth = highlightCircleWidth return copy } diff --git a/Source/Charts/Data/Implementations/Standard/CandleChartDataEntry.swift b/Source/Charts/Data/Implementations/Standard/CandleChartDataEntry.swift index 538066ad87..467bc168d1 100644 --- a/Source/Charts/Data/Implementations/Standard/CandleChartDataEntry.swift +++ b/Source/Charts/Data/Implementations/Standard/CandleChartDataEntry.swift @@ -39,44 +39,33 @@ open class CandleChartDataEntry: ChartDataEntry self.open = open self.close = close } - - @objc public init(x: Double, shadowH: Double, shadowL: Double, open: Double, close: Double, data: AnyObject?) + + @objc public convenience init(x: Double, shadowH: Double, shadowL: Double, open: Double, close: Double, icon: NSUIImage?) { - super.init(x: x, y: (shadowH + shadowL) / 2.0, data: data) - - self.high = shadowH - self.low = shadowL - self.open = open - self.close = close + self.init(x: x, shadowH: shadowH, shadowL: shadowL, open: open, close: close) + self.icon = icon } - - @objc public init(x: Double, shadowH: Double, shadowL: Double, open: Double, close: Double, icon: NSUIImage?) + + @objc public convenience init(x: Double, shadowH: Double, shadowL: Double, open: Double, close: Double, data: Any?) { - super.init(x: x, y: (shadowH + shadowL) / 2.0, icon: icon) - - self.high = shadowH - self.low = shadowL - self.open = open - self.close = close + self.init(x: x, shadowH: shadowH, shadowL: shadowL, open: open, close: close) + self.data = data } - - @objc public init(x: Double, shadowH: Double, shadowL: Double, open: Double, close: Double, icon: NSUIImage?, data: AnyObject?) + + @objc public convenience init(x: Double, shadowH: Double, shadowL: Double, open: Double, close: Double, icon: NSUIImage?, data: Any?) { - super.init(x: x, y: (shadowH + shadowL) / 2.0, icon: icon, data: data) - - self.high = shadowH - self.low = shadowL - self.open = open - self.close = close + self.init(x: x, shadowH: shadowH, shadowL: shadowL, open: open, close: close) + self.icon = icon + self.data = data } - /// - returns: The overall range (difference) between shadow-high and shadow-low. + /// The overall range (difference) between shadow-high and shadow-low. @objc open var shadowRange: Double { return abs(high - low) } - /// - returns: The body size (difference between open and close). + /// The body size (difference between open and close). @objc open var bodyRange: Double { return abs(open - close) @@ -97,9 +86,9 @@ open class CandleChartDataEntry: ChartDataEntry // MARK: NSCopying - open override func copyWithZone(_ zone: NSZone?) -> AnyObject + open override func copy(with zone: NSZone? = nil) -> Any { - let copy = super.copyWithZone(zone) as! CandleChartDataEntry + let copy = super.copy(with: zone) as! CandleChartDataEntry copy.high = high copy.low = low copy.open = open diff --git a/Source/Charts/Data/Implementations/Standard/CandleChartDataSet.swift b/Source/Charts/Data/Implementations/Standard/CandleChartDataSet.swift index 6b6247cfd8..1c51da7d26 100644 --- a/Source/Charts/Data/Implementations/Standard/CandleChartDataSet.swift +++ b/Source/Charts/Data/Implementations/Standard/CandleChartDataSet.swift @@ -21,9 +21,9 @@ open class CandleChartDataSet: LineScatterCandleRadarChartDataSet, ICandleChartD super.init() } - public override init(values: [ChartDataEntry]?, label: String?) + public override init(entries: [ChartDataEntry]?, label: String?) { - super.init(values: values, label: label) + super.init(entries: entries, label: label) } // MARK: - Data functions and accessors diff --git a/Source/Charts/Data/Implementations/Standard/ChartData.swift b/Source/Charts/Data/Implementations/Standard/ChartData.swift index 24309ebae9..1cb1fd93f7 100644 --- a/Source/Charts/Data/Implementations/Standard/ChartData.swift +++ b/Source/Charts/Data/Implementations/Standard/ChartData.swift @@ -59,11 +59,7 @@ open class ChartData: NSObject @objc open func calcMinMaxY(fromX: Double, toX: Double) { - for set in _dataSets - { - set.calcMinMaxY(fromX: fromX, toX: toX) - } - + _dataSets.forEach { $0.calcMinMaxY(fromX: fromX, toX: toX) } // apply the new data calcMinMax() } @@ -76,10 +72,7 @@ open class ChartData: NSObject _xMax = -Double.greatestFiniteMagnitude _xMin = Double.greatestFiniteMagnitude - for set in _dataSets - { - calcMinMax(dataSet: set) - } + _dataSets.forEach { calcMinMax(dataSet: $0) } _leftAxisMax = -Double.greatestFiniteMagnitude _leftAxisMin = Double.greatestFiniteMagnitude @@ -235,13 +228,13 @@ open class ChartData: NSObject } } - /// - returns: The number of LineDataSets this object contains + /// The number of LineDataSets this object contains @objc open var dataSetCount: Int { return _dataSets.count } - /// - returns: The smallest y-value the data object contains. + /// The smallest y-value the data object contains. @objc open var yMin: Double { return _yMin @@ -279,7 +272,7 @@ open class ChartData: NSObject } } - /// - returns: The greatest y-value the data object contains. + /// The greatest y-value the data object contains. @objc open var yMax: Double { return _yMax @@ -317,18 +310,18 @@ open class ChartData: NSObject } } - /// - returns: The minimum x-value the data object contains. + /// The minimum x-value the data object contains. @objc open var xMin: Double { return _xMin } - /// - returns: The maximum x-value the data object contains. + /// The maximum x-value the data object contains. @objc open var xMax: Double { return _xMax } - /// - returns: All DataSet objects this ChartData object holds. + /// All DataSet objects this ChartData object holds. @objc open var dataSets: [IChartDataSet] { get @@ -346,62 +339,33 @@ open class ChartData: NSObject /// /// **IMPORTANT: This method does calculations at runtime, do not over-use in performance critical situations.** /// - /// - parameter dataSets: the DataSet array to search - /// - parameter type: - /// - parameter ignorecase: if true, the search is not case-sensitive - /// - returns: The index of the DataSet Object with the given label. Sensitive or not. + /// - Parameters: + /// - dataSets: the DataSet array to search + /// - type: + /// - ignorecase: if true, the search is not case-sensitive + /// - Returns: The index of the DataSet Object with the given label. Sensitive or not. internal func getDataSetIndexByLabel(_ label: String, ignorecase: Bool) -> Int { + // TODO: Return nil instead of -1 if ignorecase { - for i in 0 ..< dataSets.count - { - if dataSets[i].label == nil - { - continue - } - if (label.caseInsensitiveCompare(dataSets[i].label!) == ComparisonResult.orderedSame) - { - return i - } - } + return dataSets.firstIndex { + guard let label = $0.label else { return false } + return label.caseInsensitiveCompare(label) == .orderedSame + } ?? -1 } else { - for i in 0 ..< dataSets.count - { - if label == dataSets[i].label - { - return i - } - } - } - - return -1 - } - - /// - returns: The labels of all DataSets as a string array. - internal func dataSetLabels() -> [String] - { - var types = [String]() - - for i in 0 ..< _dataSets.count - { - if dataSets[i].label == nil - { - continue - } - - types[i] = _dataSets[i].label! + return dataSets.firstIndex { $0.label == label } + ?? -1 } - - return types } - + /// Get the Entry for a corresponding highlight object /// - /// - parameter highlight: - /// - returns: The entry that is highlighted + /// - Parameters: + /// - highlight: + /// - Returns: The entry that is highlighted @objc open func entryForHighlight(_ highlight: Highlight) -> ChartDataEntry? { if highlight.dataSetIndex >= dataSets.count @@ -416,9 +380,10 @@ open class ChartData: NSObject /// **IMPORTANT: This method does calculations at runtime. Use with care in performance critical situations.** /// - /// - parameter label: - /// - parameter ignorecase: - /// - returns: The DataSet Object with the given label. Sensitive or not. + /// - Parameters: + /// - label: + /// - ignorecase: + /// - Returns: The DataSet Object with the given label. Sensitive or not. @objc open func getDataSetByLabel(_ label: String, ignorecase: Bool) -> IChartDataSet? { let index = getDataSetIndexByLabel(label, ignorecase: ignorecase) @@ -453,29 +418,17 @@ open class ChartData: NSObject /// Removes the given DataSet from this data object. /// Also recalculates all minimum and maximum values. /// - /// - returns: `true` if a DataSet was removed, `false` ifno DataSet could be removed. - @objc @discardableResult open func removeDataSet(_ dataSet: IChartDataSet!) -> Bool + /// - Returns: `true` if a DataSet was removed, `false` ifno DataSet could be removed. + @objc @discardableResult open func removeDataSet(_ dataSet: IChartDataSet) -> Bool { - if dataSet === nil - { - return false - } - - for i in 0 ..< _dataSets.count - { - if _dataSets[i] === dataSet - { - return removeDataSetByIndex(i) - } - } - - return false + guard let i = _dataSets.firstIndex(where: { $0 === dataSet }) else { return false } + return removeDataSetByIndex(i) } /// Removes the DataSet at the given index in the DataSet array from the data object. /// Also recalculates all minimum and maximum values. /// - /// - returns: `true` if a DataSet was removed, `false` ifno DataSet could be removed. + /// - Returns: `true` if a DataSet was removed, `false` ifno DataSet could be removed. @objc @discardableResult open func removeDataSetByIndex(_ index: Int) -> Bool { if index >= _dataSets.count || index < 0 @@ -529,7 +482,8 @@ open class ChartData: NSObject /// Removes the Entry object closest to the given xIndex from the ChartDataSet at the /// specified index. - /// - returns: `true` if an entry was removed, `false` ifno Entry was found that meets the specified requirements. + /// + /// - Returns: `true` if an entry was removed, `false` ifno Entry was found that meets the specified requirements. @objc @discardableResult open func removeEntry(xValue: Double, dataSetIndex: Int) -> Bool { if dataSetIndex >= _dataSets.count @@ -545,156 +499,68 @@ open class ChartData: NSObject return false } - /// - returns: The DataSet that contains the provided Entry, or null, if no DataSet contains this entry. - @objc open func getDataSetForEntry(_ e: ChartDataEntry!) -> IChartDataSet? + /// - Returns: The DataSet that contains the provided Entry, or null, if no DataSet contains this entry. + @objc open func getDataSetForEntry(_ e: ChartDataEntry) -> IChartDataSet? { - if e == nil - { - return nil - } - - for i in 0 ..< _dataSets.count - { - let set = _dataSets[i] - - if e === set.entryForXValue(e.x, closestToY: e.y) - { - return set - } - } - - return nil + return _dataSets.first { $0.entryForXValue(e.x, closestToY: e.y) === e } } - /// - returns: The index of the provided DataSet in the DataSet array of this data object, or -1 if it does not exist. + /// - Returns: The index of the provided DataSet in the DataSet array of this data object, or -1 if it does not exist. @objc open func indexOfDataSet(_ dataSet: IChartDataSet) -> Int { - for i in 0 ..< _dataSets.count - { - if _dataSets[i] === dataSet - { - return i - } - } - - return -1 + // TODO: Return nil instead of -1 + return _dataSets.firstIndex { $0 === dataSet } ?? -1 } - /// - returns: The first DataSet from the datasets-array that has it's dependency on the left axis. Returns null if no DataSet with left dependency could be found. + /// - Returns: The first DataSet from the datasets-array that has it's dependency on the left axis. Returns null if no DataSet with left dependency could be found. @objc open func getFirstLeft(dataSets: [IChartDataSet]) -> IChartDataSet? { - for dataSet in dataSets - { - if dataSet.axisDependency == .left - { - return dataSet - } - } - - return nil + return dataSets.first { $0.axisDependency == .left } } - /// - returns: The first DataSet from the datasets-array that has it's dependency on the right axis. Returns null if no DataSet with right dependency could be found. + /// - Returns: The first DataSet from the datasets-array that has it's dependency on the right axis. Returns null if no DataSet with right dependency could be found. @objc open func getFirstRight(dataSets: [IChartDataSet]) -> IChartDataSet? { - for dataSet in _dataSets - { - if dataSet.axisDependency == .right - { - return dataSet - } - } - - return nil + return dataSets.first { $0.axisDependency == .right } } - /// - returns: All colors used across all DataSet objects this object represents. + /// - Returns: All colors used across all DataSet objects this object represents. @objc open func getColors() -> [NSUIColor]? { - var clrcnt = 0 - - for i in 0 ..< _dataSets.count - { - clrcnt += _dataSets[i].colors.count - } - - var colors = [NSUIColor]() - - for i in 0 ..< _dataSets.count - { - let clrs = _dataSets[i].colors - - for clr in clrs - { - colors.append(clr) - } - } - - return colors + // TODO: Don't return nil + return _dataSets.flatMap { $0.colors } } /// Sets a custom IValueFormatter for all DataSets this data object contains. - @objc open func setValueFormatter(_ formatter: IValueFormatter?) + @objc open func setValueFormatter(_ formatter: IValueFormatter) { - guard let formatter = formatter - else { return } - - for set in dataSets - { - set.valueFormatter = formatter - } + dataSets.forEach { $0.valueFormatter = formatter } } /// Sets the color of the value-text (color in which the value-labels are drawn) for all DataSets this data object contains. - @objc open func setValueTextColor(_ color: NSUIColor!) + @objc open func setValueTextColor(_ color: NSUIColor) { - for set in dataSets - { - set.valueTextColor = color ?? set.valueTextColor - } + dataSets.forEach { $0.valueTextColor = color } } /// Sets the font for all value-labels for all DataSets this data object contains. - @objc open func setValueFont(_ font: NSUIFont!) + @objc open func setValueFont(_ font: NSUIFont) { - for set in dataSets - { - set.valueFont = font ?? set.valueFont - } + dataSets.forEach { $0.valueFont = font } } - + /// Enables / disables drawing values (value-text) for all DataSets this data object contains. @objc open func setDrawValues(_ enabled: Bool) { - for set in dataSets - { - set.drawValuesEnabled = enabled - } + dataSets.forEach { $0.drawValuesEnabled = enabled } } /// Enables / disables highlighting values for all DataSets this data object contains. /// If set to true, this means that values can be highlighted programmatically or by touch gesture. @objc open var highlightEnabled: Bool { - get - { - for set in dataSets - { - if !set.highlightEnabled - { - return false - } - } - - return true - } - set - { - for set in dataSets - { - set.highlightEnabled = newValue - } - } + get { return dataSets.allSatisfy { $0.highlightEnabled } } + set { dataSets.forEach { $0.highlightEnabled = newValue } } } /// if true, value highlightning is enabled @@ -709,52 +575,23 @@ open class ChartData: NSObject } /// Checks if this data object contains the specified DataSet. - /// - returns: `true` if so, `false` ifnot. + /// + /// - Returns: `true` if so, `false` ifnot. @objc open func contains(dataSet: IChartDataSet) -> Bool { - for set in dataSets - { - if set === dataSet - { - return true - } - } - - return false + return dataSets.contains { $0 === dataSet } } - /// - returns: The total entry count across all DataSet objects this data object contains. + /// The total entry count across all DataSet objects this data object contains. @objc open var entryCount: Int { - var count = 0 - - for set in _dataSets - { - count += set.entryCount - } - - return count + return _dataSets.reduce(0) { $0 + $1.entryCount } } - /// - returns: The DataSet object with the maximum number of entries or null if there are no DataSets. + /// The DataSet object with the maximum number of entries or null if there are no DataSets. @objc open var maxEntryCountSet: IChartDataSet? { - if _dataSets.count == 0 - { - return nil - } - - var max = _dataSets[0] - - for set in _dataSets - { - if set.entryCount > max.entryCount - { - max = set - } - } - - return max + return dataSets.max { $0.entryCount < $1.entryCount } } // MARK: - Accessibility diff --git a/Source/Charts/Data/Implementations/Standard/ChartDataEntry.swift b/Source/Charts/Data/Implementations/Standard/ChartDataEntry.swift index 9021c56670..3f29f964fc 100644 --- a/Source/Charts/Data/Implementations/Standard/ChartDataEntry.swift +++ b/Source/Charts/Data/Implementations/Standard/ChartDataEntry.swift @@ -11,10 +11,10 @@ import Foundation -open class ChartDataEntry: ChartDataEntryBase +open class ChartDataEntry: ChartDataEntryBase, NSCopying { /// the x value - @objc open var x = Double(0.0) + @objc open var x = 0.0 public required init() { @@ -22,52 +22,55 @@ open class ChartDataEntry: ChartDataEntryBase } /// An Entry represents one single entry in the chart. - /// - parameter x: the x value - /// - parameter y: the y value (the actual value of the entry) + /// + /// - Parameters: + /// - x: the x value + /// - y: the y value (the actual value of the entry) @objc public init(x: Double, y: Double) { super.init(y: y) - self.x = x } /// An Entry represents one single entry in the chart. - /// - parameter x: the x value - /// - parameter y: the y value (the actual value of the entry) - /// - parameter data: Space for additional data this Entry represents. + /// + /// - Parameters: + /// - x: the x value + /// - y: the y value (the actual value of the entry) + /// - data: Space for additional data this Entry represents. - @objc public init(x: Double, y: Double, data: AnyObject?) + @objc public convenience init(x: Double, y: Double, data: Any?) { - super.init(y: y) - - self.x = x - + self.init(x: x, y: y) self.data = data } /// An Entry represents one single entry in the chart. - /// - parameter x: the x value - /// - parameter y: the y value (the actual value of the entry) - /// - parameter icon: icon image + /// + /// - Parameters: + /// - x: the x value + /// - y: the y value (the actual value of the entry) + /// - icon: icon image - @objc public init(x: Double, y: Double, icon: NSUIImage?) + @objc public convenience init(x: Double, y: Double, icon: NSUIImage?) { - super.init(y: y, icon: icon) - - self.x = x + self.init(x: x, y: y) + self.icon = icon } /// An Entry represents one single entry in the chart. - /// - parameter x: the x value - /// - parameter y: the y value (the actual value of the entry) - /// - parameter icon: icon image - /// - parameter data: Space for additional data this Entry represents. + /// + /// - Parameters: + /// - x: the x value + /// - y: the y value (the actual value of the entry) + /// - icon: icon image + /// - data: Space for additional data this Entry represents. - @objc public init(x: Double, y: Double, icon: NSUIImage?, data: AnyObject?) + @objc public convenience init(x: Double, y: Double, icon: NSUIImage?, data: Any?) { - super.init(y: y, icon: icon, data: data) - - self.x = x + self.init(x: x, y: y) + self.icon = icon + self.data = data } // MARK: NSObject @@ -79,7 +82,7 @@ open class ChartDataEntry: ChartDataEntryBase // MARK: NSCopying - @objc open func copyWithZone(_ zone: NSZone?) -> AnyObject + open func copy(with zone: NSZone? = nil) -> Any { let copy = type(of: self).init() @@ -101,8 +104,7 @@ extension ChartDataEntry/*: Equatable*/ { return true } - return ((data == nil && object.data == nil) || (data?.isEqual(object.data) ?? false)) - && y == object.y + return y == object.y && x == object.x } } diff --git a/Source/Charts/Data/Implementations/Standard/ChartDataEntryBase.swift b/Source/Charts/Data/Implementations/Standard/ChartDataEntryBase.swift index 0dcb1c71c6..2c9d0d5744 100644 --- a/Source/Charts/Data/Implementations/Standard/ChartDataEntryBase.swift +++ b/Source/Charts/Data/Implementations/Standard/ChartDataEntryBase.swift @@ -14,10 +14,10 @@ import Foundation open class ChartDataEntryBase: NSObject { /// the y value - @objc open var y = Double(0.0) + @objc open var y = 0.0 /// optional spot for additional data this Entry represents - @objc open var data: AnyObject? + @objc open var data: Any? /// optional icon image @objc open var icon: NSUIImage? @@ -28,7 +28,9 @@ open class ChartDataEntryBase: NSObject } /// An Entry represents one single entry in the chart. - /// - parameter y: the y value (the actual value of the entry) + /// + /// - Parameters: + /// - y: the y value (the actual value of the entry) @objc public init(y: Double) { super.init() @@ -36,37 +38,37 @@ open class ChartDataEntryBase: NSObject self.y = y } - /// - parameter y: the y value (the actual value of the entry) - /// - parameter data: Space for additional data this Entry represents. + /// - Parameters: + /// - y: the y value (the actual value of the entry) + /// - data: Space for additional data this Entry represents. - @objc public init(y: Double, data: AnyObject?) + @objc public convenience init(y: Double, data: Any?) { - super.init() + self.init(y: y) - self.y = y self.data = data } - /// - parameter y: the y value (the actual value of the entry) - /// - parameter icon: icon image + /// - Parameters: + /// - y: the y value (the actual value of the entry) + /// - icon: icon image - @objc public init(y: Double, icon: NSUIImage?) + @objc public convenience init(y: Double, icon: NSUIImage?) { - super.init() - - self.y = y + self.init(y: y) + self.icon = icon } - /// - parameter y: the y value (the actual value of the entry) - /// - parameter icon: icon image - /// - parameter data: Space for additional data this Entry represents. + /// - Parameters: + /// - y: the y value (the actual value of the entry) + /// - icon: icon image + /// - data: Space for additional data this Entry represents. - @objc public init(y: Double, icon: NSUIImage?, data: AnyObject?) + @objc public convenience init(y: Double, icon: NSUIImage?, data: Any?) { - super.init() - - self.y = y + self.init(y: y) + self.icon = icon self.data = data } @@ -89,7 +91,6 @@ extension ChartDataEntryBase/*: Equatable*/ { return true } - return ((data == nil && object.data == nil) || (data?.isEqual(object.data) ?? false)) - && y == object.y + return y == object.y } } diff --git a/Source/Charts/Data/Implementations/Standard/ChartDataSet.swift b/Source/Charts/Data/Implementations/Standard/ChartDataSet.swift index 8d1736bb97..9922878da8 100644 --- a/Source/Charts/Data/Implementations/Standard/ChartDataSet.swift +++ b/Source/Charts/Data/Implementations/Standard/ChartDataSet.swift @@ -26,51 +26,52 @@ open class ChartDataSet: ChartBaseDataSet { public required init() { - values = [] + entries = [] super.init() } - public override init(label: String?) + public override convenience init(label: String?) { - values = [] - - super.init(label: label) + self.init(entries: nil, label: label) } - @objc public init(values: [ChartDataEntry]?, label: String?) + @objc public init(entries: [ChartDataEntry]?, label: String?) { - self.values = values ?? [] + self.entries = entries ?? [] super.init(label: label) self.calcMinMax() } - @objc public convenience init(values: [ChartDataEntry]?) + @objc public convenience init(entries: [ChartDataEntry]?) { - self.init(values: values, label: "DataSet") + self.init(entries: entries, label: "DataSet") } // MARK: - Data functions and accessors - /// * - /// - note: Calls `notifyDataSetChanged()` after setting a new value. - /// - returns: The array of y-values that this DataSet represents. + /// - Note: Calls `notifyDataSetChanged()` after setting a new value. + /// - Returns: The array of y-values that this DataSet represents. /// the entries that this dataset represents / holds together - @objc open var values: [ChartDataEntry] - { - didSet - { - if isIndirectValuesCall { - isIndirectValuesCall = false - return - } - notifyDataSetChanged() - } + @available(*, unavailable, renamed: "entries") + @objc + open var values: [ChartDataEntry] { return entries } + + @objc + open private(set) var entries: [ChartDataEntry] + + /// Used to replace all entries of a data set while retaining styling properties. + /// This is a separate method from a setter on `entries` to encourage usage + /// of `Collection` conformances. + /// + /// - Parameter entries: new entries to replace existing entries in the dataset + @objc + public func replaceEntries(_ entries: [ChartDataEntry]) { + self.entries = entries + notifyDataSetChanged() } - // TODO: Temporary fix for performance. Will be removed in 4.0 - private var isIndirectValuesCall = false /// maximum y-value in the value array internal var _yMax: Double = -Double.greatestFiniteMagnitude @@ -91,9 +92,9 @@ open class ChartDataSet: ChartBaseDataSet _xMax = -Double.greatestFiniteMagnitude _xMin = Double.greatestFiniteMagnitude - guard !values.isEmpty else { return } + guard !isEmpty else { return } - values.forEach { calcMinMax(entry: $0) } + forEach(calcMinMax) } open override func calcMinMaxY(fromX: Double, toX: Double) @@ -101,17 +102,14 @@ open class ChartDataSet: ChartBaseDataSet _yMax = -Double.greatestFiniteMagnitude _yMin = Double.greatestFiniteMagnitude - guard !values.isEmpty else { return } + guard !isEmpty else { return } let indexFrom = entryIndex(x: fromX, closestToY: Double.nan, rounding: .down) let indexTo = entryIndex(x: toX, closestToY: Double.nan, rounding: .up) guard !(indexTo < indexFrom) else { return } - - (indexFrom...indexTo).forEach { - // only recalculate y - calcMinMaxY(entry: values[$0]) - } + // only recalculate y + self[indexFrom...indexTo].forEach(calcMinMaxY) } @objc open func calcMinMaxX(entry e: ChartDataEntry) @@ -140,45 +138,49 @@ open class ChartDataSet: ChartBaseDataSet /// Updates the min and max x and y value of this DataSet based on the given Entry. /// - /// - parameter e: + /// - Parameters: + /// - e: internal func calcMinMax(entry e: ChartDataEntry) { calcMinMaxX(entry: e) calcMinMaxY(entry: e) } - /// - returns: The minimum y-value this DataSet holds + /// The minimum y-value this DataSet holds open override var yMin: Double { return _yMin } - /// - returns: The maximum y-value this DataSet holds + /// The maximum y-value this DataSet holds open override var yMax: Double { return _yMax } - /// - returns: The minimum x-value this DataSet holds + /// The minimum x-value this DataSet holds open override var xMin: Double { return _xMin } - /// - returns: The maximum x-value this DataSet holds + /// The maximum x-value this DataSet holds open override var xMax: Double { return _xMax } - /// - returns: The number of y-values this DataSet represents - open override var entryCount: Int { return values.count } + /// The number of y-values this DataSet represents + @available(*, deprecated, message: "Use `count` instead") + open override var entryCount: Int { return count } - /// - returns: The entry object found at the given index (not x-value!) - /// - throws: out of bounds + /// - Throws: out of bounds /// if `i` is out of bounds, it may throw an out-of-bounds exception + /// - Returns: The entry object found at the given index (not x-value!) + @available(*, deprecated, message: "Use `subscript(index:)` instead.") open override func entryForIndex(_ i: Int) -> ChartDataEntry? { - guard i >= values.startIndex, i < values.endIndex else { + guard i >= startIndex, i < endIndex else { return nil } - return values[i] + return self[i] } - /// - returns: The first Entry object found at the given x-value with binary search. + /// - Parameters: + /// - xValue: the x-value + /// - closestToY: If there are multiple y-values for the specified x-value, + /// - rounding: determine whether to round up/down/closest if there is no Entry matching the provided x-value + /// - Returns: The first Entry object found at the given x-value with binary search. /// If the no Entry at the specified x-value is found, this method returns the Entry at the closest x-value according to the rounding. /// nil if no Entry object at that x-value. - /// - parameter xValue: the x-value - /// - parameter closestToY: If there are multiple y-values for the specified x-value, - /// - parameter rounding: determine whether to round up/down/closest if there is no Entry matching the provided x-value open override func entryForXValue( _ xValue: Double, closestToY yValue: Double, @@ -187,16 +189,17 @@ open class ChartDataSet: ChartBaseDataSet let index = entryIndex(x: xValue, closestToY: yValue, rounding: rounding) if index > -1 { - return values[index] + return self[index] } return nil } - /// - returns: The first Entry object found at the given x-value with binary search. + /// - Parameters: + /// - xValue: the x-value + /// - closestToY: If there are multiple y-values for the specified x-value, + /// - Returns: The first Entry object found at the given x-value with binary search. /// If the no Entry at the specified x-value is found, this method returns the Entry at the closest x-value. /// nil if no Entry object at that x-value. - /// - parameter xValue: the x-value - /// - parameter closestToY: If there are multiple y-values for the specified x-value, open override func entryForXValue( _ xValue: Double, closestToY yValue: Double) -> ChartDataEntry? @@ -204,34 +207,34 @@ open class ChartDataSet: ChartBaseDataSet return entryForXValue(xValue, closestToY: yValue, rounding: .closest) } - /// - returns: All Entry objects found at the given xIndex with binary search. + /// - Returns: All Entry objects found at the given xIndex with binary search. /// An empty array if no Entry object at that index. open override func entriesForXValue(_ xValue: Double) -> [ChartDataEntry] { var entries = [ChartDataEntry]() - var low = values.startIndex - var high = values.endIndex - 1 + var low = startIndex + var high = endIndex - 1 while low <= high { var m = (high + low) / 2 - var entry = values[m] + var entry = self[m] // if we have a match if xValue == entry.x { - while m > 0 && values[m - 1].x == xValue + while m > 0 && self[m - 1].x == xValue { m -= 1 } - high = values.endIndex + high = endIndex // loop over all "equal" entries while m < high { - entry = values[m] + entry = self[m] if entry.x == xValue { entries.append(entry) @@ -262,27 +265,27 @@ open class ChartDataSet: ChartBaseDataSet return entries } - /// - returns: The array-index of the specified entry. + /// - Parameters: + /// - xValue: x-value of the entry to search for + /// - closestToY: If there are multiple y-values for the specified x-value, + /// - rounding: Rounding method if exact value was not found + /// - Returns: The array-index of the specified entry. /// If the no Entry at the specified x-value is found, this method returns the index of the Entry at the closest x-value according to the rounding. - /// - /// - parameter xValue: x-value of the entry to search for - /// - parameter closestToY: If there are multiple y-values for the specified x-value, - /// - parameter rounding: Rounding method if exact value was not found open override func entryIndex( x xValue: Double, closestToY yValue: Double, rounding: ChartDataSetRounding) -> Int { - var low = values.startIndex - var high = values.endIndex - 1 + var low = startIndex + var high = endIndex - 1 var closest = high while low < high { let m = (low + high) / 2 - let d1 = values[m].x - xValue - let d2 = values[m + 1].x - xValue + let d1 = self[m].x - xValue + let d2 = self[m + 1].x - xValue let ad1 = abs(d1), ad2 = abs(d2) if ad2 < ad1 @@ -318,12 +321,12 @@ open class ChartDataSet: ChartBaseDataSet if closest != -1 { - let closestXValue = values[closest].x + let closestXValue = self[closest].x if rounding == .up { // If rounding up, and found x-value is lower than specified x, and we can go upper... - if closestXValue < xValue && closest < values.endIndex - 1 + if closestXValue < xValue && closest < endIndex - 1 { closest += 1 } @@ -340,20 +343,20 @@ open class ChartDataSet: ChartBaseDataSet // Search by closest to y-value if !yValue.isNaN { - while closest > 0 && values[closest - 1].x == closestXValue + while closest > 0 && self[closest - 1].x == closestXValue { closest -= 1 } - var closestYValue = values[closest].y + var closestYValue = self[closest].y var closestYIndex = closest while true { closest += 1 - if closest >= values.endIndex { break } + if closest >= endIndex { break } - let value = values[closest] + let value = self[closest] if value.x != closestXValue { break } if abs(value.y - yValue) <= abs(closestYValue - yValue) @@ -370,139 +373,202 @@ open class ChartDataSet: ChartBaseDataSet return closest } - /// - returns: The array-index of the specified entry - /// - /// - parameter e: the entry to search for + /// - Parameters: + /// - e: the entry to search for + /// - Returns: The array-index of the specified entry + @available(*, deprecated, message: "Use `firstIndex(of:)` or `lastIndex(of:)`") open override func entryIndex(entry e: ChartDataEntry) -> Int { - for i in 0 ..< values.count - { - if values[i] === e - { - return i - } - } - - return -1 + return firstIndex(of: e) ?? -1 } /// Adds an Entry to the DataSet dynamically. /// Entries are added to the end of the list. /// This will also recalculate the current minimum and maximum values of the DataSet and the value-sum. - /// - parameter e: the entry to add - /// - returns: True + /// + /// - Parameters: + /// - e: the entry to add + /// - Returns: True + @available(*, deprecated, message: "Use `append(_:)` instead") open override func addEntry(_ e: ChartDataEntry) -> Bool { - calcMinMax(entry: e) - - isIndirectValuesCall = true - values.append(e) - + append(e) return true } /// Adds an Entry to the DataSet dynamically. /// Entries are added to their appropriate index respective to it's x-index. /// This will also recalculate the current minimum and maximum values of the DataSet and the value-sum. - /// - parameter e: the entry to add - /// - returns: True + /// + /// - Parameters: + /// - e: the entry to add + /// - Returns: True open override func addEntryOrdered(_ e: ChartDataEntry) -> Bool { calcMinMax(entry: e) - isIndirectValuesCall = true - if values.count > 0 && values.last!.x > e.x + if let last = last, last.x > e.x { var closestIndex = entryIndex(x: e.x, closestToY: e.y, rounding: .up) - while values[closestIndex].x < e.x + while self[closestIndex].x < e.x { closestIndex += 1 } - values.insert(e, at: closestIndex) + entries.insert(e, at: closestIndex) } else { - values.append(e) + append(e) } return true } - /// Removes an Entry from the DataSet dynamically. - /// This will also recalculate the current minimum and maximum values of the DataSet and the value-sum. - /// - parameter entry: the entry to remove - /// - returns: `true` if the entry was removed successfully, else if the entry does not exist + @available(*, renamed: "remove(_:)") open override func removeEntry(_ entry: ChartDataEntry) -> Bool { - var removed = false - isIndirectValuesCall = true - - for i in 0 ..< values.count - { - if values[i] === entry - { - values.remove(at: i) - removed = true - break - } - } - - notifyDataSetChanged() + return remove(entry) + } - return removed + /// Removes an Entry from the DataSet dynamically. + /// This will also recalculate the current minimum and maximum values of the DataSet and the value-sum. + /// + /// - Parameters: + /// - entry: the entry to remove + /// - Returns: `true` if the entry was removed successfully, else if the entry does not exist + open func remove(_ entry: ChartDataEntry) -> Bool + { + guard let index = firstIndex(of: entry) else { return false } + _ = remove(at: index) + return true } - + /// Removes the first Entry (at index 0) of this DataSet from the entries array. /// - /// - returns: `true` if successful, `false` if not. + /// - Returns: `true` if successful, `false` if not. + @available(*, deprecated, message: "Use `func removeFirst() -> ChartDataEntry` instead.") open override func removeFirst() -> Bool { - let entry: ChartDataEntry? = values.isEmpty ? nil : values.removeFirst() + let entry: ChartDataEntry? = isEmpty ? nil : removeFirst() return entry != nil } /// Removes the last Entry (at index size-1) of this DataSet from the entries array. /// - /// - returns: `true` if successful, `false` if not. + /// - Returns: `true` if successful, `false` if not. + @available(*, deprecated, message: "Use `func removeLast() -> ChartDataEntry` instead.") open override func removeLast() -> Bool { - let entry: ChartDataEntry? = values.isEmpty ? nil : values.removeLast() + let entry: ChartDataEntry? = isEmpty ? nil : removeLast() return entry != nil } - - /// Checks if this DataSet contains the specified Entry. - /// - returns: `true` if contains the entry, `false` if not. - open override func contains(_ e: ChartDataEntry) -> Bool - { - for entry in values - { - if entry == e - { - return true - } - } - - return false - } - + /// Removes all values from this DataSet and recalculates min and max value. + @available(*, deprecated, message: "Use `removeAll(keepingCapacity:)` instead.") open override func clear() { - values.removeAll(keepingCapacity: true) + removeAll(keepingCapacity: true) } // MARK: - Data functions and accessors // MARK: - NSCopying - open override func copyWithZone(_ zone: NSZone?) -> AnyObject + open override func copy(with zone: NSZone? = nil) -> Any { - let copy = super.copyWithZone(zone) as! ChartDataSet + let copy = super.copy(with: zone) as! ChartDataSet - copy.values = values + copy.entries = entries copy._yMax = _yMax copy._yMin = _yMin + copy._xMax = _xMax + copy._xMin = _xMin return copy } } + +// MARK: MutableCollection +extension ChartDataSet: MutableCollection { + public typealias Index = Int + public typealias Element = ChartDataEntry + + public var startIndex: Index { + return entries.startIndex + } + + public var endIndex: Index { + return entries.endIndex + } + + public func index(after: Index) -> Index { + return entries.index(after: after) + } + + @objc + public subscript(position: Index) -> Element { + get { + // This is intentionally not a safe subscript to mirror + // the behaviour of the built in Swift Collection Types + return entries[position] + } + set { + calcMinMax(entry: newValue) + entries[position] = newValue + } + } +} + +// MARK: RandomAccessCollection +extension ChartDataSet: RandomAccessCollection { + public func index(before: Index) -> Index { + return entries.index(before: before) + } +} + +// MARK: RangeReplaceableCollection +extension ChartDataSet: RangeReplaceableCollection { + public func append(_ newElement: Element) { + calcMinMax(entry: newElement) + entries.append(newElement) + } + + public func remove(at position: Index) -> Element { + let element = entries.remove(at: position) + notifyDataSetChanged() + return element + } + + public func removeFirst() -> Element { + let element = entries.removeFirst() + notifyDataSetChanged() + return element + } + + public func removeFirst(_ n: Int) { + entries.removeFirst(n) + notifyDataSetChanged() + } + + public func removeLast() -> Element { + let element = entries.removeLast() + notifyDataSetChanged() + return element + } + + public func removeLast(_ n: Int) { + entries.removeLast(n) + notifyDataSetChanged() + } + + public func removeSubrange(_ bounds: R) where R : RangeExpression, Index == R.Bound { + entries.removeSubrange(bounds) + notifyDataSetChanged() + } + + @objc + public func removeAll(keepingCapacity keepCapacity: Bool) { + entries.removeAll(keepingCapacity: keepCapacity) + notifyDataSetChanged() + } +} diff --git a/Source/Charts/Data/Implementations/Standard/CombinedChartData.swift b/Source/Charts/Data/Implementations/Standard/CombinedChartData.swift index 8d269edf66..e883c8b7f3 100644 --- a/Source/Charts/Data/Implementations/Standard/CombinedChartData.swift +++ b/Source/Charts/Data/Implementations/Standard/CombinedChartData.swift @@ -165,7 +165,7 @@ open class CombinedChartData: BarLineScatterCandleBubbleChartData } } - /// - returns: All data objects in row: line-bar-scatter-candle-bubble if not null. + /// All data objects in row: line-bar-scatter-candle-bubble if not null. @objc open var allData: [ChartData] { var data = [ChartData]() @@ -201,26 +201,12 @@ open class CombinedChartData: BarLineScatterCandleBubbleChartData open func dataIndex(_ data: ChartData) -> Int? { - return allData.index(of: data) + return allData.firstIndex(of: data) } - open override func removeDataSet(_ dataSet: IChartDataSet!) -> Bool + open override func removeDataSet(_ dataSet: IChartDataSet) -> Bool { - let datas = allData - - var success = false - - for data in datas - { - success = data.removeDataSet(dataSet) - - if success - { - break - } - } - - return success + return allData.contains { $0.removeDataSet(dataSet) } } open override func removeDataSetByIndex(_ index: Int) -> Bool @@ -269,8 +255,9 @@ open class CombinedChartData: BarLineScatterCandleBubbleChartData /// Get the Entry for a corresponding highlight object /// - /// - parameter highlight: - /// - returns: The entry that is highlighted + /// - Parameters: + /// - highlight: + /// - Returns: The entry that is highlighted open override func entryForHighlight(_ highlight: Highlight) -> ChartDataEntry? { if highlight.dataIndex >= allData.count @@ -287,19 +274,13 @@ open class CombinedChartData: BarLineScatterCandleBubbleChartData // The value of the highlighted entry could be NaN - if we are not interested in highlighting a specific value. let entries = data.getDataSetByIndex(highlight.dataSetIndex).entriesForXValue(highlight.x) - for e in entries - { - if e.y == highlight.y || highlight.y.isNaN - { - return e - } - } - return nil + return entries.first { $0.y == highlight.y || highlight.y.isNaN } } /// Get dataset for highlight /// - /// - Parameter highlight: current highlight + /// - Parameters: + /// - highlight: current highlight /// - Returns: dataset related to highlight @objc open func getDataSetByHighlight(_ highlight: Highlight) -> IChartDataSet! { diff --git a/Source/Charts/Data/Implementations/Standard/LineChartDataSet.swift b/Source/Charts/Data/Implementations/Standard/LineChartDataSet.swift index d8c29c0acd..b53ddd4d05 100644 --- a/Source/Charts/Data/Implementations/Standard/LineChartDataSet.swift +++ b/Source/Charts/Data/Implementations/Standard/LineChartDataSet.swift @@ -36,9 +36,9 @@ open class LineChartDataSet: LineRadarChartDataSet, ILineChartDataSet initialize() } - public override init(values: [ChartDataEntry]?, label: String?) + public override init(entries: [ChartDataEntry]?, label: String?) { - super.init(values: values, label: label) + super.init(entries: entries, label: label) initialize() } @@ -76,7 +76,7 @@ open class LineChartDataSet: LineRadarChartDataSet, ILineChartDataSet open var circleColors = [NSUIColor]() - /// - returns: The color at the given index of the DataSet's circle-color array. + /// - Returns: The color at the given index of the DataSet's circle-color array. /// Performs a IndexOutOfBounds check by modulus. open func getCircleColor(atIndex index: Int) -> NSUIColor? { @@ -112,7 +112,7 @@ open class LineChartDataSet: LineRadarChartDataSet, ILineChartDataSet /// If true, drawing circles is enabled open var drawCirclesEnabled = true - /// - returns: `true` if drawing circles for this DataSet is enabled, `false` ifnot + /// `true` if drawing circles for this DataSet is enabled, `false` ifnot open var isDrawCirclesEnabled: Bool { return drawCirclesEnabled } /// The color of the inner circle (the circle-hole). @@ -121,7 +121,7 @@ open class LineChartDataSet: LineRadarChartDataSet, ILineChartDataSet /// `true` if drawing circles for this DataSet is enabled, `false` ifnot open var drawCircleHoleEnabled = true - /// - returns: `true` if drawing the circle-holes is enabled, `false` ifnot. + /// `true` if drawing the circle-holes is enabled, `false` ifnot. open var isDrawCircleHoleEnabled: Bool { return drawCircleHoleEnabled } /// This is how much (in pixels) into the dash pattern are we starting from. @@ -153,11 +153,13 @@ open class LineChartDataSet: LineRadarChartDataSet, ILineChartDataSet // MARK: NSCopying - open override func copyWithZone(_ zone: NSZone?) -> AnyObject + open override func copy(with zone: NSZone? = nil) -> Any { - let copy = super.copyWithZone(zone) as! LineChartDataSet + let copy = super.copy(with: zone) as! LineChartDataSet copy.circleColors = circleColors + copy.circleHoleColor = circleHoleColor copy.circleRadius = circleRadius + copy.circleHoleRadius = circleHoleRadius copy.cubicIntensity = cubicIntensity copy.lineDashPhase = lineDashPhase copy.lineDashLengths = lineDashLengths @@ -165,6 +167,7 @@ open class LineChartDataSet: LineRadarChartDataSet, ILineChartDataSet copy.drawCirclesEnabled = drawCirclesEnabled copy.drawCircleHoleEnabled = drawCircleHoleEnabled copy.mode = mode + copy._fillFormatter = _fillFormatter return copy } } diff --git a/Source/Charts/Data/Implementations/Standard/LineRadarChartDataSet.swift b/Source/Charts/Data/Implementations/Standard/LineRadarChartDataSet.swift index 5f1770a0b7..54a3af6929 100644 --- a/Source/Charts/Data/Implementations/Standard/LineRadarChartDataSet.swift +++ b/Source/Charts/Data/Implementations/Standard/LineRadarChartDataSet.swift @@ -63,7 +63,7 @@ open class LineRadarChartDataSet: LineScatterCandleRadarChartDataSet, ILineRadar /// Please note that this method uses the path clipping for drawing the filled area (with images, gradients and layers). open var drawFilledEnabled = false - /// - returns: `true` if filled drawing is enabled, `false` ifnot + /// `true` if filled drawing is enabled, `false` ifnot open var isDrawFilledEnabled: Bool { return drawFilledEnabled @@ -71,10 +71,12 @@ open class LineRadarChartDataSet: LineScatterCandleRadarChartDataSet, ILineRadar // MARK: NSCopying - open override func copyWithZone(_ zone: NSZone?) -> AnyObject + open override func copy(with zone: NSZone? = nil) -> Any { - let copy = super.copyWithZone(zone) as! LineRadarChartDataSet - copy.fillColor = fillColor + let copy = super.copy(with: zone) as! LineRadarChartDataSet + copy.fill = fill + copy.fillAlpha = fillAlpha + copy._fillColor = _fillColor copy._lineWidth = _lineWidth copy.drawFilledEnabled = drawFilledEnabled return copy diff --git a/Source/Charts/Data/Implementations/Standard/LineScatterCandleRadarChartDataSet.swift b/Source/Charts/Data/Implementations/Standard/LineScatterCandleRadarChartDataSet.swift index b21868ab08..1c68983bbc 100644 --- a/Source/Charts/Data/Implementations/Standard/LineScatterCandleRadarChartDataSet.swift +++ b/Source/Charts/Data/Implementations/Standard/LineScatterCandleRadarChartDataSet.swift @@ -24,10 +24,10 @@ open class LineScatterCandleRadarChartDataSet: BarLineScatterCandleBubbleChartDa /// Enables / disables the vertical highlight-indicator. If disabled, the indicator is not drawn. open var drawVerticalHighlightIndicatorEnabled = true - /// - returns: `true` if horizontal highlight indicator lines are enabled (drawn) + /// `true` if horizontal highlight indicator lines are enabled (drawn) open var isHorizontalHighlightIndicatorEnabled: Bool { return drawHorizontalHighlightIndicatorEnabled } - /// - returns: `true` if vertical highlight indicator lines are enabled (drawn) + /// `true` if vertical highlight indicator lines are enabled (drawn) open var isVerticalHighlightIndicatorEnabled: Bool { return drawVerticalHighlightIndicatorEnabled } /// Enables / disables both vertical and horizontal highlight-indicators. @@ -40,9 +40,9 @@ open class LineScatterCandleRadarChartDataSet: BarLineScatterCandleBubbleChartDa // MARK: NSCopying - open override func copyWithZone(_ zone: NSZone?) -> AnyObject + open override func copy(with zone: NSZone? = nil) -> Any { - let copy = super.copyWithZone(zone) as! LineScatterCandleRadarChartDataSet + let copy = super.copy(with: zone) as! LineScatterCandleRadarChartDataSet copy.drawHorizontalHighlightIndicatorEnabled = drawHorizontalHighlightIndicatorEnabled copy.drawVerticalHighlightIndicatorEnabled = drawVerticalHighlightIndicatorEnabled return copy diff --git a/Source/Charts/Data/Implementations/Standard/PieChartData.swift b/Source/Charts/Data/Implementations/Standard/PieChartData.swift index b8476492b9..7f34383517 100644 --- a/Source/Charts/Data/Implementations/Standard/PieChartData.swift +++ b/Source/Charts/Data/Implementations/Standard/PieChartData.swift @@ -23,7 +23,7 @@ open class PieChartData: ChartData super.init(dataSets: dataSets) } - /// - returns: All DataSet objects this ChartData object holds. + /// All DataSet objects this ChartData object holds. @objc open override var dataSets: [IChartDataSet] { get @@ -102,7 +102,7 @@ open class PieChartData: ChartData /// Removes the DataSet at the given index in the DataSet array from the data object. /// Also recalculates all minimum and maximum values. /// - /// - returns: `true` if a DataSet was removed, `false` ifno DataSet could be removed. + /// - Returns: `true` if a DataSet was removed, `false` ifno DataSet could be removed. open override func removeDataSetByIndex(_ index: Int) -> Bool { if index >= _dataSets.count || index < 0 @@ -113,18 +113,12 @@ open class PieChartData: ChartData return false } - /// - returns: The total y-value sum across all DataSet objects the this object represents. + /// The total y-value sum across all DataSet objects the this object represents. @objc open var yValueSum: Double { guard let dataSet = dataSet else { return 0.0 } - - var yValueSum: Double = 0.0 - - for i in 0.. AnyObject + open override func copy(with zone: NSZone? = nil) -> Any { - let copy = super.copyWithZone(zone) as! PieChartDataEntry + let copy = super.copy(with: zone) as! PieChartDataEntry copy.label = label return copy } diff --git a/Source/Charts/Data/Implementations/Standard/PieChartDataSet.swift b/Source/Charts/Data/Implementations/Standard/PieChartDataSet.swift index 5847796068..ac0e63489a 100644 --- a/Source/Charts/Data/Implementations/Standard/PieChartDataSet.swift +++ b/Source/Charts/Data/Implementations/Standard/PieChartDataSet.swift @@ -33,9 +33,9 @@ open class PieChartDataSet: ChartDataSet, IPieChartDataSet initialize() } - public override init(values: [ChartDataEntry]?, label: String?) + public override init(entries: [ChartDataEntry]?, label: String?) { - super.init(values: values, label: label) + super.init(entries: entries, label: label) initialize() } @@ -84,6 +84,9 @@ open class PieChartDataSet: ChartDataSet, IPieChartDataSet /// When valuePosition is OutsideSlice, indicates line color open var valueLineColor: NSUIColor? = NSUIColor.black + /// When valuePosition is OutsideSlice and enabled, line will have the same color as the slice + open var useValueColorForLine: Bool = false + /// When valuePosition is OutsideSlice, indicates line width open var valueLineWidth: CGFloat = 1.0 @@ -110,11 +113,22 @@ open class PieChartDataSet: ChartDataSet, IPieChartDataSet // MARK: - NSCopying - open override func copyWithZone(_ zone: NSZone?) -> AnyObject + open override func copy(with zone: NSZone? = nil) -> Any { - let copy = super.copyWithZone(zone) as! PieChartDataSet + let copy = super.copy(with: zone) as! PieChartDataSet copy._sliceSpace = _sliceSpace + copy.automaticallyDisableSliceSpacing = automaticallyDisableSliceSpacing copy.selectionShift = selectionShift + copy.xValuePosition = xValuePosition + copy.yValuePosition = yValuePosition + copy.valueLineColor = valueLineColor + copy.valueLineWidth = valueLineWidth + copy.valueLinePart1OffsetPercentage = valueLinePart1OffsetPercentage + copy.valueLinePart1Length = valueLinePart1Length + copy.valueLinePart2Length = valueLinePart2Length + copy.valueLineVariableLength = valueLineVariableLength + copy.entryLabelFont = entryLabelFont + copy.entryLabelColor = entryLabelColor copy.highlightColor = highlightColor return copy } diff --git a/Source/Charts/Data/Implementations/Standard/RadarChartDataEntry.swift b/Source/Charts/Data/Implementations/Standard/RadarChartDataEntry.swift index 4cf7189008..e557ba9205 100644 --- a/Source/Charts/Data/Implementations/Standard/RadarChartDataEntry.swift +++ b/Source/Charts/Data/Implementations/Standard/RadarChartDataEntry.swift @@ -18,18 +18,21 @@ open class RadarChartDataEntry: ChartDataEntry { super.init() } - - /// - parameter value: The value on the y-axis. - /// - parameter data: Spot for additional data this Entry represents. - @objc public init(value: Double, data: AnyObject?) + + /// - Parameters: + /// - value: The value on the y-axis. + @objc public init(value: Double) { - super.init(x: 0.0, y: value, data: data) + super.init(x: .nan, y: value) } - - /// - parameter value: The value on the y-axis. - @objc public convenience init(value: Double) + + /// - Parameters: + /// - value: The value on the y-axis. + /// - data: Spot for additional data this Entry represents. + @objc public convenience init(value: Double, data: Any?) { - self.init(value: value, data: nil) + self.init(value: value) + self.data = data } // MARK: Data property accessors @@ -42,9 +45,9 @@ open class RadarChartDataEntry: ChartDataEntry // MARK: NSCopying - open override func copyWithZone(_ zone: NSZone?) -> AnyObject + open override func copy(with zone: NSZone? = nil) -> Any { - let copy = super.copyWithZone(zone) as! RadarChartDataEntry + let copy = super.copy(with: zone) as! RadarChartDataEntry return copy } diff --git a/Source/Charts/Data/Implementations/Standard/RadarChartDataSet.swift b/Source/Charts/Data/Implementations/Standard/RadarChartDataSet.swift index 67b4730a28..030269d6a2 100644 --- a/Source/Charts/Data/Implementations/Standard/RadarChartDataSet.swift +++ b/Source/Charts/Data/Implementations/Standard/RadarChartDataSet.swift @@ -26,9 +26,9 @@ open class RadarChartDataSet: LineRadarChartDataSet, IRadarChartDataSet initialize() } - public required override init(values: [ChartDataEntry]?, label: String?) + public required override init(entries: [ChartDataEntry]?, label: String?) { - super.init(values: values, label: label) + super.init(entries: entries, label: label) initialize() } @@ -40,7 +40,7 @@ open class RadarChartDataSet: LineRadarChartDataSet, IRadarChartDataSet /// **default**: false open var drawHighlightCircleEnabled: Bool = false - /// - returns: `true` if highlight circle should be drawn, `false` ifnot + /// `true` if highlight circle should be drawn, `false` ifnot open var isDrawHighlightCircleEnabled: Bool { return drawHighlightCircleEnabled } open var highlightCircleFillColor: NSUIColor? = NSUIColor.white diff --git a/Source/Charts/Data/Implementations/Standard/ScatterChartData.swift b/Source/Charts/Data/Implementations/Standard/ScatterChartData.swift index ff8ccaf93e..e06a60325d 100644 --- a/Source/Charts/Data/Implementations/Standard/ScatterChartData.swift +++ b/Source/Charts/Data/Implementations/Standard/ScatterChartData.swift @@ -24,25 +24,11 @@ open class ScatterChartData: BarLineScatterCandleBubbleChartData super.init(dataSets: dataSets) } - /// - returns: The maximum shape-size across all DataSets. + /// - Returns: The maximum shape-size across all DataSets. @objc open func getGreatestShapeSize() -> CGFloat { - var max = CGFloat(0.0) - - for set in _dataSets - { - let scatterDataSet = set as? IScatterChartDataSet - - if scatterDataSet == nil - { - print("ScatterChartData: Found a DataSet which is not a ScatterChartDataSet", terminator: "\n") - } - else if let size = scatterDataSet?.scatterShapeSize, size > max - { - max = size - } - } - - return max + return (_dataSets as? [IScatterChartDataSet])? + .max { $0.scatterShapeSize < $1.scatterShapeSize }? + .scatterShapeSize ?? 0 } } diff --git a/Source/Charts/Data/Implementations/Standard/ScatterChartDataSet.swift b/Source/Charts/Data/Implementations/Standard/ScatterChartDataSet.swift index 8aee713389..bc9767a06c 100644 --- a/Source/Charts/Data/Implementations/Standard/ScatterChartDataSet.swift +++ b/Source/Charts/Data/Implementations/Standard/ScatterChartDataSet.swift @@ -66,9 +66,9 @@ open class ScatterChartDataSet: LineScatterCandleRadarChartDataSet, IScatterChar // MARK: NSCopying - open override func copyWithZone(_ zone: NSZone?) -> AnyObject + open override func copy(with zone: NSZone? = nil) -> Any { - let copy = super.copyWithZone(zone) as! ScatterChartDataSet + let copy = super.copy(with: zone) as! ScatterChartDataSet copy.scatterShapeSize = scatterShapeSize copy.scatterShapeHoleRadius = scatterShapeHoleRadius copy.scatterShapeHoleColor = scatterShapeHoleColor diff --git a/Source/Charts/Data/Interfaces/IBarChartDataSet.swift b/Source/Charts/Data/Interfaces/IBarChartDataSet.swift index 6f5cad081c..b90b4dc0c2 100644 --- a/Source/Charts/Data/Interfaces/IBarChartDataSet.swift +++ b/Source/Charts/Data/Interfaces/IBarChartDataSet.swift @@ -19,10 +19,10 @@ public protocol IBarChartDataSet: IBarLineScatterCandleBubbleChartDataSet // MARK: - Styling functions and accessors - /// - returns: `true` if this DataSet is stacked (stacksize > 1) or not. + /// `true` if this DataSet is stacked (stacksize > 1) or not. var isStacked: Bool { get } - /// - returns: The maximum number of bars that can be stacked upon another in this DataSet. + /// The maximum number of bars that can be stacked upon another in this DataSet. var stackSize: Int { get } /// the color used for drawing the bar-shadows. The bar shadows is a surface behind the bar that indicates the maximum value diff --git a/Source/Charts/Data/Interfaces/IChartDataSet.swift b/Source/Charts/Data/Interfaces/IChartDataSet.swift index 293db393eb..849da103b7 100644 --- a/Source/Charts/Data/Interfaces/IChartDataSet.swift +++ b/Source/Charts/Data/Interfaces/IChartDataSet.swift @@ -27,64 +27,66 @@ public protocol IChartDataSet /// This is only needed for the autoScaleMinMax feature. func calcMinMaxY(fromX: Double, toX: Double) - /// - returns: The minimum y-value this DataSet holds + /// The minimum y-value this DataSet holds var yMin: Double { get } - /// - returns: The maximum y-value this DataSet holds + /// The maximum y-value this DataSet holds var yMax: Double { get } - /// - returns: The minimum x-value this DataSet holds + /// The minimum x-value this DataSet holds var xMin: Double { get } - /// - returns: The maximum x-value this DataSet holds + /// The maximum x-value this DataSet holds var xMax: Double { get } - /// - returns: The number of y-values this DataSet represents + /// The number of y-values this DataSet represents var entryCount: Int { get } - /// - returns: The entry object found at the given index (not x-value!) - /// - throws: out of bounds + /// - Throws: out of bounds /// if `i` is out of bounds, it may throw an out-of-bounds exception + /// - Returns: The entry object found at the given index (not x-value!) func entryForIndex(_ i: Int) -> ChartDataEntry? - /// - returns: The first Entry object found at the given x-value with binary search. + /// - Parameters: + /// - xValue: the x-value + /// - closestToY: If there are multiple y-values for the specified x-value, + /// - rounding: determine whether to round up/down/closest if there is no Entry matching the provided x-value + /// - Returns: The first Entry object found at the given x-value with binary search. /// If the no Entry at the specified x-value is found, this method returns the Entry at the closest x-value according to the rounding. /// nil if no Entry object at that x-value. - /// - parameter xValue: the x-value - /// - parameter closestToY: If there are multiple y-values for the specified x-value, - /// - parameter rounding: determine whether to round up/down/closest if there is no Entry matching the provided x-value func entryForXValue( _ xValue: Double, closestToY yValue: Double, rounding: ChartDataSetRounding) -> ChartDataEntry? - /// - returns: The first Entry object found at the given x-value with binary search. + /// - Parameters: + /// - xValue: the x-value + /// - closestToY: If there are multiple y-values for the specified x-value, + /// - Returns: The first Entry object found at the given x-value with binary search. /// If the no Entry at the specified x-value is found, this method returns the Entry at the closest x-value. /// nil if no Entry object at that x-value. - /// - parameter xValue: the x-value - /// - parameter closestToY: If there are multiple y-values for the specified x-value, func entryForXValue( _ xValue: Double, closestToY yValue: Double) -> ChartDataEntry? - /// - returns: All Entry objects found at the given x-value with binary search. + /// - Returns: All Entry objects found at the given x-value with binary search. /// An empty array if no Entry object at that x-value. func entriesForXValue(_ xValue: Double) -> [ChartDataEntry] - /// - returns: The array-index of the specified entry. + /// - Parameters: + /// - xValue: x-value of the entry to search for + /// - closestToY: If there are multiple y-values for the specified x-value, + /// - rounding: Rounding method if exact value was not found + /// - Returns: The array-index of the specified entry. /// If the no Entry at the specified x-value is found, this method returns the index of the Entry at the closest x-value according to the rounding. - /// - /// - parameter xValue: x-value of the entry to search for - /// - parameter closestToY: If there are multiple y-values for the specified x-value, - /// - parameter rounding: Rounding method if exact value was not found func entryIndex( x xValue: Double, closestToY yValue: Double, rounding: ChartDataSetRounding) -> Int - /// - returns: The array-index of the specified entry - /// - /// - parameter e: the entry to search for + /// - Parameters: + /// - e: the entry to search for + /// - Returns: The array-index of the specified entry func entryIndex(entry e: ChartDataEntry) -> Int /// Adds an Entry to the DataSet dynamically. @@ -92,8 +94,10 @@ public protocol IChartDataSet /// *optional feature, can return `false` ifnot implemented* /// /// Entries are added to the end of the list. - /// - parameter e: the entry to add - /// - returns: `true` if the entry was added successfully, `false` ifthis feature is not supported + /// + /// - Parameters: + /// - e: the entry to add + /// - Returns: `true` if the entry was added successfully, `false` ifthis feature is not supported func addEntry(_ e: ChartDataEntry) -> Bool /// Adds an Entry to the DataSet dynamically. @@ -103,51 +107,56 @@ public protocol IChartDataSet /// *optional feature, can return `false` ifnot implemented* /// /// Entries are added to the end of the list. - /// - parameter e: the entry to add - /// - returns: `true` if the entry was added successfully, `false` ifthis feature is not supported + /// + /// - Parameters: + /// - e: the entry to add + /// - Returns: `true` if the entry was added successfully, `false` ifthis feature is not supported func addEntryOrdered(_ e: ChartDataEntry) -> Bool /// Removes an Entry from the DataSet dynamically. /// /// *optional feature, can return `false` ifnot implemented* /// - /// - parameter entry: the entry to remove - /// - returns: `true` if the entry was removed successfully, `false` ifthe entry does not exist or if this feature is not supported + /// - Parameters: + /// - entry: the entry to remove + /// - Returns: `true` if the entry was removed successfully, `false` ifthe entry does not exist or if this feature is not supported func removeEntry(_ entry: ChartDataEntry) -> Bool /// Removes the Entry object at the given index in the values array from the DataSet. /// /// *optional feature, can return `false` ifnot implemented* /// - /// - parameter index: the index of the entry to remove - /// - returns: `true` if the entry was removed successfully, `false` ifthe entry does not exist or if this feature is not supported + /// - Parameters: + /// - index: the index of the entry to remove + /// - Returns: `true` if the entry was removed successfully, `false` ifthe entry does not exist or if this feature is not supported func removeEntry(index: Int) -> Bool /// Removes the Entry object closest to the given x-value from the DataSet. /// /// *optional feature, can return `false` ifnot implemented* /// - /// - parameter x: the x-value to remove - /// - returns: `true` if the entry was removed successfully, `false` ifthe entry does not exist or if this feature is not supported + /// - Parameters: + /// - x: the x-value to remove + /// - Returns: `true` if the entry was removed successfully, `false` ifthe entry does not exist or if this feature is not supported func removeEntry(x: Double) -> Bool /// Removes the first Entry (at index 0) of this DataSet from the entries array. /// /// *optional feature, can return `false` ifnot implemented* /// - /// - returns: `true` if the entry was removed successfully, `false` ifthe entry does not exist or if this feature is not supported + /// - Returns: `true` if the entry was removed successfully, `false` ifthe entry does not exist or if this feature is not supported func removeFirst() -> Bool /// Removes the last Entry (at index 0) of this DataSet from the entries array. /// /// *optional feature, can return `false` ifnot implemented* /// - /// - returns: `true` if the entry was removed successfully, `false` ifthe entry does not exist or if this feature is not supported + /// - Returns: `true` if the entry was removed successfully, `false` ifthe entry does not exist or if this feature is not supported func removeLast() -> Bool /// Checks if this DataSet contains the specified Entry. /// - /// - returns: `true` if contains the entry, `false` ifnot. + /// - Returns: `true` if contains the entry, `false` ifnot. func contains(_ e: ChartDataEntry) -> Bool /// Removes all values from this DataSet and does all necessary recalculations. @@ -170,7 +179,7 @@ public protocol IChartDataSet /// Colors are reused as soon as the number of Entries the DataSet represents is higher than the size of the colors array. var colors: [NSUIColor] { get } - /// - returns: The color at the given index of the DataSet's color array. + /// - Returns: The color at the given index of the DataSet's color array. /// This prevents out-of-bounds by performing a modulus on the color index, so colours will repeat themselves. func color(atIndex: Int) -> NSUIColor @@ -183,13 +192,13 @@ public protocol IChartDataSet /// if true, value highlighting is enabled var highlightEnabled: Bool { get set } - /// - returns: `true` if value highlighting is enabled for this dataset + /// `true` if value highlighting is enabled for this dataset var isHighlightEnabled: Bool { get } /// Custom formatter that is used instead of the auto-formatter if set var valueFormatter: IValueFormatter? { get set } - /// - returns: `true` if the valueFormatter object of this DataSet is null. + /// `true` if the valueFormatter object of this DataSet is null. var needsFormatter: Bool { get } /// Sets/get a single color for value text. @@ -197,7 +206,7 @@ public protocol IChartDataSet /// Getting will return the first color in the array. var valueTextColor: NSUIColor { get set } - /// - returns: The color at the specified index that is used for drawing the values inside the chart. Uses modulus internally. + /// - Returns: The color at the specified index that is used for drawing the values inside the chart. Uses modulus internally. func valueTextColorAt(_ index: Int) -> NSUIColor /// the font for the value-text labels @@ -232,15 +241,15 @@ public protocol IChartDataSet /// Set this to true to draw y-values on the chart. /// - /// - note: For bar and line charts: if `maxVisibleCount` is reached, no values will be drawn even if this is enabled. + /// - Note: For bar and line charts: if `maxVisibleCount` is reached, no values will be drawn even if this is enabled. var drawValuesEnabled: Bool { get set } - /// - returns: `true` if y-value drawing is enabled, `false` ifnot + /// `true` if y-value drawing is enabled, `false` ifnot var isDrawValuesEnabled: Bool { get } /// Set this to true to draw y-icons on the chart /// - /// - note: For bar and line charts: if `maxVisibleCount` is reached, no icons will be drawn even if this is enabled. + /// - Note: For bar and line charts: if `maxVisibleCount` is reached, no icons will be drawn even if this is enabled. var drawIconsEnabled: Bool { get set } /// Returns true if y-icon drawing is enabled, false if not @@ -256,6 +265,6 @@ public protocol IChartDataSet /// Set the visibility of this DataSet. If not visible, the DataSet will not be drawn to the chart upon refreshing it. var visible: Bool { get set } - /// - returns: `true` if this DataSet is visible inside the chart, or `false` ifit is currently hidden. + /// `true` if this DataSet is visible inside the chart, or `false` ifit is currently hidden. var isVisible: Bool { get } } diff --git a/Source/Charts/Data/Interfaces/ILineChartDataSet.swift b/Source/Charts/Data/Interfaces/ILineChartDataSet.swift index bc9e484907..071f269535 100644 --- a/Source/Charts/Data/Interfaces/ILineChartDataSet.swift +++ b/Source/Charts/Data/Interfaces/ILineChartDataSet.swift @@ -38,7 +38,7 @@ public protocol ILineChartDataSet: ILineRadarChartDataSet var circleColors: [NSUIColor] { get set } - /// - returns: The color at the given index of the DataSet's circle-color array. + /// - Returns: The color at the given index of the DataSet's circle-color array. /// Performs a IndexOutOfBounds check by modulus. func getCircleColor(atIndex: Int) -> NSUIColor? @@ -52,7 +52,7 @@ public protocol ILineChartDataSet: ILineRadarChartDataSet /// If true, drawing circles is enabled var drawCirclesEnabled: Bool { get set } - /// - returns: `true` if drawing circles for this DataSet is enabled, `false` ifnot + /// `true` if drawing circles for this DataSet is enabled, `false` ifnot var isDrawCirclesEnabled: Bool { get } /// The color of the inner circle (the circle-hole). @@ -61,7 +61,7 @@ public protocol ILineChartDataSet: ILineRadarChartDataSet /// `true` if drawing circles for this DataSet is enabled, `false` ifnot var drawCircleHoleEnabled: Bool { get set } - /// - returns: `true` if drawing the circle-holes is enabled, `false` ifnot. + /// `true` if drawing the circle-holes is enabled, `false` ifnot. var isDrawCircleHoleEnabled: Bool { get } /// This is how much (in pixels) into the dash pattern are we starting from. diff --git a/Source/Charts/Data/Interfaces/ILineRadarChartDataSet.swift b/Source/Charts/Data/Interfaces/ILineRadarChartDataSet.swift index b53a5337fa..d9f8980b47 100644 --- a/Source/Charts/Data/Interfaces/ILineRadarChartDataSet.swift +++ b/Source/Charts/Data/Interfaces/ILineRadarChartDataSet.swift @@ -22,7 +22,7 @@ public protocol ILineRadarChartDataSet: ILineScatterCandleRadarChartDataSet /// The color that is used for filling the line surface area. var fillColor: NSUIColor { get set } - /// - returns: The object that is used for filling the area below the line. + /// - Returns: The object that is used for filling the area below the line. /// **default**: nil var fill: Fill? { get set } @@ -40,6 +40,6 @@ public protocol ILineRadarChartDataSet: ILineScatterCandleRadarChartDataSet /// Please note that this method uses the path clipping for drawing the filled area (with images, gradients and layers). var drawFilledEnabled: Bool { get set } - /// - returns: `true` if filled drawing is enabled, `false` if not + /// `true` if filled drawing is enabled, `false` if not var isDrawFilledEnabled: Bool { get } } diff --git a/Source/Charts/Data/Interfaces/ILineScatterCandleRadarChartDataSet.swift b/Source/Charts/Data/Interfaces/ILineScatterCandleRadarChartDataSet.swift index cf646a1b56..27c2bca944 100644 --- a/Source/Charts/Data/Interfaces/ILineScatterCandleRadarChartDataSet.swift +++ b/Source/Charts/Data/Interfaces/ILineScatterCandleRadarChartDataSet.swift @@ -24,10 +24,10 @@ public protocol ILineScatterCandleRadarChartDataSet: IBarLineScatterCandleBubble /// Enables / disables the vertical highlight-indicator. If disabled, the indicator is not drawn. var drawVerticalHighlightIndicatorEnabled: Bool { get set } - /// - returns: `true` if horizontal highlight indicator lines are enabled (drawn) + /// `true` if horizontal highlight indicator lines are enabled (drawn) var isHorizontalHighlightIndicatorEnabled: Bool { get } - /// - returns: `true` if vertical highlight indicator lines are enabled (drawn) + /// `true` if vertical highlight indicator lines are enabled (drawn) var isVerticalHighlightIndicatorEnabled: Bool { get } /// Enables / disables both vertical and horizontal highlight-indicators. diff --git a/Source/Charts/Data/Interfaces/IPieChartDataSet.swift b/Source/Charts/Data/Interfaces/IPieChartDataSet.swift index 872a031170..433c08f262 100644 --- a/Source/Charts/Data/Interfaces/IPieChartDataSet.swift +++ b/Source/Charts/Data/Interfaces/IPieChartDataSet.swift @@ -12,10 +12,6 @@ import Foundation import CoreGraphics -#if !os(OSX) - import UIKit -#endif - @objc public protocol IPieChartDataSet: IChartDataSet { @@ -38,6 +34,9 @@ public protocol IPieChartDataSet: IChartDataSet /// When valuePosition is OutsideSlice, indicates line color var valueLineColor: NSUIColor? { get set } + /// When valuePosition is OutsideSlice and enabled, line will have the same color as the slice + var useValueColorForLine: Bool { get set } + /// When valuePosition is OutsideSlice, indicates line width var valueLineWidth: CGFloat { get set } diff --git a/Source/Charts/Data/Interfaces/IScatterChartDataSet.swift b/Source/Charts/Data/Interfaces/IScatterChartDataSet.swift index 5703f07d00..0565146725 100644 --- a/Source/Charts/Data/Interfaces/IScatterChartDataSet.swift +++ b/Source/Charts/Data/Interfaces/IScatterChartDataSet.swift @@ -19,18 +19,18 @@ public protocol IScatterChartDataSet: ILineScatterCandleRadarChartDataSet // MARK: - Styling functions and accessors - /// - returns: The size the scatter shape will have + /// The size the scatter shape will have var scatterShapeSize: CGFloat { get } - /// - returns: The radius of the hole in the shape (applies to Square, Circle and Triangle) + /// - Returns: The radius of the hole in the shape (applies to Square, Circle and Triangle) /// Set this to <= 0 to remove holes. /// **default**: 0.0 var scatterShapeHoleRadius: CGFloat { get } - /// - returns: Color for the hole in the shape. Setting to `nil` will behave as transparent. + /// - Returns: Color for the hole in the shape. Setting to `nil` will behave as transparent. /// **default**: nil var scatterShapeHoleColor: NSUIColor? { get } - /// - returns: The IShapeRenderer responsible for rendering this DataSet. + /// The IShapeRenderer responsible for rendering this DataSet. var shapeRenderer: IShapeRenderer? { get } } diff --git a/Source/Charts/Filters/DataApproximator.swift b/Source/Charts/Filters/DataApproximator.swift index 6cd5338ff7..234a7d11e2 100644 --- a/Source/Charts/Filters/DataApproximator.swift +++ b/Source/Charts/Filters/DataApproximator.swift @@ -38,24 +38,16 @@ open class DataApproximator: NSObject keep: &keep) // create a new array with series, only take the kept ones - var reducedEntries = [CGPoint]() - for i in 0 ..< points.count - { - if keep[i] - { - reducedEntries.append(points[i]) - } - } - - return reducedEntries + return zip(keep, points).compactMap { $0 ? nil : $1 } } /// apply the Douglas-Peucker-Reduction to an array of `CGPoint`s with a given tolerance /// - /// - parameter points: - /// - parameter tolerance: - /// - parameter start: - /// - parameter end: + /// - Parameters: + /// - points: + /// - tolerance: + /// - start: + /// - end: open class func reduceWithDouglasPeuker( points: [CGPoint], tolerance: CGFloat, diff --git a/Source/Charts/Formatters/DefaultFillFormatter.swift b/Source/Charts/Formatters/DefaultFillFormatter.swift index ea9c2a7465..3afadf35fa 100644 --- a/Source/Charts/Formatters/DefaultFillFormatter.swift +++ b/Source/Charts/Formatters/DefaultFillFormatter.swift @@ -12,10 +12,6 @@ import Foundation import CoreGraphics -#if !os(OSX) - import UIKit -#endif - /// Default formatter that calculates the position of the filled line. @objc(ChartDefaultFillFormatter) open class DefaultFillFormatter: NSObject, IFillFormatter diff --git a/Source/Charts/Formatters/IAxisValueFormatter.swift b/Source/Charts/Formatters/IAxisValueFormatter.swift index 9634334cb5..302eee18f8 100644 --- a/Source/Charts/Formatters/IAxisValueFormatter.swift +++ b/Source/Charts/Formatters/IAxisValueFormatter.swift @@ -20,10 +20,10 @@ public protocol IAxisValueFormatter: class /// /// For performance reasons, avoid excessive calculations and memory allocations inside this method. /// - /// - returns: The customized label that is drawn on the x-axis. - /// - parameter value: the value that is currently being drawn - /// - parameter axis: the axis that the value belongs to - /// + /// - Parameters: + /// - value: the value that is currently being drawn + /// - axis: the axis that the value belongs to + /// - Returns: The customized label that is drawn on the x-axis. func stringForValue(_ value: Double, axis: AxisBase?) -> String diff --git a/Source/Charts/Formatters/IFillFormatter.swift b/Source/Charts/Formatters/IFillFormatter.swift index 8a88500299..7b684fd84e 100644 --- a/Source/Charts/Formatters/IFillFormatter.swift +++ b/Source/Charts/Formatters/IFillFormatter.swift @@ -16,6 +16,6 @@ import CoreGraphics @objc(IChartFillFormatter) public protocol IFillFormatter { - /// - returns: The vertical (y-axis) position where the filled-line of the LineDataSet should end. + /// - Returns: The vertical (y-axis) position where the filled-line of the LineDataSet should end. func getFillLinePosition(dataSet: ILineChartDataSet, dataProvider: LineChartDataProvider) -> CGFloat } diff --git a/Source/Charts/Formatters/IValueFormatter.swift b/Source/Charts/Formatters/IValueFormatter.swift index 5aae95b2a1..53ca7a40c2 100644 --- a/Source/Charts/Formatters/IValueFormatter.swift +++ b/Source/Charts/Formatters/IValueFormatter.swift @@ -24,14 +24,11 @@ public protocol IValueFormatter: class /// /// For performance reasons, avoid excessive calculations and memory allocations inside this method. /// - /// - returns: The formatted label ready to be drawn - /// - /// - parameter value: The value to be formatted - /// - /// - parameter dataSetIndex: The index of the DataSet the entry in focus belongs to - /// - /// - parameter viewPortHandler: provides information about the current chart state (scale, translation, ...) - /// + /// - Parameters: + /// - value: The value to be formatted + /// - dataSetIndex: The index of the DataSet the entry in focus belongs to + /// - viewPortHandler: provides information about the current chart state (scale, translation, ...) + /// - Returns: The formatted label ready to be drawn func stringForValue(_ value: Double, entry: ChartDataEntry, dataSetIndex: Int, diff --git a/Source/Charts/Highlight/BarHighlighter.swift b/Source/Charts/Highlight/BarHighlighter.swift index 2bb81a2a33..da9e6da733 100644 --- a/Source/Charts/Highlight/BarHighlighter.swift +++ b/Source/Charts/Highlight/BarHighlighter.swift @@ -49,11 +49,13 @@ open class BarHighlighter: ChartHighlighter } /// This method creates the Highlight object that also indicates which value of a stacked BarEntry has been selected. - /// - parameter high: the Highlight to work with looking for stacked values - /// - parameter set: - /// - parameter xIndex: - /// - parameter yValue: - /// - returns: + /// + /// - Parameters: + /// - high: the Highlight to work with looking for stacked values + /// - set: + /// - xIndex: + /// - yValue: + /// - Returns: @objc open func getStackedHighlight(high: Highlight, set: IBarChartDataSet, xValue: Double, @@ -89,30 +91,18 @@ open class BarHighlighter: ChartHighlighter axis: high.axis) } - /// - returns: The index of the closest value inside the values array / ranges (stacked barchart) to the value given as a parameter. - /// - parameter entry: - /// - parameter value: - /// - returns: + /// - Parameters: + /// - entry: + /// - value: + /// - Returns: The index of the closest value inside the values array / ranges (stacked barchart) to the value given as a parameter. @objc open func getClosestStackIndex(ranges: [Range]?, value: Double) -> Int { guard let ranges = ranges else { return 0 } - - var stackIndex = 0 - - for range in ranges - { - if range.contains(value) - { - return stackIndex - } - else - { - stackIndex += 1 - } + if let stackIndex = ranges.firstIndex(where: { $0.contains(value) }) { + return stackIndex + } else { + let length = max(ranges.count - 1, 0) + return (value > ranges[length].to) ? length : 0 } - - let length = max(ranges.count - 1, 0) - - return (value > ranges[length].to) ? length : 0 } } diff --git a/Source/Charts/Highlight/ChartHighlighter.swift b/Source/Charts/Highlight/ChartHighlighter.swift index 3fe679f20d..417ba0d0af 100644 --- a/Source/Charts/Highlight/ChartHighlighter.swift +++ b/Source/Charts/Highlight/ChartHighlighter.swift @@ -28,9 +28,9 @@ open class ChartHighlighter : NSObject, IHighlighter return getHighlight(xValue: xVal, x: x, y: y) } - /// - returns: The corresponding x-pos for a given touch-position in pixels. - /// - parameter x: - /// - returns: + /// - Parameters: + /// - x: + /// - Returns: The corresponding x-pos for a given touch-position in pixels. @objc open func getValsForTouch(x: CGFloat, y: CGFloat) -> CGPoint { guard let chart = self.chart as? BarLineScatterCandleBubbleChartDataProvider else { return .zero } @@ -39,11 +39,11 @@ open class ChartHighlighter : NSObject, IHighlighter return chart.getTransformer(forAxis: .left).valueForTouchPoint(x: x, y: y) } - /// - returns: The corresponding ChartHighlight for a given x-value and xy-touch position in pixels. - /// - parameter xValue: - /// - parameter x: - /// - parameter y: - /// - returns: + /// - Parameters: + /// - xValue: + /// - x: + /// - y: + /// - Returns: The corresponding ChartHighlight for a given x-value and xy-touch position in pixels. @objc open func getHighlight(xValue xVal: Double, x: CGFloat, y: CGFloat) -> Highlight? { guard let chart = chart else { return nil } @@ -61,12 +61,12 @@ open class ChartHighlighter : NSObject, IHighlighter return detail } - /// - returns: A list of Highlight objects representing the entries closest to the given xVal. + /// - Parameters: + /// - xValue: the transformed x-value of the x-touch position + /// - x: touch position + /// - y: touch position + /// - Returns: A list of Highlight objects representing the entries closest to the given xVal. /// The returned list contains two objects per DataSet (closest rounding up, closest rounding down). - /// - parameter xValue: the transformed x-value of the x-touch position - /// - parameter x: touch position - /// - parameter y: touch position - /// - returns: @objc open func getHighlights(xValue: Double, x: CGFloat, y: CGFloat) -> [Highlight] { var vals = [Highlight]() @@ -89,16 +89,14 @@ open class ChartHighlighter : NSObject, IHighlighter return vals } - /// - returns: An array of `Highlight` objects corresponding to the selected xValue and dataSetIndex. + /// - Returns: An array of `Highlight` objects corresponding to the selected xValue and dataSetIndex. internal func buildHighlights( dataSet set: IChartDataSet, dataSetIndex: Int, xValue: Double, rounding: ChartDataSetRounding) -> [Highlight] { - var highlights = [Highlight]() - - guard let chart = self.chart as? BarLineScatterCandleBubbleChartDataProvider else { return highlights } + guard let chart = self.chart as? BarLineScatterCandleBubbleChartDataProvider else { return [] } var entries = set.entriesForXValue(xValue) if entries.count == 0, let closest = set.entryForXValue(xValue, closestToY: .nan, rounding: rounding) @@ -106,21 +104,18 @@ open class ChartHighlighter : NSObject, IHighlighter // Try to find closest x-value and take all entries for that x-value entries = set.entriesForXValue(closest.x) } - - for e in entries - { - let px = chart.getTransformer(forAxis: set.axisDependency).pixelForValues(x: e.x, y: e.y) - let highlight = Highlight(x: e.x, y: e.y, xPx: px.x, yPx: px.y, dataSetIndex: dataSetIndex, axis: set.axisDependency) - highlights.append(highlight) + return entries.map { e in + let px = chart.getTransformer(forAxis: set.axisDependency) + .pixelForValues(x: e.x, y: e.y) + + return Highlight(x: e.x, y: e.y, xPx: px.x, yPx: px.y, dataSetIndex: dataSetIndex, axis: set.axisDependency) } - - return highlights } // - MARK: - Utilities - /// - returns: The `ChartHighlight` of the closest value on the x-y cartesian axes + /// - Returns: The `ChartHighlight` of the closest value on the x-y cartesian axes internal func closestSelectionDetailByPixel( closestValues: [Highlight], x: CGFloat, @@ -148,23 +143,20 @@ open class ChartHighlighter : NSObject, IHighlighter return closest } - /// - returns: The minimum distance from a touch-y-value (in pixels) to the closest y-value (in pixels) that is displayed in the chart. + /// - Returns: The minimum distance from a touch-y-value (in pixels) to the closest y-value (in pixels) that is displayed in the chart. internal func getMinimumDistance( closestValues: [Highlight], y: CGFloat, - axis: YAxis.AxisDependency) -> CGFloat - { + axis: YAxis.AxisDependency + ) -> CGFloat { var distance = CGFloat.greatestFiniteMagnitude - for high in closestValues + for high in closestValues where high.axis == axis { - if high.axis == axis + let tempDistance = abs(getHighlightPos(high: high) - y) + if tempDistance < distance { - let tempDistance = abs(getHighlightPos(high: high) - y) - if tempDistance < distance - { - distance = tempDistance - } + distance = tempDistance } } diff --git a/Source/Charts/Highlight/Highlight.swift b/Source/Charts/Highlight/Highlight.swift index e036b08464..d1692d3fbb 100644 --- a/Source/Charts/Highlight/Highlight.swift +++ b/Source/Charts/Highlight/Highlight.swift @@ -52,14 +52,15 @@ open class Highlight: NSObject super.init() } - /// - parameter x: the x-value of the highlighted value - /// - parameter y: the y-value of the highlighted value - /// - parameter xPx: the x-pixel of the highlighted value - /// - parameter yPx: the y-pixel of the highlighted value - /// - parameter dataIndex: the index of the Data the highlighted value belongs to - /// - parameter dataSetIndex: the index of the DataSet the highlighted value belongs to - /// - parameter stackIndex: references which value of a stacked-bar entry has been selected - /// - parameter axis: the axis the highlighted value belongs to + /// - Parameters: + /// - x: the x-value of the highlighted value + /// - y: the y-value of the highlighted value + /// - xPx: the x-pixel of the highlighted value + /// - yPx: the y-pixel of the highlighted value + /// - dataIndex: the index of the Data the highlighted value belongs to + /// - dataSetIndex: the index of the DataSet the highlighted value belongs to + /// - stackIndex: references which value of a stacked-bar entry has been selected + /// - axis: the axis the highlighted value belongs to @objc public init( x: Double, y: Double, xPx: CGFloat, yPx: CGFloat, @@ -80,13 +81,14 @@ open class Highlight: NSObject _axis = axis } - /// - parameter x: the x-value of the highlighted value - /// - parameter y: the y-value of the highlighted value - /// - parameter xPx: the x-pixel of the highlighted value - /// - parameter yPx: the y-pixel of the highlighted value - /// - parameter dataSetIndex: the index of the DataSet the highlighted value belongs to - /// - parameter stackIndex: references which value of a stacked-bar entry has been selected - /// - parameter axis: the axis the highlighted value belongs to + /// - Parameters: + /// - x: the x-value of the highlighted value + /// - y: the y-value of the highlighted value + /// - xPx: the x-pixel of the highlighted value + /// - yPx: the y-pixel of the highlighted value + /// - dataSetIndex: the index of the DataSet the highlighted value belongs to + /// - stackIndex: references which value of a stacked-bar entry has been selected + /// - axis: the axis the highlighted value belongs to @objc public convenience init( x: Double, y: Double, xPx: CGFloat, yPx: CGFloat, @@ -101,14 +103,15 @@ open class Highlight: NSObject axis: axis) } - /// - parameter x: the x-value of the highlighted value - /// - parameter y: the y-value of the highlighted value - /// - parameter xPx: the x-pixel of the highlighted value - /// - parameter yPx: the y-pixel of the highlighted value - /// - parameter dataIndex: the index of the Data the highlighted value belongs to - /// - parameter dataSetIndex: the index of the DataSet the highlighted value belongs to - /// - parameter stackIndex: references which value of a stacked-bar entry has been selected - /// - parameter axis: the axis the highlighted value belongs to + /// - Parameters: + /// - x: the x-value of the highlighted value + /// - y: the y-value of the highlighted value + /// - xPx: the x-pixel of the highlighted value + /// - yPx: the y-pixel of the highlighted value + /// - dataIndex: the index of the Data the highlighted value belongs to + /// - dataSetIndex: the index of the DataSet the highlighted value belongs to + /// - stackIndex: references which value of a stacked-bar entry has been selected + /// - axis: the axis the highlighted value belongs to @objc public init( x: Double, y: Double, xPx: CGFloat, yPx: CGFloat, @@ -125,10 +128,11 @@ open class Highlight: NSObject _axis = axis } - /// - parameter x: the x-value of the highlighted value - /// - parameter y: the y-value of the highlighted value - /// - parameter dataSetIndex: the index of the DataSet the highlighted value belongs to - /// - parameter dataIndex: The data index to search in (only used in CombinedChartView currently) + /// - Parameters: + /// - x: the x-value of the highlighted value + /// - y: the y-value of the highlighted value + /// - dataSetIndex: the index of the DataSet the highlighted value belongs to + /// - dataIndex: The data index to search in (only used in CombinedChartView currently) @objc public init(x: Double, y: Double, dataSetIndex: Int, dataIndex: Int = -1) { _x = x @@ -137,9 +141,10 @@ open class Highlight: NSObject self.dataIndex = dataIndex } - /// - parameter x: the x-value of the highlighted value - /// - parameter dataSetIndex: the index of the DataSet the highlighted value belongs to - /// - parameter stackIndex: references which value of a stacked-bar entry has been selected + /// - Parameters: + /// - x: the x-value of the highlighted value + /// - dataSetIndex: the index of the DataSet the highlighted value belongs to + /// - stackIndex: references which value of a stacked-bar entry has been selected @objc public convenience init(x: Double, dataSetIndex: Int, stackIndex: Int) { self.init(x: x, y: Double.nan, dataSetIndex: dataSetIndex) diff --git a/Source/Charts/Highlight/HorizontalBarHighlighter.swift b/Source/Charts/Highlight/HorizontalBarHighlighter.swift index c3b6e2867b..103d53f982 100644 --- a/Source/Charts/Highlight/HorizontalBarHighlighter.swift +++ b/Source/Charts/Highlight/HorizontalBarHighlighter.swift @@ -40,9 +40,7 @@ open class HorizontalBarHighlighter: BarHighlighter xValue: Double, rounding: ChartDataSetRounding) -> [Highlight] { - var highlights = [Highlight]() - - guard let chart = self.chart as? BarLineScatterCandleBubbleChartDataProvider else { return highlights } + guard let chart = self.chart as? BarLineScatterCandleBubbleChartDataProvider else { return [] } var entries = set.entriesForXValue(xValue) if entries.count == 0, let closest = set.entryForXValue(xValue, closestToY: .nan, rounding: rounding) @@ -50,15 +48,12 @@ open class HorizontalBarHighlighter: BarHighlighter // Try to find closest x-value and take all entries for that x-value entries = set.entriesForXValue(closest.x) } - - for e in entries - { - let px = chart.getTransformer(forAxis: set.axisDependency).pixelForValues(x: e.y, y: e.x) - - highlights.append(Highlight(x: e.x, y: e.y, xPx: px.x, yPx: px.y, dataSetIndex: dataSetIndex, axis: set.axisDependency)) + + return entries.map { e in + let px = chart.getTransformer(forAxis: set.axisDependency) + .pixelForValues(x: e.y, y: e.x) + return Highlight(x: e.x, y: e.y, xPx: px.x, yPx: px.y, dataSetIndex: dataSetIndex, axis: set.axisDependency) } - - return highlights } internal override func getDistance(x1: CGFloat, y1: CGFloat, x2: CGFloat, y2: CGFloat) -> CGFloat diff --git a/Source/Charts/Highlight/IHighlighter.swift b/Source/Charts/Highlight/IHighlighter.swift index 56acfcc226..21ae298c34 100644 --- a/Source/Charts/Highlight/IHighlighter.swift +++ b/Source/Charts/Highlight/IHighlighter.swift @@ -15,9 +15,9 @@ import CoreGraphics @objc(IChartHighlighter) public protocol IHighlighter: class { - /// - returns: A Highlight object corresponding to the given x- and y- touch positions in pixels. - /// - parameter x: - /// - parameter y: - /// - returns: + /// - Parameters: + /// - x: + /// - y: + /// - Returns: A Highlight object corresponding to the given x- and y- touch positions in pixels. func getHighlight(x: CGFloat, y: CGFloat) -> Highlight? } diff --git a/Source/Charts/Highlight/PieRadarHighlighter.swift b/Source/Charts/Highlight/PieRadarHighlighter.swift index ec77e72f5b..c55988ab31 100644 --- a/Source/Charts/Highlight/PieRadarHighlighter.swift +++ b/Source/Charts/Highlight/PieRadarHighlighter.swift @@ -49,10 +49,11 @@ open class PieRadarHighlighter: ChartHighlighter } - /// - returns: The closest Highlight object of the given objects based on the touch position inside the chart. - /// - parameter index: - /// - parameter x: - /// - parameter y: + /// - Parameters: + /// - index: + /// - x: + /// - y: + /// - Returns: The closest Highlight object of the given objects based on the touch position inside the chart. @objc open func closestHighlight(index: Int, x: CGFloat, y: CGFloat) -> Highlight? { fatalError("closestHighlight(index, x, y) cannot be called on PieRadarChartHighlighter") diff --git a/Source/Charts/Highlight/RadarHighlighter.swift b/Source/Charts/Highlight/RadarHighlighter.swift index d54193c2f8..cfaf57aec9 100644 --- a/Source/Charts/Highlight/RadarHighlighter.swift +++ b/Source/Charts/Highlight/RadarHighlighter.swift @@ -39,10 +39,10 @@ open class RadarHighlighter: PieRadarHighlighter return closest } - /// - returns: An array of Highlight objects for the given index. + /// - Parameters: + /// - index: + /// - Returns: An array of Highlight objects for the given index. /// The Highlight objects give information about the value at the selected index and DataSet it belongs to. - /// - /// - parameter index: internal func getHighlights(forIndex index: Int) -> [Highlight] { var vals = [Highlight]() diff --git a/Source/Charts/Highlight/Range.swift b/Source/Charts/Highlight/Range.swift index 1585869ff0..4b7ead10fb 100644 --- a/Source/Charts/Highlight/Range.swift +++ b/Source/Charts/Highlight/Range.swift @@ -25,8 +25,9 @@ open class Range: NSObject super.init() } - /// - returns: `true` if this range contains (if the value is in between) the given value, `false` ifnot. - /// - parameter value: + /// - Parameters: + /// - value: + /// - Returns: `true` if this range contains (if the value is in between) the given value, `false` ifnot. @objc open func contains(_ value: Double) -> Bool { if value > from && value <= to diff --git a/Source/Charts/Interfaces/ChartDataProvider.swift b/Source/Charts/Interfaces/ChartDataProvider.swift index 99619331c0..531f04b750 100644 --- a/Source/Charts/Interfaces/ChartDataProvider.swift +++ b/Source/Charts/Interfaces/ChartDataProvider.swift @@ -15,16 +15,16 @@ import CoreGraphics @objc public protocol ChartDataProvider { - /// - returns: The minimum x-value of the chart, regardless of zoom or translation. + /// The minimum x-value of the chart, regardless of zoom or translation. var chartXMin: Double { get } - /// - returns: The maximum x-value of the chart, regardless of zoom or translation. + /// The maximum x-value of the chart, regardless of zoom or translation. var chartXMax: Double { get } - /// - returns: The minimum y-value of the chart, regardless of zoom or translation. + /// The minimum y-value of the chart, regardless of zoom or translation. var chartYMin: Double { get } - /// - returns: The maximum y-value of the chart, regardless of zoom or translation. + /// The maximum y-value of the chart, regardless of zoom or translation. var chartYMax: Double { get } var maxHighlightDistance: CGFloat { get } @@ -36,4 +36,4 @@ public protocol ChartDataProvider var data: ChartData? { get } var maxVisibleCount: Int { get } -} \ No newline at end of file +} diff --git a/Source/Charts/Jobs/AnimatedMoveViewJob.swift b/Source/Charts/Jobs/AnimatedMoveViewJob.swift index b6ea8c28e5..7a75822161 100644 --- a/Source/Charts/Jobs/AnimatedMoveViewJob.swift +++ b/Source/Charts/Jobs/AnimatedMoveViewJob.swift @@ -12,10 +12,6 @@ import Foundation import CoreGraphics -#if !os(OSX) - import UIKit -#endif - open class AnimatedMoveViewJob: AnimatedViewPortJob { internal override func animationUpdate() diff --git a/Source/Charts/Jobs/AnimatedViewPortJob.swift b/Source/Charts/Jobs/AnimatedViewPortJob.swift index eaa9fec170..7375456664 100644 --- a/Source/Charts/Jobs/AnimatedViewPortJob.swift +++ b/Source/Charts/Jobs/AnimatedViewPortJob.swift @@ -12,10 +12,6 @@ import Foundation import CoreGraphics -#if !os(OSX) - import UIKit -#endif - open class AnimatedViewPortJob: ViewPortJob { internal var phase: CGFloat = 1.0 diff --git a/Source/Charts/Jobs/MoveViewJob.swift b/Source/Charts/Jobs/MoveViewJob.swift index acc8165d39..0b6ca320e5 100644 --- a/Source/Charts/Jobs/MoveViewJob.swift +++ b/Source/Charts/Jobs/MoveViewJob.swift @@ -12,10 +12,6 @@ import Foundation import CoreGraphics -#if !os(OSX) - import UIKit -#endif - @objc(MoveChartViewJob) open class MoveViewJob: ViewPortJob { diff --git a/Source/Charts/Jobs/ZoomViewJob.swift b/Source/Charts/Jobs/ZoomViewJob.swift index bdc7e32020..a6a79394da 100644 --- a/Source/Charts/Jobs/ZoomViewJob.swift +++ b/Source/Charts/Jobs/ZoomViewJob.swift @@ -12,10 +12,6 @@ import Foundation import CoreGraphics -#if !os(OSX) - import UIKit -#endif - @objc(ZoomChartViewJob) open class ZoomViewJob: ViewPortJob { diff --git a/Source/Charts/Renderers/AxisRendererBase.swift b/Source/Charts/Renderers/AxisRendererBase.swift index 15a9206e51..302bdf5312 100644 --- a/Source/Charts/Renderers/AxisRendererBase.swift +++ b/Source/Charts/Renderers/AxisRendererBase.swift @@ -54,8 +54,10 @@ open class AxisRendererBase: Renderer } /// Computes the axis values. - /// - parameter min: the minimum value in the data object for this axis - /// - parameter max: the maximum value in the data object for this axis + /// + /// - Parameters: + /// - min: the minimum value in the data object for this axis + /// - max: the maximum value in the data object for this axis @objc open func computeAxis(min: Double, max: Double, inverted: Bool) { var min = min, max = max diff --git a/Source/Charts/Renderers/BarChartRenderer.swift b/Source/Charts/Renderers/BarChartRenderer.swift index 23e4ae3409..6b192051bb 100644 --- a/Source/Charts/Renderers/BarChartRenderer.swift +++ b/Source/Charts/Renderers/BarChartRenderer.swift @@ -12,10 +12,6 @@ import Foundation import CoreGraphics -#if !os(OSX) - import UIKit -#endif - open class BarChartRenderer: BarLineScatterCandleBubbleRenderer { /// A nested array of elements ordered logically (i.e not in visual/drawing order) for use with VoiceOver @@ -108,6 +104,7 @@ open class BarChartRenderer: BarLineScatterCandleBubbleRenderer var barRect = CGRect() var x: Double var y: Double + for i in stride(from: 0, to: min(Int(ceil(Double(dataSet.entryCount) * animator.phaseX)), dataSet.entryCount), by: 1) { @@ -128,9 +125,84 @@ open class BarChartRenderer: BarLineScatterCandleBubbleRenderer var bottom = isInverted ? (y >= 0.0 ? CGFloat(y) : 0) : (y <= 0.0 ? CGFloat(y) : 0) + + /* When drawing each bar, the renderer actually draws each bar from 0 to the required value. + * This drawn bar is then clipped to the visible chart rect in BarLineChartViewBase's draw(rect:) using clipDataToContent. + * While this works fine when calculating the bar rects for drawing, it causes the accessibilityFrames to be oversized in some cases. + * This offset attempts to undo that unnecessary drawing when calculating barRects + * + * +---------------------------------------------------------------+---------------------------------------------------------------+ + * | Situation 1: (!inverted && y >= 0) | Situation 3: (inverted && y >= 0) | + * | | | + * | y -> +--+ <- top | 0 -> ---+--+---+--+------ <- top | + * | |//| } topOffset = y - max | | | |//| } topOffset = min | + * | max -> +---------+--+----+ <- top - topOffset | min -> +--+--+---+--+----+ <- top + topOffset | + * | | +--+ |//| | | | | | |//| | | + * | | | | |//| | | | +--+ |//| | | + * | | | | |//| | | | |//| | | + * | min -> +--+--+---+--+----+ <- bottom + bottomOffset | max -> +---------+--+----+ <- bottom - bottomOffset | + * | | | |//| } bottomOffset = min | |//| } bottomOffset = y - max | + * | 0 -> ---+--+---+--+----- <- bottom | y -> +--+ <- bottom | + * | | | + * +---------------------------------------------------------------+---------------------------------------------------------------+ + * | Situation 2: (!inverted && y < 0) | Situation 4: (inverted && y < 0) | + * | | | + * | 0 -> ---+--+---+--+----- <- top | y -> +--+ <- top | + * | | | |//| } topOffset = -max | |//| } topOffset = min - y | + * | max -> +--+--+---+--+----+ <- top - topOffset | min -> +---------+--+----+ <- top + topOffset | + * | | | | |//| | | | +--+ |//| | | + * | | +--+ |//| | | | | | |//| | | + * | | |//| | | | | | |//| | | + * | min -> +---------+--+----+ <- bottom + bottomOffset | max -> +--+--+---+--+----+ <- bottom - bottomOffset | + * | |//| } bottomOffset = min - y | | | |//| } bottomOffset = -max | + * | y -> +--+ <- bottom | 0 -> ---+--+---+--+------- <- bottom | + * | | | + * +---------------------------------------------------------------+---------------------------------------------------------------+ + */ + var topOffset: CGFloat = 0.0 + var bottomOffset: CGFloat = 0.0 + if let offsetView = dataProvider as? BarChartView + { + let offsetAxis = offsetView.getAxis(dataSet.axisDependency) + if y >= 0 + { + // situation 1 + if offsetAxis.axisMaximum < y + { + topOffset = CGFloat(y - offsetAxis.axisMaximum) + } + if offsetAxis.axisMinimum > 0 + { + bottomOffset = CGFloat(offsetAxis.axisMinimum) + } + } + else // y < 0 + { + //situation 2 + if offsetAxis.axisMaximum < 0 + { + topOffset = CGFloat(offsetAxis.axisMaximum * -1) + } + if offsetAxis.axisMinimum > y + { + bottomOffset = CGFloat(offsetAxis.axisMinimum - y) + } + } + if isInverted + { + // situation 3 and 4 + // exchange topOffset/bottomOffset based on 1 and 2 + // see diagram above + (topOffset, bottomOffset) = (bottomOffset, topOffset) + } + } + //apply offset + top = isInverted ? top + topOffset : top - topOffset + bottom = isInverted ? bottom - bottomOffset : bottom + bottomOffset // multiply the height of the rect with the phase - if top > 0 + // explicitly add 0 + topOffset to indicate this is changed after adding accessibility support (#3650, #3520) + if top > 0 + topOffset { top *= CGFloat(phaseY) } @@ -139,28 +211,10 @@ open class BarChartRenderer: BarLineScatterCandleBubbleRenderer bottom *= CGFloat(phaseY) } - // When drawing with an auto calculated y-axis minimum, the renderer actually draws each bar from 0 - // to the required value. This drawn bar is then clipped to the visible chart rect in BarLineChartViewBase's draw(rect:) using clipDataToContent. - // While this works fine when calculating the bar rects for drawing, it causes the accessibilityFrames to be oversized in some cases. - // This offset attempts to undo that unnecessary drawing when calculating barRects, particularly when not using custom axis minima. - // This allows the minimum to still be visually non zero, but the rects are only drawn where necessary. - // This offset calculation also avoids cases where there are positive/negative values mixed, since those won't need this offset. - var offset: CGFloat = 0.0 - if let offsetView = dataProvider as? BarChartView { - - let offsetAxis = offsetView.leftAxis.isEnabled ? offsetView.leftAxis : offsetView.rightAxis - - if barData.yMin.sign != barData.yMax.sign { offset = 0.0 } - else if !offsetAxis._customAxisMin { - offset = CGFloat(offsetAxis.axisMinimum) - } - } - barRect.origin.x = left - barRect.size.width = right - left barRect.origin.y = top - barRect.size.height = bottom == top ? 0 : bottom - top + offset - + barRect.size.width = right - left + barRect.size.height = bottom - top buffer.rects[bufferIndex] = barRect bufferIndex += 1 } @@ -434,15 +488,13 @@ open class BarChartRenderer: BarLineScatterCandleBubbleRenderer var posOffset: CGFloat var negOffset: CGFloat let drawValueAboveBar = dataProvider.isDrawValueAboveBarEnabled - + for dataSetIndex in 0 ..< barData.dataSetCount { - guard let dataSet = dataSets[dataSetIndex] as? IBarChartDataSet else { continue } - - if !shouldDrawValues(forDataSet: dataSet) - { - continue - } + guard let + dataSet = dataSets[dataSetIndex] as? IBarChartDataSet, + shouldDrawValues(forDataSet: dataSet) + else { continue } let isInverted = dataProvider.isInverted(axis: dataSet.axisDependency) diff --git a/Source/Charts/Renderers/BarLineScatterCandleBubbleRenderer.swift b/Source/Charts/Renderers/BarLineScatterCandleBubbleRenderer.swift index 4ba1b5fac7..7c258b1f41 100644 --- a/Source/Charts/Renderers/BarLineScatterCandleBubbleRenderer.swift +++ b/Source/Charts/Renderers/BarLineScatterCandleBubbleRenderer.swift @@ -38,7 +38,7 @@ open class BarLineScatterCandleBubbleRenderer: DataRenderer return XBounds(chart: chart, dataSet: dataSet, animator: animator) } - /// - returns: `true` if the DataSet values should be drawn, `false` if not. + /// - Returns: `true` if the DataSet values should be drawn, `false` if not. internal func shouldDrawValues(forDataSet set: IChartDataSet) -> Bool { return set.isVisible && (set.isDrawValuesEnabled || set.isDrawIconsEnabled) @@ -78,8 +78,8 @@ open class BarLineScatterCandleBubbleRenderer: DataRenderer let low = chart.lowestVisibleX let high = chart.highestVisibleX - let entryFrom = dataSet.entryForXValue(low, closestToY: Double.nan, rounding: ChartDataSetRounding.down) - let entryTo = dataSet.entryForXValue(high, closestToY: Double.nan, rounding: ChartDataSetRounding.up) + let entryFrom = dataSet.entryForXValue(low, closestToY: .nan, rounding: .down) + let entryTo = dataSet.entryForXValue(high, closestToY: .nan, rounding: .up) self.min = entryFrom == nil ? 0 : dataSet.entryIndex(entry: entryFrom!) self.max = entryTo == nil ? 0 : dataSet.entryIndex(entry: entryTo!) @@ -87,3 +87,33 @@ open class BarLineScatterCandleBubbleRenderer: DataRenderer } } } + +extension BarLineScatterCandleBubbleRenderer.XBounds: RangeExpression { + public func relative(to collection: C) -> Swift.Range + where C : Collection, Bound == C.Index + { + return Swift.Range(min...min + range) + } + + public func contains(_ element: Int) -> Bool { + return (min...min + range).contains(element) + } +} + +extension BarLineScatterCandleBubbleRenderer.XBounds: Sequence { + public struct Iterator: IteratorProtocol { + private var iterator: IndexingIterator> + + fileprivate init(min: Int, max: Int) { + self.iterator = (min...max).makeIterator() + } + + public mutating func next() -> Int? { + return self.iterator.next() + } + } + + public func makeIterator() -> Iterator { + return Iterator(min: self.min, max: self.max) + } +} diff --git a/Source/Charts/Renderers/BubbleChartRenderer.swift b/Source/Charts/Renderers/BubbleChartRenderer.swift index 5309092cad..1a089e9f3e 100644 --- a/Source/Charts/Renderers/BubbleChartRenderer.swift +++ b/Source/Charts/Renderers/BubbleChartRenderer.swift @@ -12,11 +12,6 @@ import Foundation import CoreGraphics -#if !os(OSX) - import UIKit -#endif - - open class BubbleChartRenderer: BarLineScatterCandleBubbleRenderer { /// A nested array of elements ordered logically (i.e not in visual/drawing order) for use with VoiceOver. @@ -105,7 +100,7 @@ open class BubbleChartRenderer: BarLineScatterCandleBubbleRenderer let maxBubbleHeight: CGFloat = abs(viewPortHandler.contentBottom - viewPortHandler.contentTop) let referenceSize: CGFloat = min(maxBubbleHeight, maxBubbleWidth) - for j in stride(from: _xBounds.min, through: _xBounds.range + _xBounds.min, by: 1) + for j in _xBounds { guard let entry = dataSet.entryForIndex(j) as? BubbleChartDataEntry else { continue } @@ -185,7 +180,7 @@ open class BubbleChartRenderer: BarLineScatterCandleBubbleRenderer let iconsOffset = dataSet.iconsOffset - for j in _xBounds.min..._xBounds.range + _xBounds.min + for j in _xBounds { guard let e = dataSet.entryForIndex(j) as? BubbleChartDataEntry else { break } diff --git a/Source/Charts/Renderers/CandleStickChartRenderer.swift b/Source/Charts/Renderers/CandleStickChartRenderer.swift index 6da78b2b20..2e8cda3257 100644 --- a/Source/Charts/Renderers/CandleStickChartRenderer.swift +++ b/Source/Charts/Renderers/CandleStickChartRenderer.swift @@ -12,11 +12,6 @@ import Foundation import CoreGraphics -#if !os(OSX) - import UIKit -#endif - - open class CandleStickChartRenderer: LineScatterCandleRadarRenderer { @objc open weak var dataProvider: CandleChartDataProvider? @@ -43,12 +38,9 @@ open class CandleStickChartRenderer: LineScatterCandleRadarRenderer accessibleChartElements.append(element) } - for set in candleData.dataSets as! [ICandleChartDataSet] + for set in candleData.dataSets as! [ICandleChartDataSet] where set.isVisible { - if set.isVisible - { - drawDataSet(context: context, dataSet: set) - } + drawDataSet(context: context, dataSet: set) } } @@ -77,7 +69,7 @@ open class CandleStickChartRenderer: LineScatterCandleRadarRenderer context.setLineWidth(dataSet.shadowWidth) - for j in stride(from: _xBounds.min, through: _xBounds.range + _xBounds.min, by: 1) + for j in _xBounds { // get the entry guard let e = dataSet.entryForIndex(j) as? CandleChartDataEntry else { continue } @@ -291,14 +283,11 @@ open class CandleStickChartRenderer: LineScatterCandleRadarRenderer for i in 0 ..< dataSets.count { - guard let dataSet = dataSets[i] as? IBarLineScatterCandleBubbleChartDataSet + guard let + dataSet = dataSets[i] as? IBarLineScatterCandleBubbleChartDataSet, + shouldDrawValues(forDataSet: dataSet) else { continue } - if !shouldDrawValues(forDataSet: dataSet) - { - continue - } - let valueFont = dataSet.valueFont guard let formatter = dataSet.valueFormatter else { continue } @@ -313,7 +302,7 @@ open class CandleStickChartRenderer: LineScatterCandleRadarRenderer let lineHeight = valueFont.lineHeight let yOffset: CGFloat = lineHeight + 5.0 - for j in stride(from: _xBounds.min, through: _xBounds.range + _xBounds.min, by: 1) + for j in _xBounds { guard let e = dataSet.entryForIndex(j) as? CandleChartDataEntry else { break } diff --git a/Source/Charts/Renderers/ChartDataRendererBase.swift b/Source/Charts/Renderers/ChartDataRendererBase.swift index da4fd67af2..68905ff50a 100644 --- a/Source/Charts/Renderers/ChartDataRendererBase.swift +++ b/Source/Charts/Renderers/ChartDataRendererBase.swift @@ -50,7 +50,8 @@ open class DataRenderer: Renderer /// Draws all highlight indicators for the values that are currently highlighted. /// - /// - parameter indices: the highlighted values + /// - Parameters: + /// - indices: the highlighted values @objc open func drawHighlighted(context: CGContext, indices: [Highlight]) { fatalError("drawHighlighted() cannot be called on DataRenderer") diff --git a/Source/Charts/Renderers/CombinedChartRenderer.swift b/Source/Charts/Renderers/CombinedChartRenderer.swift index bc80bd0a34..8446c9b637 100644 --- a/Source/Charts/Renderers/CombinedChartRenderer.swift +++ b/Source/Charts/Renderers/CombinedChartRenderer.swift @@ -87,10 +87,7 @@ open class CombinedChartRenderer: DataRenderer open override func initBuffers() { - for renderer in _renderers - { - renderer.initBuffers() - } + _renderers.forEach { $0.initBuffers() } } open override func drawData(context: CGContext) @@ -111,26 +108,17 @@ open class CombinedChartRenderer: DataRenderer // TODO: Due to the potential complexity of data presented in Combined charts, a more usable way // for VO accessibility would be to use axis based traversal rather than by dataset. // Hence, accessibleChartElements is not populated below. (Individual renderers guard against dataSource being their respective views) - for renderer in _renderers - { - renderer.drawData(context: context) - } + _renderers.forEach { $0.drawData(context: context) } } open override func drawValues(context: CGContext) { - for renderer in _renderers - { - renderer.drawValues(context: context) - } + _renderers.forEach { $0.drawValues(context: context) } } open override func drawExtras(context: CGContext) { - for renderer in _renderers - { - renderer.drawExtras(context: context) - } + _renderers.forEach { $0.drawExtras(context: context) } } open override func drawHighlighted(context: CGContext, indices: [Highlight]) @@ -160,7 +148,12 @@ open class CombinedChartRenderer: DataRenderer data = (renderer as! BubbleChartRenderer).dataProvider?.bubbleData } - let dataIndex = data == nil ? nil : (chart?.data as? CombinedChartData)?.allData.index(of: data!) + let dataIndex: Int? = { + guard let data = data else { return nil } + return (chart?.data as? CombinedChartData)? + .allData + .firstIndex(of: data) + }() let dataIndices = indices.filter{ $0.dataIndex == dataIndex || $0.dataIndex == -1 } @@ -168,7 +161,7 @@ open class CombinedChartRenderer: DataRenderer } } - /// - returns: The sub-renderer object at the specified index. + /// - Returns: The sub-renderer object at the specified index. @objc open func getSubRenderer(index: Int) -> DataRenderer? { if index >= _renderers.count || index < 0 @@ -181,7 +174,7 @@ open class CombinedChartRenderer: DataRenderer } } - /// - returns: All sub-renderers. + /// All sub-renderers. @objc open var subRenderers: [DataRenderer] { get { return _renderers } @@ -190,10 +183,10 @@ open class CombinedChartRenderer: DataRenderer // MARK: Accessors - /// - returns: `true` if drawing values above bars is enabled, `false` ifnot + /// `true` if drawing values above bars is enabled, `false` ifnot @objc open var isDrawValueAboveBarEnabled: Bool { return drawValueAboveBarEnabled } - /// - returns: `true` if drawing shadows (maxvalue) for each bar is enabled, `false` ifnot + /// `true` if drawing shadows (maxvalue) for each bar is enabled, `false` ifnot @objc open var isDrawBarShadowEnabled: Bool { return drawBarShadowEnabled } /// the order in which the provided data objects should be drawn. diff --git a/Source/Charts/Renderers/HorizontalBarChartRenderer.swift b/Source/Charts/Renderers/HorizontalBarChartRenderer.swift index 4f493bdeea..309de7cf96 100644 --- a/Source/Charts/Renderers/HorizontalBarChartRenderer.swift +++ b/Source/Charts/Renderers/HorizontalBarChartRenderer.swift @@ -12,11 +12,6 @@ import Foundation import CoreGraphics -#if !os(OSX) - import UIKit -#endif - - open class HorizontalBarChartRenderer: BarChartRenderer { private class Buffer @@ -335,12 +330,10 @@ open class HorizontalBarChartRenderer: BarChartRenderer for dataSetIndex in 0 ..< barData.dataSetCount { - guard let dataSet = dataSets[dataSetIndex] as? IBarChartDataSet else { continue } - - if !shouldDrawValues(forDataSet: dataSet) || !(dataSet.isDrawIconsEnabled && dataSet.isVisible) - { - continue - } + guard let + dataSet = dataSets[dataSetIndex] as? IBarChartDataSet, + shouldDrawValues(forDataSet: dataSet) + else { continue } let isInverted = dataProvider.isInverted(axis: dataSet.axisDependency) @@ -393,7 +386,7 @@ open class HorizontalBarChartRenderer: BarChartRenderer // calculate the correct offset depending on the draw position of the value let valueTextWidth = valueText.size(withAttributes: [NSAttributedString.Key.font: valueFont]).width posOffset = (drawValueAboveBar ? valueOffsetPlus : -(valueTextWidth + valueOffsetPlus)) - negOffset = (drawValueAboveBar ? -(valueTextWidth + valueOffsetPlus) : valueOffsetPlus) + negOffset = (drawValueAboveBar ? -(valueTextWidth + valueOffsetPlus) : valueOffsetPlus) - rect.size.width if isInverted { diff --git a/Source/Charts/Renderers/LegendRenderer.swift b/Source/Charts/Renderers/LegendRenderer.swift index dc98b8b6a4..f0b01d093a 100755 --- a/Source/Charts/Renderers/LegendRenderer.swift +++ b/Source/Charts/Renderers/LegendRenderer.swift @@ -12,10 +12,6 @@ import Foundation import CoreGraphics -#if !os(OSX) - import UIKit -#endif - @objc(ChartLegendRenderer) open class LegendRenderer: Renderer { diff --git a/Source/Charts/Renderers/LineChartRenderer.swift b/Source/Charts/Renderers/LineChartRenderer.swift index 2d8ae7b02c..eedd92de91 100644 --- a/Source/Charts/Renderers/LineChartRenderer.swift +++ b/Source/Charts/Renderers/LineChartRenderer.swift @@ -12,11 +12,6 @@ import Foundation import CoreGraphics -#if !os(OSX) - import UIKit -#endif - - open class LineChartRenderer: LineRadarRenderer { // TODO: Currently, this nesting isn't necessary for LineCharts. However, it will make it much easier to add a custom rotor @@ -73,6 +68,8 @@ open class LineChartRenderer: LineRadarRenderer context.setLineDash(phase: 0.0, lengths: []) } + context.setLineCap(dataSet.lineCapType) + // if drawing cubic lines is enabled switch dataSet.mode { @@ -212,7 +209,7 @@ open class LineChartRenderer: LineRadarRenderer // let the spline start cubicPath.move(to: CGPoint(x: CGFloat(cur.x), y: CGFloat(cur.y * phaseY)), transform: valueToPixelMatrix) - for j in stride(from: (_xBounds.min + 1), through: _xBounds.range + _xBounds.min, by: 1) + for j in _xBounds.dropFirst() { prev = cur cur = dataSet.entryForIndex(j) @@ -313,126 +310,64 @@ open class LineChartRenderer: LineRadarRenderer } context.saveGState() - - context.setLineCap(dataSet.lineCapType) - // more than 1 color - if dataSet.colors.count > 1 - { if _lineSegments.count != pointsPerEntryPair { // Allocate once in correct size _lineSegments = [CGPoint](repeating: CGPoint(), count: pointsPerEntryPair) } - for j in stride(from: _xBounds.min, through: _xBounds.range + _xBounds.min, by: 1) + for j in stride(from: _xBounds.min, through: _xBounds.range + _xBounds.min, by: 1) + { + var e: ChartDataEntry! = dataSet.entryForIndex(j) + + if e == nil { continue } + + _lineSegments[0].x = CGFloat(e.x) + _lineSegments[0].y = CGFloat(e.y * phaseY) + + if j < _xBounds.max { - var e: ChartDataEntry! = dataSet.entryForIndex(j) - - if e == nil { continue } + e = dataSet.entryForIndex(j + 1) - _lineSegments[0].x = CGFloat(e.x) - _lineSegments[0].y = CGFloat(e.y * phaseY) + if e == nil { break } - if j < _xBounds.max + if isDrawSteppedEnabled { - e = dataSet.entryForIndex(j + 1) - - if e == nil { break } - - if isDrawSteppedEnabled - { - _lineSegments[1] = CGPoint(x: CGFloat(e.x), y: _lineSegments[0].y) - _lineSegments[2] = _lineSegments[1] - _lineSegments[3] = CGPoint(x: CGFloat(e.x), y: CGFloat(e.y * phaseY)) - } - else - { - _lineSegments[1] = CGPoint(x: CGFloat(e.x), y: CGFloat(e.y * phaseY)) - } + _lineSegments[1] = CGPoint(x: CGFloat(e.x), y: _lineSegments[0].y) + _lineSegments[2] = _lineSegments[1] + _lineSegments[3] = CGPoint(x: CGFloat(e.x), y: CGFloat(e.y * phaseY)) } else { - _lineSegments[1] = _lineSegments[0] + _lineSegments[1] = CGPoint(x: CGFloat(e.x), y: CGFloat(e.y * phaseY)) } + } + else + { + _lineSegments[1] = _lineSegments[0] + } - for i in 0..<_lineSegments.count - { - _lineSegments[i] = _lineSegments[i].applying(valueToPixelMatrix) - } - - if (!viewPortHandler.isInBoundsRight(_lineSegments[0].x)) - { - break - } - - // make sure the lines don't do shitty things outside bounds - if !viewPortHandler.isInBoundsLeft(_lineSegments[1].x) - || (!viewPortHandler.isInBoundsTop(_lineSegments[0].y) && !viewPortHandler.isInBoundsBottom(_lineSegments[1].y)) - { - continue - } - - // get the color that is set for this line-segment - context.setStrokeColor(dataSet.color(atIndex: j).cgColor) - context.strokeLineSegments(between: _lineSegments) + for i in 0..<_lineSegments.count + { + _lineSegments[i] = _lineSegments[i].applying(valueToPixelMatrix) } - } - else - { // only one color per dataset - var e1: ChartDataEntry! - var e2: ChartDataEntry! - - e1 = dataSet.entryForIndex(_xBounds.min) + if (!viewPortHandler.isInBoundsRight(_lineSegments[0].x)) + { + break + } - if e1 != nil + // make sure the lines don't do shitty things outside bounds + if !viewPortHandler.isInBoundsLeft(_lineSegments[1].x) + || (!viewPortHandler.isInBoundsTop(_lineSegments[0].y) && !viewPortHandler.isInBoundsBottom(_lineSegments[1].y)) { - context.beginPath() - var firstPoint = true - - for x in stride(from: _xBounds.min, through: _xBounds.range + _xBounds.min, by: 1) - { - e1 = dataSet.entryForIndex(x == 0 ? 0 : (x - 1)) - e2 = dataSet.entryForIndex(x) - - if e1 == nil || e2 == nil { continue } - - let pt = CGPoint( - x: CGFloat(e1.x), - y: CGFloat(e1.y * phaseY) - ).applying(valueToPixelMatrix) - - if firstPoint - { - context.move(to: pt) - firstPoint = false - } - else - { - context.addLine(to: pt) - } - - if isDrawSteppedEnabled - { - context.addLine(to: CGPoint( - x: CGFloat(e2.x), - y: CGFloat(e1.y * phaseY) - ).applying(valueToPixelMatrix)) - } - - context.addLine(to: CGPoint( - x: CGFloat(e2.x), - y: CGFloat(e2.y * phaseY) - ).applying(valueToPixelMatrix)) - } - - if !firstPoint - { - context.setStrokeColor(dataSet.color(atIndex: 0).cgColor) - context.strokePath() - } + continue } + + // get the color that is set for this line-segment + context.setStrokeColor(dataSet.color(atIndex: j).cgColor) + context.strokeLineSegments(between: _lineSegments) } context.restoreGState() @@ -518,12 +453,10 @@ open class LineChartRenderer: LineRadarRenderer for i in 0 ..< dataSets.count { - guard let dataSet = dataSets[i] as? ILineChartDataSet else { continue } - - if !shouldDrawValues(forDataSet: dataSet) - { - continue - } + guard let + dataSet = dataSets[i] as? ILineChartDataSet, + shouldDrawValues(forDataSet: dataSet) + else { continue } let valueFont = dataSet.valueFont @@ -543,8 +476,8 @@ open class LineChartRenderer: LineRadarRenderer } _xBounds.set(chart: dataProvider, dataSet: dataSet, animator: animator) - - for j in stride(from: _xBounds.min, through: min(_xBounds.min + _xBounds.range, _xBounds.max), by: 1) + + for j in _xBounds { guard let e = dataSet.entryForIndex(j) else { break } @@ -649,7 +582,7 @@ open class LineChartRenderer: LineRadarRenderer (dataSet.circleHoleColor == nil || dataSet.circleHoleColor == NSUIColor.clear) - for j in stride(from: _xBounds.min, through: _xBounds.range + _xBounds.min, by: 1) + for j in _xBounds { guard let e = dataSet.entryForIndex(j) else { break } diff --git a/Source/Charts/Renderers/PieChartRenderer.swift b/Source/Charts/Renderers/PieChartRenderer.swift index c1ceb7c1fe..c9716111dc 100644 --- a/Source/Charts/Renderers/PieChartRenderer.swift +++ b/Source/Charts/Renderers/PieChartRenderer.swift @@ -12,10 +12,6 @@ import Foundation import CoreGraphics -#if !os(OSX) - import UIKit -#endif - open class PieChartRenderer: DataRenderer { @objc open weak var chart: PieChartView? @@ -39,11 +35,9 @@ open class PieChartRenderer: DataRenderer accessibleChartElements.removeAll() for set in pieData!.dataSets as! [IPieChartDataSet] + where set.isVisible && set.entryCount > 0 { - if set.isVisible && set.entryCount > 0 - { - drawDataSet(context: context, dataSet: set) - } + drawDataSet(context: context, dataSet: set) } } } @@ -438,9 +432,20 @@ open class PieChartRenderer: DataRenderer labelPoint = CGPoint(x: pt2.x + 5, y: pt2.y - lineHeight) } - if dataSet.valueLineColor != nil + DrawLine: do { - context.setStrokeColor(dataSet.valueLineColor!.cgColor) + if dataSet.useValueColorForLine + { + context.setStrokeColor(dataSet.color(atIndex: j).cgColor) + } + else if let valueLineColor = dataSet.valueLineColor + { + context.setStrokeColor(valueLineColor.cgColor) + } + else + { + return + } context.setLineWidth(dataSet.valueLineWidth) context.move(to: CGPoint(x: pt0.x, y: pt0.y)) @@ -449,7 +454,7 @@ open class PieChartRenderer: DataRenderer context.drawPath(using: CGPathDrawingMode.stroke) } - + if drawXOutside && drawYOutside { ChartUtils.drawText( diff --git a/Source/Charts/Renderers/RadarChartRenderer.swift b/Source/Charts/Renderers/RadarChartRenderer.swift index a535cfd5d1..c2ab79fcc2 100644 --- a/Source/Charts/Renderers/RadarChartRenderer.swift +++ b/Source/Charts/Renderers/RadarChartRenderer.swift @@ -12,26 +12,16 @@ import Foundation import CoreGraphics -#if !os(OSX) - import UIKit -#endif - - open class RadarChartRenderer: LineRadarRenderer { private lazy var accessibilityXLabels: [String] = { - var labels: [String] = [] - guard let chart = chart else { return [] } guard let formatter = chart.xAxis.valueFormatter else { return [] } let maxEntryCount = chart.data?.maxEntryCountSet?.entryCount ?? 0 - for i in stride(from: 0, to: maxEntryCount, by: 1) - { - labels.append(formatter.stringForValue(Double(i), axis: chart.xAxis)) + return stride(from: 0, to: maxEntryCount, by: 1).map { + formatter.stringForValue(Double($0), axis: chart.xAxis) } - - return labels }() @objc open weak var chart: RadarChartView? @@ -64,21 +54,19 @@ open class RadarChartRenderer: LineRadarRenderer self.accessibleChartElements.append(element) } - for set in radarData!.dataSets as! [IRadarChartDataSet] + for set in radarData!.dataSets as! [IRadarChartDataSet] where set.isVisible { - if set.isVisible - { - drawDataSet(context: context, dataSet: set, mostEntries: mostEntries) - } + drawDataSet(context: context, dataSet: set, mostEntries: mostEntries) } } } /// Draws the RadarDataSet /// - /// - parameter context: - /// - parameter dataSet: - /// - parameter mostEntries: the entry count of the dataset with the most entries + /// - Parameters: + /// - context: + /// - dataSet: + /// - mostEntries: the entry count of the dataset with the most entries internal func drawDataSet(context: CGContext, dataSet: IRadarChartDataSet, mostEntries: Int) { guard let chart = chart else { return } @@ -225,12 +213,10 @@ open class RadarChartRenderer: LineRadarRenderer for i in 0 ..< data.dataSetCount { - let dataSet = data.getDataSetByIndex(i) as! IRadarChartDataSet - - if !shouldDrawValues(forDataSet: dataSet) - { - continue - } + guard let + dataSet = data.getDataSetByIndex(i) as? IRadarChartDataSet, + shouldDrawValues(forDataSet: dataSet) + else { continue } let entryCount = dataSet.entryCount diff --git a/Source/Charts/Renderers/Scatter/IShapeRenderer.swift b/Source/Charts/Renderers/Scatter/IShapeRenderer.swift index bb12d9824a..ff12ee3fb2 100644 --- a/Source/Charts/Renderers/Scatter/IShapeRenderer.swift +++ b/Source/Charts/Renderers/Scatter/IShapeRenderer.swift @@ -17,11 +17,12 @@ public protocol IShapeRenderer: class { /// Renders the provided ScatterDataSet with a shape. /// - /// - parameter context: CGContext for drawing on - /// - parameter dataSet: The DataSet to be drawn - /// - parameter viewPortHandler: Contains information about the current state of the view - /// - parameter point: Position to draw the shape at - /// - parameter color: Color to draw the shape + /// - Parameters: + /// - context: CGContext for drawing on + /// - dataSet: The DataSet to be drawn + /// - viewPortHandler: Contains information about the current state of the view + /// - point: Position to draw the shape at + /// - color: Color to draw the shape func renderShape( context: CGContext, dataSet: IScatterChartDataSet, diff --git a/Source/Charts/Renderers/ScatterChartRenderer.swift b/Source/Charts/Renderers/ScatterChartRenderer.swift index f0669cf553..57d348b28b 100644 --- a/Source/Charts/Renderers/ScatterChartRenderer.swift +++ b/Source/Charts/Renderers/ScatterChartRenderer.swift @@ -12,11 +12,6 @@ import Foundation import CoreGraphics -#if !os(OSX) - import UIKit -#endif - - open class ScatterChartRenderer: LineScatterCandleRadarRenderer { @objc open weak var dataProvider: ScatterChartDataProvider? @@ -131,16 +126,13 @@ open class ScatterChartRenderer: LineScatterCandleRadarRenderer for i in 0 ..< scatterData.dataSetCount { let dataSet = dataSets[i] - - if !shouldDrawValues(forDataSet: dataSet) - { - continue - } + guard let + formatter = dataSet.valueFormatter, + shouldDrawValues(forDataSet: dataSet) + else { continue } let valueFont = dataSet.valueFont - guard let formatter = dataSet.valueFormatter else { continue } - let trans = dataProvider.getTransformer(forAxis: dataSet.axisDependency) let valueToPixelMatrix = trans.valueToPixelMatrix @@ -151,7 +143,7 @@ open class ScatterChartRenderer: LineScatterCandleRadarRenderer _xBounds.set(chart: dataProvider, dataSet: dataSet, animator: animator) - for j in stride(from: _xBounds.min, through: _xBounds.range + _xBounds.min, by: 1) + for j in _xBounds { guard let e = dataSet.entryForIndex(j) else { break } diff --git a/Source/Charts/Renderers/XAxisRenderer.swift b/Source/Charts/Renderers/XAxisRenderer.swift index 9bb9b2782a..499ea35c8d 100644 --- a/Source/Charts/Renderers/XAxisRenderer.swift +++ b/Source/Charts/Renderers/XAxisRenderer.swift @@ -12,10 +12,6 @@ import Foundation import CoreGraphics -#if !os(OSX) - import UIKit -#endif - @objc(ChartXAxisRenderer) open class XAxisRenderer: AxisRendererBase { @@ -210,16 +206,14 @@ open class XAxisRenderer: AxisRendererBase let transformer = self.transformer else { return } - #if os(OSX) - let paraStyle = NSParagraphStyle.default.mutableCopy() as! NSMutableParagraphStyle - #else - let paraStyle = NSParagraphStyle.default.mutableCopy() as! NSMutableParagraphStyle - #endif + let paraStyle = NSParagraphStyle.default.mutableCopy() as! NSMutableParagraphStyle paraStyle.alignment = .center - let labelAttrs: [NSAttributedString.Key : Any] = [NSAttributedString.Key.font: xAxis.labelFont, - NSAttributedString.Key.foregroundColor: xAxis.labelTextColor, - NSAttributedString.Key.paragraphStyle: paraStyle] + let labelAttrs: [NSAttributedString.Key : Any] = [ + .font: xAxis.labelFont, + .foregroundColor: xAxis.labelTextColor, + .paragraphStyle: paraStyle + ] let labelRotationAngleRadians = xAxis.labelRotationAngle.DEG2RAD let centeringEnabled = xAxis.isCenterAxisLabelsEnabled @@ -422,29 +416,16 @@ open class XAxisRenderer: AxisRendererBase { guard let xAxis = self.axis as? XAxis, - let transformer = self.transformer + let transformer = self.transformer, + !xAxis.limitLines.isEmpty else { return } - var limitLines = xAxis.limitLines - - if limitLines.count == 0 - { - return - } - let trans = transformer.valueToPixelMatrix var position = CGPoint(x: 0.0, y: 0.0) - for i in 0 ..< limitLines.count + for l in xAxis.limitLines where l.isEnabled { - let l = limitLines[i] - - if !l.isEnabled - { - continue - } - context.saveGState() defer { context.restoreGState() } @@ -487,55 +468,53 @@ open class XAxisRenderer: AxisRendererBase { let label = limitLine.label - - // if drawing the limit-value label is enabled - if limitLine.drawLabelEnabled && label.count > 0 - { - let labelLineHeight = limitLine.valueFont.lineHeight - - let xOffset: CGFloat = limitLine.lineWidth + limitLine.xOffset - - if limitLine.labelPosition == .rightTop - { - ChartUtils.drawText(context: context, - text: label, - point: CGPoint( - x: position.x + xOffset, - y: viewPortHandler.contentTop + yOffset), - align: .left, - attributes: [NSAttributedString.Key.font: limitLine.valueFont, NSAttributedString.Key.foregroundColor: limitLine.valueTextColor]) - } - else if limitLine.labelPosition == .rightBottom - { - ChartUtils.drawText(context: context, - text: label, - point: CGPoint( - x: position.x + xOffset, - y: viewPortHandler.contentBottom - labelLineHeight - yOffset), - align: .left, - attributes: [NSAttributedString.Key.font: limitLine.valueFont, NSAttributedString.Key.foregroundColor: limitLine.valueTextColor]) - } - else if limitLine.labelPosition == .leftTop - { - ChartUtils.drawText(context: context, - text: label, - point: CGPoint( - x: position.x - xOffset, - y: viewPortHandler.contentTop + yOffset), - align: .right, - attributes: [NSAttributedString.Key.font: limitLine.valueFont, NSAttributedString.Key.foregroundColor: limitLine.valueTextColor]) - } - else - { - ChartUtils.drawText(context: context, - text: label, - point: CGPoint( - x: position.x - xOffset, - y: viewPortHandler.contentBottom - labelLineHeight - yOffset), - align: .right, - attributes: [NSAttributedString.Key.font: limitLine.valueFont, NSAttributedString.Key.foregroundColor: limitLine.valueTextColor]) - } + guard limitLine.drawLabelEnabled, !label.isEmpty else { return } + + let labelLineHeight = limitLine.valueFont.lineHeight + + let xOffset: CGFloat = limitLine.lineWidth + limitLine.xOffset + let attributes: [NSAttributedString.Key : Any] = [ + .font : limitLine.valueFont, + .foregroundColor : limitLine.valueTextColor + ] + + let (point, align): (CGPoint, NSTextAlignment) + switch limitLine.labelPosition { + case .topRight: + point = CGPoint( + x: position.x + xOffset, + y: viewPortHandler.contentTop + yOffset + ) + align = .left + + case .bottomRight: + point = CGPoint( + x: position.x + xOffset, + y: viewPortHandler.contentBottom - labelLineHeight - yOffset + ) + align = .left + + case .topLeft: + point = CGPoint( + x: position.x - xOffset, + y: viewPortHandler.contentTop + yOffset + ) + align = .right + + case .bottomLeft: + point = CGPoint( + x: position.x - xOffset, + y: viewPortHandler.contentBottom - labelLineHeight - yOffset + ) + align = .right } - } + ChartUtils.drawText( + context: context, + text: label, + point: point, + align: align, + attributes: attributes + ) + } } diff --git a/Source/Charts/Renderers/XAxisRendererHorizontalBarChart.swift b/Source/Charts/Renderers/XAxisRendererHorizontalBarChart.swift index 13d1eb03b8..8bdf0e7760 100644 --- a/Source/Charts/Renderers/XAxisRendererHorizontalBarChart.swift +++ b/Source/Charts/Renderers/XAxisRendererHorizontalBarChart.swift @@ -12,10 +12,6 @@ import Foundation import CoreGraphics -#if !os(OSX) - import UIKit -#endif - open class XAxisRendererHorizontalBarChart: XAxisRenderer { internal weak var chart: BarChartView? @@ -404,7 +400,7 @@ open class XAxisRendererHorizontalBarChart: XAxisRenderer let xOffset: CGFloat = 4.0 + l.xOffset let yOffset: CGFloat = l.lineWidth + labelLineHeight + l.yOffset - if l.labelPosition == .rightTop + if l.labelPosition == .topRight { ChartUtils.drawText(context: context, text: label, @@ -414,7 +410,7 @@ open class XAxisRendererHorizontalBarChart: XAxisRenderer align: .right, attributes: [NSAttributedString.Key.font: l.valueFont, NSAttributedString.Key.foregroundColor: l.valueTextColor]) } - else if l.labelPosition == .rightBottom + else if l.labelPosition == .bottomRight { ChartUtils.drawText(context: context, text: label, @@ -424,7 +420,7 @@ open class XAxisRendererHorizontalBarChart: XAxisRenderer align: .right, attributes: [NSAttributedString.Key.font: l.valueFont, NSAttributedString.Key.foregroundColor: l.valueTextColor]) } - else if l.labelPosition == .leftTop + else if l.labelPosition == .topLeft { ChartUtils.drawText(context: context, text: label, diff --git a/Source/Charts/Renderers/XAxisRendererRadarChart.swift b/Source/Charts/Renderers/XAxisRendererRadarChart.swift index 0638f3a19c..c5fcedf54c 100644 --- a/Source/Charts/Renderers/XAxisRendererRadarChart.swift +++ b/Source/Charts/Renderers/XAxisRendererRadarChart.swift @@ -12,10 +12,6 @@ import Foundation import CoreGraphics -#if !os(OSX) - import UIKit -#endif - open class XAxisRendererRadarChart: XAxisRenderer { @objc open weak var chart: RadarChartView? diff --git a/Source/Charts/Renderers/YAxisRenderer.swift b/Source/Charts/Renderers/YAxisRenderer.swift index 87bd913570..bc28bcc5a6 100644 --- a/Source/Charts/Renderers/YAxisRenderer.swift +++ b/Source/Charts/Renderers/YAxisRenderer.swift @@ -12,10 +12,6 @@ import Foundation import CoreGraphics -#if !os(OSX) - import UIKit -#endif - @objc(ChartYAxisRenderer) open class YAxisRenderer: AxisRendererBase { @@ -223,7 +219,8 @@ open class YAxisRenderer: AxisRendererBase text: text, point: CGPoint(x: fixedPosition, y: positions[i].y + offset), align: textAlign, - attributes: [NSAttributedString.Key.font: labelFont, NSAttributedString.Key.foregroundColor: labelTextColor]) + attributes: [.font: labelFont, .foregroundColor: labelTextColor] + ) } } @@ -262,10 +259,7 @@ open class YAxisRenderer: AxisRendererBase } // draw the grid - for i in 0 ..< positions.count - { - drawGridLine(context: context, position: positions[i]) - } + positions.forEach { drawGridLine(context: context, position: $0) } } if yAxis.drawZeroLineEnabled @@ -420,7 +414,7 @@ open class YAxisRenderer: AxisRendererBase let xOffset: CGFloat = 4.0 + l.xOffset let yOffset: CGFloat = l.lineWidth + labelLineHeight + l.yOffset - if l.labelPosition == .rightTop + if l.labelPosition == .topRight { ChartUtils.drawText(context: context, text: label, @@ -430,7 +424,7 @@ open class YAxisRenderer: AxisRendererBase align: .right, attributes: [NSAttributedString.Key.font: l.valueFont, NSAttributedString.Key.foregroundColor: l.valueTextColor]) } - else if l.labelPosition == .rightBottom + else if l.labelPosition == .bottomRight { ChartUtils.drawText(context: context, text: label, @@ -440,7 +434,7 @@ open class YAxisRenderer: AxisRendererBase align: .right, attributes: [NSAttributedString.Key.font: l.valueFont, NSAttributedString.Key.foregroundColor: l.valueTextColor]) } - else if l.labelPosition == .leftTop + else if l.labelPosition == .topLeft { ChartUtils.drawText(context: context, text: label, diff --git a/Source/Charts/Renderers/YAxisRendererHorizontalBarChart.swift b/Source/Charts/Renderers/YAxisRendererHorizontalBarChart.swift index ef0a54a957..a3da987eb1 100644 --- a/Source/Charts/Renderers/YAxisRendererHorizontalBarChart.swift +++ b/Source/Charts/Renderers/YAxisRendererHorizontalBarChart.swift @@ -12,10 +12,6 @@ import Foundation import CoreGraphics -#if !os(OSX) - import UIKit -#endif - open class YAxisRendererHorizontalBarChart: YAxisRenderer { public override init(viewPortHandler: ViewPortHandler, yAxis: YAxis?, transformer: Transformer?) @@ -352,7 +348,7 @@ open class YAxisRendererHorizontalBarChart: YAxisRenderer let xOffset: CGFloat = l.lineWidth + l.xOffset let yOffset: CGFloat = 2.0 + l.yOffset - if l.labelPosition == .rightTop + if l.labelPosition == .topRight { ChartUtils.drawText(context: context, text: label, @@ -362,7 +358,7 @@ open class YAxisRendererHorizontalBarChart: YAxisRenderer align: .left, attributes: [NSAttributedString.Key.font: l.valueFont, NSAttributedString.Key.foregroundColor: l.valueTextColor]) } - else if l.labelPosition == .rightBottom + else if l.labelPosition == .bottomRight { ChartUtils.drawText(context: context, text: label, @@ -372,7 +368,7 @@ open class YAxisRendererHorizontalBarChart: YAxisRenderer align: .left, attributes: [NSAttributedString.Key.font: l.valueFont, NSAttributedString.Key.foregroundColor: l.valueTextColor]) } - else if l.labelPosition == .leftTop + else if l.labelPosition == .topLeft { ChartUtils.drawText(context: context, text: label, diff --git a/Source/Charts/Renderers/YAxisRendererRadarChart.swift b/Source/Charts/Renderers/YAxisRendererRadarChart.swift index bb3e0b5c04..c98971e904 100644 --- a/Source/Charts/Renderers/YAxisRendererRadarChart.swift +++ b/Source/Charts/Renderers/YAxisRendererRadarChart.swift @@ -12,10 +12,6 @@ import Foundation import CoreGraphics -#if !os(OSX) - import UIKit -#endif - open class YAxisRendererRadarChart: YAxisRenderer { private weak var chart: RadarChartView? diff --git a/Source/Charts/Utils/ChartColorTemplates.swift b/Source/Charts/Utils/ChartColorTemplates.swift index 461ef8ab3d..534f9cb880 100644 --- a/Source/Charts/Utils/ChartColorTemplates.swift +++ b/Source/Charts/Utils/ChartColorTemplates.swift @@ -12,11 +12,6 @@ import Foundation import CoreGraphics -#if !os(OSX) - import UIKit -#endif - - open class ChartColorTemplates: NSObject { @objc open class func liberty () -> [NSUIColor] diff --git a/Source/Charts/Utils/ChartUtils.swift b/Source/Charts/Utils/ChartUtils.swift index 741b9b3859..25ccfde3db 100644 --- a/Source/Charts/Utils/ChartUtils.swift +++ b/Source/Charts/Utils/ChartUtils.swift @@ -36,8 +36,8 @@ extension FloatingPoint return self * 180 / .pi } - /// - returns: An angle between 0.0 < 360.0 (not less than zero, less than 360) - /// NOTE: Value must be in degrees + /// - Note: Value must be in degrees + /// - Returns: An angle between 0.0 < 360.0 (not less than zero, less than 360) var normalizedAngle: Self { let angle = truncatingRemainder(dividingBy: 360) @@ -288,7 +288,7 @@ open class ChartUtils return formatter } - /// - returns: The default value formatter used for all chart components that needs a default + /// - Returns: The default value formatter used for all chart components that needs a default open class func defaultValueFormatter() -> IValueFormatter { return _defaultValueFormatter diff --git a/Source/Charts/Utils/Platform+Accessibility.swift b/Source/Charts/Utils/Platform+Accessibility.swift index 304cf2c575..35f4ee317c 100644 --- a/Source/Charts/Utils/Platform+Accessibility.swift +++ b/Source/Charts/Utils/Platform+Accessibility.swift @@ -33,7 +33,7 @@ open class NSUIAccessibilityElement: UIAccessibilityElement } } - override init(accessibilityContainer container: Any) + override public init(accessibilityContainer container: Any) { // We can force unwrap since all chart views are subclasses of UIView containerView = (container as! UIView) @@ -83,7 +83,8 @@ extension NSUIView open override func index(ofAccessibilityElement element: Any) -> Int { guard let axElement = element as? NSUIAccessibilityElement else { return NSNotFound } - return (accessibilityChildren() as? [NSUIAccessibilityElement])?.index(of: axElement) ?? NSNotFound + return (accessibilityChildren() as? [NSUIAccessibilityElement])? + .firstIndex(of: axElement) ?? NSNotFound } } @@ -167,7 +168,7 @@ open class NSUIAccessibilityElement: NSAccessibilityElement } } - init(accessibilityContainer container: Any) + public init(accessibilityContainer container: Any) { // We can force unwrap since all chart views are subclasses of NSView containerView = (container as! NSView) @@ -179,7 +180,7 @@ open class NSUIAccessibilityElement: NSAccessibilityElement } } -/// NOTE: setAccessibilityRole(.list) is called at init. See Platform.swift. +/// - Note: setAccessibilityRole(.list) is called at init. See Platform.swift. extension NSUIView: NSAccessibilityGroup { open override func accessibilityLabel() -> String? diff --git a/Source/Charts/Utils/Platform.swift b/Source/Charts/Utils/Platform.swift index eef134687f..3c11b32a4a 100644 --- a/Source/Charts/Utils/Platform.swift +++ b/Source/Charts/Utils/Platform.swift @@ -1,629 +1,629 @@ import Foundation /** This file provides a thin abstraction layer atop of UIKit (iOS, tvOS) and Cocoa (OS X). The two APIs are very much -alike, and for the chart library's usage of the APIs it is often sufficient to typealias one to the other. The NSUI* -types are aliased to either their UI* implementation (on iOS) or their NS* implementation (on OS X). */ + alike, and for the chart library's usage of the APIs it is often sufficient to typealias one to the other. The NSUI* + types are aliased to either their UI* implementation (on iOS) or their NS* implementation (on OS X). */ #if os(iOS) || os(tvOS) - import UIKit - - public typealias NSUIFont = UIFont - public typealias NSUIColor = UIColor - public typealias NSUIEvent = UIEvent - public typealias NSUITouch = UITouch - public typealias NSUIImage = UIImage - public typealias NSUIScrollView = UIScrollView - public typealias NSUIGestureRecognizer = UIGestureRecognizer +import UIKit + +public typealias NSUIFont = UIFont +public typealias NSUIColor = UIColor +public typealias NSUIEvent = UIEvent +public typealias NSUITouch = UITouch +public typealias NSUIImage = UIImage +public typealias NSUIScrollView = UIScrollView +public typealias NSUIGestureRecognizer = UIGestureRecognizer public typealias NSUIGestureRecognizerState = UIGestureRecognizer.State - public typealias NSUIGestureRecognizerDelegate = UIGestureRecognizerDelegate - public typealias NSUITapGestureRecognizer = UITapGestureRecognizer - public typealias NSUIPanGestureRecognizer = UIPanGestureRecognizer +public typealias NSUIGestureRecognizerDelegate = UIGestureRecognizerDelegate +public typealias NSUITapGestureRecognizer = UITapGestureRecognizer +public typealias NSUIPanGestureRecognizer = UIPanGestureRecognizer #if !os(tvOS) - public typealias NSUIPinchGestureRecognizer = UIPinchGestureRecognizer - public typealias NSUIRotationGestureRecognizer = UIRotationGestureRecognizer +public typealias NSUIPinchGestureRecognizer = UIPinchGestureRecognizer +public typealias NSUIRotationGestureRecognizer = UIRotationGestureRecognizer #endif - public typealias NSUIScreen = UIScreen +public typealias NSUIScreen = UIScreen - public typealias NSUIDisplayLink = CADisplayLink - - extension NSUITapGestureRecognizer +public typealias NSUIDisplayLink = CADisplayLink + +extension NSUITapGestureRecognizer +{ + @objc final func nsuiNumberOfTouches() -> Int { - @objc final func nsuiNumberOfTouches() -> Int + return numberOfTouches + } + + @objc final var nsuiNumberOfTapsRequired: Int + { + get { - return numberOfTouches + return self.numberOfTapsRequired } - - @objc final var nsuiNumberOfTapsRequired: Int + set { - get - { - return self.numberOfTapsRequired - } - set - { - self.numberOfTapsRequired = newValue - } + self.numberOfTapsRequired = newValue } } - - extension NSUIPanGestureRecognizer +} + +extension NSUIPanGestureRecognizer +{ + @objc final func nsuiNumberOfTouches() -> Int { - @objc final func nsuiNumberOfTouches() -> Int - { - return numberOfTouches - } - - @objc final func nsuiLocationOfTouch(_ touch: Int, inView: UIView?) -> CGPoint - { - return super.location(ofTouch: touch, in: inView) - } + return numberOfTouches } - -#if !os(tvOS) - extension NSUIRotationGestureRecognizer + + @objc final func nsuiLocationOfTouch(_ touch: Int, inView: UIView?) -> CGPoint { - @objc final var nsuiRotation: CGFloat + return super.location(ofTouch: touch, in: inView) + } +} + +#if !os(tvOS) +extension NSUIRotationGestureRecognizer +{ + @objc final var nsuiRotation: CGFloat { - get { return rotation } - set { rotation = newValue } - } + get { return rotation } + set { rotation = newValue } } +} #endif - + #if !os(tvOS) - extension NSUIPinchGestureRecognizer - { - @objc final var nsuiScale: CGFloat +extension NSUIPinchGestureRecognizer +{ + @objc final var nsuiScale: CGFloat { - get - { - return scale - } - set - { - scale = newValue - } + get + { + return scale } - - @objc final func nsuiLocationOfTouch(_ touch: Int, inView: UIView?) -> CGPoint + set { - return super.location(ofTouch: touch, in: inView) + scale = newValue } } -#endif - open class NSUIView: UIView + @objc final func nsuiLocationOfTouch(_ touch: Int, inView: UIView?) -> CGPoint { - public final override func touchesBegan(_ touches: Set, with event: NSUIEvent?) - { - self.nsuiTouchesBegan(touches, withEvent: event) - } - - public final override func touchesMoved(_ touches: Set, with event: NSUIEvent?) - { - self.nsuiTouchesMoved(touches, withEvent: event) - } - - public final override func touchesEnded(_ touches: Set, with event: NSUIEvent?) - { - self.nsuiTouchesEnded(touches, withEvent: event) - } - - public final override func touchesCancelled(_ touches: Set, with event: NSUIEvent?) - { - self.nsuiTouchesCancelled(touches, withEvent: event) - } - - @objc open func nsuiTouchesBegan(_ touches: Set, withEvent event: NSUIEvent?) - { - super.touchesBegan(touches, with: event!) - } - - @objc open func nsuiTouchesMoved(_ touches: Set, withEvent event: NSUIEvent?) - { - super.touchesMoved(touches, with: event!) - } - - @objc open func nsuiTouchesEnded(_ touches: Set, withEvent event: NSUIEvent?) - { - super.touchesEnded(touches, with: event!) - } - - @objc open func nsuiTouchesCancelled(_ touches: Set?, withEvent event: NSUIEvent?) - { - super.touchesCancelled(touches!, with: event!) - } - - @objc var nsuiLayer: CALayer? - { - return self.layer - } - } + return super.location(ofTouch: touch, in: inView) + } +} +#endif - extension UIView +open class NSUIView: UIView +{ + public final override func touchesBegan(_ touches: Set, with event: NSUIEvent?) { - @objc final var nsuiGestureRecognizers: [NSUIGestureRecognizer]? - { - return self.gestureRecognizers - } + self.nsuiTouchesBegan(touches, withEvent: event) } - - extension UIScrollView + + public final override func touchesMoved(_ touches: Set, with event: NSUIEvent?) { - @objc var nsuiIsScrollEnabled: Bool - { - get { return isScrollEnabled } - set { isScrollEnabled = newValue } - } + self.nsuiTouchesMoved(touches, withEvent: event) } - - extension UIScreen + + public final override func touchesEnded(_ touches: Set, with event: NSUIEvent?) { - @objc final var nsuiScale: CGFloat - { - return self.scale - } + self.nsuiTouchesEnded(touches, withEvent: event) } - func NSUIGraphicsGetCurrentContext() -> CGContext? + public final override func touchesCancelled(_ touches: Set, with event: NSUIEvent?) { - return UIGraphicsGetCurrentContext() - } + self.nsuiTouchesCancelled(touches, withEvent: event) + } - func NSUIGraphicsGetImageFromCurrentImageContext() -> NSUIImage! + @objc open func nsuiTouchesBegan(_ touches: Set, withEvent event: NSUIEvent?) { - return UIGraphicsGetImageFromCurrentImageContext() - } + super.touchesBegan(touches, with: event!) + } - func NSUIGraphicsPushContext(_ context: CGContext) + @objc open func nsuiTouchesMoved(_ touches: Set, withEvent event: NSUIEvent?) { - UIGraphicsPushContext(context) - } + super.touchesMoved(touches, with: event!) + } - func NSUIGraphicsPopContext() + @objc open func nsuiTouchesEnded(_ touches: Set, withEvent event: NSUIEvent?) { - UIGraphicsPopContext() - } + super.touchesEnded(touches, with: event!) + } - func NSUIGraphicsEndImageContext() + @objc open func nsuiTouchesCancelled(_ touches: Set?, withEvent event: NSUIEvent?) { - UIGraphicsEndImageContext() - } + super.touchesCancelled(touches!, with: event!) + } - func NSUIImagePNGRepresentation(_ image: NSUIImage) -> Data? + @objc var nsuiLayer: CALayer? { - return image.pngData() - } + return self.layer + } +} - func NSUIImageJPEGRepresentation(_ image: NSUIImage, _ quality: CGFloat = 0.8) -> Data? +extension UIView +{ + @objc final var nsuiGestureRecognizers: [NSUIGestureRecognizer]? { - return image.jpegData(compressionQuality: quality) - } + return self.gestureRecognizers + } +} - func NSUIMainScreen() -> NSUIScreen? - { - return NSUIScreen.main - } +extension UIScrollView +{ + @objc var nsuiIsScrollEnabled: Bool + { + get { return isScrollEnabled } + set { isScrollEnabled = newValue } + } +} - func NSUIGraphicsBeginImageContextWithOptions(_ size: CGSize, _ opaque: Bool, _ scale: CGFloat) +extension UIScreen +{ + @objc final var nsuiScale: CGFloat { - UIGraphicsBeginImageContextWithOptions(size, opaque, scale) - } + return self.scale + } +} + +func NSUIGraphicsGetCurrentContext() -> CGContext? +{ + return UIGraphicsGetCurrentContext() +} + +func NSUIGraphicsGetImageFromCurrentImageContext() -> NSUIImage! +{ + return UIGraphicsGetImageFromCurrentImageContext() +} + +func NSUIGraphicsPushContext(_ context: CGContext) +{ + UIGraphicsPushContext(context) +} + +func NSUIGraphicsPopContext() +{ + UIGraphicsPopContext() +} + +func NSUIGraphicsEndImageContext() +{ + UIGraphicsEndImageContext() +} + +func NSUIImagePNGRepresentation(_ image: NSUIImage) -> Data? +{ + return image.pngData() +} + +func NSUIImageJPEGRepresentation(_ image: NSUIImage, _ quality: CGFloat = 0.8) -> Data? +{ + return image.jpegData(compressionQuality: quality) +} + +func NSUIMainScreen() -> NSUIScreen? +{ + return NSUIScreen.main +} + +func NSUIGraphicsBeginImageContextWithOptions(_ size: CGSize, _ opaque: Bool, _ scale: CGFloat) +{ + UIGraphicsBeginImageContextWithOptions(size, opaque, scale) +} #endif #if os(OSX) - import Cocoa - import Quartz - - public typealias NSUIFont = NSFont - public typealias NSUIColor = NSColor - public typealias NSUIEvent = NSEvent - public typealias NSUITouch = NSTouch - public typealias NSUIImage = NSImage - public typealias NSUIScrollView = NSScrollView - public typealias NSUIGestureRecognizer = NSGestureRecognizer - public typealias NSUIGestureRecognizerState = NSGestureRecognizer.State - public typealias NSUIGestureRecognizerDelegate = NSGestureRecognizerDelegate - public typealias NSUITapGestureRecognizer = NSClickGestureRecognizer - public typealias NSUIPanGestureRecognizer = NSPanGestureRecognizer - public typealias NSUIPinchGestureRecognizer = NSMagnificationGestureRecognizer - public typealias NSUIRotationGestureRecognizer = NSRotationGestureRecognizer - public typealias NSUIScreen = NSScreen - - /** On OS X there is no CADisplayLink. Use a 60 fps timer to render the animations. */ - public class NSUIDisplayLink - { - private var timer: Timer? - private var displayLink: CVDisplayLink? - private var _timestamp: CFTimeInterval = 0.0 - - private weak var _target: AnyObject? - private var _selector: Selector - - public var timestamp: CFTimeInterval - { - return _timestamp - } +import Cocoa +import Quartz + +public typealias NSUIFont = NSFont +public typealias NSUIColor = NSColor +public typealias NSUIEvent = NSEvent +public typealias NSUITouch = NSTouch +public typealias NSUIImage = NSImage +public typealias NSUIScrollView = NSScrollView +public typealias NSUIGestureRecognizer = NSGestureRecognizer +public typealias NSUIGestureRecognizerState = NSGestureRecognizer.State +public typealias NSUIGestureRecognizerDelegate = NSGestureRecognizerDelegate +public typealias NSUITapGestureRecognizer = NSClickGestureRecognizer +public typealias NSUIPanGestureRecognizer = NSPanGestureRecognizer +public typealias NSUIPinchGestureRecognizer = NSMagnificationGestureRecognizer +public typealias NSUIRotationGestureRecognizer = NSRotationGestureRecognizer +public typealias NSUIScreen = NSScreen + +/** On OS X there is no CADisplayLink. Use a 60 fps timer to render the animations. */ +public class NSUIDisplayLink +{ + private var timer: Timer? + private var displayLink: CVDisplayLink? + private var _timestamp: CFTimeInterval = 0.0 + + private weak var _target: AnyObject? + private var _selector: Selector + + public var timestamp: CFTimeInterval + { + return _timestamp + } + + init(target: Any, selector: Selector) + { + _target = target as AnyObject + _selector = selector - init(target: AnyObject, selector: Selector) + if CVDisplayLinkCreateWithActiveCGDisplays(&displayLink) == kCVReturnSuccess { - _target = target - _selector = selector - - if CVDisplayLinkCreateWithActiveCGDisplays(&displayLink) == kCVReturnSuccess - { - - CVDisplayLinkSetOutputCallback(displayLink!, { (displayLink, inNow, inOutputTime, flagsIn, flagsOut, userData) -> CVReturn in - - let _self = unsafeBitCast(userData, to: NSUIDisplayLink.self) + + CVDisplayLinkSetOutputCallback(displayLink!, { (displayLink, inNow, inOutputTime, flagsIn, flagsOut, userData) -> CVReturn in + + let _self = unsafeBitCast(userData, to: NSUIDisplayLink.self) - _self._timestamp = CFAbsoluteTimeGetCurrent() - _self._target?.performSelector(onMainThread: _self._selector, with: _self, waitUntilDone: false) + _self._timestamp = CFAbsoluteTimeGetCurrent() + _self._target?.performSelector(onMainThread: _self._selector, with: _self, waitUntilDone: false) - return kCVReturnSuccess - }, Unmanaged.passUnretained(self).toOpaque()) - } - else - { - timer = Timer(timeInterval: 1.0 / 60.0, target: target, selector: selector, userInfo: nil, repeats: true) - } - } - - deinit - { - stop() + return kCVReturnSuccess + }, Unmanaged.passUnretained(self).toOpaque()) } - - open func add(to runloop: RunLoop, forMode mode: RunLoop.Mode) + else { - if displayLink != nil - { - CVDisplayLinkStart(displayLink!) - } - else if timer != nil - { - runloop.add(timer!, forMode: mode) - } + timer = Timer(timeInterval: 1.0 / 60.0, target: target, selector: selector, userInfo: nil, repeats: true) + } } - open func remove(from: RunLoop, forMode: RunLoop.Mode) - { - stop() - } - - private func stop() - { - if displayLink != nil - { - CVDisplayLinkStop(displayLink!) - } - if timer != nil - { - timer?.invalidate() - } - } - } + deinit + { + stop() + } - /** The 'tap' gesture is mapped to clicks. */ - extension NSUITapGestureRecognizer + open func add(to runloop: RunLoop, forMode mode: RunLoop.Mode) { - final func nsuiNumberOfTouches() -> Int + if displayLink != nil { - return 1 - } - - final var nsuiNumberOfTapsRequired: Int + CVDisplayLinkStart(displayLink!) + } + else if timer != nil { - get - { - return self.numberOfClicksRequired - } - set - { - self.numberOfClicksRequired = newValue - } - } - } + runloop.add(timer!, forMode: mode) + } + } - extension NSUIPanGestureRecognizer + open func remove(from: RunLoop, forMode: RunLoop.Mode) { - final func nsuiNumberOfTouches() -> Int - { - return 1 - } - - /// FIXME: Currently there are no more than 1 touch in OSX gestures, and not way to create custom touch gestures. - final func nsuiLocationOfTouch(_ touch: Int, inView: NSView?) -> NSPoint - { - return super.location(in: inView) - } + stop() } - - extension NSUIRotationGestureRecognizer + + private func stop() { - /// FIXME: Currently there are no velocities in OSX gestures, and not way to create custom touch gestures. - final var velocity: CGFloat + if displayLink != nil { - return 0.1 + CVDisplayLinkStop(displayLink!) } - - final var nsuiRotation: CGFloat + if timer != nil { - get { return -rotation } - set { rotation = -newValue } + timer?.invalidate() } } - - extension NSUIPinchGestureRecognizer +} + +/** The 'tap' gesture is mapped to clicks. */ +extension NSUITapGestureRecognizer +{ + final func nsuiNumberOfTouches() -> Int { - final var nsuiScale: CGFloat + return 1 + } + + final var nsuiNumberOfTapsRequired: Int + { + get { - get - { - return magnification + 1.0 - } - set - { - magnification = newValue - 1.0 - } + return self.numberOfClicksRequired } - - /// FIXME: Currently there are no more than 1 touch in OSX gestures, and not way to create custom touch gestures. - final func nsuiLocationOfTouch(_ touch: Int, inView view: NSView?) -> NSPoint + set { - return super.location(in: view) + self.numberOfClicksRequired = newValue } } +} - extension NSView +extension NSUIPanGestureRecognizer +{ + final func nsuiNumberOfTouches() -> Int { - final var nsuiGestureRecognizers: [NSGestureRecognizer]? - { - return self.gestureRecognizers - } - } + return 1 + } - extension NSScrollView + /// FIXME: Currently there are no more than 1 touch in OSX gestures, and not way to create custom touch gestures. + final func nsuiLocationOfTouch(_ touch: Int, inView: NSView?) -> NSPoint { - var nsuiIsScrollEnabled: Bool - { - get { return scrollEnabled } - set { scrollEnabled = newValue } - } + return super.location(in: inView) } - - open class NSUIView: NSView - { - /// A private constant to set the accessibility role during initialization. - /// It ensures parity with the iOS element ordering as well as numbered counts of chart components. - /// (See Platform+Accessibility for details) - private let role: NSAccessibility.Role = .list +} - public override init(frame frameRect: NSRect) - { - super.init(frame: frameRect) - setAccessibilityRole(role) - } +extension NSUIRotationGestureRecognizer +{ + /// FIXME: Currently there are no velocities in OSX gestures, and not way to create custom touch gestures. + final var velocity: CGFloat + { + return 0.1 + } - required public init?(coder decoder: NSCoder) + final var nsuiRotation: CGFloat { - super.init(coder: decoder) - setAccessibilityRole(role) - } + get { return -rotation } + set { rotation = -newValue } + } +} - public final override var isFlipped: Bool +extension NSUIPinchGestureRecognizer +{ + final var nsuiScale: CGFloat { - return true - } - - func setNeedsDisplay() + get { - self.setNeedsDisplay(self.bounds) - } - - public final override func touchesBegan(with event: NSEvent) + return magnification + 1.0 + } + set { - self.nsuiTouchesBegan(event.touches(matching: .any, in: self), withEvent: event) - } + magnification = newValue - 1.0 + } + } - public final override func touchesEnded(with event: NSEvent) - { - self.nsuiTouchesEnded(event.touches(matching: .any, in: self), withEvent: event) - } + /// FIXME: Currently there are no more than 1 touch in OSX gestures, and not way to create custom touch gestures. + final func nsuiLocationOfTouch(_ touch: Int, inView view: NSView?) -> NSPoint + { + return super.location(in: view) + } +} - public final override func touchesMoved(with event: NSEvent) - { - self.nsuiTouchesMoved(event.touches(matching: .any, in: self), withEvent: event) - } +extension NSView +{ + final var nsuiGestureRecognizers: [NSGestureRecognizer]? + { + return self.gestureRecognizers + } +} - open override func touchesCancelled(with event: NSEvent) - { - self.nsuiTouchesCancelled(event.touches(matching: .any, in: self), withEvent: event) - } +extension NSScrollView +{ + var nsuiIsScrollEnabled: Bool + { + get { return scrollEnabled } + set { scrollEnabled = newValue } + } +} - open func nsuiTouchesBegan(_ touches: Set, withEvent event: NSUIEvent?) - { - super.touchesBegan(with: event!) - } +open class NSUIView: NSView +{ + /// A private constant to set the accessibility role during initialization. + /// It ensures parity with the iOS element ordering as well as numbered counts of chart components. + /// (See Platform+Accessibility for details) + private let role: NSAccessibility.Role = .list - open func nsuiTouchesMoved(_ touches: Set, withEvent event: NSUIEvent?) - { - super.touchesMoved(with: event!) - } + public override init(frame frameRect: NSRect) + { + super.init(frame: frameRect) + setAccessibilityRole(role) + } - open func nsuiTouchesEnded(_ touches: Set, withEvent event: NSUIEvent?) - { - super.touchesEnded(with: event!) - } + required public init?(coder decoder: NSCoder) + { + super.init(coder: decoder) + setAccessibilityRole(role) + } - open func nsuiTouchesCancelled(_ touches: Set?, withEvent event: NSUIEvent?) - { - super.touchesCancelled(with: event!) - } - - open var backgroundColor: NSUIColor? - { - get - { - return self.layer?.backgroundColor == nil - ? nil - : NSColor(cgColor: self.layer!.backgroundColor!) - } - set - { - self.wantsLayer = true - self.layer?.backgroundColor = newValue == nil ? nil : newValue!.cgColor - } - } + public final override var isFlipped: Bool + { + return true + } - final var nsuiLayer: CALayer? - { - return self.layer - } - } + func setNeedsDisplay() + { + self.setNeedsDisplay(self.bounds) + } - extension NSFont + public final override func touchesBegan(with event: NSEvent) { - var lineHeight: CGFloat - { - // Not sure if this is right, but it looks okay - return self.boundingRectForFont.size.height - } - } + self.nsuiTouchesBegan(event.touches(matching: .any, in: self), withEvent: event) + } - extension NSScreen + public final override func touchesEnded(with event: NSEvent) { - final var nsuiScale: CGFloat - { - return self.backingScaleFactor - } - } + self.nsuiTouchesEnded(event.touches(matching: .any, in: self), withEvent: event) + } - extension NSImage + public final override func touchesMoved(with event: NSEvent) { - var cgImage: CGImage? - { - return self.cgImage(forProposedRect: nil, context: nil, hints: nil) - } - } + self.nsuiTouchesMoved(event.touches(matching: .any, in: self), withEvent: event) + } - extension NSTouch + open override func touchesCancelled(with event: NSEvent) { - /** Touch locations on OS X are relative to the trackpad, whereas on iOS they are actually *on* the view. */ - func locationInView(view: NSView) -> NSPoint - { - let n = self.normalizedPosition - let b = view.bounds - return NSPoint(x: b.origin.x + b.size.width * n.x, y: b.origin.y + b.size.height * n.y) - } - } + self.nsuiTouchesCancelled(event.touches(matching: .any, in: self), withEvent: event) + } - extension NSScrollView + open func nsuiTouchesBegan(_ touches: Set, withEvent event: NSUIEvent?) { - var scrollEnabled: Bool - { - get - { - return true - } - set - { - // FIXME: We can't disable scrolling it on OSX - } - } + super.touchesBegan(with: event!) } - func NSUIGraphicsGetCurrentContext() -> CGContext? + open func nsuiTouchesMoved(_ touches: Set, withEvent event: NSUIEvent?) { - return NSGraphicsContext.current?.cgContext - } + super.touchesMoved(with: event!) + } - func NSUIGraphicsPushContext(_ context: CGContext) + open func nsuiTouchesEnded(_ touches: Set, withEvent event: NSUIEvent?) { - let cx = NSGraphicsContext(cgContext: context, flipped: true) - NSGraphicsContext.saveGraphicsState() - NSGraphicsContext.current = cx - } + super.touchesEnded(with: event!) + } - func NSUIGraphicsPopContext() + open func nsuiTouchesCancelled(_ touches: Set?, withEvent event: NSUIEvent?) { - NSGraphicsContext.restoreGraphicsState() - } + super.touchesCancelled(with: event!) + } - func NSUIImagePNGRepresentation(_ image: NSUIImage) -> Data? + open var backgroundColor: NSUIColor? + { + get + { + return self.layer?.backgroundColor == nil + ? nil + : NSColor(cgColor: self.layer!.backgroundColor!) + } + set + { + self.wantsLayer = true + self.layer?.backgroundColor = newValue == nil ? nil : newValue!.cgColor + } + } + + final var nsuiLayer: CALayer? { - image.lockFocus() - let rep = NSBitmapImageRep(focusedViewRect: NSMakeRect(0, 0, image.size.width, image.size.height)) - image.unlockFocus() - return rep?.representation(using: .png, properties: [:]) - } + return self.layer + } +} - func NSUIImageJPEGRepresentation(_ image: NSUIImage, _ quality: CGFloat = 0.9) -> Data? +extension NSFont +{ + var lineHeight: CGFloat { - image.lockFocus() - let rep = NSBitmapImageRep(focusedViewRect: NSMakeRect(0, 0, image.size.width, image.size.height)) - image.unlockFocus() - return rep?.representation(using: .jpeg, properties: [NSBitmapImageRep.PropertyKey.compressionFactor: quality]) - } + // Not sure if this is right, but it looks okay + return self.boundingRectForFont.size.height + } +} - private var imageContextStack: [CGFloat] = [] +extension NSScreen +{ + final var nsuiScale: CGFloat + { + return self.backingScaleFactor + } +} - func NSUIGraphicsBeginImageContextWithOptions(_ size: CGSize, _ opaque: Bool, _ scale: CGFloat) +extension NSImage +{ + var cgImage: CGImage? { - var scale = scale - if scale == 0.0 - { - scale = NSScreen.main?.backingScaleFactor ?? 1.0 - } + return self.cgImage(forProposedRect: nil, context: nil, hints: nil) + } +} - let width = Int(size.width * scale) - let height = Int(size.height * scale) +extension NSTouch +{ + /** Touch locations on OS X are relative to the trackpad, whereas on iOS they are actually *on* the view. */ + func locationInView(view: NSView) -> NSPoint + { + let n = self.normalizedPosition + let b = view.bounds + return NSPoint(x: b.origin.x + b.size.width * n.x, y: b.origin.y + b.size.height * n.y) + } +} - if width > 0 && height > 0 +extension NSScrollView +{ + var scrollEnabled: Bool + { + get { - imageContextStack.append(scale) - - let colorSpace = CGColorSpaceCreateDeviceRGB() - - guard let ctx = CGContext(data: nil, width: width, height: height, bitsPerComponent: 8, bytesPerRow: 4*width, space: colorSpace, bitmapInfo: (opaque ? CGImageAlphaInfo.noneSkipFirst.rawValue : CGImageAlphaInfo.premultipliedFirst.rawValue)) - else { return } - - ctx.concatenate(CGAffineTransform(a: 1, b: 0, c: 0, d: -1, tx: 0, ty: CGFloat(height))) - ctx.scaleBy(x: scale, y: scale) - NSUIGraphicsPushContext(ctx) - } - } + return true + } + set + { + // FIXME: We can't disable scrolling it on OSX + } + } +} + +func NSUIGraphicsGetCurrentContext() -> CGContext? +{ + return NSGraphicsContext.current?.cgContext +} + +func NSUIGraphicsPushContext(_ context: CGContext) +{ + let cx = NSGraphicsContext(cgContext: context, flipped: true) + NSGraphicsContext.saveGraphicsState() + NSGraphicsContext.current = cx +} + +func NSUIGraphicsPopContext() +{ + NSGraphicsContext.restoreGraphicsState() +} + +func NSUIImagePNGRepresentation(_ image: NSUIImage) -> Data? +{ + image.lockFocus() + let rep = NSBitmapImageRep(focusedViewRect: NSMakeRect(0, 0, image.size.width, image.size.height)) + image.unlockFocus() + return rep?.representation(using: .png, properties: [:]) +} + +func NSUIImageJPEGRepresentation(_ image: NSUIImage, _ quality: CGFloat = 0.9) -> Data? +{ + image.lockFocus() + let rep = NSBitmapImageRep(focusedViewRect: NSMakeRect(0, 0, image.size.width, image.size.height)) + image.unlockFocus() + return rep?.representation(using: .jpeg, properties: [NSBitmapImageRep.PropertyKey.compressionFactor: quality]) +} + +private var imageContextStack: [CGFloat] = [] + +func NSUIGraphicsBeginImageContextWithOptions(_ size: CGSize, _ opaque: Bool, _ scale: CGFloat) +{ + var scale = scale + if scale == 0.0 + { + scale = NSScreen.main?.backingScaleFactor ?? 1.0 + } + + let width = Int(size.width * scale) + let height = Int(size.height * scale) - func NSUIGraphicsGetImageFromCurrentImageContext() -> NSUIImage? + if width > 0 && height > 0 { - if !imageContextStack.isEmpty - { - guard let ctx = NSUIGraphicsGetCurrentContext() - else { return nil } - - let scale = imageContextStack.last! - if let theCGImage = ctx.makeImage() - { - let size = CGSize(width: CGFloat(ctx.width) / scale, height: CGFloat(ctx.height) / scale) - let image = NSImage(cgImage: theCGImage, size: size) - return image - } - } - return nil - } + imageContextStack.append(scale) + + let colorSpace = CGColorSpaceCreateDeviceRGB() + + guard let ctx = CGContext(data: nil, width: width, height: height, bitsPerComponent: 8, bytesPerRow: 4*width, space: colorSpace, bitmapInfo: (opaque ? CGImageAlphaInfo.noneSkipFirst.rawValue : CGImageAlphaInfo.premultipliedFirst.rawValue)) + else { return } - func NSUIGraphicsEndImageContext() + ctx.concatenate(CGAffineTransform(a: 1, b: 0, c: 0, d: -1, tx: 0, ty: CGFloat(height))) + ctx.scaleBy(x: scale, y: scale) + NSUIGraphicsPushContext(ctx) + } +} + +func NSUIGraphicsGetImageFromCurrentImageContext() -> NSUIImage? +{ + if !imageContextStack.isEmpty { - if imageContextStack.last != nil + guard let ctx = NSUIGraphicsGetCurrentContext() + else { return nil } + + let scale = imageContextStack.last! + if let theCGImage = ctx.makeImage() { - imageContextStack.removeLast() - NSUIGraphicsPopContext() - } - } + let size = CGSize(width: CGFloat(ctx.width) / scale, height: CGFloat(ctx.height) / scale) + let image = NSImage(cgImage: theCGImage, size: size) + return image + } + } + return nil +} - func NSUIMainScreen() -> NSUIScreen? +func NSUIGraphicsEndImageContext() +{ + if imageContextStack.last != nil { - return NSUIScreen.main - } - + imageContextStack.removeLast() + NSUIGraphicsPopContext() + } +} + +func NSUIMainScreen() -> NSUIScreen? +{ + return NSUIScreen.main +} + #endif diff --git a/Source/Charts/Utils/Transformer.swift b/Source/Charts/Utils/Transformer.swift index ca99fb2360..b50ea823c5 100644 --- a/Source/Charts/Utils/Transformer.swift +++ b/Source/Charts/Utils/Transformer.swift @@ -69,10 +69,7 @@ open class Transformer: NSObject open func pointValuesToPixel(_ points: inout [CGPoint]) { let trans = valueToPixelMatrix - for i in 0 ..< points.count - { - points[i] = points[i].applying(trans) - } + points = points.map { $0.applying(trans) } } open func pointValueToPixel(_ point: inout CGPoint) @@ -126,22 +123,14 @@ open class Transformer: NSObject open func rectValuesToPixel(_ rects: inout [CGRect]) { let trans = valueToPixelMatrix - - for i in 0 ..< rects.count - { - rects[i] = rects[i].applying(trans) - } + rects = rects.map { $0.applying(trans) } } /// Transforms the given array of touch points (pixels) into values on the chart. open func pixelsToValues(_ pixels: inout [CGPoint]) { let trans = pixelToValueMatrix - - for i in 0 ..< pixels.count - { - pixels[i] = pixels[i].applying(trans) - } + pixels = pixels.map { $0.applying(trans) } } /// Transforms the given touch point (pixels) into a value on the chart. @@ -150,7 +139,7 @@ open class Transformer: NSObject pixel = pixel.applying(pixelToValueMatrix) } - /// - returns: The x and y values in the chart at the given touch point + /// - Returns: The x and y values in the chart at the given touch point /// (encapsulated in a CGPoint). This method transforms pixel coordinates to /// coordinates / values in the chart. @objc open func valueForTouchPoint(_ point: CGPoint) -> CGPoint @@ -158,7 +147,7 @@ open class Transformer: NSObject return point.applying(pixelToValueMatrix) } - /// - returns: The x and y values in the chart at the given touch point + /// - Returns: The x and y values in the chart at the given touch point /// (x/y). This method transforms pixel coordinates to /// coordinates / values in the chart. @objc open func valueForTouchPoint(x: CGFloat, y: CGFloat) -> CGPoint diff --git a/Source/Charts/Utils/ViewPortHandler.swift b/Source/Charts/Utils/ViewPortHandler.swift index 4fde6eca50..56e034b418 100755 --- a/Source/Charts/Utils/ViewPortHandler.swift +++ b/Source/Charts/Utils/ViewPortHandler.swift @@ -443,49 +443,49 @@ open class ViewPortHandler: NSObject return (_contentRect.origin.y + _contentRect.size.height) >= normalizedY } - /// - returns: The current x-scale factor + /// The current x-scale factor @objc open var scaleX: CGFloat { return _scaleX } - /// - returns: The current y-scale factor + /// The current y-scale factor @objc open var scaleY: CGFloat { return _scaleY } - /// - returns: The minimum x-scale factor + /// The minimum x-scale factor @objc open var minScaleX: CGFloat { return _minScaleX } - /// - returns: The minimum y-scale factor + /// The minimum y-scale factor @objc open var minScaleY: CGFloat { return _minScaleY } - /// - returns: The minimum x-scale factor + /// The minimum x-scale factor @objc open var maxScaleX: CGFloat { return _maxScaleX } - /// - returns: The minimum y-scale factor + /// The minimum y-scale factor @objc open var maxScaleY: CGFloat { return _maxScaleY } - /// - returns: The translation (drag / pan) distance on the x-axis + /// The translation (drag / pan) distance on the x-axis @objc open var transX: CGFloat { return _transX } - /// - returns: The translation (drag / pan) distance on the y-axis + /// The translation (drag / pan) distance on the y-axis @objc open var transY: CGFloat { return _transY @@ -497,13 +497,13 @@ open class ViewPortHandler: NSObject return isFullyZoomedOutX && isFullyZoomedOutY } - /// - returns: `true` if the chart is fully zoomed out on it's y-axis (vertical). + /// `true` if the chart is fully zoomed out on it's y-axis (vertical). @objc open var isFullyZoomedOutY: Bool { return !(_scaleY > _minScaleY || _minScaleY > 1.0) } - /// - returns: `true` if the chart is fully zoomed out on it's x-axis (horizontal). + /// `true` if the chart is fully zoomed out on it's x-axis (horizontal). @objc open var isFullyZoomedOutX: Bool { return !(_scaleX > _minScaleX || _minScaleX > 1.0) @@ -521,31 +521,31 @@ open class ViewPortHandler: NSObject _transOffsetY = offset } - /// - returns: `true` if both drag offsets (x and y) are zero or smaller. + /// `true` if both drag offsets (x and y) are zero or smaller. @objc open var hasNoDragOffset: Bool { return _transOffsetX <= 0.0 && _transOffsetY <= 0.0 } - /// - returns: `true` if the chart is not yet fully zoomed out on the x-axis + /// `true` if the chart is not yet fully zoomed out on the x-axis @objc open var canZoomOutMoreX: Bool { return _scaleX > _minScaleX } - /// - returns: `true` if the chart is not yet fully zoomed in on the x-axis + /// `true` if the chart is not yet fully zoomed in on the x-axis @objc open var canZoomInMoreX: Bool { return _scaleX < _maxScaleX } - /// - returns: `true` if the chart is not yet fully zoomed out on the y-axis + /// `true` if the chart is not yet fully zoomed out on the y-axis @objc open var canZoomOutMoreY: Bool { return _scaleY > _minScaleY } - /// - returns: `true` if the chart is not yet fully zoomed in on the y-axis + /// `true` if the chart is not yet fully zoomed in on the y-axis @objc open var canZoomInMoreY: Bool { return _scaleY < _maxScaleY diff --git a/Source/Supporting Files/Info.plist b/Source/Supporting Files/Info.plist index 362330d131..cd18856800 100644 --- a/Source/Supporting Files/Info.plist +++ b/Source/Supporting Files/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 3.2.1 + 3.3.0 CFBundleSignature ???? CFBundleVersion diff --git a/Tests/Charts/BarChartTests.swift b/Tests/Charts/BarChartTests.swift index 67cfab73cb..c27ef6f22e 100644 --- a/Tests/Charts/BarChartTests.swift +++ b/Tests/Charts/BarChartTests.swift @@ -4,88 +4,413 @@ import FBSnapshotTestCase class BarChartTests: FBSnapshotTestCase { - - var chart: BarChartView! - var dataSet: BarChartDataSet! - override func setUp() { super.setUp() // Set to `true` to re-capture all snapshots self.recordMode = false - - // Sample data - let values: [Double] = [8, 104, 81, 93, 52, 44, 97, 101, 75, 28, - 76, 25, 20, 13, 52, 44, 57, 23, 45, 91, - 99, 14, 84, 48, 40, 71, 106, 41, 45, 61] - + } + + override func tearDown() + { + // Put teardown code here. This method is called after the invocation of each test method in the class. + super.tearDown() + } + + //MARK: Prepare + func setupCustomValuesDataEntries(values: [Double]) -> [ChartDataEntry] + { var entries: [ChartDataEntry] = Array() - for (i, value) in values.enumerated() { entries.append(BarChartDataEntry(x: Double(i), y: value, icon: UIImage(named: "icon", in: Bundle(for: self.classForCoder), compatibleWith: nil))) } - - dataSet = BarChartDataSet(values: entries, label: "Bar chart unit test data") + return entries + } + + func setupDefaultValuesDataEntries() -> [ChartDataEntry] + { + let values: [Double] = [8, 104, -81, 93, 52, -44, 97, 101, -75, 28, + -76, 25, 20, -13, 52, 44, -57, 23, 45, -91, + 99, 14, -84, 48, 40, -71, 106, 41, -45, 61] + return setupCustomValuesDataEntries(values: values) + } + + func setupPositiveValuesDataEntries() -> [ChartDataEntry] + { + let values: [Double] = [8, 104, 81, 93, 52, 44, 97, 101, 75, 28, + 76, 25, 20, 13, 52, 44, 57, 23, 45, 91, + 99, 14, 84, 48, 40, 71, 106, 41, 45, 61] + return setupCustomValuesDataEntries(values: values) + } + + func setupNegativeValuesDataEntries() -> [ChartDataEntry] + { + let values: [Double] = [-8, -104, -81, -93, -52, -44, -97, -101, -75, -28, + -76, -25, -20, -13, -52, -44, -57, -23, -45, -91, + -99, -14, -84, -48, -40, -71, -106, -41, -45, -61] + return setupCustomValuesDataEntries(values: values) + } + + func setupZeroValuesDataEntries() -> [ChartDataEntry] + { + let values = [Double](repeating: 0.0, count: 30) + return setupCustomValuesDataEntries(values: values) + } + + func setupStackedValuesDataEntries() -> [ChartDataEntry] + { + var entries: [ChartDataEntry] = Array() + entries.append(BarChartDataEntry(x: 0, yValues: [28, 50, 60, 30, 42], icon: UIImage(named: "icon"))) + entries.append(BarChartDataEntry(x: 1, yValues: [-20, -36, -52, -40, -15], icon: UIImage(named: "icon"))) + entries.append(BarChartDataEntry(x: 2, yValues: [10, 30, 40, 90, 72], icon: UIImage(named: "icon"))) + entries.append(BarChartDataEntry(x: 3, yValues: [-40, -50, -30, -60, -20], icon: UIImage(named: "icon"))) + entries.append(BarChartDataEntry(x: 4, yValues: [10, 40, 60, 45, 62], icon: UIImage(named: "icon"))) + return entries + } + + func setupDefaultStackedDataSet(chartDataEntries: [ChartDataEntry]) -> BarChartDataSet + { + let dataSet = BarChartDataSet(entries: chartDataEntries, label: "Stacked bar chart unit test data") + dataSet.drawIconsEnabled = false + dataSet.iconsOffset = CGPoint(x: 0, y: -10.0) + dataSet.colors = Array(arrayLiteral:NSUIColor(red: 46/255.0, green: 204/255.0, blue: 113/255.0, alpha: 1.0), + NSUIColor(red: 241/255.0, green: 196/255.0, blue: 15/255.0, alpha: 1.0), + NSUIColor(red: 231/255.0, green: 76/255.0, blue: 60/255.0, alpha: 1.0), + NSUIColor(red: 52/255.0, green: 152/255.0, blue: 219/255.0, alpha: 1.0) + ) + return dataSet + } + + func setupDefaultDataSet(chartDataEntries: [ChartDataEntry]) -> BarChartDataSet + { + let dataSet = BarChartDataSet(entries: chartDataEntries, label: "Bar chart unit test data") dataSet.drawIconsEnabled = false dataSet.iconsOffset = CGPoint(x: 0, y: -10.0) + return dataSet + } - let data = BarChartData(dataSet: dataSet) + func setupDefaultChart(dataSets: [BarChartDataSet]) -> BarChartView + { + let data = BarChartData(dataSets: dataSets) data.barWidth = 0.85 - chart = BarChartView(frame: CGRect(x: 0, y: 0, width: 480, height: 350)) + let chart = BarChartView(frame: CGRect(x: 0, y: 0, width: 480, height: 350)) chart.backgroundColor = NSUIColor.clear - chart.leftAxis.axisMinimum = 0.0 - chart.rightAxis.axisMinimum = 0.0 chart.data = data + return chart } - override func tearDown() + //MARK: Start Test + func testDefaultValues() { - // Put teardown code here. This method is called after the invocation of each test method in the class. - super.tearDown() + let dataEntries = setupDefaultValuesDataEntries() + let dataSet = setupDefaultDataSet(chartDataEntries: dataEntries) + let chart = setupDefaultChart(dataSets: [dataSet]) + ChartsSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance) + } - - func testDefaultValues() + + func testDefaultBarDataSetLabels() + { + let dataEntries = setupDefaultValuesDataEntries() + let dataSet = BarChartDataSet(entries: dataEntries) + dataSet.drawIconsEnabled = false + let chart = setupDefaultChart(dataSets: [dataSet]) + ChartsSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance) + } + + func testZeroValues() { - FBSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), tolerance: Snapshot.tolerance) + let dataEntries = setupZeroValuesDataEntries() + let dataSet = setupDefaultDataSet(chartDataEntries: dataEntries) + let chart = setupDefaultChart(dataSets: [dataSet]) + ChartsSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance) } - + + func testPositiveValues() + { + let dataEntries = setupPositiveValuesDataEntries() + let dataSet = setupDefaultDataSet(chartDataEntries: dataEntries) + let chart = setupDefaultChart(dataSets: [dataSet]) + ChartsSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance) + } + + func testPositiveValuesWithCustomAxisMaximum() + { + let dataEntries = setupPositiveValuesDataEntries() + let dataSet = setupDefaultDataSet(chartDataEntries: dataEntries) + let chart = setupDefaultChart(dataSets: [dataSet]) + chart.leftAxis.axisMaximum = 50 + chart.clipValuesToContentEnabled = true + chart.notifyDataSetChanged() + ChartsSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance) + } + + func testPositiveValuesWithCustomAxisMaximum2() + { + let dataEntries = setupPositiveValuesDataEntries() + let dataSet = setupDefaultDataSet(chartDataEntries: dataEntries) + let chart = setupDefaultChart(dataSets: [dataSet]) + chart.leftAxis.axisMaximum = -10 + chart.notifyDataSetChanged() + ChartsSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance) + } + + func testPositiveValuesWithCustomAxisMinimum() + { + let dataEntries = setupPositiveValuesDataEntries() + let dataSet = setupDefaultDataSet(chartDataEntries: dataEntries) + let chart = setupDefaultChart(dataSets: [dataSet]) + chart.leftAxis.axisMinimum = 50 + chart.notifyDataSetChanged() + ChartsSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance) + } + + func testPositiveValuesWithCustomAxisMinimum2() + { + let dataEntries = setupPositiveValuesDataEntries() + let dataSet = setupDefaultDataSet(chartDataEntries: dataEntries) + let chart = setupDefaultChart(dataSets: [dataSet]) + chart.leftAxis.axisMinimum = 110 + chart.notifyDataSetChanged() + ChartsSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance) + } + + func testPositiveValuesWithCustomAxisMaximumAndCustomAxisMaximum() + { + let dataEntries = setupPositiveValuesDataEntries() + let dataSet = setupDefaultDataSet(chartDataEntries: dataEntries) + let chart = setupDefaultChart(dataSets: [dataSet]) + //If min is greater than max, then min and max will be exchanged. + chart.leftAxis.axisMaximum = 200 + chart.leftAxis.axisMinimum = -10 + chart.notifyDataSetChanged() + ChartsSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance) + } + + func testNegativeValues() + { + let dataEntries = setupNegativeValuesDataEntries() + let dataSet = setupDefaultDataSet(chartDataEntries: dataEntries) + let chart = setupDefaultChart(dataSets: [dataSet]) + ChartsSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance) + } + + func testNegativeValuesWithCustomAxisMaximum() + { + let dataEntries = setupNegativeValuesDataEntries() + let dataSet = setupDefaultDataSet(chartDataEntries: dataEntries) + let chart = setupDefaultChart(dataSets: [dataSet]) + chart.leftAxis.axisMaximum = 10 + chart.notifyDataSetChanged() + ChartsSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance) + } + + func testNegativeValuesWithCustomAxisMaximum2() + { + let dataEntries = setupNegativeValuesDataEntries() + let dataSet = setupDefaultDataSet(chartDataEntries: dataEntries) + let chart = setupDefaultChart(dataSets: [dataSet]) + chart.leftAxis.axisMaximum = -150 + chart.notifyDataSetChanged() + ChartsSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance) + } + + + func testNegativeValuesWithCustomAxisMinimum() + { + let dataEntries = setupNegativeValuesDataEntries() + let dataSet = setupDefaultDataSet(chartDataEntries: dataEntries) + let chart = setupDefaultChart(dataSets: [dataSet]) + chart.leftAxis.axisMinimum = -200 + chart.notifyDataSetChanged() + ChartsSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance) + } + + func testNegativeValuesWithCustomAxisMinimum2() + { + let dataEntries = setupNegativeValuesDataEntries() + let dataSet = setupDefaultDataSet(chartDataEntries: dataEntries) + let chart = setupDefaultChart(dataSets: [dataSet]) + chart.leftAxis.axisMinimum = 10 + chart.notifyDataSetChanged() + ChartsSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance) + } + + func testNegativeValuesWithCustomAxisMaximumAndCustomAxisMaximum() + { + let dataEntries = setupNegativeValuesDataEntries() + let dataSet = setupDefaultDataSet(chartDataEntries: dataEntries) + let chart = setupDefaultChart(dataSets: [dataSet]) + //If min is greater than max, then min and max will be exchanged. + chart.leftAxis.axisMaximum = 10 + chart.leftAxis.axisMinimum = -200 + chart.notifyDataSetChanged() + ChartsSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance) + } + func testHidesValues() { + let dataEntries = setupDefaultValuesDataEntries() + let dataSet = setupDefaultDataSet(chartDataEntries: dataEntries) + let chart = setupDefaultChart(dataSets: [dataSet]) dataSet.drawValuesEnabled = false - FBSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), tolerance: Snapshot.tolerance) + chart.notifyDataSetChanged() + ChartsSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance) + } + + func testNotDrawValueAboveBars() + { + let dataEntries = setupDefaultValuesDataEntries() + let dataSet = setupDefaultDataSet(chartDataEntries: dataEntries) + let chart = setupDefaultChart(dataSets: [dataSet]) + chart.drawValueAboveBarEnabled = false + chart.notifyDataSetChanged() + ChartsSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance) + } + + func testStackedDrawValues() + { + let dataEntries = setupStackedValuesDataEntries() + let dataSet = setupDefaultStackedDataSet(chartDataEntries: dataEntries) + let chart = setupDefaultChart(dataSets: [dataSet]) + chart.notifyDataSetChanged() + ChartsSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance) + } + + func testStackedNotDrawValues() + { + let dataEntries = setupStackedValuesDataEntries() + let dataSet = setupDefaultStackedDataSet(chartDataEntries: dataEntries) + dataSet.drawValuesEnabled = false + let chart = setupDefaultChart(dataSets: [dataSet]) + chart.notifyDataSetChanged() + ChartsSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance) + } + + func testStackedNotDrawValuesAboveBars() + { + let dataEntries = setupStackedValuesDataEntries() + let dataSet = setupDefaultStackedDataSet(chartDataEntries: dataEntries) + let chart = setupDefaultChart(dataSets: [dataSet]) + chart.drawValueAboveBarEnabled = false + chart.notifyDataSetChanged() + ChartsSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance) } func testHideLeftAxis() { + let dataEntries = setupDefaultValuesDataEntries() + let dataSet = setupDefaultDataSet(chartDataEntries: dataEntries) + let chart = setupDefaultChart(dataSets: [dataSet]) chart.leftAxis.enabled = false - FBSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), tolerance: Snapshot.tolerance) + chart.notifyDataSetChanged() + ChartsSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance) } func testHideRightAxis() { + let dataEntries = setupDefaultValuesDataEntries() + let dataSet = setupDefaultDataSet(chartDataEntries: dataEntries) + let chart = setupDefaultChart(dataSets: [dataSet]) chart.rightAxis.enabled = false - FBSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), tolerance: Snapshot.tolerance) + chart.notifyDataSetChanged() + ChartsSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance) + } + + func testInvertedLeftAxis() + { + let dataEntries = setupDefaultValuesDataEntries() + let dataSet = setupDefaultDataSet(chartDataEntries: dataEntries) + let chart = setupDefaultChart(dataSets: [dataSet]) + chart.leftAxis.inverted = true + chart.notifyDataSetChanged() + ChartsSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance) + } + + func testInvertedLeftAxisWithNegativeValues() + { + let dataEntries = setupNegativeValuesDataEntries() + let dataSet = setupDefaultDataSet(chartDataEntries: dataEntries) + let chart = setupDefaultChart(dataSets: [dataSet]) + chart.leftAxis.inverted = true + chart.notifyDataSetChanged() + ChartsSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance) + } + + func testInvertedLeftAxisWithPositiveValues() + { + let dataEntries = setupPositiveValuesDataEntries() + let dataSet = setupDefaultDataSet(chartDataEntries: dataEntries) + let chart = setupDefaultChart(dataSets: [dataSet]) + chart.leftAxis.inverted = true + chart.notifyDataSetChanged() + ChartsSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance) + } + + func testInvertedRightAxis() + { + let dataEntries = setupDefaultValuesDataEntries() + let dataSet = setupDefaultDataSet(chartDataEntries: dataEntries) + dataSet.axisDependency = .right + let chart = setupDefaultChart(dataSets: [dataSet]) + chart.rightAxis.inverted = true + chart.notifyDataSetChanged() + ChartsSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance) + } + + func testInvertedRightAxisWithNegativeValues() + { + let dataEntries = setupNegativeValuesDataEntries() + let dataSet = setupDefaultDataSet(chartDataEntries: dataEntries) + dataSet.axisDependency = .right + let chart = setupDefaultChart(dataSets: [dataSet]) + chart.rightAxis.inverted = true + chart.notifyDataSetChanged() + ChartsSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance) + } + + func testInvertedRightAxisWithPositiveValues() + { + let dataEntries = setupPositiveValuesDataEntries() + let dataSet = setupDefaultDataSet(chartDataEntries: dataEntries) + dataSet.axisDependency = .right + let chart = setupDefaultChart(dataSets: [dataSet]) + chart.rightAxis.inverted = true + chart.notifyDataSetChanged() + ChartsSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance) } func testHideHorizontalGridlines() { + let dataEntries = setupDefaultValuesDataEntries() + let dataSet = setupDefaultDataSet(chartDataEntries: dataEntries) + let chart = setupDefaultChart(dataSets: [dataSet]) chart.leftAxis.drawGridLinesEnabled = false chart.rightAxis.drawGridLinesEnabled = false - FBSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), tolerance: Snapshot.tolerance) + chart.notifyDataSetChanged() + ChartsSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance) } func testHideVerticalGridlines() { + let dataEntries = setupDefaultValuesDataEntries() + let dataSet = setupDefaultDataSet(chartDataEntries: dataEntries) + let chart = setupDefaultChart(dataSets: [dataSet]) chart.xAxis.drawGridLinesEnabled = false - FBSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), tolerance: Snapshot.tolerance) + chart.notifyDataSetChanged() + ChartsSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance) } func testDrawIcons() { + let dataEntries = setupDefaultValuesDataEntries() + let dataSet = setupDefaultDataSet(chartDataEntries: dataEntries) + let chart = setupDefaultChart(dataSets: [dataSet]) dataSet.drawIconsEnabled = true - FBSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), tolerance: Snapshot.tolerance) + chart.notifyDataSetChanged() + ChartsSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance) } } diff --git a/Tests/Charts/CombinedChartTests.swift b/Tests/Charts/CombinedChartTests.swift index 269ced6880..9c19f4dcd4 100644 --- a/Tests/Charts/CombinedChartTests.swift +++ b/Tests/Charts/CombinedChartTests.swift @@ -46,7 +46,7 @@ class CombinedChartTests: FBSnapshotTestCase entries.append(BarChartDataEntry(x: Double(i), y: value, icon: UIImage(named: "icon", in: Bundle(for: self.classForCoder), compatibleWith: nil))) } - barDataSet = BarChartDataSet(values: entries, label: "Bar chart unit test data") + barDataSet = BarChartDataSet(entries: entries, label: "Bar chart unit test data") barDataSet.drawIconsEnabled = false let data = BarChartData(dataSet: barDataSet) @@ -67,7 +67,7 @@ class CombinedChartTests: FBSnapshotTestCase entries.append(ChartDataEntry(x: Double(i), y: value, icon: UIImage(named: "icon", in: Bundle(for: self.classForCoder), compatibleWith: nil))) } - lineDataSet = LineChartDataSet(values: entries, label: "Line chart unit test data") + lineDataSet = LineChartDataSet(entries: entries, label: "Line chart unit test data") lineDataSet.drawIconsEnabled = false return LineChartData(dataSet: lineDataSet) } @@ -80,7 +80,7 @@ class CombinedChartTests: FBSnapshotTestCase func testDefaultAxisDependency() { - FBSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), tolerance: Snapshot.tolerance) + ChartsSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance) } func testLeftRightAxisDependency() @@ -89,7 +89,7 @@ class CombinedChartTests: FBSnapshotTestCase barDataSet.axisDependency = .right chart.data?.notifyDataChanged() chart.notifyDataSetChanged() - FBSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), tolerance: Snapshot.tolerance) + ChartsSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance) } func testAllRightAxisDependency() @@ -98,7 +98,7 @@ class CombinedChartTests: FBSnapshotTestCase barDataSet.axisDependency = .right chart.data?.notifyDataChanged() chart.notifyDataSetChanged() - FBSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), tolerance: Snapshot.tolerance) + ChartsSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance) } } diff --git a/Tests/Charts/EquatableTests.swift b/Tests/Charts/EquatableTests.swift index 3d481776dd..26074aa266 100644 --- a/Tests/Charts/EquatableTests.swift +++ b/Tests/Charts/EquatableTests.swift @@ -23,7 +23,7 @@ class EquatableTests: XCTestCase { let data1 = NSObject() let data2 = NSObject() let entry1 = ChartDataEntry(x: 5, y: 3, icon: image, data: data1) - let entry2 = ChartDataEntry(x: 5, y: 3, icon: image, data: data2) + let entry2 = ChartDataEntry(x: 5, y: 9, icon: image, data: data2) XCTAssertFalse(entry1 == entry2) } diff --git a/Tests/Charts/HorizontalBarChartTests.swift b/Tests/Charts/HorizontalBarChartTests.swift new file mode 100644 index 0000000000..1b67a0dd27 --- /dev/null +++ b/Tests/Charts/HorizontalBarChartTests.swift @@ -0,0 +1,147 @@ +// +// HorizontalBarChartTests.swift +// ChartsTests +// +// Created by Xuan Liu on 2019/3/20. +// + +import XCTest +import FBSnapshotTestCase +@testable import Charts + +class HorizontalBarChartTests: FBSnapshotTestCase +{ + + override func setUp() + { + super.setUp() + // Set to `true` to re-capture all snapshots + self.recordMode = false + } + + override func tearDown() + { + // Put teardown code here. This method is called after the invocation of each test method in the class. + super.tearDown() + } + + //MARK: Prepare + func setupCustomValuesDataEntries(values: [Double]) -> [ChartDataEntry] + { + var entries: [ChartDataEntry] = Array() + for (i, value) in values.enumerated() + { + entries.append(BarChartDataEntry(x: Double(i), y: value, icon: UIImage(named: "icon", in: Bundle(for: self.classForCoder), compatibleWith: nil))) + } + return entries + } + + func setupStackedvaluesDataEntries() -> [ChartDataEntry] + { + var entries: [ChartDataEntry] = Array() + entries.append(BarChartDataEntry(x: 0, yValues: [28, 50, 60, 30, 42], icon: UIImage(named: "icon"))) + entries.append(BarChartDataEntry(x: 1, yValues: [-20, -36, -52, -40, -15], icon: UIImage(named: "icon"))) + entries.append(BarChartDataEntry(x: 2, yValues: [10, 30, 40, 90, 72], icon: UIImage(named: "icon"))) + entries.append(BarChartDataEntry(x: 3, yValues: [-40, -50, -30, -60, -20], icon: UIImage(named: "icon"))) + entries.append(BarChartDataEntry(x: 4, yValues: [10, 40, 60, 45, 62], icon: UIImage(named: "icon"))) + return entries + } + + func setupDefaultValuesDataEntries() -> [ChartDataEntry] + { + let values: [Double] = [8, 104, -81, 93, 52, -44, 97, 101, -75, 28, + -76, 25, 20, -13, 52, 44, -57, 23, 45, -91, + 99, 14, -84, 48, 40, -71, 106, 41, -45, 61] + return setupCustomValuesDataEntries(values: values) + } + + func setupDefaultDataSet(chartDataEntries: [ChartDataEntry]) -> BarChartDataSet + { + let dataSet = BarChartDataSet(entries: chartDataEntries, label: "Bar chart unit test data") + dataSet.drawIconsEnabled = false + dataSet.iconsOffset = CGPoint(x: 0, y: -10.0) + return dataSet + } + + func setupDefaultStackedDataSet(chartDataEntries: [ChartDataEntry]) -> BarChartDataSet + { + let dataSet = BarChartDataSet(entries: chartDataEntries, label: "Stacked bar chart unit test data") + dataSet.drawIconsEnabled = false + dataSet.iconsOffset = CGPoint(x: 0, y: -10.0) + dataSet.colors = Array(arrayLiteral:NSUIColor(red: 46/255.0, green: 204/255.0, blue: 113/255.0, alpha: 1.0), + NSUIColor(red: 241/255.0, green: 196/255.0, blue: 15/255.0, alpha: 1.0), + NSUIColor(red: 231/255.0, green: 76/255.0, blue: 60/255.0, alpha: 1.0), + NSUIColor(red: 52/255.0, green: 152/255.0, blue: 219/255.0, alpha: 1.0) + ) + return dataSet + } + + func setupDefaultChart(dataSets: [BarChartDataSet]) -> BarChartView + { + let data = BarChartData(dataSets: dataSets) + data.barWidth = 0.85 + + let chart = HorizontalBarChartView(frame: CGRect(x: 0, y: 0, width: 480, height: 350)) + chart.backgroundColor = NSUIColor.clear + chart.data = data + return chart + } + + //MARK: Start Test + func testDefaultValues() + { + let dataEntries = setupDefaultValuesDataEntries() + let dataSet = setupDefaultDataSet(chartDataEntries: dataEntries) + let chart = setupDefaultChart(dataSets: [dataSet]) + ChartsSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance) + } + + func testHidesValues() + { + let dataEntries = setupDefaultValuesDataEntries() + let dataSet = setupDefaultDataSet(chartDataEntries: dataEntries) + let chart = setupDefaultChart(dataSets: [dataSet]) + dataSet.drawValuesEnabled = false + chart.notifyDataSetChanged() + ChartsSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance) + } + + func testNotDrawValueAboveBars() + { + let dataEntries = setupDefaultValuesDataEntries() + let dataSet = setupDefaultDataSet(chartDataEntries: dataEntries) + let chart = setupDefaultChart(dataSets: [dataSet]) + chart.drawValueAboveBarEnabled = false + chart.notifyDataSetChanged() + ChartsSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance) + } + + func testStackedDrawValues() + { + let dataEntries = setupStackedvaluesDataEntries() + let dataSet = setupDefaultStackedDataSet(chartDataEntries: dataEntries) + let chart = setupDefaultChart(dataSets: [dataSet]) + chart.notifyDataSetChanged() + ChartsSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance) + } + + func testStackedNotDrawValues() + { + let dataEntries = setupStackedvaluesDataEntries() + let dataSet = setupDefaultStackedDataSet(chartDataEntries: dataEntries) + dataSet.drawValuesEnabled = false + let chart = setupDefaultChart(dataSets: [dataSet]) + chart.notifyDataSetChanged() + ChartsSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance) + } + + func testStackedNotDrawValuesAboveBars() + { + let dataEntries = setupStackedvaluesDataEntries() + let dataSet = setupDefaultStackedDataSet(chartDataEntries: dataEntries) + let chart = setupDefaultChart(dataSets: [dataSet]) + chart.drawValueAboveBarEnabled = false + chart.notifyDataSetChanged() + ChartsSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance) + } +} diff --git a/Tests/Charts/LineChartTests.swift b/Tests/Charts/LineChartTests.swift index 26f69c4b7e..98d484a54c 100755 --- a/Tests/Charts/LineChartTests.swift +++ b/Tests/Charts/LineChartTests.swift @@ -27,7 +27,7 @@ class LineChartTests: FBSnapshotTestCase entries.append(ChartDataEntry(x: Double(i), y: value, icon: UIImage(named: "icon", in: Bundle(for: self.classForCoder), compatibleWith: nil))) } - dataSet = LineChartDataSet(values: entries, label: "First unit test data") + dataSet = LineChartDataSet(entries: entries, label: "First unit test data") dataSet.drawIconsEnabled = false dataSet.iconsOffset = CGPoint(x: 0, y: 20.0) @@ -46,36 +46,36 @@ class LineChartTests: FBSnapshotTestCase func testDefaultValues() { - FBSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), tolerance: Snapshot.tolerance) + ChartsSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance) } func testHidesValues() { dataSet.drawValuesEnabled = false - FBSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), tolerance: Snapshot.tolerance) + ChartsSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance) } func testDoesntDrawCircles() { dataSet.drawCirclesEnabled = false - FBSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), tolerance: Snapshot.tolerance) + ChartsSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance) } func testIsCubic() { dataSet.mode = LineChartDataSet.Mode.cubicBezier - FBSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), tolerance: Snapshot.tolerance) + ChartsSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance) } func testDoesntDrawCircleHole() { dataSet.drawCircleHoleEnabled = false - FBSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), tolerance: Snapshot.tolerance) + ChartsSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance) } func testDrawIcons() { dataSet.drawIconsEnabled = true - FBSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), tolerance: Snapshot.tolerance) + ChartsSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance) } } diff --git a/Tests/Charts/PieChartTests.swift b/Tests/Charts/PieChartTests.swift index 8ff8697daa..1ef8051bf0 100644 --- a/Tests/Charts/PieChartTests.swift +++ b/Tests/Charts/PieChartTests.swift @@ -25,7 +25,7 @@ class PieChartTests: FBSnapshotTestCase entries.append(PieChartDataEntry(value: value, icon: UIImage(named: "icon", in: Bundle(for: self.classForCoder), compatibleWith: nil))) } - dataSet = PieChartDataSet(values: entries, label: "First unit test data") + dataSet = PieChartDataSet(entries: entries, label: "First unit test data") dataSet.drawIconsEnabled = false dataSet.iconsOffset = CGPoint(x: 0, y: 20.0) @@ -50,24 +50,24 @@ class PieChartTests: FBSnapshotTestCase func testDefaultValues() { - FBSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), tolerance: Snapshot.tolerance) + ChartsSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance) } func testHidesValues() { dataSet.drawValuesEnabled = false - FBSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), tolerance: Snapshot.tolerance) + ChartsSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance) } func testDrawIcons() { dataSet.drawIconsEnabled = true - FBSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), tolerance: Snapshot.tolerance) + ChartsSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance) } func testHideCenterLabel() { chart.drawCenterTextEnabled = false - FBSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), tolerance: Snapshot.tolerance) + ChartsSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance) } } diff --git a/Tests/Charts/Snapshot.swift b/Tests/Charts/Snapshot.swift index d7d2afe92c..bc1c28cf4e 100644 --- a/Tests/Charts/Snapshot.swift +++ b/Tests/Charts/Snapshot.swift @@ -1,23 +1,29 @@ import CoreGraphics +import FBSnapshotTestCase public struct Snapshot { - public static let tolerance: CGFloat = 0.03 + public static let tolerance: CGFloat = 0.001 public static func identifier(_ size: CGSize) -> String { - - let identifier: String - #if os(tvOS) - identifier = "tvOS" + let identifier = "tvOS" #elseif os(iOS) - identifier = "iOS" + let identifier = "iOS" #elseif os(OSX) - identifier = "macOS" + let identifier = "macOS" #else - identifier = "" + let identifier = "" #endif return "\(identifier)_\(size.width)_\(size.height)" } } + +public extension FBSnapshotTestCase +{ + func ChartsSnapshotVerifyView(_ view: UIView, identifier: String = "", suffixes: NSOrderedSet = NSOrderedSet(object: "_64"), perPixelTolerance: CGFloat = 0, overallTolerance: CGFloat = 0, file: StaticString = #file, line: UInt = #line) + { + FBSnapshotVerifyView(view, identifier: identifier, suffixes: suffixes, perPixelTolerance: perPixelTolerance, overallTolerance: overallTolerance, file: file, line: line) + } +} diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testDefaultBarDataSetLabels_iOS_375_0_667_0@2x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testDefaultBarDataSetLabels_iOS_375_0_667_0@2x.png new file mode 100644 index 0000000000..399cb61016 Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testDefaultBarDataSetLabels_iOS_375_0_667_0@2x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testDefaultBarDataSetLabels_tvOS_1920_0_1080_0@1x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testDefaultBarDataSetLabels_tvOS_1920_0_1080_0@1x.png new file mode 100644 index 0000000000..8804298654 Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testDefaultBarDataSetLabels_tvOS_1920_0_1080_0@1x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testDefaultValues_iOS_1024.0_1366.0@2x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testDefaultValues_iOS_1024.0_1366.0@2x.png deleted file mode 100644 index 4fa72960e0..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testDefaultValues_iOS_1024.0_1366.0@2x.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testDefaultValues_iOS_320.0_568.0@2x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testDefaultValues_iOS_320.0_568.0@2x.png deleted file mode 100644 index 4fa72960e0..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testDefaultValues_iOS_320.0_568.0@2x.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testDefaultValues_iOS_375.0_667.0@2x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testDefaultValues_iOS_375.0_667.0@2x.png deleted file mode 100644 index 4fa72960e0..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testDefaultValues_iOS_375.0_667.0@2x.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testDefaultValues_iOS_375_0_667_0@2x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testDefaultValues_iOS_375_0_667_0@2x.png new file mode 100644 index 0000000000..2d13cec346 Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testDefaultValues_iOS_375_0_667_0@2x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testDefaultValues_iOS_414.0_736.0@3x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testDefaultValues_iOS_414.0_736.0@3x.png deleted file mode 100644 index 6ea7636251..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testDefaultValues_iOS_414.0_736.0@3x.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testDefaultValues_iOS_768.0_1024.0@2x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testDefaultValues_iOS_768.0_1024.0@2x.png deleted file mode 100644 index 4fa72960e0..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testDefaultValues_iOS_768.0_1024.0@2x.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testDefaultValues_iOS_834.0_1112.0@2x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testDefaultValues_iOS_834.0_1112.0@2x.png deleted file mode 100644 index 4fa72960e0..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testDefaultValues_iOS_834.0_1112.0@2x.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testDefaultValues_tvOS_1920.0_1080.0.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testDefaultValues_tvOS_1920.0_1080.0.png deleted file mode 100644 index 4e06aa2c0e..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testDefaultValues_tvOS_1920.0_1080.0.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testDefaultValues_tvOS_1920_0_1080_0@1x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testDefaultValues_tvOS_1920_0_1080_0@1x.png new file mode 100644 index 0000000000..f8f6daa292 Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testDefaultValues_tvOS_1920_0_1080_0@1x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testDrawIcons_iOS_1024.0_1366.0@2x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testDrawIcons_iOS_1024.0_1366.0@2x.png deleted file mode 100644 index 1bcc1abe27..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testDrawIcons_iOS_1024.0_1366.0@2x.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testDrawIcons_iOS_320.0_568.0@2x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testDrawIcons_iOS_320.0_568.0@2x.png deleted file mode 100644 index 1bcc1abe27..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testDrawIcons_iOS_320.0_568.0@2x.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testDrawIcons_iOS_375.0_667.0@2x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testDrawIcons_iOS_375.0_667.0@2x.png deleted file mode 100644 index 1bcc1abe27..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testDrawIcons_iOS_375.0_667.0@2x.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testDrawIcons_iOS_375_0_667_0@2x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testDrawIcons_iOS_375_0_667_0@2x.png new file mode 100644 index 0000000000..ae1b940826 Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testDrawIcons_iOS_375_0_667_0@2x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testDrawIcons_iOS_414.0_736.0@3x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testDrawIcons_iOS_414.0_736.0@3x.png deleted file mode 100644 index fb2572f3b0..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testDrawIcons_iOS_414.0_736.0@3x.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testDrawIcons_iOS_768.0_1024.0@2x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testDrawIcons_iOS_768.0_1024.0@2x.png deleted file mode 100644 index 1bcc1abe27..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testDrawIcons_iOS_768.0_1024.0@2x.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testDrawIcons_iOS_834.0_1112.0@2x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testDrawIcons_iOS_834.0_1112.0@2x.png deleted file mode 100644 index 1bcc1abe27..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testDrawIcons_iOS_834.0_1112.0@2x.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testDrawIcons_tvOS_1920.0_1080.0.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testDrawIcons_tvOS_1920.0_1080.0.png deleted file mode 100644 index 8c4c2944e4..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testDrawIcons_tvOS_1920.0_1080.0.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testDrawIcons_tvOS_1920_0_1080_0@1x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testDrawIcons_tvOS_1920_0_1080_0@1x.png new file mode 100644 index 0000000000..c477eeaf78 Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testDrawIcons_tvOS_1920_0_1080_0@1x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideHorizontalGridlines_iOS_1024.0_1366.0@2x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideHorizontalGridlines_iOS_1024.0_1366.0@2x.png deleted file mode 100644 index acf2f3a8dc..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideHorizontalGridlines_iOS_1024.0_1366.0@2x.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideHorizontalGridlines_iOS_320.0_568.0@2x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideHorizontalGridlines_iOS_320.0_568.0@2x.png deleted file mode 100644 index acf2f3a8dc..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideHorizontalGridlines_iOS_320.0_568.0@2x.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideHorizontalGridlines_iOS_375.0_667.0@2x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideHorizontalGridlines_iOS_375.0_667.0@2x.png deleted file mode 100644 index acf2f3a8dc..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideHorizontalGridlines_iOS_375.0_667.0@2x.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideHorizontalGridlines_iOS_375_0_667_0@2x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideHorizontalGridlines_iOS_375_0_667_0@2x.png new file mode 100644 index 0000000000..93924be46f Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideHorizontalGridlines_iOS_375_0_667_0@2x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideHorizontalGridlines_iOS_414.0_736.0@3x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideHorizontalGridlines_iOS_414.0_736.0@3x.png deleted file mode 100644 index ae1ce8b1f1..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideHorizontalGridlines_iOS_414.0_736.0@3x.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideHorizontalGridlines_iOS_768.0_1024.0@2x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideHorizontalGridlines_iOS_768.0_1024.0@2x.png deleted file mode 100644 index acf2f3a8dc..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideHorizontalGridlines_iOS_768.0_1024.0@2x.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideHorizontalGridlines_iOS_834.0_1112.0@2x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideHorizontalGridlines_iOS_834.0_1112.0@2x.png deleted file mode 100644 index acf2f3a8dc..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideHorizontalGridlines_iOS_834.0_1112.0@2x.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideHorizontalGridlines_tvOS_1920.0_1080.0.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideHorizontalGridlines_tvOS_1920.0_1080.0.png deleted file mode 100644 index 6eecd724d1..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideHorizontalGridlines_tvOS_1920.0_1080.0.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideHorizontalGridlines_tvOS_1920_0_1080_0@1x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideHorizontalGridlines_tvOS_1920_0_1080_0@1x.png new file mode 100644 index 0000000000..bdc61bd13f Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideHorizontalGridlines_tvOS_1920_0_1080_0@1x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideLeftAxis_iOS_1024.0_1366.0@2x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideLeftAxis_iOS_1024.0_1366.0@2x.png deleted file mode 100644 index 152ade81a4..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideLeftAxis_iOS_1024.0_1366.0@2x.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideLeftAxis_iOS_320.0_568.0@2x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideLeftAxis_iOS_320.0_568.0@2x.png deleted file mode 100644 index 152ade81a4..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideLeftAxis_iOS_320.0_568.0@2x.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideLeftAxis_iOS_375.0_667.0@2x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideLeftAxis_iOS_375.0_667.0@2x.png deleted file mode 100644 index 152ade81a4..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideLeftAxis_iOS_375.0_667.0@2x.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideLeftAxis_iOS_375_0_667_0@2x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideLeftAxis_iOS_375_0_667_0@2x.png new file mode 100644 index 0000000000..14f670fe74 Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideLeftAxis_iOS_375_0_667_0@2x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideLeftAxis_iOS_414.0_736.0@3x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideLeftAxis_iOS_414.0_736.0@3x.png deleted file mode 100644 index 96f6010e89..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideLeftAxis_iOS_414.0_736.0@3x.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideLeftAxis_iOS_768.0_1024.0@2x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideLeftAxis_iOS_768.0_1024.0@2x.png deleted file mode 100644 index 152ade81a4..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideLeftAxis_iOS_768.0_1024.0@2x.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideLeftAxis_iOS_834.0_1112.0@2x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideLeftAxis_iOS_834.0_1112.0@2x.png deleted file mode 100644 index 152ade81a4..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideLeftAxis_iOS_834.0_1112.0@2x.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideLeftAxis_tvOS_1920.0_1080.0.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideLeftAxis_tvOS_1920.0_1080.0.png deleted file mode 100644 index 415ddca12d..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideLeftAxis_tvOS_1920.0_1080.0.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideLeftAxis_tvOS_1920_0_1080_0@1x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideLeftAxis_tvOS_1920_0_1080_0@1x.png new file mode 100644 index 0000000000..9f681624e0 Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideLeftAxis_tvOS_1920_0_1080_0@1x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideRightAxis_iOS_1024.0_1366.0@2x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideRightAxis_iOS_1024.0_1366.0@2x.png deleted file mode 100644 index 336c167ec1..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideRightAxis_iOS_1024.0_1366.0@2x.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideRightAxis_iOS_320.0_568.0@2x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideRightAxis_iOS_320.0_568.0@2x.png deleted file mode 100644 index 336c167ec1..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideRightAxis_iOS_320.0_568.0@2x.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideRightAxis_iOS_375.0_667.0@2x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideRightAxis_iOS_375.0_667.0@2x.png deleted file mode 100644 index 336c167ec1..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideRightAxis_iOS_375.0_667.0@2x.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideRightAxis_iOS_375_0_667_0@2x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideRightAxis_iOS_375_0_667_0@2x.png new file mode 100644 index 0000000000..5ae2ca6bf8 Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideRightAxis_iOS_375_0_667_0@2x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideRightAxis_iOS_414.0_736.0@3x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideRightAxis_iOS_414.0_736.0@3x.png deleted file mode 100644 index 9c5b2f8716..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideRightAxis_iOS_414.0_736.0@3x.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideRightAxis_iOS_768.0_1024.0@2x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideRightAxis_iOS_768.0_1024.0@2x.png deleted file mode 100644 index 336c167ec1..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideRightAxis_iOS_768.0_1024.0@2x.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideRightAxis_iOS_834.0_1112.0@2x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideRightAxis_iOS_834.0_1112.0@2x.png deleted file mode 100644 index 336c167ec1..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideRightAxis_iOS_834.0_1112.0@2x.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideRightAxis_tvOS_1920.0_1080.0.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideRightAxis_tvOS_1920.0_1080.0.png deleted file mode 100644 index 5950440138..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideRightAxis_tvOS_1920.0_1080.0.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideRightAxis_tvOS_1920_0_1080_0@1x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideRightAxis_tvOS_1920_0_1080_0@1x.png new file mode 100644 index 0000000000..e2977a0196 Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideRightAxis_tvOS_1920_0_1080_0@1x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideVerticalGridlines_iOS_1024.0_1366.0@2x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideVerticalGridlines_iOS_1024.0_1366.0@2x.png deleted file mode 100644 index 73fa308ea5..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideVerticalGridlines_iOS_1024.0_1366.0@2x.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideVerticalGridlines_iOS_320.0_568.0@2x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideVerticalGridlines_iOS_320.0_568.0@2x.png deleted file mode 100644 index 73fa308ea5..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideVerticalGridlines_iOS_320.0_568.0@2x.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideVerticalGridlines_iOS_375.0_667.0@2x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideVerticalGridlines_iOS_375.0_667.0@2x.png deleted file mode 100644 index 73fa308ea5..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideVerticalGridlines_iOS_375.0_667.0@2x.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideVerticalGridlines_iOS_375_0_667_0@2x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideVerticalGridlines_iOS_375_0_667_0@2x.png new file mode 100644 index 0000000000..8297f68973 Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideVerticalGridlines_iOS_375_0_667_0@2x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideVerticalGridlines_iOS_414.0_736.0@3x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideVerticalGridlines_iOS_414.0_736.0@3x.png deleted file mode 100644 index 0f88d8105b..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideVerticalGridlines_iOS_414.0_736.0@3x.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideVerticalGridlines_iOS_768.0_1024.0@2x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideVerticalGridlines_iOS_768.0_1024.0@2x.png deleted file mode 100644 index 73fa308ea5..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideVerticalGridlines_iOS_768.0_1024.0@2x.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideVerticalGridlines_iOS_834.0_1112.0@2x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideVerticalGridlines_iOS_834.0_1112.0@2x.png deleted file mode 100644 index 73fa308ea5..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideVerticalGridlines_iOS_834.0_1112.0@2x.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideVerticalGridlines_tvOS_1920.0_1080.0.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideVerticalGridlines_tvOS_1920.0_1080.0.png deleted file mode 100644 index f0ace9ca66..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideVerticalGridlines_tvOS_1920.0_1080.0.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideVerticalGridlines_tvOS_1920_0_1080_0@1x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideVerticalGridlines_tvOS_1920_0_1080_0@1x.png new file mode 100644 index 0000000000..9670d546ae Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHideVerticalGridlines_tvOS_1920_0_1080_0@1x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHidesValues_iOS_1024.0_1366.0@2x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHidesValues_iOS_1024.0_1366.0@2x.png deleted file mode 100644 index 5f70a7e7af..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHidesValues_iOS_1024.0_1366.0@2x.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHidesValues_iOS_320.0_568.0@2x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHidesValues_iOS_320.0_568.0@2x.png deleted file mode 100644 index 5f70a7e7af..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHidesValues_iOS_320.0_568.0@2x.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHidesValues_iOS_375.0_667.0@2x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHidesValues_iOS_375.0_667.0@2x.png deleted file mode 100644 index 5f70a7e7af..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHidesValues_iOS_375.0_667.0@2x.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHidesValues_iOS_375_0_667_0@2x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHidesValues_iOS_375_0_667_0@2x.png new file mode 100644 index 0000000000..44f1769c94 Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHidesValues_iOS_375_0_667_0@2x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHidesValues_iOS_414.0_736.0@3x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHidesValues_iOS_414.0_736.0@3x.png deleted file mode 100644 index 2f8e94dda4..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHidesValues_iOS_414.0_736.0@3x.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHidesValues_iOS_768.0_1024.0@2x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHidesValues_iOS_768.0_1024.0@2x.png deleted file mode 100644 index 5f70a7e7af..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHidesValues_iOS_768.0_1024.0@2x.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHidesValues_iOS_834.0_1112.0@2x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHidesValues_iOS_834.0_1112.0@2x.png deleted file mode 100644 index 5f70a7e7af..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHidesValues_iOS_834.0_1112.0@2x.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHidesValues_tvOS_1920.0_1080.0.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHidesValues_tvOS_1920.0_1080.0.png deleted file mode 100644 index 9a4272c255..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHidesValues_tvOS_1920.0_1080.0.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHidesValues_tvOS_1920_0_1080_0@1x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHidesValues_tvOS_1920_0_1080_0@1x.png new file mode 100644 index 0000000000..818a4c0990 Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testHidesValues_tvOS_1920_0_1080_0@1x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testInvertedLeftAxisWithNegativeValues_iOS_375_0_667_0@2x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testInvertedLeftAxisWithNegativeValues_iOS_375_0_667_0@2x.png new file mode 100644 index 0000000000..989f288e05 Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testInvertedLeftAxisWithNegativeValues_iOS_375_0_667_0@2x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testInvertedLeftAxisWithNegativeValues_tvOS_1920_0_1080_0@1x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testInvertedLeftAxisWithNegativeValues_tvOS_1920_0_1080_0@1x.png new file mode 100644 index 0000000000..bd7bd6e4f1 Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testInvertedLeftAxisWithNegativeValues_tvOS_1920_0_1080_0@1x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testInvertedLeftAxisWithPositiveValues_iOS_375_0_667_0@2x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testInvertedLeftAxisWithPositiveValues_iOS_375_0_667_0@2x.png new file mode 100644 index 0000000000..be2ae43dd1 Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testInvertedLeftAxisWithPositiveValues_iOS_375_0_667_0@2x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testInvertedLeftAxisWithPositiveValues_tvOS_1920_0_1080_0@1x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testInvertedLeftAxisWithPositiveValues_tvOS_1920_0_1080_0@1x.png new file mode 100644 index 0000000000..9e4f87071f Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testInvertedLeftAxisWithPositiveValues_tvOS_1920_0_1080_0@1x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testInvertedLeftAxis_iOS_375_0_667_0@2x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testInvertedLeftAxis_iOS_375_0_667_0@2x.png new file mode 100644 index 0000000000..7d27de0629 Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testInvertedLeftAxis_iOS_375_0_667_0@2x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testInvertedLeftAxis_tvOS_1920_0_1080_0@1x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testInvertedLeftAxis_tvOS_1920_0_1080_0@1x.png new file mode 100644 index 0000000000..1788c32029 Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testInvertedLeftAxis_tvOS_1920_0_1080_0@1x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testInvertedRightAxisWithNegativeValues_iOS_375_0_667_0@2x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testInvertedRightAxisWithNegativeValues_iOS_375_0_667_0@2x.png new file mode 100644 index 0000000000..a5191421c1 Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testInvertedRightAxisWithNegativeValues_iOS_375_0_667_0@2x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testInvertedRightAxisWithNegativeValues_tvOS_1920_0_1080_0@1x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testInvertedRightAxisWithNegativeValues_tvOS_1920_0_1080_0@1x.png new file mode 100644 index 0000000000..6e4bff4416 Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testInvertedRightAxisWithNegativeValues_tvOS_1920_0_1080_0@1x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testInvertedRightAxisWithPositiveValues_iOS_375_0_667_0@2x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testInvertedRightAxisWithPositiveValues_iOS_375_0_667_0@2x.png new file mode 100644 index 0000000000..4b4d2df1d7 Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testInvertedRightAxisWithPositiveValues_iOS_375_0_667_0@2x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testInvertedRightAxisWithPositiveValues_tvOS_1920_0_1080_0@1x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testInvertedRightAxisWithPositiveValues_tvOS_1920_0_1080_0@1x.png new file mode 100644 index 0000000000..f9f6d35fb5 Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testInvertedRightAxisWithPositiveValues_tvOS_1920_0_1080_0@1x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testInvertedRightAxis_iOS_375_0_667_0@2x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testInvertedRightAxis_iOS_375_0_667_0@2x.png new file mode 100644 index 0000000000..4c8b73bfb5 Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testInvertedRightAxis_iOS_375_0_667_0@2x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testInvertedRightAxis_tvOS_1920_0_1080_0@1x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testInvertedRightAxis_tvOS_1920_0_1080_0@1x.png new file mode 100644 index 0000000000..ab2974b928 Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testInvertedRightAxis_tvOS_1920_0_1080_0@1x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testNegativeValuesWithCustomAxisMaximum2_iOS_375_0_667_0@2x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testNegativeValuesWithCustomAxisMaximum2_iOS_375_0_667_0@2x.png new file mode 100644 index 0000000000..87604724b5 Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testNegativeValuesWithCustomAxisMaximum2_iOS_375_0_667_0@2x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testNegativeValuesWithCustomAxisMaximum2_tvOS_1920_0_1080_0@1x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testNegativeValuesWithCustomAxisMaximum2_tvOS_1920_0_1080_0@1x.png new file mode 100644 index 0000000000..156d074111 Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testNegativeValuesWithCustomAxisMaximum2_tvOS_1920_0_1080_0@1x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testNegativeValuesWithCustomAxisMaximumAndCustomAxisMaximum_iOS_375_0_667_0@2x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testNegativeValuesWithCustomAxisMaximumAndCustomAxisMaximum_iOS_375_0_667_0@2x.png new file mode 100644 index 0000000000..d04863eb76 Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testNegativeValuesWithCustomAxisMaximumAndCustomAxisMaximum_iOS_375_0_667_0@2x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testNegativeValuesWithCustomAxisMaximumAndCustomAxisMaximum_tvOS_1920_0_1080_0@1x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testNegativeValuesWithCustomAxisMaximumAndCustomAxisMaximum_tvOS_1920_0_1080_0@1x.png new file mode 100644 index 0000000000..aa604e8d4b Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testNegativeValuesWithCustomAxisMaximumAndCustomAxisMaximum_tvOS_1920_0_1080_0@1x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testNegativeValuesWithCustomAxisMaximum_iOS_375_0_667_0@2x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testNegativeValuesWithCustomAxisMaximum_iOS_375_0_667_0@2x.png new file mode 100644 index 0000000000..35f31f74a2 Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testNegativeValuesWithCustomAxisMaximum_iOS_375_0_667_0@2x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testNegativeValuesWithCustomAxisMaximum_tvOS_1920_0_1080_0@1x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testNegativeValuesWithCustomAxisMaximum_tvOS_1920_0_1080_0@1x.png new file mode 100644 index 0000000000..cd859530f2 Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testNegativeValuesWithCustomAxisMaximum_tvOS_1920_0_1080_0@1x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testNegativeValuesWithCustomAxisMinimum2_iOS_375_0_667_0@2x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testNegativeValuesWithCustomAxisMinimum2_iOS_375_0_667_0@2x.png new file mode 100644 index 0000000000..a45e218ca0 Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testNegativeValuesWithCustomAxisMinimum2_iOS_375_0_667_0@2x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testNegativeValuesWithCustomAxisMinimum2_tvOS_1920_0_1080_0@1x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testNegativeValuesWithCustomAxisMinimum2_tvOS_1920_0_1080_0@1x.png new file mode 100644 index 0000000000..f1daca0e9a Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testNegativeValuesWithCustomAxisMinimum2_tvOS_1920_0_1080_0@1x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testNegativeValuesWithCustomAxisMinimum_iOS_375_0_667_0@2x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testNegativeValuesWithCustomAxisMinimum_iOS_375_0_667_0@2x.png new file mode 100644 index 0000000000..ee9fa88517 Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testNegativeValuesWithCustomAxisMinimum_iOS_375_0_667_0@2x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testNegativeValuesWithCustomAxisMinimum_tvOS_1920_0_1080_0@1x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testNegativeValuesWithCustomAxisMinimum_tvOS_1920_0_1080_0@1x.png new file mode 100644 index 0000000000..0790dc3635 Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testNegativeValuesWithCustomAxisMinimum_tvOS_1920_0_1080_0@1x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testNegativeValues_iOS_375_0_667_0@2x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testNegativeValues_iOS_375_0_667_0@2x.png new file mode 100644 index 0000000000..d2eebf4651 Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testNegativeValues_iOS_375_0_667_0@2x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testNegativeValues_tvOS_1920_0_1080_0@1x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testNegativeValues_tvOS_1920_0_1080_0@1x.png new file mode 100644 index 0000000000..75e27ace5a Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testNegativeValues_tvOS_1920_0_1080_0@1x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testNotDrawValueAboveBars_iOS_375_0_667_0@2x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testNotDrawValueAboveBars_iOS_375_0_667_0@2x.png new file mode 100644 index 0000000000..d3a2eaf95f Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testNotDrawValueAboveBars_iOS_375_0_667_0@2x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testNotDrawValueAboveBars_tvOS_1920_0_1080_0@1x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testNotDrawValueAboveBars_tvOS_1920_0_1080_0@1x.png new file mode 100644 index 0000000000..5f129a2025 Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testNotDrawValueAboveBars_tvOS_1920_0_1080_0@1x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testPositiveValuesWithCustomAxisMaximum2_iOS_375_0_667_0@2x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testPositiveValuesWithCustomAxisMaximum2_iOS_375_0_667_0@2x.png new file mode 100644 index 0000000000..c6da33bf15 Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testPositiveValuesWithCustomAxisMaximum2_iOS_375_0_667_0@2x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testPositiveValuesWithCustomAxisMaximum2_tvOS_1920_0_1080_0@1x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testPositiveValuesWithCustomAxisMaximum2_tvOS_1920_0_1080_0@1x.png new file mode 100644 index 0000000000..17040de2ad Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testPositiveValuesWithCustomAxisMaximum2_tvOS_1920_0_1080_0@1x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testPositiveValuesWithCustomAxisMaximumAndCustomAxisMaximum_iOS_375_0_667_0@2x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testPositiveValuesWithCustomAxisMaximumAndCustomAxisMaximum_iOS_375_0_667_0@2x.png new file mode 100644 index 0000000000..f7e8c2b458 Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testPositiveValuesWithCustomAxisMaximumAndCustomAxisMaximum_iOS_375_0_667_0@2x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testPositiveValuesWithCustomAxisMaximumAndCustomAxisMaximum_tvOS_1920_0_1080_0@1x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testPositiveValuesWithCustomAxisMaximumAndCustomAxisMaximum_tvOS_1920_0_1080_0@1x.png new file mode 100644 index 0000000000..1b7585878c Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testPositiveValuesWithCustomAxisMaximumAndCustomAxisMaximum_tvOS_1920_0_1080_0@1x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testPositiveValuesWithCustomAxisMaximum_iOS_375_0_667_0@2x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testPositiveValuesWithCustomAxisMaximum_iOS_375_0_667_0@2x.png new file mode 100644 index 0000000000..fb7664f40d Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testPositiveValuesWithCustomAxisMaximum_iOS_375_0_667_0@2x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testPositiveValuesWithCustomAxisMaximum_tvOS_1920_0_1080_0@1x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testPositiveValuesWithCustomAxisMaximum_tvOS_1920_0_1080_0@1x.png new file mode 100644 index 0000000000..61ae9fc6fa Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testPositiveValuesWithCustomAxisMaximum_tvOS_1920_0_1080_0@1x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testPositiveValuesWithCustomAxisMinimum2_iOS_375_0_667_0@2x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testPositiveValuesWithCustomAxisMinimum2_iOS_375_0_667_0@2x.png new file mode 100644 index 0000000000..b04152cdaa Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testPositiveValuesWithCustomAxisMinimum2_iOS_375_0_667_0@2x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testPositiveValuesWithCustomAxisMinimum2_tvOS_1920_0_1080_0@1x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testPositiveValuesWithCustomAxisMinimum2_tvOS_1920_0_1080_0@1x.png new file mode 100644 index 0000000000..84ae02c122 Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testPositiveValuesWithCustomAxisMinimum2_tvOS_1920_0_1080_0@1x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testPositiveValuesWithCustomAxisMinimum_iOS_375_0_667_0@2x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testPositiveValuesWithCustomAxisMinimum_iOS_375_0_667_0@2x.png new file mode 100644 index 0000000000..df85bd7dae Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testPositiveValuesWithCustomAxisMinimum_iOS_375_0_667_0@2x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testPositiveValuesWithCustomAxisMinimum_tvOS_1920_0_1080_0@1x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testPositiveValuesWithCustomAxisMinimum_tvOS_1920_0_1080_0@1x.png new file mode 100644 index 0000000000..2cd8e7c2d3 Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testPositiveValuesWithCustomAxisMinimum_tvOS_1920_0_1080_0@1x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testPositiveValues_iOS_375_0_667_0@2x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testPositiveValues_iOS_375_0_667_0@2x.png new file mode 100644 index 0000000000..206a06f1ce Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testPositiveValues_iOS_375_0_667_0@2x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testPositiveValues_tvOS_1920_0_1080_0@1x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testPositiveValues_tvOS_1920_0_1080_0@1x.png new file mode 100644 index 0000000000..a097f6038d Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testPositiveValues_tvOS_1920_0_1080_0@1x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testStackedDrawValues_iOS_375_0_667_0@2x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testStackedDrawValues_iOS_375_0_667_0@2x.png new file mode 100644 index 0000000000..1393c5c758 Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testStackedDrawValues_iOS_375_0_667_0@2x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testStackedDrawValues_tvOS_1920_0_1080_0@1x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testStackedDrawValues_tvOS_1920_0_1080_0@1x.png new file mode 100644 index 0000000000..1e92a91c67 Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testStackedDrawValues_tvOS_1920_0_1080_0@1x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testStackedNotDrawValuesAboveBars_iOS_375_0_667_0@2x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testStackedNotDrawValuesAboveBars_iOS_375_0_667_0@2x.png new file mode 100644 index 0000000000..f383efb25c Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testStackedNotDrawValuesAboveBars_iOS_375_0_667_0@2x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testStackedNotDrawValuesAboveBars_tvOS_1920_0_1080_0@1x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testStackedNotDrawValuesAboveBars_tvOS_1920_0_1080_0@1x.png new file mode 100644 index 0000000000..d2f8018308 Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testStackedNotDrawValuesAboveBars_tvOS_1920_0_1080_0@1x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testStackedNotDrawValues_iOS_375_0_667_0@2x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testStackedNotDrawValues_iOS_375_0_667_0@2x.png new file mode 100644 index 0000000000..c856db0dec Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testStackedNotDrawValues_iOS_375_0_667_0@2x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testStackedNotDrawValues_tvOS_1920_0_1080_0@1x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testStackedNotDrawValues_tvOS_1920_0_1080_0@1x.png new file mode 100644 index 0000000000..b2486dc54c Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testStackedNotDrawValues_tvOS_1920_0_1080_0@1x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testZeroValues_iOS_375_0_667_0@2x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testZeroValues_iOS_375_0_667_0@2x.png new file mode 100644 index 0000000000..fdf921d778 Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testZeroValues_iOS_375_0_667_0@2x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testZeroValues_tvOS_1920_0_1080_0@1x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testZeroValues_tvOS_1920_0_1080_0@1x.png new file mode 100644 index 0000000000..00ea37e041 Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testZeroValues_tvOS_1920_0_1080_0@1x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.CombinedChartTests/testAllRightAxisDependency_iOS_375.0_667.0@2x.png b/Tests/ReferenceImages_64/ChartsTests.CombinedChartTests/testAllRightAxisDependency_iOS_375.0_667.0@2x.png deleted file mode 100644 index c4dfe1df09..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.CombinedChartTests/testAllRightAxisDependency_iOS_375.0_667.0@2x.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.CombinedChartTests/testAllRightAxisDependency_iOS_375_0_667_0@2x.png b/Tests/ReferenceImages_64/ChartsTests.CombinedChartTests/testAllRightAxisDependency_iOS_375_0_667_0@2x.png new file mode 100644 index 0000000000..2b165ed72c Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.CombinedChartTests/testAllRightAxisDependency_iOS_375_0_667_0@2x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.CombinedChartTests/testAllRightAxisDependency_tvOS_1920.0_1080.0.png b/Tests/ReferenceImages_64/ChartsTests.CombinedChartTests/testAllRightAxisDependency_tvOS_1920.0_1080.0.png deleted file mode 100644 index 2e4743d92a..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.CombinedChartTests/testAllRightAxisDependency_tvOS_1920.0_1080.0.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.CombinedChartTests/testAllRightAxisDependency_tvOS_1920_0_1080_0@1x.png b/Tests/ReferenceImages_64/ChartsTests.CombinedChartTests/testAllRightAxisDependency_tvOS_1920_0_1080_0@1x.png new file mode 100644 index 0000000000..92d5902097 Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.CombinedChartTests/testAllRightAxisDependency_tvOS_1920_0_1080_0@1x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.CombinedChartTests/testDefaultAxisDependency_iOS_375.0_667.0@2x.png b/Tests/ReferenceImages_64/ChartsTests.CombinedChartTests/testDefaultAxisDependency_iOS_375.0_667.0@2x.png deleted file mode 100644 index c4dfe1df09..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.CombinedChartTests/testDefaultAxisDependency_iOS_375.0_667.0@2x.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.CombinedChartTests/testDefaultAxisDependency_iOS_375_0_667_0@2x.png b/Tests/ReferenceImages_64/ChartsTests.CombinedChartTests/testDefaultAxisDependency_iOS_375_0_667_0@2x.png new file mode 100644 index 0000000000..2b165ed72c Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.CombinedChartTests/testDefaultAxisDependency_iOS_375_0_667_0@2x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.CombinedChartTests/testDefaultAxisDependency_tvOS_1920.0_1080.0.png b/Tests/ReferenceImages_64/ChartsTests.CombinedChartTests/testDefaultAxisDependency_tvOS_1920.0_1080.0.png deleted file mode 100644 index 2e4743d92a..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.CombinedChartTests/testDefaultAxisDependency_tvOS_1920.0_1080.0.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.CombinedChartTests/testDefaultAxisDependency_tvOS_1920_0_1080_0@1x.png b/Tests/ReferenceImages_64/ChartsTests.CombinedChartTests/testDefaultAxisDependency_tvOS_1920_0_1080_0@1x.png new file mode 100644 index 0000000000..92d5902097 Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.CombinedChartTests/testDefaultAxisDependency_tvOS_1920_0_1080_0@1x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.CombinedChartTests/testLeftRightAxisDependency_iOS_375.0_667.0@2x.png b/Tests/ReferenceImages_64/ChartsTests.CombinedChartTests/testLeftRightAxisDependency_iOS_375.0_667.0@2x.png deleted file mode 100644 index 2cd6c9332e..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.CombinedChartTests/testLeftRightAxisDependency_iOS_375.0_667.0@2x.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.CombinedChartTests/testLeftRightAxisDependency_iOS_375_0_667_0@2x.png b/Tests/ReferenceImages_64/ChartsTests.CombinedChartTests/testLeftRightAxisDependency_iOS_375_0_667_0@2x.png new file mode 100644 index 0000000000..c95e14720c Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.CombinedChartTests/testLeftRightAxisDependency_iOS_375_0_667_0@2x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.CombinedChartTests/testLeftRightAxisDependency_tvOS_1920.0_1080.0.png b/Tests/ReferenceImages_64/ChartsTests.CombinedChartTests/testLeftRightAxisDependency_tvOS_1920.0_1080.0.png deleted file mode 100644 index bd033e47b6..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.CombinedChartTests/testLeftRightAxisDependency_tvOS_1920.0_1080.0.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.CombinedChartTests/testLeftRightAxisDependency_tvOS_1920_0_1080_0@1x.png b/Tests/ReferenceImages_64/ChartsTests.CombinedChartTests/testLeftRightAxisDependency_tvOS_1920_0_1080_0@1x.png new file mode 100644 index 0000000000..da55ed12a7 Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.CombinedChartTests/testLeftRightAxisDependency_tvOS_1920_0_1080_0@1x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.HorizontalBarChartTests/testDefaultValues_iOS_375_0_667_0@2x.png b/Tests/ReferenceImages_64/ChartsTests.HorizontalBarChartTests/testDefaultValues_iOS_375_0_667_0@2x.png new file mode 100644 index 0000000000..90f3a6c692 Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.HorizontalBarChartTests/testDefaultValues_iOS_375_0_667_0@2x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.HorizontalBarChartTests/testDefaultValues_tvOS_1920_0_1080_0@1x.png b/Tests/ReferenceImages_64/ChartsTests.HorizontalBarChartTests/testDefaultValues_tvOS_1920_0_1080_0@1x.png new file mode 100644 index 0000000000..843f34edaa Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.HorizontalBarChartTests/testDefaultValues_tvOS_1920_0_1080_0@1x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.HorizontalBarChartTests/testHidesValues_iOS_375_0_667_0@2x.png b/Tests/ReferenceImages_64/ChartsTests.HorizontalBarChartTests/testHidesValues_iOS_375_0_667_0@2x.png new file mode 100644 index 0000000000..320cc39394 Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.HorizontalBarChartTests/testHidesValues_iOS_375_0_667_0@2x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.HorizontalBarChartTests/testHidesValues_tvOS_1920_0_1080_0@1x.png b/Tests/ReferenceImages_64/ChartsTests.HorizontalBarChartTests/testHidesValues_tvOS_1920_0_1080_0@1x.png new file mode 100644 index 0000000000..7a4b2bf8e6 Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.HorizontalBarChartTests/testHidesValues_tvOS_1920_0_1080_0@1x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.HorizontalBarChartTests/testNotDrawValueAboveBars_iOS_375_0_667_0@2x.png b/Tests/ReferenceImages_64/ChartsTests.HorizontalBarChartTests/testNotDrawValueAboveBars_iOS_375_0_667_0@2x.png new file mode 100644 index 0000000000..b95109203a Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.HorizontalBarChartTests/testNotDrawValueAboveBars_iOS_375_0_667_0@2x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.HorizontalBarChartTests/testNotDrawValueAboveBars_tvOS_1920_0_1080_0@1x.png b/Tests/ReferenceImages_64/ChartsTests.HorizontalBarChartTests/testNotDrawValueAboveBars_tvOS_1920_0_1080_0@1x.png new file mode 100644 index 0000000000..b14f98468b Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.HorizontalBarChartTests/testNotDrawValueAboveBars_tvOS_1920_0_1080_0@1x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.HorizontalBarChartTests/testStackedDrawValues_iOS_375_0_667_0@2x.png b/Tests/ReferenceImages_64/ChartsTests.HorizontalBarChartTests/testStackedDrawValues_iOS_375_0_667_0@2x.png new file mode 100644 index 0000000000..26a18cd238 Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.HorizontalBarChartTests/testStackedDrawValues_iOS_375_0_667_0@2x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.HorizontalBarChartTests/testStackedDrawValues_tvOS_1920_0_1080_0@1x.png b/Tests/ReferenceImages_64/ChartsTests.HorizontalBarChartTests/testStackedDrawValues_tvOS_1920_0_1080_0@1x.png new file mode 100644 index 0000000000..9e424a242e Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.HorizontalBarChartTests/testStackedDrawValues_tvOS_1920_0_1080_0@1x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.HorizontalBarChartTests/testStackedNotDrawValuesAboveBars_iOS_375_0_667_0@2x.png b/Tests/ReferenceImages_64/ChartsTests.HorizontalBarChartTests/testStackedNotDrawValuesAboveBars_iOS_375_0_667_0@2x.png new file mode 100644 index 0000000000..7b1b288eb3 Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.HorizontalBarChartTests/testStackedNotDrawValuesAboveBars_iOS_375_0_667_0@2x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.HorizontalBarChartTests/testStackedNotDrawValuesAboveBars_tvOS_1920_0_1080_0@1x.png b/Tests/ReferenceImages_64/ChartsTests.HorizontalBarChartTests/testStackedNotDrawValuesAboveBars_tvOS_1920_0_1080_0@1x.png new file mode 100644 index 0000000000..5426bf3bf8 Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.HorizontalBarChartTests/testStackedNotDrawValuesAboveBars_tvOS_1920_0_1080_0@1x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.HorizontalBarChartTests/testStackedNotDrawValues_iOS_375_0_667_0@2x.png b/Tests/ReferenceImages_64/ChartsTests.HorizontalBarChartTests/testStackedNotDrawValues_iOS_375_0_667_0@2x.png new file mode 100644 index 0000000000..ac27e55519 Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.HorizontalBarChartTests/testStackedNotDrawValues_iOS_375_0_667_0@2x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.HorizontalBarChartTests/testStackedNotDrawValues_tvOS_1920_0_1080_0@1x.png b/Tests/ReferenceImages_64/ChartsTests.HorizontalBarChartTests/testStackedNotDrawValues_tvOS_1920_0_1080_0@1x.png new file mode 100644 index 0000000000..d8d1dac773 Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.HorizontalBarChartTests/testStackedNotDrawValues_tvOS_1920_0_1080_0@1x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDefaultValues_iOS_1024.0_1366.0@2x.png b/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDefaultValues_iOS_1024.0_1366.0@2x.png deleted file mode 100644 index fb0fbbb6fd..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDefaultValues_iOS_1024.0_1366.0@2x.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDefaultValues_iOS_320.0_568.0@2x.png b/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDefaultValues_iOS_320.0_568.0@2x.png deleted file mode 100644 index fb0fbbb6fd..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDefaultValues_iOS_320.0_568.0@2x.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDefaultValues_iOS_375.0_667.0@2x.png b/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDefaultValues_iOS_375.0_667.0@2x.png deleted file mode 100644 index fb0fbbb6fd..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDefaultValues_iOS_375.0_667.0@2x.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDefaultValues_iOS_375_0_667_0@2x.png b/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDefaultValues_iOS_375_0_667_0@2x.png new file mode 100644 index 0000000000..e3e0623a25 Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDefaultValues_iOS_375_0_667_0@2x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDefaultValues_iOS_414.0_736.0@3x.png b/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDefaultValues_iOS_414.0_736.0@3x.png deleted file mode 100644 index 22baef5535..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDefaultValues_iOS_414.0_736.0@3x.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDefaultValues_iOS_768.0_1024.0@2x.png b/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDefaultValues_iOS_768.0_1024.0@2x.png deleted file mode 100644 index fb0fbbb6fd..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDefaultValues_iOS_768.0_1024.0@2x.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDefaultValues_iOS_834.0_1112.0@2x.png b/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDefaultValues_iOS_834.0_1112.0@2x.png deleted file mode 100644 index fb0fbbb6fd..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDefaultValues_iOS_834.0_1112.0@2x.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDefaultValues_tvOS_1920.0_1080.0.png b/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDefaultValues_tvOS_1920.0_1080.0.png deleted file mode 100644 index fe34d94ae5..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDefaultValues_tvOS_1920.0_1080.0.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDefaultValues_tvOS_1920_0_1080_0@1x.png b/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDefaultValues_tvOS_1920_0_1080_0@1x.png new file mode 100644 index 0000000000..5f18666d66 Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDefaultValues_tvOS_1920_0_1080_0@1x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDoesntDrawCircleHole_iOS_1024.0_1366.0@2x.png b/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDoesntDrawCircleHole_iOS_1024.0_1366.0@2x.png deleted file mode 100644 index e10fce4a24..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDoesntDrawCircleHole_iOS_1024.0_1366.0@2x.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDoesntDrawCircleHole_iOS_320.0_568.0@2x.png b/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDoesntDrawCircleHole_iOS_320.0_568.0@2x.png deleted file mode 100644 index e10fce4a24..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDoesntDrawCircleHole_iOS_320.0_568.0@2x.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDoesntDrawCircleHole_iOS_375.0_667.0@2x.png b/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDoesntDrawCircleHole_iOS_375.0_667.0@2x.png deleted file mode 100644 index e10fce4a24..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDoesntDrawCircleHole_iOS_375.0_667.0@2x.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDoesntDrawCircleHole_iOS_375_0_667_0@2x.png b/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDoesntDrawCircleHole_iOS_375_0_667_0@2x.png new file mode 100644 index 0000000000..ad68420bfa Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDoesntDrawCircleHole_iOS_375_0_667_0@2x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDoesntDrawCircleHole_iOS_414.0_736.0@3x.png b/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDoesntDrawCircleHole_iOS_414.0_736.0@3x.png deleted file mode 100644 index 3f23dd060a..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDoesntDrawCircleHole_iOS_414.0_736.0@3x.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDoesntDrawCircleHole_iOS_768.0_1024.0@2x.png b/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDoesntDrawCircleHole_iOS_768.0_1024.0@2x.png deleted file mode 100644 index e10fce4a24..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDoesntDrawCircleHole_iOS_768.0_1024.0@2x.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDoesntDrawCircleHole_iOS_834.0_1112.0@2x.png b/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDoesntDrawCircleHole_iOS_834.0_1112.0@2x.png deleted file mode 100644 index e10fce4a24..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDoesntDrawCircleHole_iOS_834.0_1112.0@2x.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDoesntDrawCircleHole_tvOS_1920.0_1080.0.png b/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDoesntDrawCircleHole_tvOS_1920.0_1080.0.png deleted file mode 100644 index 5936bb95bc..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDoesntDrawCircleHole_tvOS_1920.0_1080.0.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDoesntDrawCircleHole_tvOS_1920_0_1080_0@1x.png b/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDoesntDrawCircleHole_tvOS_1920_0_1080_0@1x.png new file mode 100644 index 0000000000..7cf6e686ee Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDoesntDrawCircleHole_tvOS_1920_0_1080_0@1x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDoesntDrawCircles_iOS_1024.0_1366.0@2x.png b/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDoesntDrawCircles_iOS_1024.0_1366.0@2x.png deleted file mode 100644 index 3be6886354..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDoesntDrawCircles_iOS_1024.0_1366.0@2x.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDoesntDrawCircles_iOS_320.0_568.0@2x.png b/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDoesntDrawCircles_iOS_320.0_568.0@2x.png deleted file mode 100644 index 3be6886354..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDoesntDrawCircles_iOS_320.0_568.0@2x.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDoesntDrawCircles_iOS_375.0_667.0@2x.png b/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDoesntDrawCircles_iOS_375.0_667.0@2x.png deleted file mode 100644 index 3be6886354..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDoesntDrawCircles_iOS_375.0_667.0@2x.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDoesntDrawCircles_iOS_375_0_667_0@2x.png b/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDoesntDrawCircles_iOS_375_0_667_0@2x.png new file mode 100644 index 0000000000..a1f9a77e97 Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDoesntDrawCircles_iOS_375_0_667_0@2x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDoesntDrawCircles_iOS_414.0_736.0@3x.png b/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDoesntDrawCircles_iOS_414.0_736.0@3x.png deleted file mode 100644 index c2e7de0268..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDoesntDrawCircles_iOS_414.0_736.0@3x.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDoesntDrawCircles_iOS_768.0_1024.0@2x.png b/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDoesntDrawCircles_iOS_768.0_1024.0@2x.png deleted file mode 100644 index 3be6886354..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDoesntDrawCircles_iOS_768.0_1024.0@2x.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDoesntDrawCircles_iOS_834.0_1112.0@2x.png b/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDoesntDrawCircles_iOS_834.0_1112.0@2x.png deleted file mode 100644 index 3be6886354..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDoesntDrawCircles_iOS_834.0_1112.0@2x.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDoesntDrawCircles_tvOS_1920.0_1080.0.png b/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDoesntDrawCircles_tvOS_1920.0_1080.0.png deleted file mode 100644 index cc5e828bde..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDoesntDrawCircles_tvOS_1920.0_1080.0.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDoesntDrawCircles_tvOS_1920_0_1080_0@1x.png b/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDoesntDrawCircles_tvOS_1920_0_1080_0@1x.png new file mode 100644 index 0000000000..5300de3bd0 Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDoesntDrawCircles_tvOS_1920_0_1080_0@1x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDrawIcons_iOS_1024.0_1366.0@2x.png b/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDrawIcons_iOS_1024.0_1366.0@2x.png deleted file mode 100644 index c3b51c8a5c..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDrawIcons_iOS_1024.0_1366.0@2x.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDrawIcons_iOS_320.0_568.0@2x.png b/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDrawIcons_iOS_320.0_568.0@2x.png deleted file mode 100644 index c3b51c8a5c..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDrawIcons_iOS_320.0_568.0@2x.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDrawIcons_iOS_375.0_667.0@2x.png b/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDrawIcons_iOS_375.0_667.0@2x.png deleted file mode 100644 index c3b51c8a5c..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDrawIcons_iOS_375.0_667.0@2x.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDrawIcons_iOS_375_0_667_0@2x.png b/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDrawIcons_iOS_375_0_667_0@2x.png new file mode 100644 index 0000000000..659b1b62d2 Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDrawIcons_iOS_375_0_667_0@2x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDrawIcons_iOS_414.0_736.0@3x.png b/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDrawIcons_iOS_414.0_736.0@3x.png deleted file mode 100644 index 210da9dbec..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDrawIcons_iOS_414.0_736.0@3x.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDrawIcons_iOS_768.0_1024.0@2x.png b/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDrawIcons_iOS_768.0_1024.0@2x.png deleted file mode 100644 index c3b51c8a5c..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDrawIcons_iOS_768.0_1024.0@2x.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDrawIcons_iOS_834.0_1112.0@2x.png b/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDrawIcons_iOS_834.0_1112.0@2x.png deleted file mode 100644 index c3b51c8a5c..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDrawIcons_iOS_834.0_1112.0@2x.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDrawIcons_tvOS_1920.0_1080.0.png b/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDrawIcons_tvOS_1920.0_1080.0.png deleted file mode 100644 index 6056592067..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDrawIcons_tvOS_1920.0_1080.0.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDrawIcons_tvOS_1920_0_1080_0@1x.png b/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDrawIcons_tvOS_1920_0_1080_0@1x.png new file mode 100644 index 0000000000..b7202ea64c Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDrawIcons_tvOS_1920_0_1080_0@1x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testHidesValues_iOS_1024.0_1366.0@2x.png b/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testHidesValues_iOS_1024.0_1366.0@2x.png deleted file mode 100644 index 1933882d1c..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testHidesValues_iOS_1024.0_1366.0@2x.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testHidesValues_iOS_320.0_568.0@2x.png b/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testHidesValues_iOS_320.0_568.0@2x.png deleted file mode 100644 index 1933882d1c..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testHidesValues_iOS_320.0_568.0@2x.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testHidesValues_iOS_375.0_667.0@2x.png b/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testHidesValues_iOS_375.0_667.0@2x.png deleted file mode 100644 index 1933882d1c..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testHidesValues_iOS_375.0_667.0@2x.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testHidesValues_iOS_375_0_667_0@2x.png b/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testHidesValues_iOS_375_0_667_0@2x.png new file mode 100644 index 0000000000..2bb6f59d7d Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testHidesValues_iOS_375_0_667_0@2x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testHidesValues_iOS_414.0_736.0@3x.png b/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testHidesValues_iOS_414.0_736.0@3x.png deleted file mode 100644 index 60dc9c7158..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testHidesValues_iOS_414.0_736.0@3x.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testHidesValues_iOS_768.0_1024.0@2x.png b/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testHidesValues_iOS_768.0_1024.0@2x.png deleted file mode 100644 index 1933882d1c..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testHidesValues_iOS_768.0_1024.0@2x.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testHidesValues_iOS_834.0_1112.0@2x.png b/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testHidesValues_iOS_834.0_1112.0@2x.png deleted file mode 100644 index 1933882d1c..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testHidesValues_iOS_834.0_1112.0@2x.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testHidesValues_tvOS_1920.0_1080.0.png b/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testHidesValues_tvOS_1920.0_1080.0.png deleted file mode 100644 index d557d82d07..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testHidesValues_tvOS_1920.0_1080.0.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testHidesValues_tvOS_1920_0_1080_0@1x.png b/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testHidesValues_tvOS_1920_0_1080_0@1x.png new file mode 100644 index 0000000000..2dab9c39d6 Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testHidesValues_tvOS_1920_0_1080_0@1x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testIsCubic_iOS_1024.0_1366.0@2x.png b/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testIsCubic_iOS_1024.0_1366.0@2x.png deleted file mode 100644 index 052e4357f5..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testIsCubic_iOS_1024.0_1366.0@2x.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testIsCubic_iOS_320.0_568.0@2x.png b/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testIsCubic_iOS_320.0_568.0@2x.png deleted file mode 100644 index 052e4357f5..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testIsCubic_iOS_320.0_568.0@2x.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testIsCubic_iOS_375.0_667.0@2x.png b/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testIsCubic_iOS_375.0_667.0@2x.png deleted file mode 100644 index 052e4357f5..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testIsCubic_iOS_375.0_667.0@2x.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testIsCubic_iOS_375_0_667_0@2x.png b/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testIsCubic_iOS_375_0_667_0@2x.png new file mode 100644 index 0000000000..1b0a5898cb Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testIsCubic_iOS_375_0_667_0@2x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testIsCubic_iOS_414.0_736.0@3x.png b/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testIsCubic_iOS_414.0_736.0@3x.png deleted file mode 100644 index 5ec513de31..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testIsCubic_iOS_414.0_736.0@3x.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testIsCubic_iOS_768.0_1024.0@2x.png b/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testIsCubic_iOS_768.0_1024.0@2x.png deleted file mode 100644 index 052e4357f5..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testIsCubic_iOS_768.0_1024.0@2x.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testIsCubic_iOS_834.0_1112.0@2x.png b/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testIsCubic_iOS_834.0_1112.0@2x.png deleted file mode 100644 index 052e4357f5..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testIsCubic_iOS_834.0_1112.0@2x.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testIsCubic_tvOS_1920.0_1080.0.png b/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testIsCubic_tvOS_1920.0_1080.0.png deleted file mode 100644 index 87f57c9d6b..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testIsCubic_tvOS_1920.0_1080.0.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testIsCubic_tvOS_1920_0_1080_0@1x.png b/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testIsCubic_tvOS_1920_0_1080_0@1x.png new file mode 100644 index 0000000000..2ba856164c Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testIsCubic_tvOS_1920_0_1080_0@1x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.PieChartTests/testDefaultValues_iOS_375.0_667.0@2x.png b/Tests/ReferenceImages_64/ChartsTests.PieChartTests/testDefaultValues_iOS_375.0_667.0@2x.png deleted file mode 100644 index 9da0674e15..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.PieChartTests/testDefaultValues_iOS_375.0_667.0@2x.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.PieChartTests/testDefaultValues_iOS_375_0_667_0@2x.png b/Tests/ReferenceImages_64/ChartsTests.PieChartTests/testDefaultValues_iOS_375_0_667_0@2x.png new file mode 100644 index 0000000000..26c56bdf14 Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.PieChartTests/testDefaultValues_iOS_375_0_667_0@2x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.PieChartTests/testDefaultValues_tvOS_1920.0_1080.0.png b/Tests/ReferenceImages_64/ChartsTests.PieChartTests/testDefaultValues_tvOS_1920.0_1080.0.png deleted file mode 100644 index 24894ec72c..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.PieChartTests/testDefaultValues_tvOS_1920.0_1080.0.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.PieChartTests/testDefaultValues_tvOS_1920_0_1080_0@1x.png b/Tests/ReferenceImages_64/ChartsTests.PieChartTests/testDefaultValues_tvOS_1920_0_1080_0@1x.png new file mode 100644 index 0000000000..672cdeb5d6 Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.PieChartTests/testDefaultValues_tvOS_1920_0_1080_0@1x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.PieChartTests/testDrawCenterLabel_iOS_375.0_667.0@2x.png b/Tests/ReferenceImages_64/ChartsTests.PieChartTests/testDrawCenterLabel_iOS_375.0_667.0@2x.png deleted file mode 100644 index 9da0674e15..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.PieChartTests/testDrawCenterLabel_iOS_375.0_667.0@2x.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.PieChartTests/testDrawIcons_iOS_375.0_667.0@2x.png b/Tests/ReferenceImages_64/ChartsTests.PieChartTests/testDrawIcons_iOS_375.0_667.0@2x.png deleted file mode 100644 index 5f909fc896..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.PieChartTests/testDrawIcons_iOS_375.0_667.0@2x.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.PieChartTests/testDrawIcons_iOS_375_0_667_0@2x.png b/Tests/ReferenceImages_64/ChartsTests.PieChartTests/testDrawIcons_iOS_375_0_667_0@2x.png new file mode 100644 index 0000000000..aeaaa7b745 Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.PieChartTests/testDrawIcons_iOS_375_0_667_0@2x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.PieChartTests/testDrawIcons_tvOS_1920.0_1080.0.png b/Tests/ReferenceImages_64/ChartsTests.PieChartTests/testDrawIcons_tvOS_1920.0_1080.0.png deleted file mode 100644 index 82148c58b9..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.PieChartTests/testDrawIcons_tvOS_1920.0_1080.0.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.PieChartTests/testDrawIcons_tvOS_1920_0_1080_0@1x.png b/Tests/ReferenceImages_64/ChartsTests.PieChartTests/testDrawIcons_tvOS_1920_0_1080_0@1x.png new file mode 100644 index 0000000000..ffa5a1847e Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.PieChartTests/testDrawIcons_tvOS_1920_0_1080_0@1x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.PieChartTests/testHideCenterLabel_iOS_375.0_667.0@2x.png b/Tests/ReferenceImages_64/ChartsTests.PieChartTests/testHideCenterLabel_iOS_375.0_667.0@2x.png deleted file mode 100644 index de0bd84c37..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.PieChartTests/testHideCenterLabel_iOS_375.0_667.0@2x.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.PieChartTests/testHideCenterLabel_iOS_375_0_667_0@2x.png b/Tests/ReferenceImages_64/ChartsTests.PieChartTests/testHideCenterLabel_iOS_375_0_667_0@2x.png new file mode 100644 index 0000000000..651ec08a92 Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.PieChartTests/testHideCenterLabel_iOS_375_0_667_0@2x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.PieChartTests/testHideCenterLabel_tvOS_1920.0_1080.0.png b/Tests/ReferenceImages_64/ChartsTests.PieChartTests/testHideCenterLabel_tvOS_1920.0_1080.0.png deleted file mode 100644 index d235b80e0a..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.PieChartTests/testHideCenterLabel_tvOS_1920.0_1080.0.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.PieChartTests/testHideCenterLabel_tvOS_1920_0_1080_0@1x.png b/Tests/ReferenceImages_64/ChartsTests.PieChartTests/testHideCenterLabel_tvOS_1920_0_1080_0@1x.png new file mode 100644 index 0000000000..d97914b7ca Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.PieChartTests/testHideCenterLabel_tvOS_1920_0_1080_0@1x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.PieChartTests/testHidesValues_iOS_375.0_667.0@2x.png b/Tests/ReferenceImages_64/ChartsTests.PieChartTests/testHidesValues_iOS_375.0_667.0@2x.png deleted file mode 100644 index 12225dbef9..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.PieChartTests/testHidesValues_iOS_375.0_667.0@2x.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.PieChartTests/testHidesValues_iOS_375_0_667_0@2x.png b/Tests/ReferenceImages_64/ChartsTests.PieChartTests/testHidesValues_iOS_375_0_667_0@2x.png new file mode 100644 index 0000000000..5d6e0059fc Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.PieChartTests/testHidesValues_iOS_375_0_667_0@2x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.PieChartTests/testHidesValues_tvOS_1920.0_1080.0.png b/Tests/ReferenceImages_64/ChartsTests.PieChartTests/testHidesValues_tvOS_1920.0_1080.0.png deleted file mode 100644 index 59dfa8c1ac..0000000000 Binary files a/Tests/ReferenceImages_64/ChartsTests.PieChartTests/testHidesValues_tvOS_1920.0_1080.0.png and /dev/null differ diff --git a/Tests/ReferenceImages_64/ChartsTests.PieChartTests/testHidesValues_tvOS_1920_0_1080_0@1x.png b/Tests/ReferenceImages_64/ChartsTests.PieChartTests/testHidesValues_tvOS_1920_0_1080_0@1x.png new file mode 100644 index 0000000000..11d04fb97b Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.PieChartTests/testHidesValues_tvOS_1920_0_1080_0@1x.png differ