Files
TJWaterFrontend_Refine/src/components/olmap/DMALeakDetection/utils.ts
T

22 lines
439 B
TypeScript

export const AREA_COLORS = [
"#2563eb",
"#7c3aed",
"#0891b2",
"#16a34a",
"#ca8a04",
"#dc2626",
"#ea580c",
"#0f766e",
"#4338ca",
"#be123c",
];
export const getAreaColor = (areaId: string | number | undefined) => {
const text = String(areaId ?? "");
let hash = 0;
for (let i = 0; i < text.length; i += 1) {
hash = (hash * 31 + text.charCodeAt(i)) >>> 0;
}
return AREA_COLORS[hash % AREA_COLORS.length];
};