@@ -199,7 +199,7 @@ export function XYChart({
199199 }
200200
201201 // use formatting hint of first x axis column to format ticks
202- const xAxisColumn : KibanaDatatableColumn | undefined = Object . values ( data . tables ) [ 0 ] . columns . find (
202+ const xAxisColumn = Object . values ( data . tables ) [ 0 ] . columns . find (
203203 ( { id } ) => id === layers [ 0 ] . xAccessor
204204 ) ;
205205 const xAxisFormatter = formatFactory ( xAxisColumn && xAxisColumn . formatHint ) ;
@@ -222,8 +222,32 @@ export function XYChart({
222222 const xTitle = ( xAxisColumn && xAxisColumn . name ) || args . xTitle ;
223223
224224 function calculateMinInterval ( ) {
225- // add minInterval only for single row value as it cannot be determined from dataset
226- if ( data . dateRange && layers . every ( layer => data . tables [ layer . layerId ] . rows . length <= 1 ) ) {
225+ // check all the tables to see if all of the rows have the same timestamp
226+ // that would mean that chart will draw a single bar
227+ const isSingleTimestampInXDomain = ( ) => {
228+ const nonEmptyLayers = layers . filter (
229+ layer => data . tables [ layer . layerId ] . rows . length && layer . xAccessor
230+ ) ;
231+
232+ if ( ! nonEmptyLayers . length ) {
233+ return ;
234+ }
235+
236+ const firstRowValue =
237+ data . tables [ nonEmptyLayers [ 0 ] . layerId ] . rows [ 0 ] [ nonEmptyLayers [ 0 ] . xAccessor ! ] ;
238+ for ( const layer of nonEmptyLayers ) {
239+ if (
240+ layer . xAccessor &&
241+ data . tables [ layer . layerId ] . rows . some ( row => row [ layer . xAccessor ! ] !== firstRowValue )
242+ ) {
243+ return false ;
244+ }
245+ }
246+ return true ;
247+ } ;
248+
249+ // add minInterval only for single point in domain
250+ if ( data . dateRange && isSingleTimestampInXDomain ( ) ) {
227251 if ( xAxisColumn ?. meta ?. aggConfigParams ?. interval !== 'auto' )
228252 return parseInterval ( xAxisColumn ?. meta ?. aggConfigParams ?. interval ) ?. asMilliseconds ( ) ;
229253
0 commit comments