Skip to content

Commit 8041beb

Browse files
committed
Refactor TernaryCharts tests
1 parent 6264032 commit 8041beb

File tree

6 files changed

+101
-61
lines changed

6 files changed

+101
-61
lines changed

tests/Common/FSharpTestBase/FSharpTestBase.fsproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
<Compile Include="TestCharts\Chart3DTestCharts.fs" />
1818
<Compile Include="TestCharts\ChartPolarTestCharts.fs" />
1919
<Compile Include="TestCharts\ChartMapTestCharts.fs" />
20+
<Compile Include="TestCharts\ChartTernaryTestCharts.fs" />
2021
<Compile Include="TestCharts\ChartDomainTestCharts.fs" />
2122
</ItemGroup>
2223

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
module ChartTernaryTestCharts
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+
module ScatterTernary = ()
12+
13+
module PointTernary =
14+
15+
let ``Styled ternary point chart`` =
16+
Chart.PointTernary(abc = [1,2,3], UseDefaults = false)
17+
|> Chart.withAAxis(LinearAxis.init(Title = Title.init("A"), Color = Color.fromKeyword ColorKeyword.DarkOrchid))
18+
|> Chart.withBAxis(LinearAxis.init(Title = Title.init("B"), Color = Color.fromKeyword ColorKeyword.DarkRed))
19+
|> Chart.withCAxis(LinearAxis.init(Title = Title.init("C"), Color = Color.fromKeyword ColorKeyword.DarkCyan))
20+
21+
module LineTernary =
22+
23+
let ``Styled ternary line chart`` =
24+
Chart.LineTernary(
25+
A = [10; 20; 30; 40; 50; 60; 70; 80;],
26+
B = ([10; 20; 30; 40; 50; 60; 70; 80;] |> List.rev),
27+
Sum = 100,
28+
ShowMarkers = true,
29+
LineDash = StyleParam.DrawingStyle.DashDot,
30+
UseDefaults = false
31+
)
32+
|> Chart.withTernary(
33+
Ternary.init(
34+
AAxis = LinearAxis.init(Color = Color.fromKeyword ColorKeyword.DarkOrchid),
35+
BAxis = LinearAxis.init(Color = Color.fromKeyword ColorKeyword.DarkRed),
36+
CAxis = LinearAxis.init(Color = Color.fromKeyword ColorKeyword.DarkCyan)
37+
)
38+
)
39+
40+
module BubbleTernary = ()

tests/CoreTests/CoreTests/CoreTests.fsproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
<Compile Include="HtmlCodegen\Chart3D.fs" />
1616
<Compile Include="HtmlCodegen\ChartPolar.fs" />
1717
<Compile Include="HtmlCodegen\ChartMap.fs" />
18+
<Compile Include="HtmlCodegen\ChartTernary.fs" />
1819
<Compile Include="HtmlCodegen\ChartDomain.fs" />
1920
<!--HTMLCodegen-->
2021

@@ -31,7 +32,6 @@
3132
<Compile Include="Traces\TraceID.fs" />
3233
<Compile Include="HtmlCodegen\SimpleTests.fs" />
3334
<Compile Include="HtmlCodegen\ChartLayout.fs" />
34-
<Compile Include="HtmlCodegen\TernaryCharts.fs" />
3535
<Compile Include="HtmlCodegen\CarpetCharts.fs" />
3636
<Compile Include="HtmlCodegen\CategoricalCharts.fs" />
3737
<Compile Include="HtmlCodegen\SmithCharts.fs" />
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
module CoreTests.HTMLCodegen.ChartTernary
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 ChartTernaryTestCharts
11+
12+
module ScatterTernary =
13+
[<Tests>]
14+
let ``ScatterTernary chart HTML codegeneration tests`` =
15+
testList "HTMLCodegen.ChartTernary" [
16+
testList "ScatterTernary" [
17+
]
18+
]
19+
20+
module PointTernary =
21+
[<Tests>]
22+
let ``PointTernary chart HTML codegeneration tests`` =
23+
testList "HTMLCodegen.ChartTernary" [
24+
testList "PointTernary" [
25+
testCase "Point data" ( fun () ->
26+
"""var data = [{"type":"scatterternary","mode":"markers","a":[1],"b":[2],"c":[3],"marker":{},"line":{}}];"""
27+
|> chartGeneratedContains PointTernary.``Styled ternary point chart``
28+
)
29+
testCase "Point layout" ( fun () ->
30+
"""var layout = {"ternary":{"aaxis":{"color":"rgba(153, 50, 204, 1.0)","title":{"text":"A"}},"baxis":{"color":"rgba(139, 0, 0, 1.0)","title":{"text":"B"}},"caxis":{"color":"rgba(0, 139, 139, 1.0)","title":{"text":"C"}}}};"""
31+
|> chartGeneratedContains PointTernary.``Styled ternary point chart``
32+
)
33+
]
34+
]
35+
36+
module LineTernary =
37+
[<Tests>]
38+
let ``LineTernary chart HTML codegeneration tests`` =
39+
testList "HTMLCodegen.ChartTernary" [
40+
testList "LineTernary" [
41+
testCase "Line data" ( fun () ->
42+
"""var data = [{"type":"scatterternary","mode":"lines+markers","a":[10,20,30,40,50,60,70,80],"b":[80,70,60,50,40,30,20,10],"marker":{},"line":{"dash":"dashdot"},"sum":100}];"""
43+
|> chartGeneratedContains LineTernary.``Styled ternary line chart``
44+
)
45+
testCase "Line layout" ( fun () ->
46+
"""var layout = {"ternary":{"aaxis":{"color":"rgba(153, 50, 204, 1.0)"},"baxis":{"color":"rgba(139, 0, 0, 1.0)"},"caxis":{"color":"rgba(0, 139, 139, 1.0)"}}};"""
47+
|> chartGeneratedContains LineTernary.``Styled ternary line chart``
48+
)
49+
]
50+
]
51+
52+
module BubbleTernary =
53+
[<Tests>]
54+
let ``BubbleTernary chart HTML codegeneration tests`` =
55+
testList "HTMLCodegen.ChartTernary" [
56+
testList "BubbleTernary" [
57+
]
58+
]

tests/CoreTests/CoreTests/HTMLCodegen/TernaryCharts.fs

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

tests/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ Currently, the following test projects are contained:
6464

6565
#### CoreTests.fsproj
6666

67-
The largets test suirte by far that tests all things Plotly.NET, such as HTML code generation, JSON serialization, Object validity, etc.
67+
The largets test suite by far that tests all things Plotly.NET, such as HTML code generation, JSON serialization, Object validity, etc.
6868

6969
#### CSharpInteroperabilityTests.csproj
7070

0 commit comments

Comments
 (0)