UNPKG

zz-chart

Version:

Alauda Chart components by Alauda Frontend Team

28 lines 804 B
import { DEFAULT_COLORS } from "../utils/constant.js"; export class ChartColorManager { constructor() { this.colorMap = new Map(); } getChartColor(key) { if (!key) return DEFAULT_COLORS[0]; if (this.colorMap.has(key)) { return this.colorMap.get(key); } const color = DEFAULT_COLORS[this.colorMap.size % DEFAULT_COLORS.length]; this.colorMap.set(key, color); return color; } cleanupChartColors(validKeys) { const currentKeys = new Set(validKeys); for (const key of this.colorMap.keys()) { if (!currentKeys.has(key)) { this.colorMap.delete(key); } } } reset() { this.colorMap.clear(); } } //# sourceMappingURL=color.js.map