Repository: danielgindi/Charts
File: Source/Charts/Data/Implementations/Standard/ChartData.swift (Swift)

Code before:

import Foundation

open class ChartData: NSObject, ExpressibleByArrayLiteral
{
    internal var _yMax: Double = -Double.greatestFiniteMagnitude
    internal var _yMin: Double = Double.greatestFiniteMagnitude
    internal var _xMax: Double = -Double.greatestFiniteMagnitude
    internal var _xMin: Double = Double.greatestFiniteMagnitude
    internal var _leftAxisMax: Double = -Double.greatestFiniteMagnitude
    internal var _leftAxisMin: Double = Double.greatestFiniteMagnitude
    internal var _rightAxisMax: Double = -Double.greatestFiniteMagnitude
    internal var _rightAxisMin: Double = Double.greatestFiniteMagnitude
    
    internal var _dataSets = [ChartDataSetProtocol]()
    
    public override required init()
    {
        super.init()
    }

    public required init(arrayLiteral elements: ChartDataSetProtocol...)
    {
        super.init()

        _dataSets = dataSets

        self.initialize(dataSets: _dataSets)
    }

    @objc public init(dataSets: [ChartDataSetProtocol]?)
    {
        super.init()
        
        _dataSets = dataSets ?? [ChartDataSetProtocol]()
        
        self.initialize(dataSets: _dataSets)
    }
    
    @objc public convenience init(dataSet: ChartDataSetProtocol?)
    {
        self.init(dataSets: dataSet === nil ? nil : [dataSet!])
    }
    
    internal func initialize(dataSets: [ChartDataSetProtocol])
    {
        notifyDataChanged()
    }
    
    /// Call this method to let the ChartData know that the underlying data has changed.
    /// Calling this performs all necessary recalculations needed when the contained data has changed.

Review comment (suggestion):
is there any implicit declare of `dataSets` here, I don't see init(arrayLiteral elements: ChartDataSetProtocol...) declared.
Besides, there used to be a PR that removes `_` from some interval vars. Any guideline when to use `_` and not? I remember I asked a similar question.

Code after:

import Foundation

open class ChartData: NSObject, ExpressibleByArrayLiteral
{
    internal var _yMax: Double = -Double.greatestFiniteMagnitude
    internal var _yMin: Double = Double.greatestFiniteMagnitude
    internal var _xMax: Double = -Double.greatestFiniteMagnitude
    internal var _xMin: Double = Double.greatestFiniteMagnitude
    internal var _leftAxisMax: Double = -Double.greatestFiniteMagnitude
    internal var _leftAxisMin: Double = Double.greatestFiniteMagnitude
    internal var _rightAxisMax: Double = -Double.greatestFiniteMagnitude
    internal var _rightAxisMin: Double = Double.greatestFiniteMagnitude
    
    internal var _dataSets = [ChartDataSetProtocol]()
    
    public override required init()
    {
        super.init()
    }

    public required init(arrayLiteral elements: ChartDataSetProtocol...)
    {
        super.init()

        _dataSets = elements

        self.initialize(dataSets: _dataSets)
    }

    @objc public init(dataSets: [ChartDataSetProtocol]?)
    {
        super.init()
        
        _dataSets = dataSets ?? [ChartDataSetProtocol]()
        
        self.initialize(dataSets: _dataSets)
    }
    
    @objc public convenience init(dataSet: ChartDataSetProtocol?)
    {
        self.init(dataSets: dataSet === nil ? nil : [dataSet!])
    }
    
    internal func initialize(dataSets: [ChartDataSetProtocol])
    {
        notifyDataChanged()
    }
    
    /// Call this method to let the ChartData know that the underlying data has changed.
    /// Calling this performs all necessary recalculations needed when the contained data has changed.