diff --git a/ts/routes/graphs/card-counts.ts b/ts/routes/graphs/card-counts.ts index e31c0a5b9..0bd400f8a 100644 --- a/ts/routes/graphs/card-counts.ts +++ b/ts/routes/graphs/card-counts.ts @@ -18,6 +18,8 @@ import { schemeGreens, schemeOranges, schemeReds, + schemePurples, + schemeBuPu, select, sum, } from "d3"; @@ -31,15 +33,32 @@ export interface GraphData { totalCards: string; } -const barColours = [ +let barColours; + +if((window as any).colorBlindMode) +{ + barColours = [ + schemeBlues[5][2], /* new */ + schemeOranges[5][2], /* learn */ + schemeReds[5][2], /* relearn */ + schemePurples[7][4], /* young */ + schemeBuPu[8][6], /* mature */ + "#00FF60", /* suspended */ + "#1F1F1F", /* buried */ + ]; +} +else +{ + barColours = [ schemeBlues[5][2], /* new */ schemeOranges[5][2], /* learn */ schemeReds[5][2], /* relearn */ schemeGreens[5][2], /* young */ schemeGreens[5][3], /* mature */ "#FFDC41", /* suspended */ - "grey", /* buried */ -]; + "#grey", /* buried */ + ]; +} function countCards(data: GraphsResponse, separateInactive: boolean): Count[] { const countData = separateInactive ? data.cardCounts!.excludingInactive! : data.cardCounts!.includingInactive!; diff --git a/ts/routes/graphs/ease.ts b/ts/routes/graphs/ease.ts index 26de02096..4d2739191 100644 --- a/ts/routes/graphs/ease.ts +++ b/ts/routes/graphs/ease.ts @@ -8,8 +8,8 @@ import type { GraphsResponse } from "@generated/anki/stats_pb"; import * as tr from "@generated/ftl"; import { localizedNumber } from "@tslib/i18n"; -import type { Bin, ScaleLinear } from "d3"; -import { bin, extent, interpolateRdYlGn, scaleLinear, scaleSequential, sum } from "d3"; +import type { Bin, ScaleLinear, ScaleSequential } from "d3"; +import { bin, extent, interpolateRdYlGn, interpolateTurbo, scaleLinear, scaleSequential, sum } from "d3"; import type { SearchDispatch, TableDatum } from "./graph-helpers"; import { getNumericMapBinValue, numericMap } from "./graph-helpers"; @@ -84,7 +84,17 @@ export function prepareData( .thresholds(ticks)(allEases.entries() as any); const total = sum(bins as any, getNumericMapBinValue); - const colourScale = scaleSequential(interpolateRdYlGn).domain([xMin, 300]); + + let colourScale; + + if ((window as any).colorBlindMode) + { + colourScale = scaleSequential(interpolateTurbo).domain([xMin, 300]); + } + else + { + colourScale = scaleSequential(interpolateRdYlGn).domain([xMin, 300]); + } function hoverText(bin: Bin, _percent: number): string { const minPct = Math.floor(bin.x0!); diff --git a/ts/routes/graphs/intervals.ts b/ts/routes/graphs/intervals.ts index ffd41b238..8a806a168 100644 --- a/ts/routes/graphs/intervals.ts +++ b/ts/routes/graphs/intervals.ts @@ -10,7 +10,7 @@ import * as tr from "@generated/ftl"; import { localizedNumber } from "@tslib/i18n"; import { timeSpan } from "@tslib/time"; import type { Bin } from "d3"; -import { bin, extent, interpolateBlues, quantile, scaleLinear, scaleSequential, sum } from "d3"; +import { bin, extent, interpolateBlues, interpolateCividis, quantile, scaleLinear, scaleSequential, sum } from "d3"; import type { SearchDispatch, TableDatum } from "./graph-helpers"; import { numericMap } from "./graph-helpers"; @@ -147,8 +147,24 @@ export function prepareIntervalData( return [null, []]; } - const adjustedRange = scaleLinear().range([0.7, 0.3]); - const colourScale = scaleSequential((n) => interpolateBlues(adjustedRange(n)!)).domain([xMax!, xMin!]); + let adjustedRange; + let colourScale; + + if ((window as any).colorBlindMode) + { + adjustedRange = scaleLinear().range([0.1, 1.0]); + colourScale = scaleSequential((n) => interpolateCividis(adjustedRange(n)!)).domain([xMax!, xMin!]); + } + else + { + adjustedRange = scaleLinear().range([0.7, 0.3]); + colourScale = scaleSequential((n) => interpolateBlues(adjustedRange(n)!)).domain([xMax!, xMin!]); + } + + //const adjustedRange = scaleLinear().range([0.7, 0.3]); + //const adjustedRange = scaleLinear().range([0.1, 1.0]); + //const colourScale = scaleSequential((n) => interpolateBlues(adjustedRange(n)!)).domain([xMax!, xMin!]); + //const colourScale = scaleSequential((n) => interpolateCividis(adjustedRange(n)!)).domain([xMax!, xMin!]); function hoverText( bin: Bin,