File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import chroma from "chroma-js" ;
22
3- export const getDistributedColor = ( current : number , total : number ) => {
4- return chroma . hsl ( ( 360 / total ) * current , 0.6 , 0.5 ) . hex ( ) ;
3+ export const EQUINOR_CHART_PALETTE : readonly string [ ] = [
4+ "#007079" , // Moss Green 100
5+ "#FF1243" , // Energy Red 100
6+ "#243746" , // Slate Blue 100
7+ "#FFC67A" , // Spruce Wood 100
8+ "#7193AE" , // Mist Blue 100
9+ "#A8CED1" , // Lichen Green 55
10+ "#EB0037" , // Equinor Red
11+ "#3AADA8" , // Moss Green 55
12+ "#FF92A8" , // Energy Red 55
13+ ] as const ;
14+
15+ export const getDistributedColor = ( current : number , total : number ) : string => {
16+ if ( total <= 0 ) return EQUINOR_CHART_PALETTE [ 0 ] ;
17+
18+ if ( total <= EQUINOR_CHART_PALETTE . length ) {
19+ return EQUINOR_CHART_PALETTE [ current % EQUINOR_CHART_PALETTE . length ] ;
20+ }
21+
22+ const scale = chroma . scale ( [ ...EQUINOR_CHART_PALETTE ] ) . mode ( "lab" ) ;
23+ return scale ( current / Math . max ( total - 1 , 1 ) ) . hex ( ) ;
524} ;
You can’t perform that action at this time.
0 commit comments