Skip to content

FoamTree color stability #500

@CreativeTechGuy

Description

@CreativeTechGuy

Issue description

It's currently impossible to compare two outputs side-by-side since the boxes can shift around and the colors are seemingly random. I'd like a way to be able to compare differences between two bundle analysis and the easiest way I can think of achieving that is to make the colors deterministic rather than random.

Technical info

Not really an issue, more of a suggestion.

From the FoamTree docs, we could use groupColorDecorator and attach the color to each item in the list of groups. (See the "Colors defined in the data model" section of the docs). To ensure stability between different runs, the colors should be based on the file name of the chunk. Webpack's chunks are in the form of <id>.<hash>.<ext> so we should only consider the first part of that when determining the color since the hashes will change.

I believe the id numbers of each chunk also are in a finite range (cannot confirm but just from testing) so we could translate the 1-999 ids with a percent in the hsl color space. This should give us an easy way to map between chunks and colors and would give a pretty decent spread of colors.

For chunks with names rather than numbers as their ids, we could come up with a similar hashing algorithm which turns the characters into a color.

Debug info

N/A

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions