Skip to content

Create different Chart Types in C# #70

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
LucasNmn opened this issue Apr 12, 2021 · 6 comments
Closed

Create different Chart Types in C# #70

LucasNmn opened this issue Apr 12, 2021 · 6 comments

Comments

@LucasNmn
Copy link

Hi there,

I am able to create different point charts in C# with Plotly. As soon as I choose a different chart type like Line, the implementation fails. It makes no difference whether I only specify the two data sequences or the whole parameters that are not required.

Is this a known issue or am i missing something?

@kMutagene
Copy link
Collaborator

Hi @LucasNmn, can you give me a sample code snippet so i can test if i can reproduce what you are experiencing?

@LucasNmn
Copy link
Author

Working Sample (with Point):

double[] x = new double[] { 1,3,4,5,6,7};
double[] y = new double[] { 5,7,6,5,4,3};
...
var chart = Chart.Point(x,y,"Sample",true,StyleParam.Symbol.Circle,"Green",1,null,null,null,null,null,null,false);

or without optional arguments:

var chart2 = Chart.Point(x,y);

Not Working (for Example Line) :
var chartLine = Chart.Line(x,y, "Sample", true, StyleParam.Symbol.Square, "Green", 1, null, null, null, null, null, null, null, null, false) ;

or
var charLine2 = new Chart.Line(x,y);

So the initialization fails and Visual Studio tells me that the type arguments are not explicit.

@kMutagene
Copy link
Collaborator

yep, that one is on us. In many places we let the F# type inference handle the typing of arguments for us, and that does not seem to translate well into C#. The offenders in the case of Chart.Line are the Dash and Width Parameters. When annotating those you can use Chart.Line like this:

static void Main(string[] args)
        {
            double[] x = new double[] { 1, 2 };
            double[] y = new double[] { 5, 10 };
            GenericChart.GenericChart chart = Chart.Line<double,double,StyleParam.DrawingStyle,double>(x: x, y: y, Dash: StyleParam.DrawingStyle.Dash, Width:.2 );
            chart
                .WithTraceName("Hello from C#", true)
                .WithX_AxisStyle(title: "xAxis", Showgrid: false, Showline: true)
                .WithY_AxisStyle(title: "yAxis", Showgrid: false, Showline: true)
                .Show();
        }

This is not ideal and i will try to fix this asap by adding explicit type annotations for all Chart Extensions.

@dsp6414
Copy link

dsp6414 commented Apr 12, 2021

i also expect Some Csharp examples.

@LucasNmn
Copy link
Author

yep, that one is on us. In many places we let the F# type inference handle the typing of arguments for us, and that does not seem to translate well into C#. The offenders in the case of Chart.Line are the Dash and Width Parameters. When annotating those you can use Chart.Line like this:

static void Main(string[] args)
        {
            double[] x = new double[] { 1, 2 };
            double[] y = new double[] { 5, 10 };
            GenericChart.GenericChart chart = Chart.Line<double,double,StyleParam.DrawingStyle,double>(x: x, y: y, Dash: StyleParam.DrawingStyle.Dash, Width:.2 );
            chart
                .WithTraceName("Hello from C#", true)
                .WithX_AxisStyle(title: "xAxis", Showgrid: false, Showline: true)
                .WithY_AxisStyle(title: "yAxis", Showgrid: false, Showline: true)
                .Show();
        }

This is not ideal and i will try to fix this asap by adding explicit type annotations for all Chart Extensions.

Ok, thanks for the tip. I will try that.

@LucasNmn
Copy link
Author

It's working. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants