feat: pass color range parameters to the heatmap component

This commit is contained in:
Mattc1221 2023-11-09 00:53:42 -06:00
parent ce9d6f15d7
commit bc1414729a
2 changed files with 18 additions and 1 deletions

View File

@ -71,6 +71,9 @@ function Calendar(element, props) {
valueFormatter, valueFormatter,
verboseMap, verboseMap,
theme, theme,
colorRangeEnd,
colorRangeStart,
useCustomColorRange,
} = props; } = props;
const container = d3Select(element) const container = d3Select(element)
@ -93,7 +96,9 @@ function Calendar(element, props) {
calContainer.text(`${METRIC_TEXT}: ${verboseMap[metric] || metric}`); calContainer.text(`${METRIC_TEXT}: ${verboseMap[metric] || metric}`);
} }
const timestamps = metricsData[metric]; const timestamps = metricsData[metric];
const extents = d3Extent(Object.keys(timestamps), key => timestamps[key]); const extents = useCustomColorRange
? [colorRangeStart, colorRangeEnd - 1]
: d3Extent(Object.keys(timestamps), key => timestamps[key]);
const step = (extents[1] - extents[0]) / (steps - 1); const step = (extents[1] - extents[0]) / (steps - 1);
const colorScale = getSequentialSchemeRegistry() const colorScale = getSequentialSchemeRegistry()
.get(linearColorScheme) .get(linearColorScheme)

View File

@ -35,12 +35,21 @@ export default function transformProps(chartProps) {
subdomainGranularity, subdomainGranularity,
xAxisTimeFormat, xAxisTimeFormat,
yAxisFormat, yAxisFormat,
colorRangeEnd,
colorRangeStart,
} = formData; } = formData;
const { verboseMap } = datasource; const { verboseMap } = datasource;
const timeFormatter = ts => getFormattedUTCTime(ts, xAxisTimeFormat); const timeFormatter = ts => getFormattedUTCTime(ts, xAxisTimeFormat);
const valueFormatter = getNumberFormatter(yAxisFormat); const valueFormatter = getNumberFormatter(yAxisFormat);
// Get the color range if both are specified
const useCustomColorRange =
colorRangeEnd !== undefined &&
colorRangeEnd !== '' &&
colorRangeStart !== undefined &&
colorRangeStart !== '';
return { return {
height, height,
data: queriesData[0].data, data: queriesData[0].data,
@ -57,5 +66,8 @@ export default function transformProps(chartProps) {
timeFormatter, timeFormatter,
valueFormatter, valueFormatter,
verboseMap, verboseMap,
colorRangeEnd,
colorRangeStart,
useCustomColorRange,
}; };
} }