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

Donut charts #29

Closed
wants to merge 4 commits into from
Closed

Donut charts #29

wants to merge 4 commits into from

Conversation

seunomonije
Copy link
Collaborator

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

Copy link
Contributor

@gracetian6 gracetian6 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 and was readable

also please allow sharing for your screen share link

@seunomonije
Copy link
Collaborator Author

seunomonije commented Jul 13, 2020

@gracetian6 @laptou I made it so both of yall are "editors" and can share it. Everyone else who has the link may comment.

Comment on lines 2 to 3
/* the higher the number, the less filled */
--percent: 8;
Copy link
Collaborator

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 the circle 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));

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

  1. I put the variable on root because there is no container in this pr to add it to.
  2. 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.
  3. I tried to set the pathLength attribute to 100 and try it that way, but changing the stroke-dashoffset had no effect.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Collaborator

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

Copy link
Collaborator Author

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

client/css/analysis.css Outdated Show resolved Hide resolved
@laptou laptou linked an issue Jul 13, 2020 that may be closed by this pull request
Base automatically changed from Contiguous-backend-2 to master July 15, 2020 19:38
@seunomonije seunomonije reopened this Jul 15, 2020
@seunomonije
Copy link
Collaborator Author

Will include these in better pull request.

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.

Lint errors in analysis.js
3 participants