cheminfo / nmrium

React component to display and process nuclear magnetic resonance (NMR) spectra.
https://docs.nmrium.org
MIT License
55 stars 25 forks source link

Recolor spectra on 2D #2990

Closed lpatiny closed 6 months ago

lpatiny commented 7 months ago

Would be nice that recolor spectra also works on 2D. For now we can only recolor the positive part of the 2D.

image

hamed-musallam commented 7 months ago

The recoloring functionality is working but it takes into account the constant colors which we defined in the past based on the experiment value.

https://github.com/cheminfo/nmrium/blob/bc28413e2b82ea62cee7600addb2a4b1e5738058/src/data/utilities/generateColor.ts#L26-L33

lpatiny commented 7 months ago

Ok I see. I would then have 2 buttons, one for 'Set predefined colors' and the current one for 'Recolor'

With the current behavior, is it normal that even if I delete all the predefined colors

image

recolor does nothing ?

2024-03-25 11 53 25

hamed-musallam commented 7 months ago

As you know we recently added the feature of predefined colors which differs from what you're currently observing.

https://github.com/cheminfo/nmrium/blob/bc28413e2b82ea62cee7600addb2a4b1e5738058/src/data/utilities/generateColor.ts#L26-L33

Within the color function, we initially search for predefined custom colors. If none are found, we then check for constant colors. If neither exists, we generate a random color

hamed-musallam commented 7 months ago

I suggest updating the constant colors to align with the latest schema we agreed upon. Additionally, we can have two buttons: one to apply the color preferences and the other to generate colors randomly

lpatiny commented 7 months ago

So I think the 2 buttons approach (default and distinct) is the way to go.

I also get strange results when I try to recolor using the contextual menu.

2024-03-25 12 08 55

hamed-musallam commented 7 months ago

So I think the 2 buttons approach (default and distinct) is the way to go.

I also get strange results when I try to recolor using the contextual menu.

2024-03-25 12 08 55 2024-03-25 12 08 55

This may not be an issue in 1D but it is in 2. It should rely on column (experiment) values to generate the colors but it seems is not, I will check why this not working but the question should we generate a random color in this case or we should keep relying on experiment to ensure consistency

lpatiny commented 7 months ago

Yes it should be a random color in this case. Same is true in 1D. If we recolor by distinct value (contextual menu) we should have one color per distinct value.

hamed-musallam commented 7 months ago

This applies to all other information except for the experiment column. For the experiment column, should it be a random color too, or based on the predefined colors?

lpatiny commented 7 months ago

If we have the button to reset the experiment colors I think the contextual menu should always make the random color.