Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Add missing properties to copy(with:) methods #3715

Merged
merged 2 commits into from
Nov 4, 2018

Conversation

dstranz
Copy link
Contributor

@dstranz dstranz commented Oct 26, 2018

Issue Link 🔗

#3578

Goals ⚽

  • Add missing properties to copy(with:) methods

Implementation Details 🚧

Add any missing property to copy(with:) methods

Testing Details 🔍

I didn't add any tests cases, but if you think it will be valuable let me know.

#hacktoberfest #coinpaprika

@dstranz dstranz changed the title #3578 Add missing properties to copy(with:) methods Add missing properties to copy(with:) methods Oct 26, 2018
@codecov-io
Copy link

codecov-io commented Oct 26, 2018

Codecov Report

Merging #3715 into master will increase coverage by 1.66%.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3715      +/-   ##
==========================================
+ Coverage   31.01%   32.67%   +1.66%     
==========================================
  Files         114      114              
  Lines       10482    10754     +272     
==========================================
+ Hits         3251     3514     +263     
- Misses       7231     7240       +9
Impacted Files Coverage Δ
...Data/Implementations/Standard/ChartDataEntry.swift 56.66% <ø> (ø) ⬆️
...s/Data/Implementations/Standard/ChartDataSet.swift 23.33% <ø> (ø) ⬆️
...ata/Implementations/Standard/BarChartDataSet.swift 62.68% <0%> (-1.93%) ⬇️
...a/Implementations/Standard/BarChartDataEntry.swift 1.96% <0%> (-0.02%) ⬇️
...ata/Implementations/Standard/PieChartDataSet.swift 28.57% <0%> (-18.49%) ⬇️
...ta/Implementations/Standard/LineChartDataSet.swift 30% <0%> (-2.44%) ⬇️
...mplementations/Standard/CandleChartDataEntry.swift 0% <0%> (ø) ⬆️
...Charts/Data/Implementations/ChartBaseDataSet.swift 14.4% <0%> (-1.68%) ⬇️
...Implementations/Standard/ScatterChartDataSet.swift 0% <0%> (ø) ⬆️
.../Implementations/Standard/BubbleChartDataSet.swift 0% <0%> (ø) ⬆️
... and 11 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3b07904...fae3be7. Read the comment docs.

@liuxuan30
Copy link
Member

thanks for this PR. I wonder if this is a complete list for now?

btw, I wonder if there is better ideas/solutions, because people would add new properties without remembering to add in copy(). Either could we tell whether we must add in copy(), or any smart way to auto add, or just by reviewers have to keep it in mind

@jjatie any thoughts

@jjatie
Copy link
Collaborator

jjatie commented Nov 1, 2018

Really, the only way to keep on top of this is to do it by hand. One solution would be to implement the data model as Swift structs, but only expose them through classes. We get copy semantics and only have to add one property to the copy override i.e:

internal struct DataEntry: Equatable {
    let x: Int
    let y: Int
}

@objc
public class ChartDataEntry: NSObject {

    internal private(set) var entry: DataEntry

    var x: Int {
        get { return entry.x }
        set(x) { entry.x = x }
    }
    
    var y: Int {
        get { return entry.y }
        set(y) { entry.y = y }
    }

    func copy(with zone: NSZone? = nil) -> Any {
        let copy = type(of: self).init()
        copy.entry = entry
    }
}

It might be possible too, to create a protocol for this i.e.

protocol DataEntryProtocol {
    var x: { get set }
    var y: { get set }
}

extension DataEntry: DataEntryProtocol { }
extension ChartDataEntry: DataEntryProtocol { }

Then we could update our API to accept the protocol instead of the concrete type. This would allow us to start developing a nicer Swift API, and move objc compatibility into its own library for Charts 4. Charts 5 could drop objc compatibility altogether, and then we can remove the protocol from the library too (possibly).

Obviously this is all outside the scope of this PR, but we should start thinking about way to separate Obj-C functionality from the core lib.

Copy link
Collaborator

@jjatie jjatie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, there is a glaring error in Charts. We aren't actually conforming to NSCopying as the base method we use func copyWithZone(_:) -> AnyObject is not the method the protocol requires.
Please replace this with func copy(with zone: NSZone? = nil) -> Any everywhere in the library it is needed.

@dstranz
Copy link
Contributor Author

dstranz commented Nov 2, 2018

@jjatie I've just added NSCopying conformance to base classes to have compiler validation & changed method names.

@jjatie jjatie merged commit 076f260 into ChartsOrg:master Nov 4, 2018
@dstranz dstranz deleted the feature/missing_properties_copies branch November 5, 2018 07:04
@liuxuan30
Copy link
Member

I can't believe how func copyWithZone(_:) -> AnyObject is added, lol

mtpromano pushed a commit to MobileTradingPartnersLLP/ios-charts that referenced this pull request Jan 22, 2019
…ing/swift-4.2

* commit 'f2795b9813e7e8c2bcdac3f4c3cc74790116999e': (108 commits)
  Remove delegate method call for translation when no translation really occured
  add call chartScaled() after double tap (ChartsOrg#3770)
  fix ChartsOrg#3719
  Update README.md (ChartsOrg#3737)
  Fix applying lineCap value for line chart data sets (Fixes ChartsOrg#3739)
  Fix legend offset bug for horizontal bar chart (Fixes ChartsOrg#3301)
  Add missing properties to copy(with:) methods (ChartsOrg#3715)
  improvements in barRect height calculation  (ChartsOrg#3650)
  Remove meaningless comment
  fix wrong assignment to axisMaxLabels property
  Add missing empty line between Summary and other section manually
  fix casting warnings
  Fix guard statement format.
  Fix memory leak for macOS.
  Update ChartViewBase.swift
  bump version to 3.2.1
  close ChartsOrg#3659: fix index out of bounds issue when using stacked bar chart
  Fix memory leak after rendering
  close ChartsOrg#3661: update podspec to include swift verison
  fix issue ChartsOrg#3662
  ...

# Conflicts:
#	Charts.xcodeproj/project.pbxproj
#	ChartsDemo-iOS/ChartsDemo-iOS.xcodeproj/project.pbxproj
#	ChartsDemo-iOS/Objective-C/Demos/LineChartFilledViewController.m
#	ChartsDemo-iOS/Objective-C/Demos/RadarChartViewController.m
#	ChartsDemo-iOS/Swift/Demos/CandleStickChartViewController.swift
#	Rakefile
#	Source/Charts/Charts/BarLineChartViewBase.swift
#	Source/Charts/Charts/ChartViewBase.swift
#	Source/Charts/Charts/HorizontalBarChartView.swift
#	Source/Charts/Charts/PieChartView.swift
#	Source/Charts/Charts/RadarChartView.swift
#	Source/Charts/Components/Legend.swift
#	Source/Charts/Components/Marker.swift
#	Source/Charts/Components/YAxis.swift
#	Source/Charts/Data/Implementations/ChartBaseDataSet.swift
#	Source/Charts/Data/Implementations/Standard/ChartData.swift
#	Source/Charts/Data/Implementations/Standard/PieChartData.swift
#	Source/Charts/Data/Interfaces/ChartDataSetProtocol.swift
#	Source/Charts/Data/Interfaces/ScatterChartDataSetProtocol.swift
#	Source/Charts/Filters/DataApproximator+N.swift
#	Source/Charts/Formatters/FillFormatter.swift
#	Source/Charts/Formatters/ValueFormatter.swift
#	Source/Charts/Highlight/BarHighlighter.swift
#	Source/Charts/Highlight/ChartHighlighter.swift
#	Source/Charts/Highlight/HorizontalBarHighlighter.swift
#	Source/Charts/Renderers/AxisRendererBase.swift
#	Source/Charts/Renderers/BarChartRenderer.swift
#	Source/Charts/Renderers/BarLineScatterCandleBubbleRenderer.swift
#	Source/Charts/Renderers/BubbleChartRenderer.swift
#	Source/Charts/Renderers/CandleStickChartRenderer.swift
#	Source/Charts/Renderers/ChartDataRendererBase.swift
#	Source/Charts/Renderers/CombinedChartRenderer.swift
#	Source/Charts/Renderers/HorizontalBarChartRenderer.swift
#	Source/Charts/Renderers/LegendRenderer.swift
#	Source/Charts/Renderers/LineChartRenderer.swift
#	Source/Charts/Renderers/PieChartRenderer.swift
#	Source/Charts/Renderers/RadarChartRenderer.swift
#	Source/Charts/Renderers/Renderer.swift
#	Source/Charts/Renderers/ScatterChartRenderer.swift
#	Source/Charts/Renderers/XAxisRenderer.swift
#	Source/Charts/Renderers/XAxisRendererHorizontalBarChart.swift
#	Source/Charts/Renderers/XAxisRendererRadarChart.swift
#	Source/Charts/Renderers/YAxisRenderer.swift
#	Source/Charts/Renderers/YAxisRendererHorizontalBarChart.swift
#	Source/Charts/Renderers/YAxisRendererRadarChart.swift
#	Source/Charts/Utils/ChartUtils.swift
#	Source/Charts/Utils/ViewPortHandler.swift
#	Tests/ReferenceImages_64/ChartsTests.CombinedChartTests/testAllRightAxisDependency_iOS_375.0_667.0@2x.png
#	Tests/ReferenceImages_64/ChartsTests.CombinedChartTests/testAllRightAxisDependency_tvOS_1920.0_1080.0.png
#	Tests/ReferenceImages_64/ChartsTests.CombinedChartTests/testDefaultAxisDependency_iOS_375.0_667.0@2x.png
#	Tests/ReferenceImages_64/ChartsTests.CombinedChartTests/testDefaultAxisDependency_tvOS_1920.0_1080.0.png
#	Tests/ReferenceImages_64/ChartsTests.CombinedChartTests/testLeftRightAxisDependency_iOS_375.0_667.0@2x.png
#	Tests/ReferenceImages_64/ChartsTests.CombinedChartTests/testLeftRightAxisDependency_tvOS_1920.0_1080.0.png
leandropjp added a commit to leandropjp/Charts that referenced this pull request Jun 5, 2019
* Added delegate callback to detect when panning is finished, to potentially allow users to manually reset the hightlight values once panning is complete

* Changed the part of the code where the delegate gets called

* Make NSUIAccessibilityElement initializer public.

* Add Parameters Section

```
(\n[ ]+)(((/// - parameter \w+:.*\s+)(///((\s+)|( \s+.+\s+)))?)*/// - parameter \w+:.*)
```

```
$1/// - Parameters:$1$2
```

* Remove parameter prefix

```
/// - parameter (\w+):(.*)(\s+///(\n))*(\s+)
```

```
///   - $1:$2$4$5
```

* Remove property’s `returns` section

```
/// - returns: (.+\s+((override|@IBOutlet|@objc|weak|unowned|lazy|static|class|open|public|private|fileprivate|internal)(\(set\))? )*(var|let))
```

```
/// $1
```

* Add missing `-`

```
/// (note|return|parameters|throws):
```

```
/// - $1:
```

* Sort sections

```
((///)[ ]+[^-\n]+(\s+))?(((((/// - Parameters:\s+(/// (( - \w+:)|([^-]{1})).*\s+)+)\s+)|(/// - Returns:.*\s+(/// [^-]{1}.*\s+)*)|(/// - Note:.*\s+(/// [^-]{1}.*\s+)*)|(/// - Throws:.*\s+(/// [^-]{1}.*\s+)*))(///\n\s+)?)+)
```

```
$1$2$3$15$7$17$13
```

* Uppercased the section title

* fix function groupBars document error

* Remove duplicated section

* Update ChartViewBase.swift

Updated documentation in the code based on feedback

* Add missing empty line between Summary and other section manually

* fix wrong assignment to axisMaxLabels property

* Remove meaningless comment

* improvements in barRect height calculation  (ChartsOrg#3650)

* fixed barRectCaculation

* fixed offset calculation

* Fix the  mess caused by the setting the min&min value of the y-axis by error :
Just simply swap their values

* Fix the mess caused by the setting the min&min value of the y-axis by error

* Revert "Fix the mess caused by the setting the min&min value of the y-axis by error"

This reverts commit 526a73a.

* Fix the mess caused by the setting the min&min value of the y-axis by error

* update offset calculation

* update code style

* update code style

* update offset calculation

* keep barRect calculation untouched

try to simply the calculation. keep barRect calculation untouched

* After the correction of min and max ,  they should be assigned back to  _axisMinimum and _axisMaximum

* add demo for bar chart unit test

* update unit test

* revert last commit

* update unit test

* make sure max is greater than min &
turnoff record mode for barchartest

* add new UT and fix some issues.

1. add more bar chart UT
2. code style fix
3. manually add chart.notifyDataSetChanged() - some old UT and new ones forget to call this method, leading the test images to be wrong.

Notice:
some test images diff shows slight pixel shift, not sure why, but both old and new image seems drawing correctly

* update tvOS images

* update tolerance to 1% & more swift-y

* update tvOS images, removing "Description Label", (not rendered anymore)

changing tolerance will trigger "Description Label" detection

* update iOS test images, "Description Label" no longer rendered.

* fixed offset calculation in some cases.
moved those codes into the for loop. because the offset of each bar may be different.
(detail in comments)

* Update Source/Charts/Renderers/BarChartRenderer.swift

Co-Authored-By: potato04 <shiww@outlook.com>

* Add missing properties to copy(with:) methods (ChartsOrg#3715)

* ChartsOrg#3578 Add missing properties to copy(with:) methods

* Add NSCopying conformance

* Fix legend offset bug for horizontal bar chart (Fixes ChartsOrg#3301)

* Fix applying lineCap value for line chart data sets (Fixes ChartsOrg#3739)

DataSets for line chart have lineCap property which is supposed to be applied to the chart line. But it was applied only if dataSet is drawn in linear/stepped mode. This commit makes lineCap work for any existing mode.

* Update README.md (ChartsOrg#3737)

Replace a confusing sentence with a clear one. Fix grammatical errors.

* fix ChartsOrg#3719

* add call chartScaled() after double tap (ChartsOrg#3770)

* Remove delegate method call for translation when no translation really occured

* Removed use of `values` where appropriate

* Fixed `addEntry` implementation

* Deprecated direct usage of values

* BarLineScatterCandleBubbleRenderer.XBounds conformance to RangeExpression and Sequence

Sequence conformance simplifies for-in loops
Looking forward to when data types conforming to Collection, RangeExpression conformance by XBounds allows for slicing of the collections further simplifying algorithms on data/datasets.

* Draws the line chart the same way regardless of the number of colors for the data set (ChartsOrg#3764)

* Multiple colors for valueline (Fixes ChartsOrg#3480) (ChartsOrg#3709)

* Multiple colors for valueline (Fixes ChartsOrg#3480)

This change adds a flag matchValueLineColorToPieSlice to PieChartDataSet and IPieChartDataSet protocol.
When enabled, valuelines will have the same color as slices they attached to.
matchValueLineColorToPieSlice is set to false by default, so colors won't be changed in old projects that use Charts.

* Changed variable name from matchValueLineColorToPieSlice to valueLineAutoColor

* Changed variable name from valueLineAutoColor to useValueColorForLine

* Changed variable name from valueLineAutoColor to useValueColorForLine

* fix code style

fix code style

* Changed check for useValueColorForLine with suggested

* fix code style

* Added name DrawLine: to do{} section

* bump version to 3.2.2

* update change log

* Renamed `values` to `entries` to reflect the property's type

Removed arbitrary setter access to `entries` to encourage use of `Collection` mechanics
Added `replaceEntries`

* Fixed tests

* Create "chartViewDidEndAnimate" callback function in "ChartViewBase" that is called when Animator stops animating

* Update protocol function description

* Improve HorizontalBarChart offset calculation for negative value labels (Fixes ChartsOrg#3850)

* Replace AnyObject with Any

This is in line with how Objc interfaces are now imported

* Fixed target on NSUIDisplayLink

* Removed unnecessary #if statements and unified style to align with Xcode's indentation

* Velocity samples calculation (ChartsOrg#3883)

* Updated `PieRadarChartViewBase.sampleVelocity(touchLocation:)` algorithm.

* Updated `PieRadarChartViewBase.calculateVelocity` algorithm

* Updated naming for `_velocitySamples`

* A fix for ChartsOrg#3848. Use a stock iterator instead of a custom one. (ChartsOrg#3891)

* Migrating to built-in algorithms (ChartsOrg#3892)

* Align `ChartLimit.LabelPosition` naming with `UIRectCorner` (ChartsOrg#3846)

* Align `ChartLimit.LabelPosition` naming with `UIRectCorner`

* Fixed Demos

* fix indent after replacing if with guard

* reverted mistaken changes

* Removed unused #if statements

* add animator reference to animatorDidStop ChartViewBase delegate callback.

* Minor updates for Swift 5 (ChartsOrg#3874)

* Minor updates for Swift 5

Need FBSnapshotTestCase to be updated

* Updated testing Framework for Swift 5

bumped minimum deployment version to 8.4

* Bumped Travis Xcode version

* Fix test failures. add a new extension to only use 64bit arch. This is the companion commit that only has code change regards fixing test failures.

* delete unused test images with specific screen size. this is a companion commit to only have deleted files

* rename the in-use test images. this is a companion commit to only have renamed files.

* change image diff to 0.001 tolerance
make clipValuesToContentEnabled to true to fix BarTests:testPositiveValuesWithCustomAxisMaximum() failure

* 1. merge master to fix xBounds iterator() to match the behavior of `stride(from: _xBounds.min, through: _xBounds.range + _xBounds.min, by: 1)`
this fix issues from ChartsOrg@2a1ecb4

2. revert clipValuesToContentEnabled to false by default. but enable it for bar chart test - testPositiveValuesWithCustomAxisMaximum()

3. update tvOS test image for testPositiveValuesWithCustomAxisMaximum. After changing tolerance to 0.001, it fails while the same iOS test pass.
I looked into the image diff, it shows the intersect of bar top edge and axis line at value 50 has diff, but I suppose the image is the same. safe to merge.

* fix ChartsOrg#3860. maxHeight didn't count the last label

* Reassess convenience initializers (ChartsOrg#3862)

* Reassess convenience initializers

The only data required to initialize an entry is an x and y value (or y in the case of Pie and Radar). All other data can easily be updated by initializing and assigning properties on the entry. Therefor, those initializers should be the ones marked as convenience.
Made initializer declarations consistent.

* Modernize BarChartDataEntry internal calculations

* Style updated for PR

* Fix horizontal bar chart not drawing values and add unit tests (ChartsOrg#3906)

* fix horizontal bar chart drawValues not correctly drawing and add testNotDrawValueAboveBars UT

* add unit tests for horizontal bar chart, including default tests and drawValues and drawValuesAboveBars
default data entries included positive and negative values

* add tvOS test images

* add stacked bar tests for bar chart unit tests

* fix typo

* change to guard statement for shouldDrawValues

* update test images to match master branch

* Data as any (ChartsOrg#3863)

* `ChartEntry.data` is now of type `Any`

There is no need to restrict `ChartEntry.data` to `AnyObject`. This PR loosens that restriction. As a result we cannot compare `data`, though this should never have been the case in the first place.

* Updated `ChartDataEntry` initializers to accept `Any` for `data`

* Updated test

* bump version to 3.3

* update change log

* update gemfile

* correct 3.3 to 3.3.0.

* For ChartsOrg#3917. make init(label: String?) convenient initializer (ChartsOrg#3973)

* fix ChartsOrg#3917. make `init(label: String?)` to be a convenient init to enable auto inheritance.

* add UT for default dataSet label
leandropjp added a commit to leandropjp/Charts that referenced this pull request Aug 9, 2019
* Avoid passing NaN to CoreGraphics API (Fixes ChartsOrg#1626)

* Added delegate callback to detect when panning is finished, to potentially allow users to manually reset the hightlight values once panning is complete

* Changed the part of the code where the delegate gets called

* Make NSUIAccessibilityElement initializer public.

* Add Parameters Section

```
(\n[ ]+)(((/// - parameter \w+:.*\s+)(///((\s+)|( \s+.+\s+)))?)*/// - parameter \w+:.*)
```

```
$1/// - Parameters:$1$2
```

* Remove parameter prefix

```
/// - parameter (\w+):(.*)(\s+///(\n))*(\s+)
```

```
///   - $1:$2$4$5
```

* Remove property’s `returns` section

```
/// - returns: (.+\s+((override|@IBOutlet|@objc|weak|unowned|lazy|static|class|open|public|private|fileprivate|internal)(\(set\))? )*(var|let))
```

```
/// $1
```

* Add missing `-`

```
/// (note|return|parameters|throws):
```

```
/// - $1:
```

* Sort sections

```
((///)[ ]+[^-\n]+(\s+))?(((((/// - Parameters:\s+(/// (( - \w+:)|([^-]{1})).*\s+)+)\s+)|(/// - Returns:.*\s+(/// [^-]{1}.*\s+)*)|(/// - Note:.*\s+(/// [^-]{1}.*\s+)*)|(/// - Throws:.*\s+(/// [^-]{1}.*\s+)*))(///\n\s+)?)+)
```

```
$1$2$3$15$7$17$13
```

* Uppercased the section title

* fix function groupBars document error

* Remove duplicated section

* Update ChartViewBase.swift

Updated documentation in the code based on feedback

* Add missing empty line between Summary and other section manually

* fix wrong assignment to axisMaxLabels property

* Remove meaningless comment

* improvements in barRect height calculation  (ChartsOrg#3650)

* fixed barRectCaculation

* fixed offset calculation

* Fix the  mess caused by the setting the min&min value of the y-axis by error :
Just simply swap their values

* Fix the mess caused by the setting the min&min value of the y-axis by error

* Revert "Fix the mess caused by the setting the min&min value of the y-axis by error"

This reverts commit 526a73a.

* Fix the mess caused by the setting the min&min value of the y-axis by error

* update offset calculation

* update code style

* update code style

* update offset calculation

* keep barRect calculation untouched

try to simply the calculation. keep barRect calculation untouched

* After the correction of min and max ,  they should be assigned back to  _axisMinimum and _axisMaximum

* add demo for bar chart unit test

* update unit test

* revert last commit

* update unit test

* make sure max is greater than min &
turnoff record mode for barchartest

* add new UT and fix some issues.

1. add more bar chart UT
2. code style fix
3. manually add chart.notifyDataSetChanged() - some old UT and new ones forget to call this method, leading the test images to be wrong.

Notice:
some test images diff shows slight pixel shift, not sure why, but both old and new image seems drawing correctly

* update tvOS images

* update tolerance to 1% & more swift-y

* update tvOS images, removing "Description Label", (not rendered anymore)

changing tolerance will trigger "Description Label" detection

* update iOS test images, "Description Label" no longer rendered.

* fixed offset calculation in some cases.
moved those codes into the for loop. because the offset of each bar may be different.
(detail in comments)

* Update Source/Charts/Renderers/BarChartRenderer.swift

Co-Authored-By: potato04 <shiww@outlook.com>

* Add missing properties to copy(with:) methods (ChartsOrg#3715)

* ChartsOrg#3578 Add missing properties to copy(with:) methods

* Add NSCopying conformance

* Fix legend offset bug for horizontal bar chart (Fixes ChartsOrg#3301)

* Fix applying lineCap value for line chart data sets (Fixes ChartsOrg#3739)

DataSets for line chart have lineCap property which is supposed to be applied to the chart line. But it was applied only if dataSet is drawn in linear/stepped mode. This commit makes lineCap work for any existing mode.

* Update README.md (ChartsOrg#3737)

Replace a confusing sentence with a clear one. Fix grammatical errors.

* fix ChartsOrg#3719

* add call chartScaled() after double tap (ChartsOrg#3770)

* Remove delegate method call for translation when no translation really occured

* Removed use of `values` where appropriate

* Fixed `addEntry` implementation

* Deprecated direct usage of values

* BarLineScatterCandleBubbleRenderer.XBounds conformance to RangeExpression and Sequence

Sequence conformance simplifies for-in loops
Looking forward to when data types conforming to Collection, RangeExpression conformance by XBounds allows for slicing of the collections further simplifying algorithms on data/datasets.

* Draws the line chart the same way regardless of the number of colors for the data set (ChartsOrg#3764)

* Multiple colors for valueline (Fixes ChartsOrg#3480) (ChartsOrg#3709)

* Multiple colors for valueline (Fixes ChartsOrg#3480)

This change adds a flag matchValueLineColorToPieSlice to PieChartDataSet and IPieChartDataSet protocol.
When enabled, valuelines will have the same color as slices they attached to.
matchValueLineColorToPieSlice is set to false by default, so colors won't be changed in old projects that use Charts.

* Changed variable name from matchValueLineColorToPieSlice to valueLineAutoColor

* Changed variable name from valueLineAutoColor to useValueColorForLine

* Changed variable name from valueLineAutoColor to useValueColorForLine

* fix code style

fix code style

* Changed check for useValueColorForLine with suggested

* fix code style

* Added name DrawLine: to do{} section

* bump version to 3.2.2

* update change log

* Renamed `values` to `entries` to reflect the property's type

Removed arbitrary setter access to `entries` to encourage use of `Collection` mechanics
Added `replaceEntries`

* Fixed tests

* Create "chartViewDidEndAnimate" callback function in "ChartViewBase" that is called when Animator stops animating

* Update protocol function description

* Improve HorizontalBarChart offset calculation for negative value labels (Fixes ChartsOrg#3850)

* Replace AnyObject with Any

This is in line with how Objc interfaces are now imported

* Fixed target on NSUIDisplayLink

* Removed unnecessary #if statements and unified style to align with Xcode's indentation

* Velocity samples calculation (ChartsOrg#3883)

* Updated `PieRadarChartViewBase.sampleVelocity(touchLocation:)` algorithm.

* Updated `PieRadarChartViewBase.calculateVelocity` algorithm

* Updated naming for `_velocitySamples`

* A fix for ChartsOrg#3848. Use a stock iterator instead of a custom one. (ChartsOrg#3891)

* Migrating to built-in algorithms (ChartsOrg#3892)

* Align `ChartLimit.LabelPosition` naming with `UIRectCorner` (ChartsOrg#3846)

* Align `ChartLimit.LabelPosition` naming with `UIRectCorner`

* Fixed Demos

* fix indent after replacing if with guard

* reverted mistaken changes

* Removed unused #if statements

* add animator reference to animatorDidStop ChartViewBase delegate callback.

* Minor updates for Swift 5 (ChartsOrg#3874)

* Minor updates for Swift 5

Need FBSnapshotTestCase to be updated

* Updated testing Framework for Swift 5

bumped minimum deployment version to 8.4

* Bumped Travis Xcode version

* Fix test failures. add a new extension to only use 64bit arch. This is the companion commit that only has code change regards fixing test failures.

* delete unused test images with specific screen size. this is a companion commit to only have deleted files

* rename the in-use test images. this is a companion commit to only have renamed files.

* change image diff to 0.001 tolerance
make clipValuesToContentEnabled to true to fix BarTests:testPositiveValuesWithCustomAxisMaximum() failure

* 1. merge master to fix xBounds iterator() to match the behavior of `stride(from: _xBounds.min, through: _xBounds.range + _xBounds.min, by: 1)`
this fix issues from ChartsOrg@2a1ecb4

2. revert clipValuesToContentEnabled to false by default. but enable it for bar chart test - testPositiveValuesWithCustomAxisMaximum()

3. update tvOS test image for testPositiveValuesWithCustomAxisMaximum. After changing tolerance to 0.001, it fails while the same iOS test pass.
I looked into the image diff, it shows the intersect of bar top edge and axis line at value 50 has diff, but I suppose the image is the same. safe to merge.

* fix ChartsOrg#3860. maxHeight didn't count the last label

* Reassess convenience initializers (ChartsOrg#3862)

* Reassess convenience initializers

The only data required to initialize an entry is an x and y value (or y in the case of Pie and Radar). All other data can easily be updated by initializing and assigning properties on the entry. Therefor, those initializers should be the ones marked as convenience.
Made initializer declarations consistent.

* Modernize BarChartDataEntry internal calculations

* Style updated for PR

* Fix horizontal bar chart not drawing values and add unit tests (ChartsOrg#3906)

* fix horizontal bar chart drawValues not correctly drawing and add testNotDrawValueAboveBars UT

* add unit tests for horizontal bar chart, including default tests and drawValues and drawValuesAboveBars
default data entries included positive and negative values

* add tvOS test images

* add stacked bar tests for bar chart unit tests

* fix typo

* change to guard statement for shouldDrawValues

* update test images to match master branch

* Data as any (ChartsOrg#3863)

* `ChartEntry.data` is now of type `Any`

There is no need to restrict `ChartEntry.data` to `AnyObject`. This PR loosens that restriction. As a result we cannot compare `data`, though this should never have been the case in the first place.

* Updated `ChartDataEntry` initializers to accept `Any` for `data`

* Updated test

* bump version to 3.3

* update change log

* update gemfile

* correct 3.3 to 3.3.0.

* For ChartsOrg#3917. make init(label: String?) convenient initializer (ChartsOrg#3973)

* fix ChartsOrg#3917. make `init(label: String?)` to be a convenient init to enable auto inheritance.

* add UT for default dataSet label

* Added a safety check before an unsafe array operation

* Update Info.plist

* Update License

Changed year in license file

* fixed stacked chart bug when there are different stacks on columns. (ChartsOrg#4029)

fix ChartsOrg#3659
* fixed stacked chart bug when there are different stacks on columns.
* added empty array check
leandropjp added a commit to leandropjp/Charts that referenced this pull request Nov 1, 2019
* Avoid passing NaN to CoreGraphics API (Fixes ChartsOrg#1626)

* Added delegate callback to detect when panning is finished, to potentially allow users to manually reset the hightlight values once panning is complete

* Changed the part of the code where the delegate gets called

* Make NSUIAccessibilityElement initializer public.

* Add Parameters Section

```
(\n[ ]+)(((/// - parameter \w+:.*\s+)(///((\s+)|( \s+.+\s+)))?)*/// - parameter \w+:.*)
```

```
$1/// - Parameters:$1$2
```

* Remove parameter prefix

```
/// - parameter (\w+):(.*)(\s+///(\n))*(\s+)
```

```
///   - $1:$2$4$5
```

* Remove property’s `returns` section

```
/// - returns: (.+\s+((override|@IBOutlet|@objc|weak|unowned|lazy|static|class|open|public|private|fileprivate|internal)(\(set\))? )*(var|let))
```

```
/// $1
```

* Add missing `-`

```
/// (note|return|parameters|throws):
```

```
/// - $1:
```

* Sort sections

```
((///)[ ]+[^-\n]+(\s+))?(((((/// - Parameters:\s+(/// (( - \w+:)|([^-]{1})).*\s+)+)\s+)|(/// - Returns:.*\s+(/// [^-]{1}.*\s+)*)|(/// - Note:.*\s+(/// [^-]{1}.*\s+)*)|(/// - Throws:.*\s+(/// [^-]{1}.*\s+)*))(///\n\s+)?)+)
```

```
$1$2$3$15$7$17$13
```

* Uppercased the section title

* fix function groupBars document error

* Remove duplicated section

* Update ChartViewBase.swift

Updated documentation in the code based on feedback

* Add missing empty line between Summary and other section manually

* fix wrong assignment to axisMaxLabels property

* Remove meaningless comment

* improvements in barRect height calculation  (ChartsOrg#3650)

* fixed barRectCaculation

* fixed offset calculation

* Fix the  mess caused by the setting the min&min value of the y-axis by error :
Just simply swap their values

* Fix the mess caused by the setting the min&min value of the y-axis by error

* Revert "Fix the mess caused by the setting the min&min value of the y-axis by error"

This reverts commit 526a73a.

* Fix the mess caused by the setting the min&min value of the y-axis by error

* update offset calculation

* update code style

* update code style

* update offset calculation

* keep barRect calculation untouched

try to simply the calculation. keep barRect calculation untouched

* After the correction of min and max ,  they should be assigned back to  _axisMinimum and _axisMaximum

* add demo for bar chart unit test

* update unit test

* revert last commit

* update unit test

* make sure max is greater than min &
turnoff record mode for barchartest

* add new UT and fix some issues.

1. add more bar chart UT
2. code style fix
3. manually add chart.notifyDataSetChanged() - some old UT and new ones forget to call this method, leading the test images to be wrong.

Notice:
some test images diff shows slight pixel shift, not sure why, but both old and new image seems drawing correctly

* update tvOS images

* update tolerance to 1% & more swift-y

* update tvOS images, removing "Description Label", (not rendered anymore)

changing tolerance will trigger "Description Label" detection

* update iOS test images, "Description Label" no longer rendered.

* fixed offset calculation in some cases.
moved those codes into the for loop. because the offset of each bar may be different.
(detail in comments)

* Update Source/Charts/Renderers/BarChartRenderer.swift

Co-Authored-By: potato04 <shiww@outlook.com>

* Add missing properties to copy(with:) methods (ChartsOrg#3715)

* ChartsOrg#3578 Add missing properties to copy(with:) methods

* Add NSCopying conformance

* Fix legend offset bug for horizontal bar chart (Fixes ChartsOrg#3301)

* Fix applying lineCap value for line chart data sets (Fixes ChartsOrg#3739)

DataSets for line chart have lineCap property which is supposed to be applied to the chart line. But it was applied only if dataSet is drawn in linear/stepped mode. This commit makes lineCap work for any existing mode.

* Update README.md (ChartsOrg#3737)

Replace a confusing sentence with a clear one. Fix grammatical errors.

* fix ChartsOrg#3719

* add call chartScaled() after double tap (ChartsOrg#3770)

* Remove delegate method call for translation when no translation really occured

* Removed use of `values` where appropriate

* Fixed `addEntry` implementation

* Deprecated direct usage of values

* BarLineScatterCandleBubbleRenderer.XBounds conformance to RangeExpression and Sequence

Sequence conformance simplifies for-in loops
Looking forward to when data types conforming to Collection, RangeExpression conformance by XBounds allows for slicing of the collections further simplifying algorithms on data/datasets.

* Draws the line chart the same way regardless of the number of colors for the data set (ChartsOrg#3764)

* Multiple colors for valueline (Fixes ChartsOrg#3480) (ChartsOrg#3709)

* Multiple colors for valueline (Fixes ChartsOrg#3480)

This change adds a flag matchValueLineColorToPieSlice to PieChartDataSet and IPieChartDataSet protocol.
When enabled, valuelines will have the same color as slices they attached to.
matchValueLineColorToPieSlice is set to false by default, so colors won't be changed in old projects that use Charts.

* Changed variable name from matchValueLineColorToPieSlice to valueLineAutoColor

* Changed variable name from valueLineAutoColor to useValueColorForLine

* Changed variable name from valueLineAutoColor to useValueColorForLine

* fix code style

fix code style

* Changed check for useValueColorForLine with suggested

* fix code style

* Added name DrawLine: to do{} section

* bump version to 3.2.2

* update change log

* Renamed `values` to `entries` to reflect the property's type

Removed arbitrary setter access to `entries` to encourage use of `Collection` mechanics
Added `replaceEntries`

* Fixed tests

* Create "chartViewDidEndAnimate" callback function in "ChartViewBase" that is called when Animator stops animating

* Update protocol function description

* Improve HorizontalBarChart offset calculation for negative value labels (Fixes ChartsOrg#3850)

* Replace AnyObject with Any

This is in line with how Objc interfaces are now imported

* Fixed target on NSUIDisplayLink

* Removed unnecessary #if statements and unified style to align with Xcode's indentation

* Velocity samples calculation (ChartsOrg#3883)

* Updated `PieRadarChartViewBase.sampleVelocity(touchLocation:)` algorithm.

* Updated `PieRadarChartViewBase.calculateVelocity` algorithm

* Updated naming for `_velocitySamples`

* A fix for ChartsOrg#3848. Use a stock iterator instead of a custom one. (ChartsOrg#3891)

* Migrating to built-in algorithms (ChartsOrg#3892)

* Align `ChartLimit.LabelPosition` naming with `UIRectCorner` (ChartsOrg#3846)

* Align `ChartLimit.LabelPosition` naming with `UIRectCorner`

* Fixed Demos

* fix indent after replacing if with guard

* reverted mistaken changes

* Removed unused #if statements

* add animator reference to animatorDidStop ChartViewBase delegate callback.

* Minor updates for Swift 5 (ChartsOrg#3874)

* Minor updates for Swift 5

Need FBSnapshotTestCase to be updated

* Updated testing Framework for Swift 5

bumped minimum deployment version to 8.4

* Bumped Travis Xcode version

* Fix test failures. add a new extension to only use 64bit arch. This is the companion commit that only has code change regards fixing test failures.

* delete unused test images with specific screen size. this is a companion commit to only have deleted files

* rename the in-use test images. this is a companion commit to only have renamed files.

* change image diff to 0.001 tolerance
make clipValuesToContentEnabled to true to fix BarTests:testPositiveValuesWithCustomAxisMaximum() failure

* 1. merge master to fix xBounds iterator() to match the behavior of `stride(from: _xBounds.min, through: _xBounds.range + _xBounds.min, by: 1)`
this fix issues from ChartsOrg@2a1ecb4

2. revert clipValuesToContentEnabled to false by default. but enable it for bar chart test - testPositiveValuesWithCustomAxisMaximum()

3. update tvOS test image for testPositiveValuesWithCustomAxisMaximum. After changing tolerance to 0.001, it fails while the same iOS test pass.
I looked into the image diff, it shows the intersect of bar top edge and axis line at value 50 has diff, but I suppose the image is the same. safe to merge.

* fix ChartsOrg#3860. maxHeight didn't count the last label

* Reassess convenience initializers (ChartsOrg#3862)

* Reassess convenience initializers

The only data required to initialize an entry is an x and y value (or y in the case of Pie and Radar). All other data can easily be updated by initializing and assigning properties on the entry. Therefor, those initializers should be the ones marked as convenience.
Made initializer declarations consistent.

* Modernize BarChartDataEntry internal calculations

* Style updated for PR

* Fix horizontal bar chart not drawing values and add unit tests (ChartsOrg#3906)

* fix horizontal bar chart drawValues not correctly drawing and add testNotDrawValueAboveBars UT

* add unit tests for horizontal bar chart, including default tests and drawValues and drawValuesAboveBars
default data entries included positive and negative values

* add tvOS test images

* add stacked bar tests for bar chart unit tests

* fix typo

* change to guard statement for shouldDrawValues

* update test images to match master branch

* Data as any (ChartsOrg#3863)

* `ChartEntry.data` is now of type `Any`

There is no need to restrict `ChartEntry.data` to `AnyObject`. This PR loosens that restriction. As a result we cannot compare `data`, though this should never have been the case in the first place.

* Updated `ChartDataEntry` initializers to accept `Any` for `data`

* Updated test

* bump version to 3.3

* update change log

* update gemfile

* correct 3.3 to 3.3.0.

* For ChartsOrg#3917. make init(label: String?) convenient initializer (ChartsOrg#3973)

* fix ChartsOrg#3917. make `init(label: String?)` to be a convenient init to enable auto inheritance.

* add UT for default dataSet label

* fix ChartsOrg#3975.
if we disable highlight for pie chart data set, we still need to render without a shift.

* Added a safety check before an unsafe array operation

* Update Info.plist

* Update License

Changed year in license file

* fixed stacked chart bug when there are different stacks on columns. (ChartsOrg#4029)

fix ChartsOrg#3659
* fixed stacked chart bug when there are different stacks on columns.
* added empty array check

* fix ChartsOrg#4093, also close ChartsOrg#3960
1. change XBounds iterator to use self.min + self.range rather than self.x
2. align drawLinear,  drawCubicBezier to new XBounds iterator.
3. fix unexpected dash line during linear animation due to reading the next entry point

* Fix Swift Package Manager compile issue

Signed-off-by: Ryne Cheow <rynecheow@gmail.com>

* Unspecify library type

Signed-off-by: Ryne Cheow <rynecheow@gmail.com>

* Fix gitignore to ignore .swiftpm as a directory

Signed-off-by: Ryne Cheow <rynecheow@gmail.com>

* Apply Xcode11 changes
automatic remove warnings detected by Xcode11

* bump to iPhone 8 as iPhone 7 has been dropped out

* bump to test framework to 6.1

* chart types that are not affected by formatter change

* tests affected by formatter change of `minimumIntegerDigits` from 0 to 1

* regenerate bar chart tests

* rebuild tvOS test images

* Fixes ChartsOrg#4099: Line renderer did not render lines if their coordinates fell outside of the viewport. (ChartsOrg#4100)

* Fixed ChartsOrg#4099: Line renderer did not render lines if they coordinates fell outside of the viewport, even though they might intersect the viewport.

* Updated inline documentation.

* Implemented code review feedback and removed unnecessary checks for performance reasons.

* Simplified and clarified the linear function to check for collisions with the left, top and bottom edges of the view port, and commented out the unecessary logic that checks for collision with the right edge of the view port.

* Updated in-line documentation.

* Update ViewPortHandler.swift

add a check for vertical line and a few comments change

* bump to 3.4.0

* fix change log format

* fix pod build and update gems

* introduce gracefully degrading abstractions for dark mode for ios and… (ChartsOrg#4171)

* introduce gracefully degrading abstractions for dark mode for ios and macos and use them to draw text

* it's .labelColor not .label on NSColor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants