Skip to content

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

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
gaviei opened this issue Aug 26, 2021 · 0 comments · Fixed by #250
Closed

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

gaviei opened this issue Aug 26, 2021 · 0 comments · Fixed by #250

Comments

@gaviei
Copy link

gaviei commented Aug 26, 2021

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"))  
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

Successfully merging a pull request may close this issue.

1 participant