ChartsOrg / Charts

Beautiful charts for iOS/tvOS/OSX! The Apple side of the crossplatform MPAndroidChart.
Apache License 2.0
27.48k stars 5.98k forks source link

Crash using highlighted value in combined charts #5116

Open barabashd opened 10 months ago

barabashd commented 10 months ago

What did you do?

  1. I created a combined chart with scatter and bar charts.
  2. Highlighted a scatter value.

What did you expect to happen?

No crashes

What happened instead?

App crashes

Reason?

The bar chart will have the same index as the scatter, and instead of highlighting the scatter, it tries to highlight the bar chart.

DGCharts Environment

DGCharts version/Branch/Commit Number: 5.0.0 / master Xcode version: 15.0.1 (15A507) Swift version: 5.9 Platform(s) running DGCharts: Simulator iPhone 15 iOS 17.0.1 macOS version running Xcode: Sonoma 14.0

Demo Project

https://github.com/danielgindi/Charts/assets/24472528/3a53c4e2-25a9-417a-8152-574c82d0e8e4

https://github.com/barabashd/Charts/tree/combined_data_crash_example

TKZwo commented 7 months ago

I had a similar array out of bounds crash in a groupedBarChart/LineChart setup. (2 Bars, 1 line) and I ended up creating my own Renderer class inheriting from CombinedChartRenderer and overriding the drawHighlighted() function to only use the default BarChartRenderer.