import { BoxPlotDef } from 'vega-lite/build/src/compositemark/boxplot' ; import { EncodingWithFacet } from 'vega-lite/build/src/encoding' ; import { MarkDef } from 'vega-lite/build/src/mark' ; import { FacetedCompositeUnitSpec , GenericUnitSpec , isUnitSpec } from 'vega-lite/build/src/spec' ; import { GenericState , UndoableStateBase } from '../models/index' ; import { createSelector } from 'reselect' ; import { Selector } from 'reselect/src/reselect' ; import { PlotTabState , State } from '../models/index' ; import { ResultPlot } from '../models/result' ; import { Result , RESULT_TYPES , ResultType } from '../models/result' ; import { selectIsQueryEmpty , selectIsQuerySpecific } from './shelf' ; import { selectActiveTab } from './tab' ; export const selectResult = RESULT_TYPES . reduce ( ( selectors , resultType ) => { selectors [ resultType ] = createSelector ( selectActiveTab , ( plotTabState ) => plotTabState . result [ resultType ] ) ; return selectors ; } , { } ) ; export const selectResultLimit = RESULT_TYPES . reduce ( ( selectors , resultType ) => { selectors [ resultType ] = createSelector ( selectResult [ resultType ] , ( result ) => result . limit ) ; return selectors ; } , { } ) ; const selectResultPlots = RESULT_TYPES . reduce ( ( selectors , resultType ) => { selectors [ resultType ] = createSelector ( selectResult [ resultType ] , ( result ) => result . plots ) ; return selectors ; } , { } ) ; export const selectMainSpec = createSelector ( selectIsQuerySpecific , selectIsQueryEmpty , selectResultPlots . main , ( isQuerySpecific , isQueryEmpty , mainPlots ) : FacetedCompositeUnitSpec => { if ( ! isQuerySpecific || ! mainPlots || isQueryEmpty ) { return undefined ; } return mainPlots [ 0 ] . spec ; } ) ;