@@ -2,7 +2,7 @@ import SwiftPlot
22import Foundation
33
44extension LineChartTests {
5-
5+
66 func testLineChart_positiveYOrigin( ) throws {
77 let x : [ Float ] = [ 0 , 1 , 2 , 3 ]
88 let y : [ Float ] = [ 70 , 80 , 95 , 100 ]
@@ -16,7 +16,7 @@ extension LineChartTests {
1616
1717 try renderAndVerify ( lineGraph, size: Size ( width: 300 , height: 300 ) )
1818 }
19-
19+
2020 func testLineChart_positiveYOrigin_secondary( ) throws {
2121 let x : [ Float ] = [ 0 , 1 , 2 , 3 ]
2222 let y : [ Float ] = [ 70 , 80 , 95 , 100 ]
@@ -32,10 +32,10 @@ extension LineChartTests {
3232 lineGraph. plotLineThickness = 3.0
3333 lineGraph. enablePrimaryAxisGrid = true
3434 lineGraph. enableSecondaryAxisGrid = true
35-
35+
3636 try renderAndVerify ( lineGraph, size: Size ( width: 400 , height: 400 ) )
3737 }
38-
38+
3939 func testLineChart_negativeYOrigin( ) throws {
4040 let x : [ Float ] = [ 0 , 1 , 2 , 3 ]
4141 let y : [ Float ] = [ - 70 , - 80 , - 95 , - 100 ]
@@ -49,7 +49,7 @@ extension LineChartTests {
4949
5050 try renderAndVerify ( lineGraph, size: Size ( width: 300 , height: 300 ) )
5151 }
52-
52+
5353 func testLineChart_positiveXOrigin( ) throws {
5454 let x : [ Float ] = [ 5 , 6 , 7 , 8 ]
5555 let y : [ Float ] = [ 70 , 80 , 95 , 100 ]
@@ -63,7 +63,7 @@ extension LineChartTests {
6363
6464 try renderAndVerify ( lineGraph, size: Size ( width: 300 , height: 300 ) )
6565 }
66-
66+
6767 func testLineChart_negativeXOrigin( ) throws {
6868 let x : [ Float ] = [ - 5 , - 6 , - 7 , - 8 ]
6969 let y : [ Float ] = [ - 70 , - 80 , - 95 , - 100 ]
@@ -77,7 +77,7 @@ extension LineChartTests {
7777
7878 try renderAndVerify ( lineGraph, size: Size ( width: 300 , height: 300 ) )
7979 }
80-
80+
8181 func testLineChart_positiveXOrigin_secondary( ) throws {
8282 let x : [ Float ] = [ 0 , 1 , 2 , 3 ]
8383 let y : [ Float ] = [ 70 , 80 , 95 , 100 ]
@@ -94,10 +94,10 @@ extension LineChartTests {
9494 lineGraph. plotLineThickness = 3.0
9595 lineGraph. enablePrimaryAxisGrid = true
9696 lineGraph. enableSecondaryAxisGrid = true
97-
97+
9898 try renderAndVerify ( lineGraph, size: Size ( width: 400 , height: 400 ) )
9999 }
100-
100+
101101 func testLineChart_negativeXOrigin_unsorted( ) throws {
102102 let x : [ Float ] = [ - 8 , - 7 , - 6 , - 5 ]
103103 let y : [ Float ] = [ 70 , 80 , 95 , 100 ]
@@ -111,7 +111,7 @@ extension LineChartTests {
111111
112112 try renderAndVerify ( lineGraph, size: Size ( width: 300 , height: 300 ) )
113113 }
114-
114+
115115 func testLineChart_crossX( ) throws {
116116 func someFunction( _ x: Float ) -> Float { ( x * x) + 10 }
117117 var lineGraph_func = LineGraph < Float , Float > ( enablePrimaryAxisGrid: true )
@@ -126,7 +126,7 @@ extension LineChartTests {
126126 lineGraph_func. plotLabel. yLabel = " Y-AXIS "
127127 try renderAndVerify ( lineGraph_func, size: Size ( width: 400 , height: 400 ) )
128128 }
129-
129+
130130 func testLineChart_crossY( ) throws {
131131 func someFunction( _ x: Float ) -> Float { 5 * cos( 2 * x * x) / x }
132132 var lineGraph_func = LineGraph < Float , Float > ( enablePrimaryAxisGrid: true )
@@ -141,22 +141,22 @@ extension LineChartTests {
141141 lineGraph_func. plotLabel. yLabel = " Y-AXIS "
142142 try renderAndVerify ( lineGraph_func, size: Size ( width: 400 , height: 400 ) )
143143 }
144-
144+
145145 func testLineChart_crossBothAxes( ) throws {
146146 var lineGraph = LineGraph < Float , Float > ( enablePrimaryAxisGrid: true ,
147147 enableSecondaryAxisGrid: false )
148148 let clamp : ClosedRange < Float > ? = - 150 ... 150
149- lineGraph. addFunction ( { pow ( $0 , 2 ) } , minX: - 5 , maxX: 5 , clampY: clamp, label: " 2 " , color: . lightBlue)
150- lineGraph. addFunction ( { pow ( $0 , 3 ) } , minX: - 5 , maxX: 5 , clampY: clamp, label: " 3 " , color: . orange)
151- lineGraph. addFunction ( { pow ( $0 , 4 ) } , minX: - 5 , maxX: 5 , clampY: clamp, label: " 4 " , color: . red)
152- lineGraph. addFunction ( { pow ( $0 , 5 ) } , minX: - 5 , maxX: 5 , clampY: clamp, label: " 5 " , color: . brown)
153- lineGraph. addFunction ( { pow ( $0 , 6 ) } , minX: - 5 , maxX: 5 , clampY: clamp, label: " 6 " , color: . purple)
154- lineGraph. addFunction ( { pow ( $0 , 7 ) } , minX: - 5 , maxX: 5 , clampY: clamp, label: " 7 " , color: . green)
149+ lineGraph. addFunction ( { Float ( truncating : pow ( Decimal ( Double ( $0 ) ) , Int ( 2 ) ) as NSNumber ) } , minX: - 5 , maxX: 5 , clampY: clamp, label: " 2 " , color: . lightBlue)
150+ lineGraph. addFunction ( { Float ( truncating : pow ( Decimal ( Double ( $0 ) ) , Int ( 3 ) ) as NSNumber ) } , minX: - 5 , maxX: 5 , clampY: clamp, label: " 3 " , color: . orange)
151+ lineGraph. addFunction ( { Float ( truncating : pow ( Decimal ( Double ( $0 ) ) , Int ( 4 ) ) as NSNumber ) } , minX: - 5 , maxX: 5 , clampY: clamp, label: " 4 " , color: . red)
152+ lineGraph. addFunction ( { Float ( truncating : pow ( Decimal ( Double ( $0 ) ) , Int ( 5 ) ) as NSNumber ) } , minX: - 5 , maxX: 5 , clampY: clamp, label: " 5 " , color: . brown)
153+ lineGraph. addFunction ( { Float ( truncating : pow ( Decimal ( Double ( $0 ) ) , Int ( 6 ) ) as NSNumber ) } , minX: - 5 , maxX: 5 , clampY: clamp, label: " 6 " , color: . purple)
154+ lineGraph. addFunction ( { Float ( truncating : pow ( Decimal ( Double ( $0 ) ) , Int ( 7 ) ) as NSNumber ) } , minX: - 5 , maxX: 5 , clampY: clamp, label: " 7 " , color: . green)
155155 lineGraph. plotTitle. title = " y = x^n "
156156 lineGraph. plotLabel. xLabel = " x "
157157 lineGraph. plotLabel. yLabel = " y "
158158 lineGraph. backgroundColor = . transparent
159-
159+
160160 try renderAndVerify ( lineGraph, size: Size ( width: 800 , height: 400 ) )
161161 }
162162}
0 commit comments