import { LegendItem } from '../../../../common/legend' ; import { createCustomCachedSelector } from '../../../../state/create_selector' ; import { getChartThemeSelector } from '../../../../state/selectors/get_chart_theme' ; import { getDeselectedSeriesSelector } from '../../../../state/selectors/get_deselected_data_series' ; import { getSettingsSpecSelector } from '../../../../state/selectors/get_settings_specs' ; import { computeLegend } from '../../legend/legend' ; import { DataSeries } from '../../utils/series' ; import { getLastValues } from '../utils/get_last_value' ; import { computeSeriesDomainsSelector } from './compute_series_domains' ; import { getSeriesColorsSelector } from './get_series_color_map' ; import { getSiDataSeriesMapSelector } from './get_si_dataseries_map' ; import { getSeriesSpecsSelector , getAxisSpecsSelector } from './get_specs' ; internal export const computeLegendSelector = createCustomCachedSelector ( [ getSeriesSpecsSelector , computeSeriesDomainsSelector , getChartThemeSelector , getSeriesColorsSelector , getAxisSpecsSelector , getDeselectedSeriesSelector , getSettingsSpecSelector , getSiDataSeriesMapSelector , ] , ( seriesSpecs , { formattedDataSeries , xDomain } , chartTheme , seriesColors , axesSpecs , deselectedDataSeries , settings , siDataSeriesMap ) : LegendItem [ ] => { const lastValues = getLastValues ( formattedDataSeries , xDomain ) ; return computeLegend ( formattedDataSeries , lastValues , seriesColors , seriesSpecs , axesSpecs , settings . showLegendExtra , siDataSeriesMap , deselectedDataSeries , chartTheme , settings . rotation ) ; } ) ;