Skip to content

Add ability to select coloscheme for spectrogram #142

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

Merged
merged 12 commits into from
May 5, 2025

Conversation

naglepuff
Copy link
Collaborator

@naglepuff naglepuff commented Apr 9, 2025

Fix #133

Adds the ability to select a color scheme to apply to the spectrogram on the front end. The "0" value can be set as well (defaults to black). Also adds the ability to change the default color scheme on the Admin page.

@naglepuff naglepuff force-pushed the issue-133-alt-color-scheme branch 2 times, most recently from 426f473 to 5223263 Compare April 10, 2025 21:28
@naglepuff naglepuff marked this pull request as ready for review April 10, 2025 21:31
@naglepuff naglepuff requested a review from BryonLewis April 10, 2025 21:33
Copy link
Collaborator

@BryonLewis BryonLewis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few suggestions:

  • Remove Alpha selection from background color picker
  • Maybe add a default background color to go along with the color scheme
  • Suggestion on representation of the color scheme in the color scheme picker through a custom component
  • Swapping watch effect to a more explicit watch

const gValues = ref('');
const bValues = ref('');

watchEffect(() => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this be switched to a more explicit watch (I know it may have a few variables it is watching, such as backgroundColor and colorScheme)? I've just been bitten in the past by watchEffect getting large and making it difficult to determine the triggering variable/function.

Below is just an explanation of why I have an aversion to watchEffect ,but I'm open to have my mind changed:
It was a more complicated instance with other issues, but the watchEffect made it difficult to track the logic down. A codebase I was being onboarded on had a function that modified a ref, that function was passed a prop into a child component that was renamed and then used in a large (~200 line watchEffect). The chaining and the name changes made it difficult for me to determine why and where the variable was changing.

Comment on lines 523 to 528
<v-color-picker
v-model="backgroundColor"
elevation="0"
/>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add mode='hex' or mode='rgb' to the attributes on this component. It will remove the alpha portion of the selector. Really isn't needed because I don't think it would apply to the background color.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is implemented in a new component called ColorPickerMenu.

Comment on lines 493 to 506
<v-select
v-model="colorScheme"
label="Color Scheme"
:items="colorSchemes"
item-title="title"
item-value="scheme"
variant="outlined"
density="compact"
width="75"
hide-details
return-object
/>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we may want to include an indication of the color scheme mostly because I don't know off hand what those names mean.

Something like this:
image
I included a component that can be used as a base (it's a text file because github doesn't like .vue files). It's just a custom V-select that provides a visual indication of the color scheme. Feel free to modify anything in it (I did the highlighting and border stuff quick for the individual items).
I think this or something like this should replace the configuration color picker as well.

ColorSchemePicker.txt

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I like the component. I made some changes to it, such as switching to <script setup> and changing the styles a bit.

Comment on lines +27 to +31
default_color_scheme = models.CharField(
max_length=20,
choices=AvailableColorScheme.choices,
default=AvailableColorScheme.INFERNO,
)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you're adding a default color scheme should there be a default background color as well?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would make sense, yes. I've gone ahead and done that, and squashed both migrations into one.

@naglepuff naglepuff force-pushed the issue-133-alt-color-scheme branch from bc844ca to 9e6c1ff Compare April 14, 2025 18:49
@naglepuff naglepuff force-pushed the issue-133-alt-color-scheme branch from 9e6c1ff to 310df37 Compare April 22, 2025 19:25
@naglepuff naglepuff force-pushed the issue-133-alt-color-scheme branch from a32defc to f1d2d96 Compare April 30, 2025 16:07
@naglepuff naglepuff requested a review from BryonLewis April 30, 2025 16:11
Copy link
Collaborator

@BryonLewis BryonLewis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, only thing is I would remove the unnecessary yarn.lock file from this PR.

@naglepuff naglepuff force-pushed the issue-133-alt-color-scheme branch from 4a86587 to 4aa27f0 Compare May 2, 2025 20:41
@naglepuff
Copy link
Collaborator Author

@BryonLewis I've rebased this and regenerated the new migration to keep the history linear. Rebasing was mostly smooth, with some small conflicts that felt straightforward to resolve. LMK if you'd like to take another look or if I should merge this in

@BryonLewis
Copy link
Collaborator

I think you're good to merge.

@naglepuff naglepuff merged commit f8030fc into main May 5, 2025
6 checks passed
@naglepuff naglepuff mentioned this pull request May 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Alternate Color Scheme Testing
2 participants