Skip to content

Commit

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

fix #3659
* fixed stacked chart bug when there are different stacks on columns.
* added empty array check
  • Loading branch information
Scalman authored and liuxuan30 committed Jul 29, 2019
1 parent 2d80b44 commit 8c28cfa
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 8c28cfa

Please sign in to comment.