Skip to content

Feature/spectrogram scrolly#17

Merged
conorato merged 11 commits intomasterfrom
feature/spectrogram-scrolly
Sep 21, 2020
Merged

Feature/spectrogram scrolly#17
conorato merged 11 commits intomasterfrom
feature/spectrogram-scrolly

Conversation

@conorato
Copy link
Copy Markdown
Contributor

@conorato conorato commented Sep 16, 2020

Task link

Summary

Modifications include turning the spectrogram visualization to a scrollytelling.
It involved:

  • Extraction of redundant code from previous scrollytelling component to a D3ComponentScrollyTelling
  • Modification of the X axis to display time instead of time since start of recording
  • Addition of callbacks to be able to display with opacity by sleep stage
  • Spectrogram also receives hypnogram data

Other modifications not related to the spectrogram (oups):

  • Reduced linter's printWidth
    The previous printWidth was too wide for my computer screen, and, in my opinion, made the code harder to read (can be debated). I did not run the linter against all files, since it can be done au fur à mesure.

@conorato
Copy link
Copy Markdown
Contributor Author

Copy link
Copy Markdown
Contributor

@WilliamHarvey97 WilliamHarvey97 left a comment

Choose a reason for hiding this comment

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

Incroyable! Bien heureux qu'on ait terminé le D3.

Comment thread .vscode/.prettierrc.yaml
semi: true
singleQuote: true
printWidth: 150
printWidth: 80
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Bonne idée, cela dépasse de l'écran autrement.

Comment thread web/src/components/d3component.js
Comment thread web/src/components/d3component_scrollytelling.js Outdated
const D3ComponentScrollyTelling = ({
callback,
data,
isInitialized,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

isLoaded et setIsLoaded?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

En fait, ces variables sont plutôt utilisées pour définir si la visualisation a été initialisée ou non. C'est donc utilisé plus tard quand on va appeller les callbacks (ex. spectrogramCallbacks['W']) quand on va scroller à travers un waypoint.

Le nom est isInitialized est alors, selon moi, plus appropriée, comme on ne load pas de données dans ce cas (désolé, c'est moi qui était confuse tout à l'heure en expliquant pourquoi on faisait ça).


import { convertTimestampsToDates } from '../utils';
import { STAGES_ORDERED, EPOCH_DURATION_SEC } from '../constants';
import { convertTimestampsToDates, convertEpochsToAnnotations } from '../utils';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

C'est peut-être plus le rôle du back-end de convertir les epochs de 30s en plage de stade de sommeil contigües. Pour l'instant c'est ok comme ça fonctionne, mais je me dis que ce sera important de déplacer ça.

.append('g')
.attr(
'transform',
`translate(${MARGIN.LEFT + spectrogramWidth}, ${MARGIN.TOP})`,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

J'imagine que ce serait mieux de faire la différence entre les margin de la légende et du spectrogramme. Peut-être créer deux objets même s'ils ont les mêmes valeurs serait préférable.

Copy link
Copy Markdown
Contributor Author

@conorato conorato Sep 19, 2020

Choose a reason for hiding this comment

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

Dans ce cas-ci, on ne définit pas le margin de la légende, mais plutôt le déplacement à faire en X pour arriver à la position voulue de la légende. On additionne donc le margin de droite, la largeur du spectrogramme, et on arrive à l'endroit en X où mettre la légende.
J'allais suggérer de faire une constante pour définir les positions en X et Y, mais comme il faudrait en fait faire une fonction qui prend en paramètre spectrogramWidth, je ne crois pas que ça l'aiderait tant à la lisibilité.

Comment thread web/src/d3/spectrogram/axes_legend.js Outdated
g
.append('text')
.attr('x', spectrogramWidth / 2)
.attr('y', -MARGIN.TOP / 3)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Peut-être créer une constante MARGIN_TITLE = {LEFT: ..., ...., BOTTOM: ...};

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Il faudrait faire une fonction qui prend en paramètre spectrogramWidth.. je ne pense pas que ça l'aiderait à la lisibilité. Aussi, c'est plutôt les positions en x et en y, et non les margins. J'ai ajouté une variable pour la position en Y

Comment thread web/src/d3/spectrogram/spectrogram.js Outdated
Comment thread web/src/d3/spectrogram/spectrogram.js Outdated
Comment thread web/src/d3/utils.js Outdated
@conorato conorato merged commit 12e1c27 into master Sep 21, 2020
@conorato conorato deleted the feature/spectrogram-scrolly branch September 21, 2020 20:04
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.

2 participants