Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

how to define Args parameter for UpdateMenuButton.init for release version 5.0 #456

Answered by kMutagene
kunjiangkun asked this question in Q&A
Discussion options

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?

You must be logged in to vote

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:

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.Res...

Replies: 1 comment

Comment options

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:

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}))
You must be logged in to vote
0 replies
Answer selected by kunjiangkun
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /