git-log--graph icon indicating copy to clipboard operation
git-log--graph copied to clipboard

Graph color palette

Open dimateos opened this issue 1 year ago • 4 comments

Hey again!

I was wondering how colors per branch are picked. For example in this case I ended up with very low contrasty colors: red, orange, orange again, red again...

I think that what mhutchie.git-graph did was have a set of very high contrast colors and assign them from left to right, so at least the top of the graph would have 2/3 nicely different colors.

Here it seems that the colors are assigned per branch retrieved or something?

image


Also can the colors be tweaked in the CSS? And the highlighted branch line background? line thickness? The subtle gray highlight looks a bit bad in a dark background.

Tagging https://github.com/phil294/GitLG/issues/56 as colors should be part of the design

dimateos avatar Nov 28 '24 16:11 dimateos

They are currently calculated based on the hash of the branch name, so always stable. They are picked from a set of pre-defined colors. These aren't super great though, some aren't quite readable - especially in light theme which we support now. Note that the background color is now also variable, so avoiding e.g.blue on blue entirely is difficult.

Modifying by CSS is possible, but I don't think the branch names are exposed as class names (or are they?), so you could only change them all to the same color. The other properties like thickness can be tweaked with custom CSS option. Yep, the shadow color is too bright

phil294 avatar Nov 29 '24 21:11 phil294

I dont see them as class names nope, I guess I could select them based on exact stroke color and swap it, not ideal.

  • Maybe the set of pre-defined colors could be a setting? Instead of relying on the custom css
    • The setting for css IMO is great for tweaking without waiting for specific settings tho!

I see the benefit of always using the class names instead of the relative position of the branch in the graph: you get matching branch colors in the branch selector + (if you do not rename the remote) same colors as your colleagues. image

But potentially you can get the same/similar colors for parallel branches, so maybe its worth considering an alternative even if you loose then constant coloring: the user may simply need high contrast colors for the current branches shown in the graph.

So the current method is NICE so definitely would keep it as an option (even the default probably), but we could leave this issue open to reference its trade-offs and a potential alternative setting.

dimateos avatar Dec 02 '24 09:12 dimateos

Jup, both good ideas!

phil294 avatar Dec 02 '24 09:12 phil294

I have the same request - I have a lot of branches in my repo, and the colors are difficult to see/use. I'd like to customize the look of the branch to be like the git-graph extension : smaller, without the bold font. I don't really need to have colors in branch name.

j3rem1e avatar May 05 '25 10:05 j3rem1e

the default logic hasn't changed, but you can now fully configure branch coloring with new config settings branch-colors, branch-color-strategy, and branch-color-custom-mapping.

phil294 avatar Jun 29 '25 23:06 phil294