the BubbleChartDataSet colors property is bound to chart view x-axis, not data-set entries (Charts 3.0.2)
- Dominant language
- Swift
- Stars
- 28k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
while working with bubble data sets and charts i noticed that in bubble data sets, even though the documentation for `ChartBaseDataSet.colors` says that colors are bound to data-set entries, when you assign colors to the data set and render it in a bubble chart view, Charts 3.0.2 bounds the data-set colors to the x-axis range, not the data-set entries. line 95 in `BubbleChartRenderer.swift` confirms this:
`for j in stride(from: _xBounds.min, through: _xBounds.range + _xBounds.min, by: 1)`
that’s different from a similar line (299) in `BarChartRenderer.swift`:
`for j in stride(from: 0, to: buffer.rects.count, by: 1)`
i had a hard time understanding why my color assignments weren’t being followed in bubble charts. the documentation for the `BubbleChartDataSet` and `BubbleChartRenderer` classes don’t mention this diversion from the guidance provided in `ChartBaseDataSet.swift` for the colors property.
however, because i have to “expand” my colors array to include slots for all the items in the x-axis to have the colors correctly assigned to the data entries on the chart, i wonder whether the issue is in the documentation or the implementation.
attached are my supporting materials.
[iOSChartsDemo.zip](https://github.com/danielgindi/Charts/files/1347357/iOSChartsDemo.zip)
Contributor guide
Research direction
Start by reproducing the color mismatch with the attached iOSChartsDemo.zip. Compare line 95 in BubbleChartRenderer.swift with line 299 in BarChartRenderer.swift and the colors guidance in ChartBaseDataSet.swift. Determine whether the intended entry binding requires an implementation or documentation change, then verify that the behavior and documentation agree.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- 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
- 42/100