ChartsOrg / ChartsOrg/Charts

Radar chart crash if number of axes is increased.

Open
#4,364 2 comments 1 reaction 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?
I had a radar chart being displayed with 10 spokes (i.e. 10 axes coming from the centre).
I displayed data on it okay.
Then I *added* another spoke to make 11 to be displayed (note you must increase the overall number from that used initially).
I updated the data set with the requisite number of entries.
I called notifyDataSetChanged()

## What did you expect to happen?
I expected the chart to display itself again as normal, this time with 11 spokes in the radar chart wheel.

## What happened instead?
It crashed with index out of bounds in RadarChartRenderer line 125.

I traced the problem back to accessibilityXLabels. This variable is set up lazy and once evaluated it is kept. So when the number of spokes increases it still has the old number. This then causes the IOOB.

I removed the lazy evaluation and just made it a simple computed property and the crash stopped.

## Charts Environment

**Charts version/Branch/Commit Number:** 3.5.0
**Xcode version:** 11.4.1
**Swift version:** 5.2.2
**Platform(s) running Charts:** macOS
**macOS version running Xcode:** 10.15.4

## Demo Project

It is embedded in my code but I think is easy to reproduce.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.