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 with numbers #78

Open
wants to merge 3 commits into
base: vanilla-bars-backend
Choose a base branch
from

Conversation

gracetian6
Copy link
Contributor

@gracetian6 gracetian6 commented Jul 31, 2020

  • added svg numbers to the bar charts to display the counts
  • not sure if there's a better way to format the numbers within the svg rects -- any advice appreciated!

image

(also I will change the number color to be more aesthetically pleasing)

@gracetian6 gracetian6 self-assigned this Jul 31, 2020
Comment on lines +49 to +56
const value = document.createElementNS(SVG_NS, 'text');
g.append(value);
value.setAttribute('class', 'bar-value');
value.setAttribute('x', 3 * GRAPH_LEFT_PADDING);
value.setAttribute('y', barContainerHeight * i + barThickness);
value.setAttribute('text-anchor', 'middle');
value.fill = 'white';
value.textContent = chartValues[i];
Copy link
Contributor Author

@gracetian6 gracetian6 Aug 4, 2020

Choose a reason for hiding this comment

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

not sure if this is the best way to format the svg number within the svg rects.
I do it by setting the coordinates. Other advice is appreciated!

@gracetian6 gracetian6 marked this pull request as ready for review August 4, 2020 02:47
Copy link
Collaborator

@laptou laptou left a comment

Choose a reason for hiding this comment

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

Nice. LGTM.

I don't think there's any particular way to make the numbers look 'nicer'. You could prevent the text from appearing horizontally squished by calculating the distortion that is being applied to the SVG, and then applying the inverse distortion to the text (i.e., the SVG is square by default but is forced into a rectangle by your CSS, this is what makes the text look squished).

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.

LGTM

const barTextContainer = document.getElementById('bar-text');
const category = document.createElement('div');
barTextContainer.appendChild(category);
category.setAttribute('class', 'category');
category.textContent = chartCategories[i];

Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: remove extra newline

@@ -39,6 +39,10 @@
fill: var(--color-accent-special);
}

.bar-value {
fill: #FF69B4 ;
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: remove space before semicolon and add a comment indicating the color that this value evaluates to ("purple")

@@ -60,3 +71,5 @@ GENRE_ANALYSIS.then((genreAnalysisInfo) => {
Object.keys(genreAnalysisInfo.genreData),
genreAnalysisInfo.maxGenreCount);
});

// createBarChart([2,1], ["hello", "bye"], 2)
Copy link
Collaborator

Choose a reason for hiding this comment

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

this should be removed

@@ -39,6 +39,10 @@
fill: var(--color-accent-special);
}

.bar-value {
fill: #FF69B4 ;
Copy link
Contributor

Choose a reason for hiding this comment

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

Use a darker value like #943b68 to improve contrast.

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