ChartsOrg / ChartsOrg/Charts

Order of ChartDataEntry has impact on chart rendering of data points

Open
#2,858 9 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 seeing some strange behavior using LineChart in iOS / swift 3. In this situation my data comes back from server in reverse order desired on the chart (most recent data is first, with oldest data last).

For some reason the order I add the ChartDataEntry(s) to the dataset(s) matters. I've verified my x axis data points are valid (1-56) for the last 8 weeks of days. If I add them 1..56 it works fine, if I add them 56-1 the axis scales are correct for both axis but no data is displayed if they are added 56 first and 1 last.

Perhaps I missing a method call that re-orders them or something?

Ideally I'd expect you could add any data points at any time and they would be reflected properly in the Chart.

I'm using LineChartView with LineChartDataSet and ChartDataEntry objects.

It's not difficult to work-around but figured it's either a bug or something simple I'm missing.

Thanks,

Mike

Contributor guide

Open the contributing guide

Research direction

Start with the LineChartView, LineChartDataSet, and ChartDataEntry behavior described in the report. Reproduce the issue with x values added in ascending and descending order, then trace how the dataset is consumed for rendering. Done means both insertion orders display the same data correctly, with tests covering the two cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
ios, swift
Domain
data-visualization, mobile-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 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.