Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature - New set of color palette added #206

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/lib/options/options.models.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { Action } from '../store';
import type { Data, WideData } from '../data';
import type { Palette } from './palette';

export interface OptionsAction extends Action {
payload: Partial<Options>;
Expand Down Expand Up @@ -53,7 +54,7 @@ export interface Options {
dateCounter: string | ((currentDate: string, dateSlice: Data[], allDates: string[]) => string);
caption: string | ((currentDate: string, dateSlice: Data[], allDates: string[]) => string);

colorMap: { [key: string]: string } | string[];
colorMap: { [key: string]: string } | string[] | Palette;
fixedOrder: string[];
}

Expand Down
5 changes: 4 additions & 1 deletion src/lib/options/options.reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { getDateString } from '../utils';
import type { Reducer } from '../store';
import type { Options, OptionsAction } from './options.models';
import { actionTypes } from './options.actions';
import { palettes } from './palette';

export const defaultOptions: Options = {
dataShape: 'auto',
Expand Down Expand Up @@ -77,7 +78,9 @@ export const optionsReducer: Reducer<Options, OptionsAction> = (state = defaultO
? [...options.colorMap].map(String)
: typeof options.colorMap === 'object'
? { ...options.colorMap }
: state.colorMap;
: options.colorMap && options.colorMap in palettes
? palettes[options.colorMap]
: state.colorMap;

const topN = fixedOrder.length || Number(options.topN) || state.topN;

Expand Down
345 changes: 345 additions & 0 deletions src/lib/options/palette.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,345 @@
// color palette src = https://github.com/mwaskom/seaborn/blob/master/seaborn/palettes.py

const deep = [
'#4C72B0',
'#DD8452',
'#55A868',
'#C44E52',
'#8172B3',
'#937860',
'#DA8BC3',
'#8C8C8C',
'#CCB974',
'#64B5CD',
];
const muted = [
'#4878D0',
'#EE854A',
'#6ACC64',
'#D65F5F',
'#956CB4',
'#8C613C',
'#DC7EC0',
'#797979',
'#D5BB67',
'#82C6E2',
];
const pastel = [
'#A1C9F4',
'#FFB482',
'#8DE5A1',
'#FF9F9B',
'#D0BBFF',
'#DEBB9B',
'#FAB0E4',
'#CFCFCF',
'#FFFEA3',
'#B9F2F0',
];
const bright = [
'#023EFF',
'#FF7C00',
'#1AC938',
'#E8000B',
'#8B2BE2',
'#9F4800',
'#F14CC1',
'#A3A3A3',
'#FFC400',
'#00D7FF',
];
const dark = [
'#001C7F',
'#B1400D',
'#12711C',
'#8C0800',
'#591E71',
'#592F0D',
'#A23582',
'#3C3C3C',
'#B8850A',
'#006374',
];
const colorblind = [
'#0173B2',
'#DE8F05',
'#029E73',
'#D55E00',
'#CC78BC',
'#CA9161',
'#FBAFE4',
'#949494',
'#ECE133',
'#56B4E9',
];
const vibrantRedGoldGreen = [
"#b10318",
"#dba13a",
"#309343",
"#d82526",
"#ffc156",
"#f26c64",
"#67bf5c",
"#ffee71",
"#9fcd99",
"#729ece",
];
const natureInspired = [
"#ff9e4a",
"#67bf5c",
"#ed665d",
"#ad8bc9",
"#a8786e",
"#ff7f0e",
"#2ca02c",
"#d62728",
"#8c564b",
"#bcbd22",
];
const sunsetTones = [
"#ed97ca",
"#a2a2a2",
"#cdc05d",
"#6dccda",
"#aec7e8",
"#ff7f0e",
"#17becf",
"#9edae5",
"#9467bd",
"#e377c2",
];
const pastelDream = [
"#7f7f7f",
"#acac58",
"#2f77b4",
"#ff7f0e",
"#2ca02c",
"#d62728",
"#9467bd",
"#8c564b",
"#e377c2",
"#bcbd22",
];
const earthyNeutrals = [
"#32a251",
"#ff7f0f",
"#3cb7cc",
"#ffcd4a",
"#b85a0d",
"#cdc05d",
"#a5acaf",
"#8f8782",
"#cfcfcf",
"#2f77b4",
];
const retroPop = [
"#7b66d2",
"#dc5fbd",
"#94917b",
"#998688",
"#d098ee",
"#9467bd",
"#17becf",
"#ff7f0e",
"#2ca02c",
"#d62728",
];
const boldContrast = [
"#ed97ca",
"#a2a2a2",
"#cdc05d",
"#6dccda",
"#aec7e8",
"#17becf",
"#ff7f0e",
"#9467bd",
"#8c564b",
"#bcbd22",
];
const softVintage = [
"#7f7f7f",
"#32a251",
"#ff7f0f",
"#b85a0d",
"#cdc05d",
"#a5acaf",
"#8f8782",
"#cfcfcf",
"#2f77b4",
"#9467bd",
];
const elegantPastels = [
"#7b66d2",
"#a699e8",
"#dc5fbd",
"#ffd0da",
"#5f5a41",
"#ac613c",
"#cdc05d",
"#9edae5",
"#9467bd",
"#ff7f0e",
];
const autumnWarmth = [
"#7b66d2",
"#d62728",
"#9467bd",
"#ff9e4a",
"#cdc05d",
"#8c564b",
"#bcbd22",
"#2f77b4",
"#aec7e8",
"#6dccda",
];
const oceanBreeze = [
"#006ba4",
"#17becf",
"#5f9ed1",
"#9edae5",
"#aec7e8",
"#6dccda",
"#2f77b4",
"#ffcd4a",
"#ff7f0e",
"#ff9e4a",
];
const forestMystic = [
"#309343",
"#2ca02c",
"#50a251",
"#32a251",
"#cdc05d",
"#bcbd22",
"#acac58",
"#9fcd99",
"#67bf5c",
"#b85a0d",
];
const berryMix = [
"#b10318",
"#d62728",
"#f26c64",
"#ed97ca",
"#e377c2",
"#9467bd",
"#7b66d2",
"#a699e8",
"#dc5fbd",
"#998688",
];
const goldenHour = [
"#dba13a",
"#ffc156",
"#ff9e4a",
"#ff7f0e",
"#ffcd4a",
"#cdc05d",
"#ac613c",
"#b85a0d",
"#9467bd",
"#e377c2",
];
const neonLights = [
"#ff7f0e",
"#d62728",
"#ffcd4a",
"#32a251",
"#17becf",
"#aec7e8",
"#7b66d2",
"#e377c2",
"#dc5fbd",
"#cdc05d",
];
const vintageRetro = [
"#8c564b",
"#998688",
"#ac613c",
"#b85a0d",
"#7b66d2",
"#9467bd",
"#cdc05d",
"#ff7f0e",
"#e377c2",
"#ff9e4a",
];
const iceCreamDream = [
"#dc5fbd",
"#e377c2",
"#ffcd4a",
"#cdc05d",
"#acac58",
"#7b66d2",
"#a699e8",
"#9467bd",
"#aec7e8",
"#17becf",
];
const boldSunset = [
"#d62728",
"#ff7f0e",
"#ff9e4a",
"#ffcd4a",
"#cdc05d",
"#32a251",
"#67bf5c",
"#17becf",
"#6dccda",
"#aec7e8",
];
const midnightPastels = [
"#7f7f7f",
"#a2a2a2",
"#8f8782",
"#cfcfcf",
"#5f5a41",
"#94917b",
"#998688",
"#e377c2",
"#9467bd",
"#cdc05d",
];
const softNeutrals = [
"#a5acaf",
"#cfcfcf",
"#8f8782",
"#cdc05d",
"#b85a0d",
"#ac613c",
"#ff9e4a",
"#9467bd",
"#dc5fbd",
"#e377c2",
];

export const palettes = {
deep,
muted,
pastel,
bright,
dark,
colorblind,
vibrantRedGoldGreen,
natureInspired,
sunsetTones,
pastelDream,
earthyNeutrals,
retroPop,
boldContrast,
softVintage,
elegantPastels,
autumnWarmth,
oceanBreeze,
forestMystic,
berryMix,
goldenHour,
neonLights,
vintageRetro,
iceCreamDream,
boldSunset,
midnightPastels,
softNeutrals
} as const;

export type Palette = keyof typeof palettes;
Loading
Loading