class ColorPicker { private colorIndex = 0 private readonly colorMap: Map = new Map() colorScheme: string[] = [ '#dc2626', '#27C', '#FB0', '#2C8', '#569', '#0CE', '#E8A', '#DDA', '#C86', '#F72', '#C8C', '#BCA', '#F27', ] getColor (key: string): string { let color = this.colorMap.get(key) if (!color) { color = this.getNewColor() this.colorMap.set(key, color) } return color } getNewColor (): string { return this.colorScheme[this.colorIndex++ % this.colorScheme.length] } setColor (key: string, color: string) { this.colorMap.set(key, color) } } export const colorPicker = new ColorPicker()