99import SwiftUI
1010import SwiftViz
1111
12- public struct VerticalAxisView < ScaleType: Scale > : View {
12+ public struct VerticalAxisView < ScaleType: Scale > : View where ScaleType . InputType == Double , ScaleType . OutputType == Float {
1313 let topInset : CGFloat
1414 let bottomInset : CGFloat
1515 let leftOffset : CGFloat
@@ -23,16 +23,16 @@ public struct VerticalAxisView<ScaleType: Scale>: View {
2323 leftOffset = 30
2424 tickLength = 5
2525 }
26-
27- func tickList( geometry: GeometryProxy ) -> [ ScaleType . TickType ] {
26+
27+ func tickList< InputType , OutputType > ( geometry: GeometryProxy ) -> [ Tick < InputType , OutputType > ] where ScaleType. InputType == InputType , ScaleType . OutputType == OutputType {
2828 // protect against Preview sending in stupid values
2929 // of geometry that can't be made into a reasonable range
3030 // otherwise the next line will crash preview...
3131 if geometry. size. width < topInset + bottomInset {
32- return [ ScaleType . TickType ] ( )
32+ return [ Tick < InputType , OutputType > ] ( )
3333 }
34- let geometryRange = 0.0 ... CGFloat ( geometry. size. height - topInset - bottomInset)
35- return scale. ticks ( count : 10 , range : geometryRange )
34+ let upperBound = Float ( geometry. size. height - topInset - bottomInset)
35+ return scale. ticks ( rangeLower : 0 , rangeHigher : upperBound )
3636 }
3737
3838 public var body : some View {
@@ -48,8 +48,8 @@ public struct VerticalAxisView<ScaleType: Scale>: View {
4848 path. addLine ( to: CGPoint ( x: self . leftOffset + self . tickLength, y: geometry. size. height - self . bottomInset) )
4949
5050 for tick in self . tickList ( geometry: geometry) {
51- path. move ( to: CGPoint ( x: self . leftOffset, y: tick. rangeLocation + self . topInset) )
52- path. addLine ( to: CGPoint ( x: self . leftOffset + self . tickLength, y: tick. rangeLocation + self . topInset) )
51+ path. move ( to: CGPoint ( x: self . leftOffset, y: CGFloat ( tick. rangeLocation) + self . topInset) )
52+ path. addLine ( to: CGPoint ( x: self . leftOffset + self . tickLength, y: CGFloat ( tick. rangeLocation) + self . topInset) )
5353 }
5454 } . stroke ( )
5555// ForEach(self.tickList(geometry: geometry)) { tickStruct in
@@ -63,10 +63,10 @@ public struct VerticalAxisView<ScaleType: Scale>: View {
6363struct VerticalAxisView_Previews : PreviewProvider {
6464 static var previews : some View {
6565 Group {
66- VerticalAxisView ( scale: LinearScale ( domain : 0 ... 1.0 , isClamped : false ) )
66+ VerticalAxisView ( scale: LinearScale . create ( 0 ... 1.0 ) )
6767 . frame ( width: 100 , height: 400 , alignment: . center)
6868
69- VerticalAxisView ( scale: LogScale ( domain : 1 ... 10.0 , isClamped : false ) )
69+ VerticalAxisView ( scale: LogScale . DoubleScale ( from : 0 , to : 10 , transform : . none ) )
7070 . frame ( width: 100 , height: 400 , alignment: . center)
7171 }
7272 }
0 commit comments