LayTec-AG / Plotly.Blazor

This library packages the well-known charting library plotly.js into a razor component that can be used in a Blazor project.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Setting Heatmap Colorscale

EuanKirkhope opened this issue · comments

commented

I'm trying to set a custom color scale in a heatmap, but can't work out the C# syntax. I've various instances of the following but none work:

ColorScale = new List<object>
            {
                (0.0, "#f33"),
                (0.5, "#3f3"),
                (1.0, "#33f")
            },

ColorScale = new Dictionary<double, string>
            {
                {0.0, "#f33" },
                {0.5, "#3f3" },
                {1.0, "#33f" }
            },

The JS reference is:

    colorscale: [
        ['0.0', 'rgb(165,0,38)'],
        ['0.1', 'rgb(215,48,39)'],
        ['0.2', 'rgb(244,109,67)'],
        ['0.3', 'rgb(253,174,97)'],
        ['0.4', 'rgb(254,224,144)'],
        ['0.5', 'rgb(224,243,248)'],
        ['0.6', 'rgb(171,217,233)'],
        ['0.7', 'rgb(116,173,209)'],
        ['0.8', 'rgb(69,117,180)'],
        ['1.0', 'rgb(49,54,149)']
  ]

commented

All good found the info in the plotly schma, an array of two item arrays...

ColorScale = new object[]
            {
                new object[] {0.0, "#f33" },
                new object[] {0.5, "#3f3" },
                new object[] {1.0, "#33f" }
            },