@ -28,10 +28,21 @@ export const HistogramTransformerEditor = ({
const labelWidth = 18 ;
const [ isInvalid , setInvalid ] = useState ( {
bucketCount : ! numberOrVariableValidator ( options . bucketCount || '' ) ,
bucketSize : ! numberOrVariableValidator ( options . bucketSize || '' ) ,
bucketOffset : ! numberOrVariableValidator ( options . bucketOffset || '' ) ,
} ) ;
const onBucketCountChanged = useCallback (
( val? : number ) = > {
onChange ( {
. . . options ,
bucketCount : val ,
} ) ;
} ,
[ onChange , options ]
) ;
const onBucketSizeChanged = useCallback (
( val? : number ) = > {
onChange ( {
@ -52,6 +63,18 @@ export const HistogramTransformerEditor = ({
[ onChange , options ]
) ;
const onVariableBucketCountChanged = useCallback (
( value : string ) = > {
setInvalid ( { . . . isInvalid , bucketCount : ! numberOrVariableValidator ( value ) } ) ;
onChange ( {
. . . options ,
bucketCount : Number ( value ) === 0 ? undefined : Number ( value ) ,
} ) ;
} ,
[ onChange , options , isInvalid ]
) ;
const onVariableBucketSizeChanged = useCallback (
( value : string ) = > {
setInvalid ( { . . . isInvalid , bucketSize : ! numberOrVariableValidator ( value ) } ) ;
@ -105,6 +128,20 @@ export const HistogramTransformerEditor = ({
return (
< div >
< InlineFieldRow >
< InlineField
labelWidth = { labelWidth }
label = { histogramFieldInfo . bucketCount . name }
tooltip = { histogramFieldInfo . bucketCount . description }
>
< NumberInput
value = { options . bucketCount }
placeholder = "Default: 30"
onChange = { onBucketCountChanged }
min = { 0 }
/ >
< / InlineField >
< / InlineFieldRow >
< InlineFieldRow >
< InlineField
labelWidth = { labelWidth }
@ -138,6 +175,22 @@ export const HistogramTransformerEditor = ({
return (
< div >
< InlineFieldRow >
< InlineField
invalid = { isInvalid . bucketCount }
error = { 'Value needs to be an integer or a variable' }
labelWidth = { labelWidth }
label = { histogramFieldInfo . bucketCount . name }
tooltip = { histogramFieldInfo . bucketCount . description }
>
< SuggestionsInput
suggestions = { variables }
value = { options . bucketCount }
placeholder = "Default: 30"
onChange = { onVariableBucketCountChanged }
/ >
< / InlineField >
< / InlineFieldRow >
< InlineFieldRow >
< InlineField
invalid = { isInvalid . bucketSize }