@@ -71,14 +71,8 @@ import {
7171 isStringSelectDisplayType ,
7272 validateChartForm ,
7373} from '@/components/ChartEditor/utils' ;
74- import {
75- HEATMAP_DURATION_NUMBER_FORMAT ,
76- type HeatmapScaleType ,
77- } from '@/components/DBHeatmapChart' ;
74+ import { HEATMAP_DURATION_NUMBER_FORMAT } from '@/components/DBHeatmapChart' ;
7875import { ErrorBoundary } from '@/components/Error/ErrorBoundary' ;
79- import HeatmapSettingsDrawer , {
80- HeatmapSettingsValues ,
81- } from '@/components/HeatmapSettingsDrawer' ;
8276import { InputControlled } from '@/components/InputControlled' ;
8377import SaveToDashboardModal from '@/components/SaveToDashboardModal' ;
8478import { getStoredLanguage } from '@/components/SearchInput/SearchWhereInput' ;
@@ -349,6 +343,7 @@ export default function EditTimeChartForm({
349343 colorRules ,
350344 backgroundChart ,
351345 legendTemplate ,
346+ heatmapScaleType ,
352347 ] = useWatch ( {
353348 control,
354349 name : [
@@ -364,6 +359,7 @@ export default function EditTimeChartForm({
364359 'colorRules' ,
365360 'backgroundChart' ,
366361 'legendTemplate' ,
362+ 'series.0.heatmapScaleType' ,
367363 ] ,
368364 } ) ;
369365
@@ -395,6 +391,7 @@ export default function EditTimeChartForm({
395391 colorRules,
396392 backgroundChart,
397393 legendTemplate,
394+ heatmapScaleType,
398395 } ) ,
399396 [
400397 alignDateRangeToGranularity ,
@@ -409,6 +406,7 @@ export default function EditTimeChartForm({
409406 colorRules ,
410407 backgroundChart ,
411408 legendTemplate ,
409+ heatmapScaleType ,
412410 ] ,
413411 ) ;
414412
@@ -417,11 +415,6 @@ export default function EditTimeChartForm({
417415 { open : openDisplaySettings , close : closeDisplaySettings } ,
418416 ] = useDisclosure ( false ) ;
419417
420- const [
421- heatmapSettingsOpened ,
422- { open : openHeatmapSettings , close : closeHeatmapSettings } ,
423- ] = useDisclosure ( false ) ;
424-
425418 // Only update this on submit, otherwise we'll have issues
426419 // with using the source value from the last submit
427420 // (ex. ignoring local custom source updates)
@@ -890,6 +883,7 @@ export default function EditTimeChartForm({
890883 colorRules,
891884 backgroundChart,
892885 legendTemplate,
886+ heatmapScaleType,
893887 } : ChartConfigDisplaySettings ,
894888 isDirty : boolean ,
895889 ) => {
@@ -916,6 +910,9 @@ export default function EditTimeChartForm({
916910 if ( configType === 'promql' ) {
917911 setValue ( 'legendTemplate' , legendTemplate ?? '' ) ;
918912 }
913+ if ( displayType === DisplayType . Heatmap ) {
914+ setValue ( 'series.0.heatmapScaleType' , heatmapScaleType ) ;
915+ }
919916 // Display settings live in a separate drawer form, so RHF can't track
920917 // them. Latch dirty state only when the drawer reports actual changes.
921918 if ( isDirty ) {
@@ -924,44 +921,7 @@ export default function EditTimeChartForm({
924921 }
925922 onSubmit ( ) ;
926923 } ,
927- [ setValue , onDirtyChange , onSubmit , configType ] ,
928- ) ;
929-
930- const handleUpdateHeatmapSettings = useCallback (
931- ( data : HeatmapSettingsValues ) => {
932- setValue ( 'series.0.valueExpression' , data . value ) ;
933- setValue ( 'series.0.countExpression' , data . count || 'count()' ) ;
934- setValue ( 'series.0.heatmapScaleType' , data . scaleType ) ;
935- // Heatmap settings are applied outside RHF's change tracking.
936- subFormDirtyRef . current = true ;
937- onDirtyChange ?.( true ) ;
938- onSubmit ( ) ;
939- closeHeatmapSettings ( ) ;
940- } ,
941- [ setValue , onDirtyChange , onSubmit , closeHeatmapSettings ] ,
942- ) ;
943-
944- const heatmapValueExpression = useWatch ( {
945- control,
946- name : 'series.0.valueExpression' ,
947- } ) ;
948- const heatmapCountExpression = useWatch ( {
949- control,
950- name : 'series.0.countExpression' ,
951- } ) ;
952- const heatmapScaleType : HeatmapScaleType =
953- useWatch ( {
954- control,
955- name : 'series.0.heatmapScaleType' ,
956- } ) ?? 'log' ;
957-
958- const heatmapSettingsDefaults = useMemo (
959- ( ) => ( {
960- value : heatmapValueExpression || '' ,
961- count : heatmapCountExpression || 'count()' ,
962- scaleType : heatmapScaleType ,
963- } ) ,
964- [ heatmapValueExpression , heatmapCountExpression , heatmapScaleType ] ,
924+ [ setValue , onDirtyChange , onSubmit , configType , displayType ] ,
965925 ) ;
966926
967927 const tableConnection = useMemo (
@@ -1152,7 +1112,6 @@ export default function EditTimeChartForm({
11521112 chartConfigForExplanations = { chartConfigForExplanations }
11531113 onSubmit = { onSubmit }
11541114 openDisplaySettings = { openDisplaySettings }
1155- openHeatmapSettings = { openHeatmapSettings }
11561115 />
11571116 ) }
11581117 < ChartActionBar
@@ -1221,17 +1180,10 @@ export default function EditTimeChartForm({
12211180 } ) }
12221181 onChange = { handleUpdateDisplaySettings }
12231182 onClose = { closeDisplaySettings }
1224- isPerSeriesNumberFormatAllowed = { configType !== 'sql' }
1225- />
1226- < HeatmapSettingsDrawer
1227- opened = { heatmapSettingsOpened }
1228- onClose = { closeHeatmapSettings }
1229- connection = { tableConnection }
1230- sourceId = { tableSource ?. id }
1231- dateRange = { dateRange }
1232- parentRef = { parentRef }
1233- defaultValues = { heatmapSettingsDefaults }
1234- onSubmit = { handleUpdateHeatmapSettings }
1183+ // Heatmaps format with the chart-level number format only.
1184+ isPerSeriesNumberFormatAllowed = {
1185+ configType !== 'sql' && displayType !== DisplayType . Heatmap
1186+ }
12351187 />
12361188 </ div >
12371189 ) ;
0 commit comments