ChartsOrg / ChartsOrg/Charts

Only one point is displayed if the last two values have the same x

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

Description

I'm having troubles displaying points with same x values, but only if they are at the end of the list. It's also reproducible in the Charts Demo app:

If we have two points with the same x, everything is displayed correctly
`[values addObject:[[ChartDataEntry alloc] initWithX:20 y:50 icon: [UIImage imageNamed:@"icon"]]];
[values addObject:[[ChartDataEntry alloc] initWithX:20 y:10 icon: [UIImage imageNamed:@"icon"]]];`
![image](https://cloud.githubusercontent.com/assets/1624834/26084875/6f6403f2-39d7-11e7-9593-56f21b7bda6b.png)

If we have three points, last two of them have the same x, only one of those two is shown
`[values addObject:[[ChartDataEntry alloc] initWithX:10 y:30 icon: [UIImage imageNamed:@"icon"]]];
[values addObject:[[ChartDataEntry alloc] initWithX:20 y:50 icon: [UIImage imageNamed:@"icon"]]];
[values addObject:[[ChartDataEntry alloc] initWithX:20 y:10 icon: [UIImage imageNamed:@"icon"]]];`
![image](https://cloud.githubusercontent.com/assets/1624834/26084855/42cd4538-39d7-11e7-828e-ad73b973960e.png)

If we have 4 points, 2nd and 3rd have the same x, everything is displayed correctly
`[values addObject:[[ChartDataEntry alloc] initWithX:10 y:30 icon: [UIImage imageNamed:@"icon"]]];
[values addObject:[[ChartDataEntry alloc] initWithX:20 y:50 icon: [UIImage imageNamed:@"icon"]]];
[values addObject:[[ChartDataEntry alloc] initWithX:20 y:10 icon: [UIImage imageNamed:@"icon"]]];
[values addObject:[[ChartDataEntry alloc] initWithX:40 y:60 icon: [UIImage imageNamed:@"icon"]]];`
![image](https://cloud.githubusercontent.com/assets/1624834/26084836/30870922-39d7-11e7-8d17-94428483c76c.png)

Same issue if there's more than two points btw, only one is being displayed

Contributor guide

Open the contributing guide

Research direction

Reproduce the issue in the Charts Demo app using the ChartDataEntry sequences shown in the report, especially duplicate x values at the end of the list. Trace the chart rendering path from those entries and verify the result by checking that every point with the same x value is displayed, including cases with more than two duplicates.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
data-visualization
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.