Charts
Charts copied to clipboard
fix not displaying all lines in graph
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
Please merge this, it works and the bug breaks our product 🥲
@danielgindi 🙏
@danielgindi Please merge this 🙏 we can't update to the latest version as it breaks our line charts
This solution is also duplicated by #4730 (#4710).
I too am waiting on this; stuck on Charts 3.x until resolved.
@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)
}
}
Hi, is it possible to merge this in? I am also stuck at version 3 because of charts with multiple LineChartDataSets aren't working.