Skip to content

Commit 1c6a1ec

Browse files
authored
Fix chart range bug of non-HC anomaly and feature charts (#122)
Signed-off-by: Tyler Ohlsen <ohltyler@amazon.com>
1 parent 0f1882e commit 1c6a1ec

File tree

2 files changed

+27
-9
lines changed

2 files changed

+27
-9
lines changed

public/pages/AnomalyCharts/components/FeatureChart/FeatureChart.tsx

+6-3
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,8 @@ export const FeatureChart = (props: FeatureChartProps) => {
9090
const getDisabledChartBackground = () =>
9191
darkModeEnabled() ? '#25262E' : '#F0F0F0';
9292

93-
const [showCustomExpression, setShowCustomExpression] = useState<boolean>(
94-
false
95-
);
93+
const [showCustomExpression, setShowCustomExpression] =
94+
useState<boolean>(false);
9695
const timeFormatter = niceTimeFormatter([
9796
props.dateRange.startDate,
9897
props.dateRange.endDate,
@@ -216,6 +215,10 @@ export const FeatureChart = (props: FeatureChartProps) => {
216215
showLegendDisplayValue={false}
217216
legendPosition={Position.Right}
218217
theme={FEATURE_CHART_THEME}
218+
xDomain={{
219+
min: props.dateRange.startDate,
220+
max: props.dateRange.endDate,
221+
}}
219222
/>
220223
{props.feature.featureEnabled ? (
221224
<RectAnnotation

public/pages/AnomalyCharts/containers/AnomalyDetailsChart.tsx

+21-6
Original file line numberDiff line numberDiff line change
@@ -304,11 +304,18 @@ export const AnomalyDetailsChart = React.memo(
304304
}, [props.anomalies, zoomRange, aggregatedAnomalies, selectedAggId]);
305305

306306
const handleZoomRangeChange = (start: number, end: number) => {
307-
setZoomRange({
308-
startDate: start,
309-
endDate: end,
310-
});
311-
props.onZoomRangeChange(start, end);
307+
// In the HC scenario, we only want to change the local zoom range.
308+
// We don't want to change the overall date range, since that would auto-de-select
309+
// any selected heatmap cell, and re-fetch results based on the new date range
310+
if (props.isHCDetector) {
311+
setZoomRange({
312+
startDate: start,
313+
endDate: end,
314+
});
315+
props.onZoomRangeChange(start, end);
316+
} else {
317+
props.onDateRangeChange(start, end);
318+
}
312319
};
313320

314321
useEffect(() => {
@@ -505,14 +512,22 @@ export const AnomalyDetailsChart = React.memo(
505512
const end = get(
506513
brushArea,
507514
'x.1',
508-
DEFAULT_DATE_PICKER_RANGE.start
515+
DEFAULT_DATE_PICKER_RANGE.end
509516
);
510517
handleZoomRangeChange(start, end);
511518
if (props.onDatePickerRangeChange) {
512519
props.onDatePickerRangeChange(start, end);
513520
}
514521
}}
515522
theme={ANOMALY_CHART_THEME}
523+
xDomain={
524+
showAggregateResults
525+
? undefined
526+
: {
527+
min: zoomRange.startDate,
528+
max: zoomRange.endDate,
529+
}
530+
}
516531
/>
517532
{(props.isHCDetector && !props.selectedHeatmapCell) ||
518533
props.isHistorical ? null : (

0 commit comments

Comments
 (0)