MCPcopy Create free account
hub / github.com/aghyad97/browserytools / getColorForDataKey

Function getColorForDataKey

src/components/ChartCustomizationPanel.tsx:95–116  ·  view source on GitHub ↗
(key: string, index: number)

Source from the content-addressed store, hash-verified

93 };
94
95 const getColorForDataKey = (key: string, index: number): string => {
96 if (settings.colorScheme === "custom" && settings.customColors.length > 0) {
97 return settings.customColors[index % settings.customColors.length];
98 }
99
100 if (settings.colorScheme === "preset") {
101 const preset = THEME_PRESETS.find((p) => p.id === settings.themePreset);
102 if (preset) {
103 return preset.colors[index % preset.colors.length];
104 }
105 }
106
107 // Default colors
108 const defaultColors = [
109 "hsl(var(--chart-1))",
110 "hsl(var(--chart-2))",
111 "hsl(var(--chart-3))",
112 "hsl(var(--chart-4))",
113 "hsl(var(--chart-5))",
114 ];
115 return defaultColors[index % defaultColors.length];
116 };
117
118 const applyThemeOrderToCustom = () => {
119 const preset =

Callers 1

ChartCustomizationPanelFunction · 0.85

Calls 1

findMethod · 0.80

Tested by

no test coverage detected