how to define Args parameter for UpdateMenuButton.init for release version 5.0 #456
-
Following code doesn't compile anymore with release 5.0: UpdateMenuButton.init(Args: new string[] { "mode", "lines"}, Label: "Lines", Method: UpdateMethod.Restyle) Args with string[] is no longer valid. How to define args with release 5.0? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hi @kunjiangkun, The original intention of changing the argument type to This means that you now have to create dynamic objects with field names set to your argument names. Here is a simple example: using Plotly.NET;
using Plotly.NET.LayoutObjects;
using DynamicObj;
var mode1 = new DynamicObj.DynamicObj();
mode1.SetValue("mode", "markers");
var mode2 = new DynamicObj.DynamicObj();
mode2.SetValue("mode", "lines");
var myBtn1 = UpdateMenuButton.init(
Args: new DynamicObj.DynamicObj[] {mode1}, Label: "Markers", Method: StyleParam.UpdateMethod.Restyle);
var myBtn2 = UpdateMenuButton.init(
Args: new DynamicObj.DynamicObj[] {mode2}, Label: "Lines", Method: StyleParam.UpdateMethod.Restyle);
Chart2D.Chart.Point<int,int,string>(
x: new[] {1, 2, 3, 4},
y: new[] {10, 11, 12, 13}
)
.WithUpdateMenu(UpdateMenu.init(Buttons: new UpdateMenuButton[] {myBtn1, myBtn2})) |
Beta Was this translation helpful? Give feedback.
Hi @kunjiangkun,
The original intention of changing the argument type to
DynamicObj[]
was to support arguments of different types (see #414), because in the final schema,args
is a json array with arbitrary types.This means that you now have to create dynamic objects with field names set to your argument names. Here is a simple example: