import React , { lazy } from 'react' ; import { render , unmountComponentAtNode } from 'react-dom' ; import { KibanaThemeProvider } from '../../../kibana_react/public' ; import { ExpressionRenderDefinition } from '../../../expressions/public' ; import { VisualizationContainer } from '../../../visualizations/public' ; import { ChartsPluginSetup } from '../../../charts/public' ; import { VisTypeVislibCoreSetup } from './plugin' ; import { VislibRenderValue , vislibVisName } from './vis_type_vislib_vis_fn' ; import { VislibChartType } from './types' ; import { PieRenderValue } from './pie_fn' ; const VislibWrapper = lazy ( ( ) => import ( './vis_wrapper' ) ) ; function shouldShowNoResultsMessage ( visData , visType ) { if ( [ 'goal' , 'gauge' ] . includes ( visType as string ) ) { return false ; } const rows = visData ?. rows ; const isZeroHits = visData ?. hits === 0 || ( rows && ! rows . length ) ; return Boolean ( isZeroHits ) ; } export const getVislibVisRenderer = ( core , charts ) => ( { name : vislibVisName , displayName : 'Vislib visualization' , reuseDomNode : true , render : async ( domNode , config , handlers ) => { const showNoResult = shouldShowNoResultsMessage ( config . visData , config . visType ) ; handlers . onDestroy ( ( ) => unmountComponentAtNode ( domNode ) ) ; render ( < KibanaThemeProvider theme$ = { core . theme . theme$ } > < VisualizationContainer handlers = { handlers } showNoResult = { showNoResult } > < VislibWrapper { ... config } core = { core } charts = { charts } handlers = { handlers } / > < /VisualizationContainer> < /KibanaThemeProvider>, domNode); } , } ) ;