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

Fixed bug handling 1 and 0 #1

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

Conversation

tiefling
Copy link

Hi,

I've added some documentation to this, applied a fix to handle a bug where a single item of a value of 1 or 0 would make the circle disappear and also added some error handling to make it easier to debug when it's not working.

Defaults will also apply if you don't provide radius for example so that the item fills it's container.

Nice donut!

README.md Outdated
@@ -32,4 +32,4 @@ And if you need to, you can update the values:
})


Have fun!
https://raw.githubusercontent.com/ismaell/js-donut-chart
Copy link
Owner

Choose a reason for hiding this comment

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

Why?

Copy link
Author

Choose a reason for hiding this comment

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

Unintentional copy / paste error I should think. Totally unintentional

this.spec = spec;
this.element = null;

this.update({});
Copy link
Owner

Choose a reason for hiding this comment

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

Please don't change the indentation in the same commit. Also, what's the rationale for changing it?

Copy link
Author

Choose a reason for hiding this comment

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

I'm not aware that I changed the indentation at all. I did move some methods around in the page order but I don't think I changed the indentation at all....

@@ -1,7 +1,7 @@
<html>
<head>
<style>
.chart-item-bg {stroke: #ddd}
.chart-item-bg {stroke: #000000}
Copy link
Owner

Choose a reason for hiding this comment

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

I am guessing this change slipped thru.

Copy link
Author

Choose a reason for hiding this comment

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

This was intentional. Switching the stroke to black made it much clearer to debug at the very very small levels that I was dealing with where it would break trying to cover off the closest acceptable fraction close to 1 / 0. I wanted the highest possible contrast.

donut-chart.js Outdated
if (this.element) this.element.remove();
this.element = this.parent.appendChild(code);
} else {
throw new Error("No parent defined for the chart.")
Copy link
Owner

Choose a reason for hiding this comment

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

I would prefer the following style:

if (!this.parent)
    throw new Error("...")
...

Copy link
Author

Choose a reason for hiding this comment

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

Fix en route

Keith Jackson and others added 2 commits May 29, 2018 15:22
Re-added request for fun which I seem to have removed unintentionally
@ismaell ismaell self-assigned this Sep 16, 2019
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