diff --git a/src/Plotly.NET/Layout/ObjectAbstractions/Common/UpdateMenu.fs b/src/Plotly.NET/Layout/ObjectAbstractions/Common/UpdateMenu.fs index 0216bc60..f0607cf7 100644 --- a/src/Plotly.NET/Layout/ObjectAbstractions/Common/UpdateMenu.fs +++ b/src/Plotly.NET/Layout/ObjectAbstractions/Common/UpdateMenu.fs @@ -10,8 +10,8 @@ type UpdateMenuButton() = static member init ( - [] ?Args: seq, - [] ?Args2: seq, + [] ?Args: seq, + [] ?Args2: seq, [] ?Execute: bool, [] ?Label: string, [] ?Method: StyleParam.UpdateMethod, @@ -34,8 +34,8 @@ type UpdateMenuButton() = static member style ( - [] ?Args: seq, - [] ?Args2: seq, + [] ?Args: seq, + [] ?Args2: seq, [] ?Execute: bool, [] ?Label: string, [] ?Method: StyleParam.UpdateMethod, diff --git a/tests/Common/FSharpTestBase/FSharpTestBase.fsproj b/tests/Common/FSharpTestBase/FSharpTestBase.fsproj index 842b5772..1f7e2035 100644 --- a/tests/Common/FSharpTestBase/FSharpTestBase.fsproj +++ b/tests/Common/FSharpTestBase/FSharpTestBase.fsproj @@ -12,6 +12,7 @@ + diff --git a/tests/Common/FSharpTestBase/TestCharts/FeatureAdditions/UpdateMenuButton_Args.fs b/tests/Common/FSharpTestBase/TestCharts/FeatureAdditions/UpdateMenuButton_Args.fs new file mode 100644 index 00000000..2e66e3c8 --- /dev/null +++ b/tests/Common/FSharpTestBase/TestCharts/FeatureAdditions/UpdateMenuButton_Args.fs @@ -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 + ) + ) \ No newline at end of file diff --git a/tests/ConsoleApps/FSharpConsole/Program.fs b/tests/ConsoleApps/FSharpConsole/Program.fs index 5b16cc20..0dbc9ae7 100644 --- a/tests/ConsoleApps/FSharpConsole/Program.fs +++ b/tests/ConsoleApps/FSharpConsole/Program.fs @@ -14,10 +14,33 @@ let getZeroCollection n : float []= [] let main argv = - Chart.Histogram2DContour( - MultiX = [["A";"A";"A";"B";"B"];["AA"; "AA"; "AB"; "BA"; "BB"]], - MultiY = [["A";"A";"A";"B";"B"];["AA"; "AA"; "AB"; "BA"; "BB"]], + + 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 + ) + ) |> Chart.show 0 \ No newline at end of file diff --git a/tests/CoreTests/CoreTests/CoreTests.fsproj b/tests/CoreTests/CoreTests/CoreTests.fsproj index 4e8302ae..08b1d28e 100644 --- a/tests/CoreTests/CoreTests/CoreTests.fsproj +++ b/tests/CoreTests/CoreTests/CoreTests.fsproj @@ -45,6 +45,7 @@ + diff --git a/tests/CoreTests/CoreTests/FeatureAdditions/UpdateMenuButton_Args.fs b/tests/CoreTests/CoreTests/FeatureAdditions/UpdateMenuButton_Args.fs new file mode 100644 index 00000000..f575448d --- /dev/null +++ b/tests/CoreTests/CoreTests/FeatureAdditions/UpdateMenuButton_Args.fs @@ -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`` = + + [] + 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`` + } + ] \ No newline at end of file