diff --git a/packages/ott-vis-panel/src/colors.ts b/packages/ott-vis-panel/src/colors.ts index 6490f91e2..27a424350 100644 --- a/packages/ott-vis-panel/src/colors.ts +++ b/packages/ott-vis-panel/src/colors.ts @@ -1,12 +1,18 @@ +import * as d3 from "d3"; + class ColorProvider { + private color = d3.scaleOrdinal(d3.schemeCategory10); + private assignments: Map = new Map(); + public assign(thing: string): string { - // TODO: implement - return ""; + if (!this.assignments.has(thing)) { + this.assignments.set(thing, this.color(thing)); + } + return this.assignments.get(thing)!; } - public assignments(): Map { - // TODO: implement - return new Map(); + public getAssignments(): Map { + return this.assignments; } }