-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- UpdateMenuButton Args is now a collection of DynamicObj - Add tests
- Loading branch information
Showing
6 changed files
with
133 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
tests/Common/FSharpTestBase/TestCharts/FeatureAdditions/UpdateMenuButton_Args.fs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
module UpdateMenuButton_Args_TestCharts | ||
|
||
open Plotly.NET | ||
open Plotly.NET.TraceObjects | ||
open Plotly.NET.LayoutObjects | ||
open DynamicObj | ||
|
||
// https://github.com/plotly/Plotly.NET/issues/414 | ||
|
||
module ``UpdateMenuButton Args as DynamicObj collection #414`` = | ||
|
||
let ``Simple point chart with update buttons triggerin relayout for x axis range`` = | ||
let buttons = | ||
[ for i in 0 .. 9 -> | ||
UpdateMenuButton.init( | ||
Label = $"0 - {i}", | ||
Name = $"{i}", | ||
Visible = true, | ||
Method = StyleParam.UpdateMethod.Relayout, | ||
Args = ( | ||
let tmp = DynamicObj() | ||
tmp?("xaxis.range") <- [0; i] | ||
[tmp] | ||
) | ||
) | ||
] | ||
|
||
Chart.Point( | ||
x = [0 .. 10], | ||
y = [0 .. 10], | ||
UseDefaults = false | ||
) | ||
|> Chart.withUpdateMenu( | ||
UpdateMenu.init( | ||
Buttons = buttons | ||
) | ||
) | ||
|
||
let ``Simple point chart with update buttons triggerin relayout for x and y axis range`` = | ||
|
||
let buttons = | ||
[ for i in 0 .. 9 -> | ||
UpdateMenuButton.init( | ||
Label = $"0 - {i}", | ||
Name = $"{i}", | ||
Visible = true, | ||
Method = StyleParam.UpdateMethod.Relayout, | ||
Args = ( | ||
let tmp = DynamicObj() | ||
tmp?("xaxis.range") <- [0; i] | ||
tmp?("yaxis.range") <- [0; i] | ||
[tmp] | ||
) | ||
) | ||
] | ||
|
||
Chart.Point( | ||
|
||
x = [0 .. 10], | ||
y = [0 .. 10], | ||
UseDefaults = false | ||
) | ||
|> Chart.withUpdateMenu( | ||
UpdateMenu.init( | ||
Buttons = buttons | ||
) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
tests/CoreTests/CoreTests/FeatureAdditions/UpdateMenuButton_Args.fs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// https://github.com/plotly/Plotly.NET/issues/414 | ||
|
||
module CoreTests.UpdateMenuButton_Args | ||
|
||
open Expecto | ||
open Plotly.NET | ||
open Plotly.NET.LayoutObjects | ||
open Plotly.NET.TraceObjects | ||
|
||
open TestUtils.HtmlCodegen | ||
open UpdateMenuButton_Args_TestCharts | ||
|
||
module ``UpdateMenuButton Args as DynamicObj collection #414`` = | ||
|
||
[<Tests>] | ||
let ``UpdateMenuButton Args as DynamicObj collection #414`` = | ||
testList "FeatureAddition.UpdateMenuButton Args must be DynamicObj collection" [ | ||
test "relayout x axis range data" { | ||
"""var data = [{"type":"scatter","mode":"markers","x":[0,1,2,3,4,5,6,7,8,9,10],"y":[0,1,2,3,4,5,6,7,8,9,10],"marker":{},"line":{}}];""" | ||
|> chartGeneratedContains ``UpdateMenuButton Args as DynamicObj collection #414``.``Simple point chart with update buttons triggerin relayout for x axis range`` | ||
} | ||
test "relayout x axis range layout" { | ||
"""var layout = {"updatemenus":[{"buttons":[{"args":[{"xaxis.range":[0,0]}],"label":"0 - 0","method":"relayout","name":"0","visible":true},{"args":[{"xaxis.range":[0,1]}],"label":"0 - 1","method":"relayout","name":"1","visible":true},{"args":[{"xaxis.range":[0,2]}],"label":"0 - 2","method":"relayout","name":"2","visible":true},{"args":[{"xaxis.range":[0,3]}],"label":"0 - 3","method":"relayout","name":"3","visible":true},{"args":[{"xaxis.range":[0,4]}],"label":"0 - 4","method":"relayout","name":"4","visible":true},{"args":[{"xaxis.range":[0,5]}],"label":"0 - 5","method":"relayout","name":"5","visible":true},{"args":[{"xaxis.range":[0,6]}],"label":"0 - 6","method":"relayout","name":"6","visible":true},{"args":[{"xaxis.range":[0,7]}],"label":"0 - 7","method":"relayout","name":"7","visible":true},{"args":[{"xaxis.range":[0,8]}],"label":"0 - 8","method":"relayout","name":"8","visible":true},{"args":[{"xaxis.range":[0,9]}],"label":"0 - 9","method":"relayout","name":"9","visible":true}]}]};""" | ||
|> chartGeneratedContains ``UpdateMenuButton Args as DynamicObj collection #414``.``Simple point chart with update buttons triggerin relayout for x axis range`` | ||
} | ||
test "relayout x and y axis range data" { | ||
"""var data = [{"type":"scatter","mode":"markers","x":[0,1,2,3,4,5,6,7,8,9,10],"y":[0,1,2,3,4,5,6,7,8,9,10],"marker":{},"line":{}}];""" | ||
|> chartGeneratedContains ``UpdateMenuButton Args as DynamicObj collection #414``.``Simple point chart with update buttons triggerin relayout for x and y axis range`` | ||
} | ||
test "relayout x and y axis range layout" { | ||
"""var layout = {"updatemenus":[{"buttons":[{"args":[{"xaxis.range":[0,0],"yaxis.range":[0,0]}],"label":"0 - 0","method":"relayout","name":"0","visible":true},{"args":[{"xaxis.range":[0,1],"yaxis.range":[0,1]}],"label":"0 - 1","method":"relayout","name":"1","visible":true},{"args":[{"xaxis.range":[0,2],"yaxis.range":[0,2]}],"label":"0 - 2","method":"relayout","name":"2","visible":true},{"args":[{"xaxis.range":[0,3],"yaxis.range":[0,3]}],"label":"0 - 3","method":"relayout","name":"3","visible":true},{"args":[{"xaxis.range":[0,4],"yaxis.range":[0,4]}],"label":"0 - 4","method":"relayout","name":"4","visible":true},{"args":[{"xaxis.range":[0,5],"yaxis.range":[0,5]}],"label":"0 - 5","method":"relayout","name":"5","visible":true},{"args":[{"xaxis.range":[0,6],"yaxis.range":[0,6]}],"label":"0 - 6","method":"relayout","name":"6","visible":true},{"args":[{"xaxis.range":[0,7],"yaxis.range":[0,7]}],"label":"0 - 7","method":"relayout","name":"7","visible":true},{"args":[{"xaxis.range":[0,8],"yaxis.range":[0,8]}],"label":"0 - 8","method":"relayout","name":"8","visible":true},{"args":[{"xaxis.range":[0,9],"yaxis.range":[0,9]}],"label":"0 - 9","method":"relayout","name":"9","visible":true}]}]};""" | ||
|> chartGeneratedContains ``UpdateMenuButton Args as DynamicObj collection #414``.``Simple point chart with update buttons triggerin relayout for x and y axis range`` | ||
} | ||
] |