import { Theme , ScaleType , SelectionState } from '@thematic/core' ; import { Selection } from 'd3-selection' ; param theme param size export function nominal ( theme , size ) { const scale = theme . scales ( ) . nominal ( size ) ; return ( key ) : string => scale ( key ) . hex ( ) ; } param theme param size export function nominalBold ( theme , size ) { const scale = theme . scales ( ) . nominalBold ( size ) ; return ( key ) : string => scale ( key ) . hex ( ) ; } param theme param size export function nominalMuted ( theme , size ) { const scale = theme . scales ( ) . nominalMuted ( size ) ; return ( key ) : string => scale ( key ) . hex ( ) ; } param theme param domain param scaleType param quantiles export function sequential ( theme , domain , scaleType ? , quantiles ? ) { const scale = theme . scales ( ) . sequential ( domain , scaleType , quantiles ) ; return ( value ) : string => scale ( value ) . hex ( ) ; } param theme param domain param scaleType param quantiles export function sequential2 ( theme , domain , scaleType ? , quantiles ? ) { const scale = theme . scales ( ) . sequential2 ( domain , scaleType , quantiles ) ; return ( value ) : string => scale ( value ) . hex ( ) ; } param theme param domain param scaleType param quantiles export function diverging ( theme , domain , scaleType ? , quantiles ? ) { const scale = theme . scales ( ) . diverging ( domain , scaleType , quantiles ) ; return ( value ) : string => scale ( value ) . hex ( ) ; } param theme param domain param scaleType param quantiles export function diverging2 ( theme , domain , scaleType ? , quantiles ? ) { const scale = theme . scales ( ) . diverging2 ( domain , scaleType , quantiles ) ; return ( value ) : string => scale ( value ) . hex ( ) ; } param theme param domain param scaleType param quantiles export function greys ( theme , domain , scaleType ? , quantiles ? ) { const scale = theme . scales ( ) . greys ( domain , scaleType , quantiles ) ; return ( value ) : string => scale ( value ) . hex ( ) ; } export function applyNominalAttrWithSignalState ( selection , attr , getState , accessor , theme , size ) { const normal = theme . scales ( ) . nominal ( size ) ; const muted = theme . scales ( ) . nominalMuted ( size ) ; const bold = theme . scales ( ) . nominalBold ( size ) ; selection . attr ( attr , d => { const selectionState = getState ( d ) ; const key = accessor ( d ) ; switch ( selectionState ) { case SelectionState . Normal : return normal ( key ) . hex ( ) ; case SelectionState . Hovered : return bold ( key ) . hex ( ) ; case SelectionState . Selected : return bold ( key ) . hex ( ) ; case SelectionState . Suppressed : return muted ( key ) . hex ( ) ; default : return null ; } } ) ; }