diff --git a/Sources/FioriCharts/Charts/Common/YAxisView.swift b/Sources/FioriCharts/Charts/Common/YAxisView.swift index 28360590c..602999489 100644 --- a/Sources/FioriCharts/Charts/Common/YAxisView.swift +++ b/Sources/FioriCharts/Charts/Common/YAxisView.swift @@ -57,8 +57,6 @@ struct YAxisView: View { //.fixedSize() .font(.system(size: axis.labels.fontSize)) .foregroundColor(axis.labels.color) -// .position(x: min(rect.size.width / 2, label.pos.x), -// y: label.pos.y) .position(x: label.pos.x, y: label.pos.y) .frame(maxWidth: rect.size.width) @@ -100,12 +98,6 @@ struct YAxisView_Previews: PreviewProvider { .frame(width: 80, height: 200, alignment: .topLeading) .previewLayout(.sizeThatFits) - } -// return YAxisView(axisDataSource: axisDataSource) -// .environmentObject(Tests.stockModels[1]) -// .frame(width: 80, height: 200, alignment: .topLeading) -// .padding() -// .previewLayout(.sizeThatFits) - + } } } diff --git a/Sources/FioriCharts/Model/ChartModel.swift b/Sources/FioriCharts/Model/ChartModel.swift index b48f590ba..445a56c30 100644 --- a/Sources/FioriCharts/Model/ChartModel.swift +++ b/Sources/FioriCharts/Model/ChartModel.swift @@ -199,7 +199,7 @@ public class ChartModel: ObservableObject, Identifiable, NSCopying { */ @Published public var numericAxis: ChartNumericAxisAttributes - @Published public var xAxisLabelsPosition: XAxisLabelsPosition = .dynamic + @Published public var xAxisLabelsPosition: XAxisLabelsPosition = .fixedBottom /** Provides attributes for the secondary numeric axis. @@ -572,6 +572,7 @@ public class ChartModel: ObservableObject, Identifiable, NSCopying { categoryAxis: ChartCategoryAxisAttributes, numericAxis: ChartNumericAxisAttributes, secondaryNumericAxis: ChartNumericAxisAttributes, + xAxisLabelsPosition: XAxisLabelsPosition = .fixedBottom, indexOfStockSeries: Int = 0, indexesOfSecondaryValueAxis: IndexSet, indexesOfColumnSeries: IndexSet, @@ -590,6 +591,7 @@ public class ChartModel: ObservableObject, Identifiable, NSCopying { self._categoryAxis = Published(initialValue: categoryAxis) self._numericAxis = Published(initialValue: numericAxis) self._secondaryNumericAxis = Published(initialValue: secondaryNumericAxis) + self._xAxisLabelsPosition = Published(initialValue: xAxisLabelsPosition) self.numberOfGridlines = numberOfGridlines self.selectionMode = selectionMode @@ -630,6 +632,7 @@ public class ChartModel: ObservableObject, Identifiable, NSCopying { categoryAxis: self.categoryAxis.copy() as! ChartCategoryAxisAttributes, numericAxis: self.numericAxis.copy() as! ChartNumericAxisAttributes, secondaryNumericAxis: self.secondaryNumericAxis.copy() as! ChartNumericAxisAttributes, + xAxisLabelsPosition: self.xAxisLabelsPosition, indexOfStockSeries: self.indexOfStockSeries, indexesOfSecondaryValueAxis: self.indexesOfSecondaryValueAxis, indexesOfColumnSeries: self.indexesOfColumnSeries, @@ -657,6 +660,7 @@ public class ChartModel: ObservableObject, Identifiable, NSCopying { categoryAxis: ChartCategoryAxisAttributes? = nil, numericAxis: ChartNumericAxisAttributes? = nil, secondaryNumericAxis: ChartNumericAxisAttributes? = nil, + xAxisLabelsPosition: XAxisLabelsPosition = .fixedBottom, indexOfStockSeries: Int = 0, indexesOfSecondaryValueAxis: [Int]? = nil, indexesOfColumnSeries: [Int]? = nil, @@ -757,6 +761,7 @@ public class ChartModel: ObservableObject, Identifiable, NSCopying { self._seriesAttributes = Published(initialValue: sa) } + self._xAxisLabelsPosition = Published(initialValue: xAxisLabelsPosition) self.numberOfGridlines = numberOfGridlines self.selectionMode = selectionMode if chartType == .donut { @@ -801,6 +806,7 @@ public class ChartModel: ObservableObject, Identifiable, NSCopying { categoryAxis: ChartCategoryAxisAttributes? = nil, numericAxis: ChartNumericAxisAttributes? = nil, secondaryNumericAxis: ChartNumericAxisAttributes? = nil, + xAxisLabelsPosition: XAxisLabelsPosition = .fixedBottom, indexOfStockSeries: Int = 0, indexesOfSecondaryValueAxis: [Int]? = nil, indexesOfColumnSeries: [Int]? = nil, @@ -974,6 +980,7 @@ public class ChartModel: ObservableObject, Identifiable, NSCopying { self._seriesAttributes = Published(initialValue: sa) } + self._xAxisLabelsPosition = Published(initialValue: xAxisLabelsPosition) self.numberOfGridlines = numberOfGridlines self.selectionMode = selectionMode if chartType == .donut { @@ -1400,6 +1407,7 @@ extension ChartModel: CustomStringConvertible { "categoryAxis": \(String(describing: categoryAxis)), "numericAxis": \(String(describing: numericAxis)), "secondaryNumericAxis": \(String(describing: secondaryNumericAxis)), + "xAxisLabelsPosition": \(String(describing: xAxisLabelsPosition)), "indexesOfSecondaryValueAxis": \(String(describing: indexesOfSecondaryValueAxis.sorted())), "indexesOfColumnSeries": \(String(describing: indexesOfColumnSeries.sorted())), "indexesOfTotalsCategories": \(String(describing: indexesOfTotalsCategories.sorted())),