Skip to content

Improve usability from C# #52

Closed
Closed
@kMutagene

Description

@kMutagene

Description

There were already reports regarding problems using Plotly.NET from C#, e.g. #29 .

Problems regarding the translation of F# options into C# have been fixed, however there are 2 main issues left:

  • Extension methods defined in the ChartExtensions module do not works as intended. This can be fixed using the [<System.Runtime.CompilerServices.Extension>] atttribute for those methods, making it possible to call the methods on chart instances in C#, e.g

    myChart |> Chart.Show

    will in C# be

    myChart.Show()

    The extension method must have the Chart as first parameter though, so overloads for all fitting methods are necessary. Additionally, using static ChartExtensions already works.

    implemented via members of GenericChart via c1ed1be

  • Generic types are easier to use in F#. Consider the following F# example:

    Chart.Point(data,Color="#ffffff")

    In this case, Color is not typed in the Chart.Point function, and is infered as generic 'a1. This is not the case in C#, where you must annotate it (the second string annotation). :

    var chart = Chart.Point<double, double, string, string>(data, Color: "#ffffff");
    
    //This is what you should be able to do:
    var chart = Chart.Point<double, double, string>(data, Color: "#ffffff");

    I see no solution for that other than adding type annotations to the respective parameters extensively.

However, when these issues are taken care of, from my limited usage of C# it seems like we can reach comfortable usage in that language with these features added.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions