Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add ternary tests
  • Loading branch information
kMutagene committed Sep 15, 2021
commit 6501a3a1294de3799745100915f3e96d5c08bb05
58 changes: 58 additions & 0 deletions tests/Plotly.NET.Tests/HtmlCodegen/TernaryCharts.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
module Tests.TernaryCharts

open Expecto
open Plotly.NET
open Plotly.NET.LayoutObjects
open Plotly.NET.TraceObjects
open Plotly.NET.GenericChart
open System

open TestUtils.HtmlCodegen

let pointTernary =
Chart.PointTernary([1,2,3])
|> Chart.withAAxis(LinearAxis.init(Title = Title.init("A"), Color = Color.fromKeyword ColorKeyword.DarkOrchid))
|> Chart.withBAxis(LinearAxis.init(Title = Title.init("B"), Color = Color.fromKeyword ColorKeyword.DarkRed))
|> Chart.withCAxis(LinearAxis.init(Title = Title.init("C"), Color = Color.fromKeyword ColorKeyword.DarkCyan))

let lineTernary =
Chart.LineTernary(
A = [10; 20; 30; 40; 50; 60; 70; 80;],
B = ([10; 20; 30; 40; 50; 60; 70; 80;] |> List.rev),
Sum = 100,
ShowMarkers = true,
Dash = StyleParam.DrawingStyle.DashDot
)
|> Chart.withTernary(
Ternary.init(
AAxis = LinearAxis.init(Color = Color.fromKeyword ColorKeyword.DarkOrchid),
BAxis = LinearAxis.init(Color = Color.fromKeyword ColorKeyword.DarkRed),
CAxis = LinearAxis.init(Color = Color.fromKeyword ColorKeyword.DarkCyan)
)
)

[<Tests>]
let ``Ternary Point charts`` =
testList "TernaryCharts.Line charts" [
testCase "Point data" ( fun () ->
"""var data = [{"type":"scatterternary","mode":"markers","a":[1],"b":[2],"c":[3],"marker":{}}];"""
|> chartGeneratedContains pointTernary
)
testCase "Point layout" ( fun () ->
"""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"}}}};"""
|> chartGeneratedContains pointTernary
)
]

[<Tests>]
let ``Ternary Line charts`` =
testList "TernaryCharts.Line charts" [
testCase "Line data" ( fun () ->
"""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":{}}];"""
|> chartGeneratedContains lineTernary
)
testCase "Line layout" ( fun () ->
"""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)"}}};"""
|> chartGeneratedContains lineTernary
)
]
1 change: 1 addition & 0 deletions tests/Plotly.NET.Tests/Plotly.NET.Tests.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<Compile Include="HtmlCodegen\MapboxMapCharts.fs" />
<Compile Include="HtmlCodegen\FinanceCharts.fs" />
<Compile Include="HtmlCodegen\PolarCharts.fs" />
<Compile Include="HtmlCodegen\TernaryCharts.fs" />
<Compile Include="HtmlCodegen\CategoricalCharts.fs" />
<Compile Include="ImageExport.fs" />
<Compile Include="Main.fs" />
Expand Down