nicolaskruchten / pivottable

Open-source Javascript Pivot Table (aka Pivot Grid, Pivot Chart, Cross-Tab) implementation with drag'n'drop.
https://pivottable.js.org/
MIT License
4.35k stars 1.08k forks source link

Heatmap to color cells even when all the values are the same #1306

Open chutzimir opened 2 years ago

chutzimir commented 2 years ago

Currently when the table only plots one possible value (e.g., table of NULL and 1), the cells with a value have no color. I thought this is counterintuitive, so I tried a custom heatmap using the weather example. Indeed, using Plotly as below I can get the same heatmap as now, but when my table only has a single possible value I can still tell the cells with values from those with no value because they are white.

    rendererOptions: {
        heatmap: {
            colorScaleGenerator: function(values) {
                var min, max;
                min = Math.min.apply(Math, values);
                max = Math.max.apply(Math, values);
                return Plotly.d3.scale.linear()
                    .domain([min, max])
                    .range(["white", "red"])
                ;
            }
        }
    },