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

fix not displaying all lines in graph #4687

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kscheff
Copy link

@kscheff kscheff commented Jul 16, 2021

Issue Link 🔗

#4662

Goals ⚽

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 🚧

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 🔍

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

Copy link

@peacedudes peacedudes left a comment

Choose a reason for hiding this comment

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

This works for me, and I need it too. It may be clearer to write:

            let low = Swift.max(chart.lowestVisibleX, dataSet.xMin)
            let high = Swift.min(chart.highestVisibleX, dataSet.xMax)

arturo-marzo added a commit to arturo-marzo/Charts that referenced this pull request Oct 20, 2021
@schusterlich
Copy link

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

@schusterlich
Copy link

@danielgindi 🙏

@SarahHassaine
Copy link

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

@zygoat
Copy link

zygoat commented Aug 10, 2022

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

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

@developforapple
Copy link

developforapple commented Aug 26, 2022

@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)
    }
}

@mortenkleveland
Copy link

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

aaadonai added a commit to signos-health/Charts that referenced this pull request Mar 17, 2023
aaadonai added a commit to signos-health/Charts that referenced this pull request Mar 24, 2023
Making sure that lowerBound is <= upperBound
Github discussion: ChartsOrg#4687 (review)
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.

8 participants