diff --git a/.changeset/heatmap-inline-settings.md b/.changeset/heatmap-inline-settings.md
new file mode 100644
index 0000000000..9f56875219
--- /dev/null
+++ b/.changeset/heatmap-inline-settings.md
@@ -0,0 +1,5 @@
+---
+'@hyperdx/app': patch
+---
+
+feat: Edit heatmap value and count inline in the chart editor
diff --git a/packages/app/src/components/ChartDisplaySettingsDrawer.tsx b/packages/app/src/components/ChartDisplaySettingsDrawer.tsx
index 20f3ee0894..b65654f4b6 100644
--- a/packages/app/src/components/ChartDisplaySettingsDrawer.tsx
+++ b/packages/app/src/components/ChartDisplaySettingsDrawer.tsx
@@ -27,6 +27,7 @@ import { shouldFillNullsWithZero } from '@/ChartUtils';
import { MAX_RENDERED_TIME_CHART_SERIES } from '@/defaults';
import { FormatTime } from '@/useFormatTime';
+import { HeatmapScaleControl } from './DBHeatmapChart/HeatmapScaleControl';
import { BackgroundChartInput } from './BackgroundChartInput';
import {
attachLocalIds,
@@ -35,6 +36,7 @@ import {
stripLocalIds,
} from './ColorRulesEditor';
import { ColorSwatchInput } from './ColorSwatchInput';
+import type { HeatmapScaleType } from './DBHeatmapChart';
import { CheckBoxControlled, TextInputControlled } from './InputControlled';
import { DEFAULT_NUMBER_FORMAT, NumberFormatForm } from './NumberFormat';
@@ -61,6 +63,8 @@ export type ChartConfigDisplaySettings = Pick<
// PromQL-only: Handlebars template over each series' Prometheus label set
// that renders the legend/tooltip name.
legendTemplate?: string;
+ // Heatmaps only; stored on the heatmap's select[0].
+ heatmapScaleType?: HeatmapScaleType;
};
/**
@@ -113,6 +117,7 @@ function applyDefaultSettings(
? attachLocalIds(settings.colorRules)
: undefined,
backgroundChart: settings.backgroundChart,
+ heatmapScaleType: settings.heatmapScaleType ?? 'log',
};
}
@@ -243,6 +248,8 @@ export default function ChartDisplaySettingsDrawer({
? 'Available on PromQL range queries.'
: 'Available on query-builder number tiles.';
+ const showHeatmapScale = displayType === DisplayType.Heatmap;
+
return (
)}
+ {showHeatmapScale && (
+ <>
+ (
+
+ )}
+ />
+
+ >
+ )}
+
{showLegendTemplate && (
<>
diff --git a/packages/app/src/components/DBEditTimeChartForm/ChartEditorControls.tsx b/packages/app/src/components/DBEditTimeChartForm/ChartEditorControls.tsx
index 7ee774b584..6b17169d4e 100644
--- a/packages/app/src/components/DBEditTimeChartForm/ChartEditorControls.tsx
+++ b/packages/app/src/components/DBEditTimeChartForm/ChartEditorControls.tsx
@@ -83,7 +83,6 @@ type ChartEditorControlsProps = {
chartConfigForExplanations?: ChartConfigWithOptTimestamp;
onSubmit: (suppressErrorNotification?: boolean) => void;
openDisplaySettings: () => void;
- openHeatmapSettings: () => void;
};
export function ChartEditorControls({
@@ -117,7 +116,6 @@ export function ChartEditorControls({
chartConfigForExplanations,
onSubmit,
openDisplaySettings,
- openHeatmapSettings,
}: ChartEditorControlsProps) {
// Formulas (HDX-5080): derived series computed from the chart's series via
// letter-ref arithmetic expressions. Metric and event (log/trace) sources,
@@ -224,12 +222,15 @@ export function ChartEditorControls({
{displayType === DisplayType.Heatmap && Array.isArray(select) ? (
) : displayType === DisplayType.EventPatterns ? (
diff --git a/packages/app/src/components/DBEditTimeChartForm/EditTimeChartForm.tsx b/packages/app/src/components/DBEditTimeChartForm/EditTimeChartForm.tsx
index 0cf87aae5e..a4dd663af9 100644
--- a/packages/app/src/components/DBEditTimeChartForm/EditTimeChartForm.tsx
+++ b/packages/app/src/components/DBEditTimeChartForm/EditTimeChartForm.tsx
@@ -71,14 +71,8 @@ import {
isStringSelectDisplayType,
validateChartForm,
} from '@/components/ChartEditor/utils';
-import {
- HEATMAP_DURATION_NUMBER_FORMAT,
- type HeatmapScaleType,
-} from '@/components/DBHeatmapChart';
+import { HEATMAP_DURATION_NUMBER_FORMAT } from '@/components/DBHeatmapChart';
import { ErrorBoundary } from '@/components/Error/ErrorBoundary';
-import HeatmapSettingsDrawer, {
- HeatmapSettingsValues,
-} from '@/components/HeatmapSettingsDrawer';
import { InputControlled } from '@/components/InputControlled';
import SaveToDashboardModal from '@/components/SaveToDashboardModal';
import { getStoredLanguage } from '@/components/SearchInput/SearchWhereInput';
@@ -349,6 +343,7 @@ export default function EditTimeChartForm({
colorRules,
backgroundChart,
legendTemplate,
+ heatmapScaleType,
] = useWatch({
control,
name: [
@@ -364,6 +359,7 @@ export default function EditTimeChartForm({
'colorRules',
'backgroundChart',
'legendTemplate',
+ 'series.0.heatmapScaleType',
],
});
@@ -395,6 +391,7 @@ export default function EditTimeChartForm({
colorRules,
backgroundChart,
legendTemplate,
+ heatmapScaleType,
}),
[
alignDateRangeToGranularity,
@@ -409,6 +406,7 @@ export default function EditTimeChartForm({
colorRules,
backgroundChart,
legendTemplate,
+ heatmapScaleType,
],
);
@@ -417,11 +415,6 @@ export default function EditTimeChartForm({
{ open: openDisplaySettings, close: closeDisplaySettings },
] = useDisclosure(false);
- const [
- heatmapSettingsOpened,
- { open: openHeatmapSettings, close: closeHeatmapSettings },
- ] = useDisclosure(false);
-
// Only update this on submit, otherwise we'll have issues
// with using the source value from the last submit
// (ex. ignoring local custom source updates)
@@ -890,6 +883,7 @@ export default function EditTimeChartForm({
colorRules,
backgroundChart,
legendTemplate,
+ heatmapScaleType,
}: ChartConfigDisplaySettings,
isDirty: boolean,
) => {
@@ -916,6 +910,9 @@ export default function EditTimeChartForm({
if (configType === 'promql') {
setValue('legendTemplate', legendTemplate ?? '');
}
+ if (displayType === DisplayType.Heatmap) {
+ setValue('series.0.heatmapScaleType', heatmapScaleType);
+ }
// Display settings live in a separate drawer form, so RHF can't track
// them. Latch dirty state only when the drawer reports actual changes.
if (isDirty) {
@@ -924,44 +921,7 @@ export default function EditTimeChartForm({
}
onSubmit();
},
- [setValue, onDirtyChange, onSubmit, configType],
- );
-
- const handleUpdateHeatmapSettings = useCallback(
- (data: HeatmapSettingsValues) => {
- setValue('series.0.valueExpression', data.value);
- setValue('series.0.countExpression', data.count || 'count()');
- setValue('series.0.heatmapScaleType', data.scaleType);
- // Heatmap settings are applied outside RHF's change tracking.
- subFormDirtyRef.current = true;
- onDirtyChange?.(true);
- onSubmit();
- closeHeatmapSettings();
- },
- [setValue, onDirtyChange, onSubmit, closeHeatmapSettings],
- );
-
- const heatmapValueExpression = useWatch({
- control,
- name: 'series.0.valueExpression',
- });
- const heatmapCountExpression = useWatch({
- control,
- name: 'series.0.countExpression',
- });
- const heatmapScaleType: HeatmapScaleType =
- useWatch({
- control,
- name: 'series.0.heatmapScaleType',
- }) ?? 'log';
-
- const heatmapSettingsDefaults = useMemo(
- () => ({
- value: heatmapValueExpression || '',
- count: heatmapCountExpression || 'count()',
- scaleType: heatmapScaleType,
- }),
- [heatmapValueExpression, heatmapCountExpression, heatmapScaleType],
+ [setValue, onDirtyChange, onSubmit, configType, displayType],
);
const tableConnection = useMemo(
@@ -1152,7 +1112,6 @@ export default function EditTimeChartForm({
chartConfigForExplanations={chartConfigForExplanations}
onSubmit={onSubmit}
openDisplaySettings={openDisplaySettings}
- openHeatmapSettings={openHeatmapSettings}
/>
)}
-
);
diff --git a/packages/app/src/components/DBEditTimeChartForm/HeatmapSeriesEditor.tsx b/packages/app/src/components/DBEditTimeChartForm/HeatmapSeriesEditor.tsx
index 3fd98cfb7a..6b80142729 100644
--- a/packages/app/src/components/DBEditTimeChartForm/HeatmapSeriesEditor.tsx
+++ b/packages/app/src/components/DBEditTimeChartForm/HeatmapSeriesEditor.tsx
@@ -1,51 +1,122 @@
import { useMemo } from 'react';
-import { Control, UseFormSetValue } from 'react-hook-form';
+import { Control, FieldErrors, UseFormSetValue } from 'react-hook-form';
import { tcFromSource } from '@hyperdx/common-utils/dist/core/metadata';
import { TSource } from '@hyperdx/common-utils/dist/types';
-import { Button, Divider, Flex } from '@mantine/core';
+import { Button, Divider, Flex, Stack, Text, Tooltip } from '@mantine/core';
+import { IconHelpCircle } from '@tabler/icons-react';
import { ChartEditorFormState } from '@/components/ChartEditor/types';
+import { EDITOR_INPUT_HEIGHTS } from '@/components/editorInputHeights';
import SearchWhereInput from '@/components/SearchInput/SearchWhereInput';
+import { SQLInlineEditorControlled } from '@/components/SQLEditor/SQLInlineEditor';
type HeatmapSeriesEditorProps = {
control: Control;
setValue: UseFormSetValue;
+ errors: FieldErrors;
tableSource?: TSource;
dateRange?: [Date, Date];
+ parentRef: HTMLElement | null;
onSubmit: () => void;
onOpenDisplaySettings: () => void;
};
+function InlineLabel({ label, tooltip }: { label: string; tooltip: string }) {
+ return (
+
+
+ {label}
+
+
+
+
+
+ );
+}
+
export function HeatmapSeriesEditor({
control,
setValue,
+ errors,
tableSource,
dateRange,
+ parentRef,
onSubmit,
onOpenDisplaySettings,
}: HeatmapSeriesEditorProps) {
const connection = useMemo(() => tcFromSource(tableSource), [tableSource]);
return (
-
-
- setValue('whereLanguage', lang)
- }
- enableVariables
- />
-
+
+
+
+
+ setValue('whereLanguage', lang)
+ }
+ enableVariables
+ />
+
+
diff --git a/packages/app/src/components/DBHeatmapChart/HeatmapScaleControl.tsx b/packages/app/src/components/DBHeatmapChart/HeatmapScaleControl.tsx
new file mode 100644
index 0000000000..f8583e4292
--- /dev/null
+++ b/packages/app/src/components/DBHeatmapChart/HeatmapScaleControl.tsx
@@ -0,0 +1,33 @@
+import { Box, SegmentedControl, Text } from '@mantine/core';
+
+import type { HeatmapScaleType } from './heatmapGrid';
+
+const SCALE_OPTIONS: { label: string; value: HeatmapScaleType }[] = [
+ { label: 'Log', value: 'log' },
+ { label: 'Linear', value: 'linear' },
+];
+
+export function HeatmapScaleControl({
+ value,
+ onChange,
+}: {
+ value: HeatmapScaleType;
+ onChange: (value: HeatmapScaleType) => void;
+}) {
+ return (
+
+
+ Y axis scale
+
+ {
+ if (v === 'log' || v === 'linear') onChange(v);
+ }}
+ data={SCALE_OPTIONS}
+ data-testid="heatmap-scale-control"
+ />
+
+ );
+}
diff --git a/packages/app/src/components/DBHeatmapChart/heatmapQueries.ts b/packages/app/src/components/DBHeatmapChart/heatmapQueries.ts
index 87ac2e3599..4a988f9cfd 100644
--- a/packages/app/src/components/DBHeatmapChart/heatmapQueries.ts
+++ b/packages/app/src/components/DBHeatmapChart/heatmapQueries.ts
@@ -153,7 +153,8 @@ export function buildHeatmapBucketConfig({
nBuckets: number;
}): BuilderChartConfigWithDateRange {
const valueExpression = config.select[0].valueExpression;
- const countExpression = config.select[0].countExpression ?? 'count()';
+ // The chart editor saves a cleared Count input as ''.
+ const countExpression = config.select[0].countExpression?.trim() || 'count()';
const isAggregateExpression = isAggregateFunction(valueExpression);
const bucketExprAgg =
diff --git a/packages/app/src/components/HeatmapSettingsDrawer.tsx b/packages/app/src/components/HeatmapSettingsDrawer.tsx
index db2b5b56e5..15b47a02b9 100644
--- a/packages/app/src/components/HeatmapSettingsDrawer.tsx
+++ b/packages/app/src/components/HeatmapSettingsDrawer.tsx
@@ -3,18 +3,10 @@ import { useForm, useWatch } from 'react-hook-form';
import { z } from 'zod';
import { zodResolver } from '@hookform/resolvers/zod';
import { TableConnection } from '@hyperdx/common-utils/dist/core/metadata';
-import {
- Box,
- Button,
- Divider,
- Drawer,
- Group,
- SegmentedControl,
- Stack,
- Text,
-} from '@mantine/core';
+import { Button, Divider, Drawer, Group, Stack } from '@mantine/core';
import { IconPlayerPlay } from '@tabler/icons-react';
+import { HeatmapScaleControl } from '@/components/DBHeatmapChart/HeatmapScaleControl';
import { SQLInlineEditorControlled } from '@/components/SQLEditor/SQLInlineEditor';
const HeatmapSettingsSchema = z.object({
@@ -72,24 +64,10 @@ export default function HeatmapSettingsDrawer({
>