-
Notifications
You must be signed in to change notification settings - Fork 1
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
Donut charts #29
Donut charts #29
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good and was readable
also please allow sharing for your screen share link
@gracetian6 @laptou I made it so both of yall are "editors" and can share it. Everyone else who has the link may comment. |
client/css/analysis.css
Outdated
/* the higher the number, the less filled */ | ||
--percent: 8; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the higher the number, the less filled
Why did you do it like that? Also, why did you put the variable on :root
instead of on the donut chart container?
You could make the --percent
variable work like an actual percentage by doing this:
- set the
pathLength
attribute of thecircle
element to 100; then the browser will always do stroke calculations as if the circle's circumference is 100 units (which means a stroke dash offset of 1 will actually offset the stroke by 1%) - use
calc()
to do subtraction at the site where you use the variable:stroke-dashoffset: calc(100 - var(--percent));
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- I put the variable on root because there is no container in this pr to add it to.
- I did it like this so that in JS, I could easily change the
--percent
variable for each donut from there and it would fill the circle accordingly. 440 is approximately 2πr where r is 70 as seen in the code.- For example, if Perspective returns 70% toxicity, do 440 - 440*.70 in js and then set the
--percent
variable from there. Very simple.
- For example, if Perspective returns 70% toxicity, do 440 - 440*.70 in js and then set the
- I tried to set the
pathLength
attribute to 100 and try it that way, but changing thestroke-dashoffset
had no effect.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check this out: https://jsfiddle.net/jc5pn9rm/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And you can use calc()
if you want the donut to fill up counterclockwise instead of clockwise
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very very nice. Thank you
Will include these in better pull request. |
Finished the donut charts in a scaleable way. Each category will have a different color. I will also change the code to allow for more modification once everything is in master and I can actually run the front-end code on my computer.
JSFiddle: https://jsfiddle.net/ncdqm8hs/1/
And if that doesn't work, screen recording: https://drive.google.com/file/d/1zxy3eArrNZG_fTeJYt00xAc_gZFPBgKy/view?usp=sharing