Skip to content

Commit

Permalink
fixed stacked chart bug when there are different stacks on columns. (C…
Browse files Browse the repository at this point in the history
…hartsOrg#4029)

fix ChartsOrg#3659
* fixed stacked chart bug when there are different stacks on columns.
* added empty array check
  • Loading branch information
Scalman authored and SwiftPolar committed Mar 20, 2023
1 parent bd3e85e commit 92bf49e
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Source/Charts/Renderers/BarChartRenderer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -867,9 +867,12 @@ open class BarChartRenderer: BarLineScatterCandleBubbleRenderer
} else {
stackLabel = nil
}


//Handles empty array of yValues
let yValue = vals.isEmpty ? 0.0 : vals[idx % vals.count]

elementValueText = dataSet.valueFormatter?.stringForValue(
vals[idx % stackSize],
yValue,
entry: e,
dataSetIndex: dataSetIndex,
viewPortHandler: viewPortHandler) ?? "\(e.y)"
Expand Down

0 comments on commit 92bf49e

Please sign in to comment.