Skip to content
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

Feature/spectrogram scrolly #17

Merged
merged 11 commits into from
Sep 21, 2020
Merged

Feature/spectrogram scrolly #17

merged 11 commits into from
Sep 21, 2020

Conversation

conorato
Copy link
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
Contributor Author

Copy link
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.

tabWidth: 2
semi: true
singleQuote: true
printWidth: 150
printWidth: 80
Copy link
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.

web/src/components/d3component.js Show resolved Hide resolved
web/src/components/d3component_scrollytelling.js Outdated Show resolved Hide resolved
const D3ComponentScrollyTelling = ({
callback,
data,
isInitialized,
Copy link
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
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).

@@ -1,7 +1,7 @@
import _ from 'lodash';

import { convertTimestampsToDates } from '../utils';
import { STAGES_ORDERED, EPOCH_DURATION_SEC } from '../constants';
import { convertTimestampsToDates, convertEpochsToAnnotations } from '../utils';
Copy link
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
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
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é.

g
.append('text')
.attr('x', spectrogramWidth / 2)
.attr('y', -MARGIN.TOP / 3)
Copy link
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
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

web/src/d3/spectrogram/spectrogram.js Outdated Show resolved Hide resolved
web/src/d3/spectrogram/spectrogram.js Outdated Show resolved Hide resolved
web/src/d3/utils.js Outdated Show resolved Hide resolved
@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