Uh oh!
There was an error while loading. Please reload this page.
how to define Args parameter for UpdateMenuButton.init for release version 5.0 #456
Answered
bykMutagene
kunjiangkun
asked this question in
Q&A
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? |
Answered by
kMutagene
Jun 5, 2024
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: usingPlotly.NET;usingPlotly.NET.LayoutObjects;usingDynamicObj;varmode1=newDynamicObj.DynamicObj();mode1.SetValue("mode","markers");varmode2=newDynamicObj.DynamicObj();mode2.SetValue("mode","lines");varmyBtn1=UpdateMenuButton.init(Args:newDynamicObj.DynamicObj[]{mode1},Label:"Markers",Method:StyleParam.UpdateMethod.Restyle);varmyBtn2=UpdateMenuButton.init(Args:newDynamicObj.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:newUpdateMenuButton[]{myBtn1,myBtn2})) |
0 replies
Answer selected bykunjiangkun
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
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,argsis 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: