File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed
Sources/Charts/Chart/Styles/Area Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -7,13 +7,14 @@ public struct StackedAreaChartStyle: ChartStyle {
77
88 public func makeBody( configuration: Self . Configuration ) -> some View {
99 ZStack {
10- ForEach ( Array ( configuration. dataMatrix. flipDirection ( ) . stacked ( ) . reversed ( ) . enumerated ( ) ) , id: \. self. offset) { enumeratedData in
11- self . colors. prefix ( configuration . dataMatrix . count ) . reversed ( ) [ enumeratedData. offset % self . colors. count] . clipShape (
10+ ForEach ( Array ( configuration. dataMatrix. transpose ( ) . stacked ( ) . enumerated ( ) ) , id: \. self. offset) { enumeratedData in
11+ colors [ enumeratedData. offset % colors. count] . clipShape (
1212 AreaChart (
1313 unitData: enumeratedData. element,
1414 lineType: self . lineType
1515 )
1616 )
17+ . zIndex ( - Double( enumeratedData. offset) )
1718 }
1819 }
1920 . drawingGroup ( )
@@ -38,14 +39,14 @@ extension Collection where Element == [CGFloat] {
3839}
3940
4041extension Array where Element == [ CGFloat ] {
41- func flipDirection ( ) -> [ [ CGFloat ] ] {
42+ func transpose ( ) -> [ [ CGFloat ] ] {
4243 let columnsCount = self . first? . count ?? 0
4344 let rowCount = self . count
4445
4546 return ( 0 ..< columnsCount) . map { columnIndex in
4647 ( 0 ..< rowCount) . map { rowIndex in
4748 return self [ rowIndex] [ columnIndex]
48- } . reversed ( )
49+ }
4950 }
5051 }
5152}
You can’t perform that action at this time.
0 commit comments