ChartsOrg / ChartsOrg/Charts

Line chart does not render when X axis maximum is set higher than the largest X value in the data set

Open
#4,605 1 comment 7 reactions 0 assignees View on GitHub
Dominant language
Swift
Stars
28k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

When using a line chart if the x axis has its maximum value set above the largest value in the data set the chart will not render.

For example if the data set contained the X values 0, 1, 2, 3 & 4 it would render fine with a maximum X axis of 3 or 4 but if set to 5 or higher the chart will not render.

Also related to this because ChartDataSet class uses '-1' to indicate an entry has not been found if the largest entry found for the X axis is actually -1 then the chart won't render either.

I have created a minimal app with an example.

In the example a line chart with 5 data points with the X values 0, 1, 2, 3 & 4 is displayed. There are then buttons to change the X axis maximum to 3, 4 or 5. Tapping 3 and 4 will render the line chart but tapping 5 doesn't.

Charts version: 4.0.1 (latest swift package manager version).
Xcode version: 12.4 (12D4e)
Swift Version: 5 (see example app)
Platform running Charts: iOS
macOS version: Big Sur 11.2.3
[ChartsTest.zip](https://github.com/danielgindi/Charts/files/6162589/ChartsTest.zip)

Contributor guide

Open the contributing guide

Research direction

Start with the attached ChartsTest.zip minimal iOS app and reproduce the failure by setting the line chart X-axis maximum to 5. Read the ChartDataSet class and trace the largest-X lookup; done means the chart renders when the maximum exceeds the largest data value and when that value is -1.

Written by the indexing model from the issue text.

Assessment

Tech stack
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
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.