Skip to content

Commit 6501a3a

Browse files
committed
Add ternary tests
1 parent a7a45dd commit 6501a3a

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
module Tests.TernaryCharts
2+
3+
open Expecto
4+
open Plotly.NET
5+
open Plotly.NET.LayoutObjects
6+
open Plotly.NET.TraceObjects
7+
open Plotly.NET.GenericChart
8+
open System
9+
10+
open TestUtils.HtmlCodegen
11+
12+
let pointTernary =
13+
Chart.PointTernary([1,2,3])
14+
|> Chart.withAAxis(LinearAxis.init(Title = Title.init("A"), Color = Color.fromKeyword ColorKeyword.DarkOrchid))
15+
|> Chart.withBAxis(LinearAxis.init(Title = Title.init("B"), Color = Color.fromKeyword ColorKeyword.DarkRed))
16+
|> Chart.withCAxis(LinearAxis.init(Title = Title.init("C"), Color = Color.fromKeyword ColorKeyword.DarkCyan))
17+
18+
let lineTernary =
19+
Chart.LineTernary(
20+
A = [10; 20; 30; 40; 50; 60; 70; 80;],
21+
B = ([10; 20; 30; 40; 50; 60; 70; 80;] |> List.rev),
22+
Sum = 100,
23+
ShowMarkers = true,
24+
Dash = StyleParam.DrawingStyle.DashDot
25+
)
26+
|> Chart.withTernary(
27+
Ternary.init(
28+
AAxis = LinearAxis.init(Color = Color.fromKeyword ColorKeyword.DarkOrchid),
29+
BAxis = LinearAxis.init(Color = Color.fromKeyword ColorKeyword.DarkRed),
30+
CAxis = LinearAxis.init(Color = Color.fromKeyword ColorKeyword.DarkCyan)
31+
)
32+
)
33+
34+
[<Tests>]
35+
let ``Ternary Point charts`` =
36+
testList "TernaryCharts.Line charts" [
37+
testCase "Point data" ( fun () ->
38+
"""var data = [{"type":"scatterternary","mode":"markers","a":[1],"b":[2],"c":[3],"marker":{}}];"""
39+
|> chartGeneratedContains pointTernary
40+
)
41+
testCase "Point layout" ( fun () ->
42+
"""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"}}}};"""
43+
|> chartGeneratedContains pointTernary
44+
)
45+
]
46+
47+
[<Tests>]
48+
let ``Ternary Line charts`` =
49+
testList "TernaryCharts.Line charts" [
50+
testCase "Line data" ( fun () ->
51+
"""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],"sum":100,"line":{"dash":"dashdot"},"marker":{}}];"""
52+
|> chartGeneratedContains lineTernary
53+
)
54+
testCase "Line layout" ( fun () ->
55+
"""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)"}}};"""
56+
|> chartGeneratedContains lineTernary
57+
)
58+
]

tests/Plotly.NET.Tests/Plotly.NET.Tests.fsproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
<Compile Include="HtmlCodegen\MapboxMapCharts.fs" />
2020
<Compile Include="HtmlCodegen\FinanceCharts.fs" />
2121
<Compile Include="HtmlCodegen\PolarCharts.fs" />
22+
<Compile Include="HtmlCodegen\TernaryCharts.fs" />
2223
<Compile Include="HtmlCodegen\CategoricalCharts.fs" />
2324
<Compile Include="ImageExport.fs" />
2425
<Compile Include="Main.fs" />

0 commit comments

Comments
 (0)