Skip to content

Commit 1f1b4fb

Browse files
committed
Refactor CarpetCharts tests
1 parent 8041beb commit 1f1b4fb

File tree

5 files changed

+228
-147
lines changed

5 files changed

+228
-147
lines changed

tests/Common/FSharpTestBase/FSharpTestBase.fsproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
<Compile Include="TestCharts\ChartPolarTestCharts.fs" />
1919
<Compile Include="TestCharts\ChartMapTestCharts.fs" />
2020
<Compile Include="TestCharts\ChartTernaryTestCharts.fs" />
21+
<Compile Include="TestCharts\ChartCarpetTestCharts.fs" />
2122
<Compile Include="TestCharts\ChartDomainTestCharts.fs" />
2223
</ItemGroup>
2324

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
module ChartCarpetTestCharts
2+
3+
4+
open Plotly.NET
5+
open Plotly.NET.TraceObjects
6+
open Plotly.NET.LayoutObjects
7+
open System
8+
9+
open TestUtils.DataGeneration
10+
open Deedle
11+
12+
let internal a = [4.; 4.; 4.; 4.5; 4.5; 4.5; 5.; 5.; 5.; 6.; 6.; 6.]
13+
let internal b = [1.; 2.; 3.; 1.; 2.; 3.; 1.; 2.; 3.; 1.; 2.; 3.]
14+
let internal y = [2.; 3.5; 4.; 3.; 4.5; 5.; 5.5; 6.5; 7.5; 8.; 8.5; 10.]
15+
16+
let internal carpets =
17+
[
18+
Chart.Carpet(carpetId = "carpet1",A = a, B = b, Y = y, UseDefaults = false)
19+
Chart.Carpet(carpetId = "carpet2",A = (a |> List.rev) , B = (b |> List.rev), Y = (y |> List.map (fun x -> x + 10.)), UseDefaults = false)
20+
Chart.Carpet(carpetId = "carpet3",A = a, B = b, Y = (y |> List.map (fun x -> x + 20.)), UseDefaults = false)
21+
Chart.Carpet(carpetId = "carpet4",A = (a |> List.rev) , B = (b |> List.rev), Y = (y |> List.map (fun x -> x + 30.)), UseDefaults = false)
22+
Chart.Carpet(carpetId = "carpet5",A = a, B = b, Y = (y |> List.map (fun x -> x + 40.)), UseDefaults = false)
23+
]
24+
25+
let internal aData = [4.; 5.; 5.; 6.]
26+
let internal bData = [1.; 1.; 2.; 3.]
27+
let internal sizes = [5; 10; 15; 20]
28+
29+
let internal carpetCharts =
30+
[
31+
Chart.ScatterCarpet(
32+
a = aData,b = bData,
33+
mode = StyleParam.Mode.Lines_Markers,
34+
carpetAnchorId = "carpet1",
35+
Name = "Scatter",
36+
MultiMarkerSymbol =[
37+
StyleParam.MarkerSymbol.ArrowDown
38+
StyleParam.MarkerSymbol.TriangleNW
39+
StyleParam.MarkerSymbol.DiamondX
40+
StyleParam.MarkerSymbol.Hexagon2
41+
],
42+
MarkerColor = Color.fromColors ([Red; Blue; Green; Yellow] |> List.map Color.fromKeyword),
43+
UseDefaults = false
44+
)
45+
Chart.PointCarpet(a = aData, b = bData, carpetAnchorId = "carpet2",Name = "Point", UseDefaults = false)
46+
Chart.LineCarpet(a = aData, b = bData, carpetAnchorId = "carpet3",Name = "Line", UseDefaults = false)
47+
Chart.SplineCarpet(a = aData, b = bData, carpetAnchorId = "carpet4",Name = "Spline", UseDefaults = false)
48+
Chart.BubbleCarpet(absizes = (Seq.zip3 aData bData sizes), carpetAnchorId = "carpet5",Name = "Bubble", UseDefaults = false)
49+
]
50+
51+
module Carpet =
52+
53+
let ``Base carpet chart`` = carpets[0]
54+
55+
module ScatterCarpet =
56+
57+
let ``Simple carpet scatter chart`` = Chart.combine [carpets.[0]; carpetCharts.[0]]
58+
59+
module PointCarpet =
60+
61+
let ``Simple carpet point chart`` = Chart.combine [carpets.[1]; carpetCharts.[1]]
62+
63+
module LineCarpet =
64+
65+
let ``Simple carpet line chart`` = Chart.combine [carpets.[2]; carpetCharts.[2]]
66+
67+
module SplineCarpet =
68+
69+
let ``Simple carpet spline chart`` = Chart.combine [carpets.[3]; carpetCharts.[3]]
70+
71+
module BubbleCarpet =
72+
73+
let ``Simple carpet bubble chart`` = Chart.combine [carpets.[4]; carpetCharts.[4]]
74+
75+
module ContourCarpet =
76+
77+
let ``Styled carpet contour chart`` =
78+
[
79+
Chart.Carpet(
80+
carpetId = "contour",
81+
A = [0.; 1.; 2.; 3.; 0.; 1.; 2.; 3.; 0.; 1.; 2.; 3.],
82+
B = [4.; 4.; 4.; 4.; 5.; 5.; 5.; 5.; 6.; 6.; 6.; 6.],
83+
X = [2.; 3.; 4.; 5.; 2.2; 3.1; 4.1; 5.1; 1.5; 2.5; 3.5; 4.5],
84+
Y = [1.; 1.4; 1.6; 1.75; 2.; 2.5; 2.7; 2.75; 3.; 3.5; 3.7; 3.75],
85+
AAxis = LinearAxis.initCarpet(
86+
TickPrefix = "a = ",
87+
Smoothing = 0.,
88+
MinorGridCount = 9,
89+
AxisType = StyleParam.AxisType.Linear
90+
),
91+
BAxis = LinearAxis.initCarpet(
92+
TickPrefix = "b = ",
93+
Smoothing = 0.,
94+
MinorGridCount = 9,
95+
AxisType = StyleParam.AxisType.Linear
96+
),
97+
UseDefaults = false,
98+
Opacity = 0.75
99+
)
100+
Chart.ContourCarpet(
101+
z = [1.; 1.96; 2.56; 3.0625; 4.; 5.0625; 1.; 7.5625; 9.; 12.25; 15.21; 14.0625],
102+
carpetAnchorId = "contour",
103+
A = [0; 1; 2; 3; 0; 1; 2; 3; 0; 1; 2; 3],
104+
B = [4; 4; 4; 4; 5; 5; 5; 5; 6; 6; 6; 6],
105+
UseDefaults = false,
106+
ContourLineColor = Color.fromKeyword White,
107+
ShowContourLabels = true
108+
)
109+
]
110+
|> Chart.combine

tests/CoreTests/CoreTests/CoreTests.fsproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
<Compile Include="HtmlCodegen\ChartPolar.fs" />
1717
<Compile Include="HtmlCodegen\ChartMap.fs" />
1818
<Compile Include="HtmlCodegen\ChartTernary.fs" />
19+
<Compile Include="HtmlCodegen\ChartCarpet.fs" />
1920
<Compile Include="HtmlCodegen\ChartDomain.fs" />
2021
<!--HTMLCodegen-->
2122

@@ -32,7 +33,6 @@
3233
<Compile Include="Traces\TraceID.fs" />
3334
<Compile Include="HtmlCodegen\SimpleTests.fs" />
3435
<Compile Include="HtmlCodegen\ChartLayout.fs" />
35-
<Compile Include="HtmlCodegen\CarpetCharts.fs" />
3636
<Compile Include="HtmlCodegen\CategoricalCharts.fs" />
3737
<Compile Include="HtmlCodegen\SmithCharts.fs" />
3838
<Compile Include="HtmlCodegen\MulticategoryData.fs" />

tests/CoreTests/CoreTests/HTMLCodegen/CarpetCharts.fs

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

0 commit comments

Comments
 (0)