From 736236e9ca200a021b0c051cfc2eb91e411a2442 Mon Sep 17 00:00:00 2001 From: Christoph Kluge Date: Tue, 14 Jan 2025 17:40:25 +0100 Subject: [PATCH] add colorblind setting and friendly palettes - mode applies to plot data, plot background color, statsseries colors, roofline timescale --- web/frontend/src/config/UserSettings.svelte | 6 +- .../src/config/user/PlotColorScheme.svelte | 66 +++++++++++++++++-- .../src/config/user/PlotRenderOptions.svelte | 52 +++++++++++++-- .../src/generic/plots/MetricPlot.svelte | 14 ++-- .../src/generic/plots/Roofline.svelte | 3 +- 5 files changed, 125 insertions(+), 16 deletions(-) diff --git a/web/frontend/src/config/UserSettings.svelte b/web/frontend/src/config/UserSettings.svelte index 539aadf..1b59e31 100644 --- a/web/frontend/src/config/UserSettings.svelte +++ b/web/frontend/src/config/UserSettings.svelte @@ -18,6 +18,7 @@ const ccconfig = getContext("cc-config"); let message = { msg: "", target: "", color: "#d63384" }; let displayMessage = false; + let cbmode = ccconfig?.plot_general_colorblindMode || false; async function handleSettingSubmit(event) { const selector = event.detail.selector @@ -28,6 +29,9 @@ const res = await fetch(form.action, { method: "POST", body: formData }); if (res.ok) { let text = await res.text(); + if (formData.get("key") === "plot_general_colorblindMode") { + cbmode = JSON.parse(formData.get("value")); + } popMessage(text, target, "#048109"); } else { let text = await res.text(); @@ -51,4 +55,4 @@ handleSettingSubmit(e)}/> handleSettingSubmit(e)}/> - handleSettingSubmit(e)}/> + handleSettingSubmit(e)}/> diff --git a/web/frontend/src/config/user/PlotColorScheme.svelte b/web/frontend/src/config/user/PlotColorScheme.svelte index d180327..1cb5d86 100644 --- a/web/frontend/src/config/user/PlotColorScheme.svelte +++ b/web/frontend/src/config/user/PlotColorScheme.svelte @@ -24,6 +24,7 @@ export let config; export let message; export let displayMessage; + export let cbmode = false; const dispatch = createEventDispatcher(); function updateSetting(selector, target) { @@ -265,6 +266,62 @@ ], }; + // https://personal.sron.nl/~pault/ + // https://tsitsul.in/blog/coloropt/ + const cvdschemes = { + HighContrast: [ + "rgb(221,170,51)", + "rgb(187,85,102)", + "rgb(0,68,136)", + "rgb(0,0,0)", + ], + Bright: [ + "rgb(68,119,170)", + "rgb(102,204,238)", + "rgb(34,136,51)", + "rgb(204,187,68)", + "rgb(238,102,119)", + "rgb(170,51,119)", + "rgb(187,187,187)", + ], + Muted: [ + "rgb(51,34,136)", + "rgb(136,204,238)", + "rgb(68,170,153)", + "rgb(17,119,51)", + "rgb(153,153,51)", + "rgb(221,204,119)", + "rgb(204,102,119)", + "rgb(136,34,85)", + "rgb(170,68,153)", + "rgb(221,221,221)", + ], + NormalSixColor: [ + "rgb(64,83,211)", + "rgb(221,179,16)", + "rgb(181,29,20)", + "rgb(0,190,255)", + "rgb(251,73,176)", + "rgb(0,178,93)", + "rgb(202,202,202)", + ], + NormalTwelveColor: [ + "rgb(235,172,35)", + "rgb(184,0,88)", + "rgb(0,140,249)", + "rgb(0,110,0)", + "rgb(0,187,173)", + "rgb(209,99,230)", + "rgb(178,69,2)", + "rgb(255,146,135)", + "rgb(89,84,214)", + "rgb(0,198,248)", + "rgb(135,133,0)", + "rgb(0,167,108)", + "rgb(189,189,189)", + ] + } + @@ -281,7 +338,7 @@ -
Color Scheme for Timeseries Plots
+
Color Scheme for Timeseries Plots {cbmode ? `(Color Blind Friendly Palettes)` : ``}
{#if displayMessage && message.target == "cs"}
@@ -293,7 +350,7 @@ - {#each Object.entries(colorschemes) as [name, rgbrow]} + {#each Object.entries(cbmode ? cvdschemes : colorschemes) as [name, rgbrow]}
{name} @@ -333,8 +390,9 @@