Skip to content

Table.cellValues and TableColorCells read two dimensional arrays in different orders #155

@gaviei

Description

@gaviei

Regarding the example Cell Color Based on Variable in https://plotly.com/python/table/, values are used as a base for higher or lesser cell color intensity.
When implementing the example in Plotly.Net, I noticed that cell values are read to the right, while cell colors are read down, which is not a bug, but makes usability a awkward in such cases:

#r "nuget: Plotly.NET, 2.0.0-preview.6"
#r "nuget: Plotly.NET.Interactive, 2.0.0-preview.6"

open Plotly.NET
open System

let headers = ["<b>Column A</b>"; "<b>Column B</b>"; "<b>Column C</b>"]

let rows = [
                [5; 5; 6]
                [8; 2; 7]
                [5; 4; 6]
                [0; 2; 1]
                [0; 4; 0]
                [1; 7; 1]
                [7; 7; 8]
                [6; 1; 8]
                [2; 7; 3]
                [4; 0; 8]
            ];

let maxIntensity = 8.0
let maxTone = 200.0
let toneOfRed intensity =     
    let blueGreenValue = (1.0 - (float intensity / maxIntensity)) * maxTone
    sprintf "rgb(235, %.0f, %.0f)" blueGreenValue blueGreenValue

let colorCells = rows |> Seq.map (Seq.map toneOfRed) 
let colorCells2 = [colorCells |> Seq.map(Seq.item 0);
                   colorCells |> Seq.map(Seq.item 1); 
                   colorCells |> Seq.map(Seq.item 2)]

Chart.Table(headers, 
            rows,
            ColorCells = colorCells2,
            LineCells = Line.init(Width = 0.0),
            FontCells = Font.init(Color="#FFFFFF"))  

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions