Skip to content

Commit 6264032

Browse files
committed
Refactor PolarCharts tests
1 parent 2518abd commit 6264032

File tree

5 files changed

+151
-117
lines changed

5 files changed

+151
-117
lines changed

tests/Common/FSharpTestBase/FSharpTestBase.fsproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
<Compile Include="TestUtils.fs" />
1616
<Compile Include="TestCharts\Chart2DTestCharts.fs" />
1717
<Compile Include="TestCharts\Chart3DTestCharts.fs" />
18+
<Compile Include="TestCharts\ChartPolarTestCharts.fs" />
1819
<Compile Include="TestCharts\ChartMapTestCharts.fs" />
1920
<Compile Include="TestCharts\ChartDomainTestCharts.fs" />
2021
</ItemGroup>
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
module ChartPolarTestCharts
2+
3+
open Plotly.NET
4+
open Plotly.NET.TraceObjects
5+
open Plotly.NET.LayoutObjects
6+
open System
7+
8+
open TestUtils.DataGeneration
9+
open Deedle
10+
11+
let internal radial = [ 1; 2; 3; 4; 5; 6; 7;]
12+
let internal theta = [0; 45; 90; 135; 200; 320; 184;]
13+
14+
module ScatterPolar = ()
15+
16+
module PointPolar =
17+
18+
let ``Simple polar point chart`` = Chart.PointPolar(r = radial,theta = theta, UseDefaults = false)
19+
20+
module LinePolar =
21+
22+
let ``Simple polar line chart with line style`` =
23+
Chart.LinePolar(r = radial,theta = theta, UseDefaults = false)
24+
|> Chart.withLineStyle(Color=Color.fromString "purple",Dash=StyleParam.DrawingStyle.DashDot)
25+
26+
module SplinePolar =
27+
28+
let ``styled polar spline chart`` =
29+
Chart.SplinePolar(
30+
r = radial,
31+
theta = theta,
32+
MultiText=["one";"two";"three";"four";"five";"six";"seven"],
33+
TextPosition=StyleParam.TextPosition.TopCenter,
34+
ShowMarkers=true,
35+
UseDefaults = false
36+
)
37+
38+
module BubblePolar = ()
39+
40+
module BarPolar =
41+
42+
let ``Styled windrose chart`` =
43+
let r = [77.5; 72.5; 70.0; 45.0; 22.5; 42.5; 40.0; 62.5]
44+
let r2 = [57.5; 50.0; 45.0; 35.0; 20.0; 22.5; 37.5; 55.0]
45+
let r3 = [40.0; 30.0; 30.0; 35.0; 7.5; 7.5; 32.5; 40.0]
46+
let r4 = [20.0; 7.5; 15.0; 22.5; 2.5; 2.5; 12.5; 22.5]
47+
48+
let t = ["North"; "N-E"; "East"; "S-E"; "South"; "S-W"; "West"; "N-W"]
49+
50+
[
51+
Chart.BarPolar (r = r , theta = t, Name="11-14 m/s" , MarkerPatternShape = StyleParam.PatternShape.Checked , UseDefaults = false)
52+
Chart.BarPolar (r = r2, theta = t, Name="8-11 m/s" , MarkerPatternShape = StyleParam.PatternShape.DiagonalChecked, UseDefaults = false)
53+
Chart.BarPolar (r = r3, theta = t, Name="5-8 m/s" , MarkerPatternShape = StyleParam.PatternShape.VerticalLines , UseDefaults = false)
54+
Chart.BarPolar (r = r4, theta = t, Name="< 5 m/s" , MarkerPatternShape = StyleParam.PatternShape.HorizontalLines, UseDefaults = false)
55+
]
56+
|> Chart.combine
57+
|> Chart.withAngularAxis(
58+
AngularAxis.init(
59+
CategoryOrder = StyleParam.CategoryOrder.Array,
60+
CategoryArray = (["East"; "N-E"; "North"; "N-W"; "West"; "S-W"; "South"; "S-E";]) // set the order of the categorical axis
61+
)
62+
)

tests/CoreTests/CoreTests/CoreTests.fsproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
<!--Test charts-->
1414
<Compile Include="HTMLCodegen\Chart2D.fs" />
1515
<Compile Include="HtmlCodegen\Chart3D.fs" />
16+
<Compile Include="HtmlCodegen\ChartPolar.fs" />
1617
<Compile Include="HtmlCodegen\ChartMap.fs" />
1718
<Compile Include="HtmlCodegen\ChartDomain.fs" />
1819
<!--HTMLCodegen-->
@@ -30,7 +31,6 @@
3031
<Compile Include="Traces\TraceID.fs" />
3132
<Compile Include="HtmlCodegen\SimpleTests.fs" />
3233
<Compile Include="HtmlCodegen\ChartLayout.fs" />
33-
<Compile Include="HtmlCodegen\PolarCharts.fs" />
3434
<Compile Include="HtmlCodegen\TernaryCharts.fs" />
3535
<Compile Include="HtmlCodegen\CarpetCharts.fs" />
3636
<Compile Include="HtmlCodegen\CategoricalCharts.fs" />
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
module CoreTests.HTMLCodegen.ChartPolar
2+
3+
open Expecto
4+
open Plotly.NET
5+
open Plotly.NET.LayoutObjects
6+
open Plotly.NET.TraceObjects
7+
open Plotly.NET.GenericChart
8+
9+
open TestUtils.HtmlCodegen
10+
open ChartPolarTestCharts
11+
12+
module ScatterPolar =
13+
[<Tests>]
14+
let ``ScatterPolar chart HTML codegeneration tests`` =
15+
testList "HTMLCodegen.ChartPolar" [
16+
testList "ScatterPolar" [
17+
]
18+
]
19+
20+
module PointPolar =
21+
[<Tests>]
22+
let ``PointPolar chart HTML codegeneration tests`` =
23+
testList "HTMLCodegen.ChartPolar" [
24+
testList "PointPolar" [
25+
testCase "Polar Point data" ( fun () ->
26+
"""var data = [{"type":"scatterpolar","mode":"markers","r":[1,2,3,4,5,6,7],"theta":[0,45,90,135,200,320,184],"marker":{}}];"""
27+
|> chartGeneratedContains PointPolar.``Simple polar point chart``
28+
);
29+
testCase "Polar Point layout" ( fun () ->
30+
emptyLayout PointPolar.``Simple polar point chart``
31+
);
32+
]
33+
]
34+
35+
module LinePolar =
36+
[<Tests>]
37+
let ``LinePolar chart HTML codegeneration tests`` =
38+
testList "HTMLCodegen.ChartPolar" [
39+
testList "LinePolar" [
40+
testCase "Polar Line data" ( fun () ->
41+
"""var data = [{"type":"scatterpolar","mode":"lines","r":[1,2,3,4,5,6,7],"theta":[0,45,90,135,200,320,184],"marker":{},"line":{"color":"purple","dash":"dashdot"}}];"""
42+
|> chartGeneratedContains LinePolar.``Simple polar line chart with line style``
43+
);
44+
testCase "Polar Line layout" ( fun () ->
45+
emptyLayout LinePolar.``Simple polar line chart with line style``
46+
);
47+
]
48+
]
49+
50+
module SplinePolar =
51+
[<Tests>]
52+
let ``SplinePolar chart HTML codegeneration tests`` =
53+
testList "HTMLCodegen.ChartPolar" [
54+
testList "SplinePolar" [
55+
testCase "Polar Spline data" ( fun () ->
56+
"""var data = [{"type":"scatterpolar","mode":"lines+markers+text","r":[1,2,3,4,5,6,7],"theta":[0,45,90,135,200,320,184],"text":["one","two","three","four","five","six","seven"],"textposition":"top center","marker":{},"line":{"shape":"spline"}}];"""
57+
|> chartGeneratedContains SplinePolar.``styled polar spline chart``
58+
);
59+
testCase "Polar Spline layout" ( fun () ->
60+
emptyLayout SplinePolar.``styled polar spline chart``
61+
);
62+
]
63+
]
64+
65+
module BubblePolar =
66+
[<Tests>]
67+
let ``BubblePolar chart HTML codegeneration tests`` =
68+
testList "HTMLCodegen.ChartPolar" [
69+
testList "BubblePolar" [
70+
]
71+
]
72+
73+
module BarPolar =
74+
[<Tests>]
75+
let ``BarPolar chart HTML codegeneration tests`` =
76+
testList "HTMLCodegen.ChartPolar" [
77+
testList "BarPolar" [
78+
testCase "Polar Bar data" ( fun () ->
79+
"""var data = [{"type":"barpolar","name":"11-14 m/s","r":[77.5,72.5,70.0,45.0,22.5,42.5,40.0,62.5],"theta":["North","N-E","East","S-E","South","S-W","West","N-W"],"marker":{"pattern":{"shape":"+"}}},{"type":"barpolar","name":"8-11 m/s","r":[57.5,50.0,45.0,35.0,20.0,22.5,37.5,55.0],"theta":["North","N-E","East","S-E","South","S-W","West","N-W"],"marker":{"pattern":{"shape":"x"}}},{"type":"barpolar","name":"5-8 m/s","r":[40.0,30.0,30.0,35.0,7.5,7.5,32.5,40.0],"theta":["North","N-E","East","S-E","South","S-W","West","N-W"],"marker":{"pattern":{"shape":"|"}}},{"type":"barpolar","name":"< 5 m/s","r":[20.0,7.5,15.0,22.5,2.5,2.5,12.5,22.5],"theta":["North","N-E","East","S-E","South","S-W","West","N-W"],"marker":{"pattern":{"shape":"-"}}}];"""
80+
|> chartGeneratedContains BarPolar.``Styled windrose chart``
81+
);
82+
testCase "Polar Bar layout" ( fun () ->
83+
"""var layout = {"polar":{"angularaxis":{"categoryorder":"array","categoryarray":["East","N-E","North","N-W","West","S-W","South","S-E"]}}};"""
84+
|> chartGeneratedContains BarPolar.``Styled windrose chart``
85+
);
86+
]
87+
]

tests/CoreTests/CoreTests/HTMLCodegen/PolarCharts.fs

Lines changed: 0 additions & 116 deletions
This file was deleted.

0 commit comments

Comments
 (0)