Skip to content

Commit cb5fdbb

Browse files
authored
Merge pull request #467 from Ed9uard/increase-color-slots-466
fix: increase color slots from 10 to 20 (#466)
2 parents 09ec29e + 404d697 commit cb5fdbb

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

src/app/components/ui/chart-colors-config/chart-colors-config.component.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,12 +208,25 @@ export class ChartColorsConfigComponent implements OnInit, OnDestroy {
208208
*/
209209
private getDefaultColors(): IChartColorsConfig {
210210
const opt = Highcharts.getOptions();
211+
const baseColors = (opt.colors ?? []).filter((c): c is string => typeof c === 'string');
212+
const generatedColors = this.generateHSLColors(10);
213+
const hcColors = Array.from(new Set([...baseColors, ...generatedColors])).slice(0, 20);
214+
211215
return {
212-
hcColors: opt.colors?.slice() as any || '',
213-
hcBackground: opt.chart?.backgroundColor as string || '',
214-
hcTextColor: (opt as any).labels?.style?.color || '',
216+
hcColors,
217+
hcBackground: String(opt.chart?.backgroundColor ?? ''),
218+
hcTextColor: String((opt as any).labels?.style?.color ?? ''),
215219
hcBorderColor: '', // opt.plotOptions.bar.borderColor as string,
216220
hcLineColor: '#e6e6e6' // ((this.chart as any).colorAxis as ColorAxisOptions).minorGridLineColor as string
217221
};
218222
}
223+
224+
private generateHSLColors(count: number): string[] {
225+
return Array.from({ length: count }, (_, i) => {
226+
const colorAngle = Math.round((270 / (count - 1)) * i);
227+
return `hsl(${colorAngle}, 100%, 50%)`;
228+
});
229+
}
219230
}
231+
232+

0 commit comments

Comments
 (0)