Skip to content

'GenericChart' does not contain a definition for 'WithTitle' #491

@giiyms

Description

@giiyms

I keep getting the error while using Plotly.NET.CSharp.

Error: (46,5): error CS1061: 'GenericChart' does not contain a definition for 'WithTitle' and no accessible extension method 'WithTitle' accepting a first argument of type 'GenericChart' could be found (are you missing a using directive or an assembly reference?)

It works when I call the Extension directly Plotly.NET.GenericChartExtensions.WithTitle(chart, "foobar") but chart.WithTitle("foobar") does not work.

I think its unsure whether to use F# or C# GenericChart. Any workarounds?

using Ext = Plotly.NET.GenericChartExtensions;
using StyleParam = Plotly.NET.StyleParam;
using Color = Plotly.NET.Color;
using Marker = Plotly.NET.TraceObjects.Marker;
using MarkerSymbol = Plotly.NET.StyleParam.MarkerSymbol;
using Mode = Plotly.NET.StyleParam.Mode;
using Colorscale = Plotly.NET.StyleParam.Colorscale;
using ColorKeyword = Plotly.NET.ColorKeyword;
using Title = Plotly.NET.Title;


var pcaLeadingTrailingChart = Chart.Scatter<double, double, string>(
    x: new[] { pc1Values[leadingIdx], pc1Values[trailingIdx] },
    y: new[] { pc2Values[leadingIdx], pc2Values[trailingIdx] },
    mode: Mode.Markers,
    MarkerColor: Color.fromColors(new[] { Color.fromKeyword(ColorKeyword.Red), Color.fromKeyword(ColorKeyword.Blue) }),
    Marker: Marker.init(
        Size: 10,
        Symbol: MarkerSymbol.Circle
    ),
    Name: "Leading/Trailing PCA"
);

Plotly.NET.GenericChartExtensions.WithTitle(pcaLeadingTrailingChart, "Leading/Trailing PCA");


// I think it is meant to work like this but it does not
var pcaLeadingTrailingChart = Chart.Scatter<double, double, string>(
    x: new[] { pc1Values[leadingIdx], pc1Values[trailingIdx] },
    y: new[] { pc2Values[leadingIdx], pc2Values[trailingIdx] },
    mode: Mode.Markers,
    MarkerColor: Color.fromColors(new[] { Color.fromKeyword(ColorKeyword.Red), Color.fromKeyword(ColorKeyword.Blue) }),
    Marker: Marker.init(
        Size: 10,
        Symbol: MarkerSymbol.Circle
    ),
    Name: "Leading/Trailing PCA"
).WithTitle("Leading/Trailing PCA");

Error: (46,5): error CS1061: 'GenericChart' does not contain a definition for 'WithTitle' and no accessible extension method 'WithTitle' accepting a first argument of type 'GenericChart' could be found (are you missing a using directive or an assembly reference?)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions