Skip to content

Commit

Permalink
feat: 🎸 add xAxisLabelsPosition to init()
Browse files Browse the repository at this point in the history
add xAxisLabelsPosition to init() and change its default value to
fixedBottom
  • Loading branch information
shengxu7 committed Sep 10, 2020
1 parent 7cdf3dd commit 76a3611
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
10 changes: 1 addition & 9 deletions Sources/FioriCharts/Charts/Common/YAxisView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)

}
}
}
10 changes: 9 additions & 1 deletion Sources/FioriCharts/Model/ChartModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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,
Expand All @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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())),
Expand Down

0 comments on commit 76a3611

Please sign in to comment.