Repository: danielgindi/Charts
File: Source/Charts/Charts/ChartViewBase.swift (Swift)

Code before:
                constrainedToSize: self.bounds.size,
                anchor: CGPoint(x: 0.5, y: 0.5),
                angleRadians: 0.0)
            
            return
        }
        
        if !_offsetsCalculated
        {
            calculateOffsets()
            _offsetsCalculated = true
        }
    }
    
    /// Draws the description text in the bottom right corner of the chart (per default)
    @objc internal func drawDescription(context: CGContext)
    {
        // check if description should be drawn
        guard
            let description = chartDescription,
            description.isEnabled,
            let descriptionText = description.text,
            descriptionText.characters.count > 0
            else { return }
        
        let position: CGPoint
        if let descriptionPosition = description.position {
            position = descriptionPosition
        } else {
            let frame = self.bounds
            position = CGPoint(
                x: frame.width - _viewPortHandler.offsetRight - description.xOffset,
                y: frame.height - _viewPortHandler.offsetBottom - description.yOffset - description.font.lineHeight)
        }
        
        var attrs = [NSAttributedStringKey : Any]()
        
        attrs[NSAttributedStringKey.font] = description.font
        attrs[NSAttributedStringKey.foregroundColor] = description.textColor

        ChartUtils.drawText(
            context: context,
            text: descriptionText,
            point: position,
            align: description.textAlign,
            attributes: attrs)
    }
    
    // MARK: - Highlighting
    
    /// - returns: The array of currently highlighted values. This might an empty if nothing is highlighted.

Review comment (suggestion):
Could be cleaner to do this.
```
 let p = description.position ?? CGPoint(x: bounds.width - _viewPortHandler.offsetRight - description.xOffset,
                                            y: bounds.height - _viewPortHandler.offsetBottom - description.yOffset - description.font.lineHeight)
```

Might just come down to preference.

Code after:
                constrainedToSize: self.bounds.size,
                anchor: CGPoint(x: 0.5, y: 0.5),
                angleRadians: 0.0)
            
            return
        }
        
        if !_offsetsCalculated
        {
            calculateOffsets()
            _offsetsCalculated = true
        }
    }
    
    /// Draws the description text in the bottom right corner of the chart (per default)
    @objc internal func drawDescription(context: CGContext)
    {
        // check if description should be drawn
        guard
            let description = chartDescription,
            description.isEnabled,
            let descriptionText = description.text,
            descriptionText.count > 0
            else { return }
        
        let position = description.position ?? CGPoint(x: bounds.width - _viewPortHandler.offsetRight - description.xOffset,
                                                       y: bounds.height - _viewPortHandler.offsetBottom - description.yOffset - description.font.lineHeight)
        
        var attrs = [NSAttributedStringKey : Any]()
        
        attrs[NSAttributedStringKey.font] = description.font
        attrs[NSAttributedStringKey.foregroundColor] = description.textColor

        ChartUtils.drawText(
            context: context,
            text: descriptionText,
            point: position,
            align: description.textAlign,
            attributes: attrs)
    }
    
    // MARK: - Highlighting
    
    /// - returns: The array of currently highlighted values. This might an empty if nothing is highlighted.
    @objc open var highlighted: [Highlight]
    {
        return _indicesToHighlight
    }
    
    /// Set this to false to prevent values from being highlighted by tap gesture.
    /// Values can still be highlighted via drag or programmatically.