ChartsOrg / ChartsOrg/Charts

[CombinedChart] Line entries disappears when changing `xAxis.spaceMax` or `xAxis.axisMaximum` with positive values (to fix the cropped bars)

Open
#4,710 8 comments 6 reactions 0 assignees View on GitHub
Dominant language
Swift
Stars
28k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

* [x] I've read, understood, and done my best to follow the [*CONTRIBUTING guidelines](https://github.com/jjatie/Charts/blob/master/CONTRIBUTING.md).

## What did you do?

While using the `CombinedChartView` with `barData` and `lineData` properly set, I realised the first and last bars cropped and after a few searches it's now clear that [it's a known issue](https://github.com/danielgindi/Charts/issues/3186) and when trying the suggested workarounds, I noticed that the line rendering breaks when changing the `xAxis.spaceMax` or `xAxis.axisMaximum` which internally ends up in the same code path.

The video below explains the case:

https://user-images.githubusercontent.com/469209/131644473-1da2f0ec-36da-4a50-a08d-41a81b22ae47.mov

## What did you expect to happen?

I expected to fix the fist and last cropped bars issue without breaking the line chart.

## What happened instead?

The line rendering breaks and disappears, ending up with just the very first entry.

## Charts Environment

**master** but also tried the branch `bugfix/xbounds-iterator` with no luck
**Xcode version: 12.5**
**Swift version: 5.5**
**Platform(s) running Charts: iOS**
**macOS version running Xcode: Big Sur 11.5.2**

## Demo Project
[ChartExample.zip](https://github.com/danielgindi/Charts/files/7090305/ChartExample.zip)

### Any help on how to workaround it is very appreciated!

Thank you

Contributor guide

Open the contributing guide

Research direction

Start with the attached ChartExample project and reproduce the issue in CombinedChartView using barData and lineData with positive xAxis.spaceMax or xAxis.axisMaximum. Compare the rendering against the cropped-bar workaround; done means the first and last bars are not cropped and all line entries remain visible.

Written by the indexing model from the issue text.

Assessment

Tech stack
ios, swift
Domain
data-visualization, mobile-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.