mirror of
https://github.com/apache/superset.git
synced 2026-04-22 01:24:43 +00:00
[heatmap] numerous improvements (#3456)
* [heatmap] numerous improvements * flexibility as to how to sort X and Y axis (alpha/value, desc/asc) * option to show a legend * fixed margins, maximize real estate * allowed users to define bounds * Tunning
This commit is contained in:
committed by
GitHub
parent
8223729e1e
commit
49f24d128b
@@ -116,17 +116,20 @@ export const getColorFromScheme = (function () {
|
||||
};
|
||||
}());
|
||||
|
||||
export const colorScalerFactory = function (colors, data, accessor) {
|
||||
export const colorScalerFactory = function (colors, data, accessor, extents) {
|
||||
// Returns a linear scaler our of an array of color
|
||||
if (!Array.isArray(colors)) {
|
||||
/* eslint no-param-reassign: 0 */
|
||||
colors = spectrums[colors];
|
||||
}
|
||||
let ext = [0, 1];
|
||||
if (data !== undefined) {
|
||||
if (extents) {
|
||||
ext = extents;
|
||||
}
|
||||
if (data) {
|
||||
ext = d3.extent(data, accessor);
|
||||
}
|
||||
const chunkSize = (ext[1] - ext[0]) / (colors.length - 1);
|
||||
const points = colors.map((col, i) => i * chunkSize);
|
||||
return d3.scale.linear().domain(points).range(colors);
|
||||
const points = colors.map((col, i) => ext[0] + (i * chunkSize));
|
||||
return d3.scale.linear().domain(points).range(colors).clamp(true);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user