Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate unique colors for each category #247

Open
philipsens opened this issue Dec 19, 2024 · 1 comment
Open

Generate unique colors for each category #247

philipsens opened this issue Dec 19, 2024 · 1 comment
Labels
enhancement New feature or request frontend

Comments

@philipsens
Copy link
Member

If we create a hash of the category name, we can make endless categories without the need to give them all a color.

The name could be converted to a particular color, and we can apply the shade so they all look modern.

@Matthbo
Copy link
Member

Matthbo commented Dec 19, 2024

Example on how to calculate colour in hsl

function createHslColorFromString(string: string) {
    let hash = 0;
    for (let i = 0; i < string.length; i++) {
        hash += string.codePointAt(i);
    }

    const hue = hash % 360;

    return `hsl(${hue}, 90%, 85%)`;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request frontend
Projects
None yet
Development

No branches or pull requests

2 participants