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+ ]
0 commit comments