Any C# sample with connectgaps #434
-
Hello, do you have any sample in C# to help create a line plot with connectgaps property ? I saw #146, but i don't know how to convert it from F# to C#. Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
@davidsaurel, if it is the dynamic object syntax that is the issue, you may check https://plotly.net/#Declarative-style-in-C-using-the-underlying Otherwise, chatgpt often helps translate language you don't know to another syntax, despite it wouldn't be 1 to 1 due to Plotly.NET.CSharp having its own set of idioms on top of the underlying implementation, and C# being a bit restrictive with bringing types of same name from different namespaces in scope. In meantime, you can add a F# project to your dotnet solution, and put the code sample there, extract the parameters, and call it from C# code. If you come up with the equivalent known to work sample, you may contribute it to the documentation, if the bindings are missing in C#, you may contribute a PR to this repository to add support for it. I could not translate it quickly, because of C# tooling lacking around script, and the editor from dotnet interactive not having the extensive language support needed to solve the issue at hand quickly. |
Beta Was this translation helpful? Give feedback.
-
@davidsaurel thanks for this question. I am afraid that applying this in C# is quite hard because you must either apply the tracestyle function (which is very FSharpy as it takes a function as argument) or use dynamic object style. The first solution would look like this. It has the same problems that eventually lead to However, as a workaround it at least works: using Plotly.NET.CSharp;
var chart =
Chart.Scatter<float,int,string>(
mode: Plotly.NET.StyleParam.Mode.Lines_Markers,
x: new float[] { 1, 2, float.NaN, 4 },
y: new int[] { 1, 2, 3, 4 }
);
Plotly.NET.GenericChart.mapTrace(
Plotly.NET.Trace2DStyle.Scatter<float,float,float,float,float,float,float,float,float,float,float,float,float,float,Plotly.NET.Trace>(
ConnectGaps: true
),
chart
);
chart I think we eventually need a |
Beta Was this translation helpful? Give feedback.
-
Thanks you guys |
Beta Was this translation helpful? Give feedback.
@davidsaurel thanks for this question. I am afraid that applying this in C# is quite hard because you must either apply the tracestyle function (which is very FSharpy as it takes a function as argument) or use dynamic object style.
The first solution would look like this. It has the same problems that eventually lead to
Plotly.NET.CSharp
(see #322), namely the huge amount of generic type annotations that you just do not have to set using the function from F#.However, as a workaround it at least works: