Skip to content

Commit

Permalink
manually set palette is no longer squished in heatmaps
Browse files Browse the repository at this point in the history
  • Loading branch information
kloivenn committed Feb 15, 2024
1 parent e073e83 commit e34c096
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
10 changes: 10 additions & 0 deletions example/hetamap.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,15 @@
.mode("canvas")
.value((row, col) => Math.random())
.legendTitle("BBB!")
.place("#container");

var hm_bw = lc.heatmap()
.nrows(30)
.ncols(30)
.mode("canvas")
.palette(["white", "black"])
.colourDomain([0, 1])
.value((row, col) => Math.random())
.legendTitle("CCC!")
.place("#container");
</script>
2 changes: 1 addition & 1 deletion lib/linked-charts.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/heatmap.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export function heatmap(id, chart){
if(Array.isArray(value)){
value = value.map(el => /^#[0-9a-fA-F]{8,8}$/.test(el) ? el.substring(0, 7) : el);
return d3.scaleLinear()
.domain(d3.range(value.length).map(function(el) {return el/value.length}))
.domain(d3.range(value.length).map(function(el) {return el/(value.length - 1)}))
.range(value);
}
if(typeof value === "function")
Expand Down

0 comments on commit e34c096

Please sign in to comment.