Charts icon indicating copy to clipboard operation
Charts copied to clipboard

fix not displaying all lines in graph

Open kscheff opened this issue 3 years ago • 6 comments

Issue Link :link:

#4662

Goals :soccer:

When multiple lines with different xMin and xMax values are present and the view port includes all lines then all of the lines should be drawn.

Implementation Details :construction:

Calculating Xbounds for the "shorter" line fails, due to not finding a valid index for highestVisibleX or lowestVisibleX. Modifying the low and high marks for .entryForXValue() solves the issue.

Testing Details :mag:

Observing to display lines that a) have a higher xMin value than the lowestVisibleXValue b) have a lower xMax value than the highestVisbleXValue

kscheff avatar Jul 16 '21 13:07 kscheff

Please merge this, it works and the bug breaks our product 🥲

schusterlich avatar Dec 05 '21 18:12 schusterlich

@danielgindi 🙏

schusterlich avatar Dec 05 '21 18:12 schusterlich

@danielgindi Please merge this 🙏 we can't update to the latest version as it breaks our line charts

SarahHassaine avatar Aug 10 '22 15:08 SarahHassaine

This solution is also duplicated by #4730 (#4710).

I too am waiting on this; stuck on Charts 3.x until resolved.

zygoat avatar Aug 10 '22 16:08 zygoat

@danielgindi Please merge this.

Here's my workaround: Using a subclass of LineChartDataSet, override the entryForXValue(_, rounding:) method. In this method, xValue is recalculated by xMin and xMax constraints. Where the LineChartDataSet is used previously, use this subclass instead.

class CustomLineChartDataSet: LineChartDataSet {
    override func entryForXValue(_ xValue: Double, closestToY yValue: Double, rounding: ChartDataSetRounding) -> ChartDataEntry? {
        let newXValue = Swift.min(Swift.max(xValue, xMin), xMax)
        return super.entryForXValue(newXValue, closestToY: yValue, rounding: rounding)
    }
}

developforapple avatar Aug 26 '22 12:08 developforapple

Hi, is it possible to merge this in? I am also stuck at version 3 because of charts with multiple LineChartDataSets aren't working.

mortenkleveland avatar Sep 20 '22 10:09 mortenkleveland