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

Vanilla bars w/ BACKEND DATA!! #74

Open
wants to merge 20 commits into
base: master
Choose a base branch
from
Open

Conversation

gracetian6
Copy link
Contributor

@gracetian6 gracetian6 commented Jul 30, 2020

  • integrate backend with front end bar chart
  • uses ES modules for variable transfer
  • fetched GENRE_ANALYSIS in genre.js and moved this JSON obj to bar.js

Backend data looks like:
image

FRONT END BAR CHART:
image

@gracetian6 gracetian6 marked this pull request as ready for review July 30, 2020 16:56
client/js/bar.js Outdated
Comment on lines 59 to 61
Object.values(DATA.genreData),
Object.keys(DATA.genreData),
DATA.maxGenreCount);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure if Object.values and Object.keys is the best way to do it

I assume that the array returned from both methods should match up with each other

Copy link
Collaborator

Choose a reason for hiding this comment

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

If they match up then I think this is a clever-ish solution to your problem. You could also just change createBarChart to accept the entire map and then loop through the key-value pairs there. I personally prefer the second method, but I'd also like to see what @laptou has to say about it.

@gracetian6 gracetian6 self-assigned this Jul 30, 2020
client/.eslintrc Outdated Show resolved Hide resolved
client/js/util.js Outdated Show resolved Hide resolved
@gracetian6 gracetian6 changed the title Vanilla bars backend Vanilla bars w/ BACKEND DATA!! Jul 30, 2020
Base automatically changed from vanilla-bars-text to master July 31, 2020 01:01
client/js/bar.js Outdated Show resolved Hide resolved
client/js/bar.js Outdated
Comment on lines 59 to 61
Object.values(DATA.genreData),
Object.keys(DATA.genreData),
DATA.maxGenreCount);
Copy link
Collaborator

Choose a reason for hiding this comment

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

If they match up then I think this is a clever-ish solution to your problem. You could also just change createBarChart to accept the entire map and then loop through the key-value pairs there. I personally prefer the second method, but I'd also like to see what @laptou has to say about it.

client/js/util.js Outdated Show resolved Hide resolved
client/.eslintrc Outdated Show resolved Hide resolved
client/js/bar.js Outdated Show resolved Hide resolved
* and displays on youtube-genre.html
*/

const genreBlock = document.getElementById('genres');
document.body.onload = fetchMusicGenre();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why are you calling fetchMusicGenre() as an onload handler if you call it on line 24?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

O good point

client/js/genre.js Outdated Show resolved Hide resolved
client/js/util.js Outdated Show resolved Hide resolved
@laptou
Copy link
Collaborator

laptou commented Jul 31, 2020

nit: there is no such thing as an ESLint module. these files are ES modules. ESLint is just a program that looks at your code and flags any stylistic errors.

@gracetian6 gracetian6 requested a review from laptou August 4, 2020 01:34
Copy link
Collaborator

@seunomonije seunomonije 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!

client/js/bar.js Outdated
@@ -59,4 +54,9 @@ function createBarChart(chartValues, chartCategories) {
}
}

createBarChart(CHART_VALUES, CHART_CATEGORIES);
GENRE_ANALYSIS.then((genreAnalysisInfo) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I mentioned this in another review, but consider renaming GENRE_ANALYSIS to GENRE_ANALYSIS_TASK or GENRE_ANALYSIS_PROMISE so that it is extra clear that this object is a Promise.

createBarChart(CHART_VALUES, CHART_CATEGORIES);
GENRE_ANALYSIS_PROMISE.then((genreAnalysisInfo) => {
createBarChart(
Object.values(genreAnalysisInfo.genreData),
Copy link
Collaborator

Choose a reason for hiding this comment

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

My opinion here would be to pass the entire map rather than separating it out. In createBarChart, we start to lose the connection between these two arrays when you're accessing values in one array based on the length of the other array. Open to other thoughts though @geekster777?

Copy link
Contributor

Choose a reason for hiding this comment

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

+1. It makes your function call more concise, and like Jess said, keeps the direct connection between your categories and their values.

client/js/genre.js Outdated Show resolved Hide resolved
client/js/bar.js Outdated Show resolved Hide resolved
createBarChart(CHART_VALUES, CHART_CATEGORIES);
GENRE_ANALYSIS_PROMISE.then((genreAnalysisInfo) => {
createBarChart(
Object.values(genreAnalysisInfo.genreData),
Copy link
Contributor

Choose a reason for hiding this comment

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

+1. It makes your function call more concise, and like Jess said, keeps the direct connection between your categories and their values.

client/js/bar.js Outdated Show resolved Hide resolved
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.

5 participants