import { getVisSchemas , VisToExpressionAst } from '../../../visualizations/public' ; import { buildExpression , buildExpressionFunction } from '../../../expressions/public' ; import { PieVisParams } from './pie' ; import { vislibPieName , VisTypeVislibPieExpressionFunctionDefinition } from './pie_fn' ; import { getEsaggsFn } from './to_ast_esaggs' ; export const toExpressionAst = async ( vis , params ) => { const schemas = getVisSchemas ( vis , params ) ; const visConfig = { ... vis . params , dimensions : { metric : schemas . metric [ 0 ] , buckets : schemas . segment , splitRow : schemas . split_row , splitColumn : schemas . split_column , } , } ; const visTypePie = buildExpressionFunction < VisTypeVislibPieExpressionFunctionDefinition > ( vislibPieName , { visConfig : JSON . stringify ( visConfig ) , } ) ; const ast = buildExpression ( [ getEsaggsFn ( vis ) , visTypePie ] ) ; return ast . toAst ( ) ; } ;