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

Pie chart freaks out with negative values. #7

Closed
borgar opened this issue Mar 18, 2013 · 6 comments
Closed

Pie chart freaks out with negative values. #7

borgar opened this issue Mar 18, 2013 · 6 comments

Comments

@borgar
Copy link

borgar commented Mar 18, 2013

See: http://jsfiddle.net/MVWWC/

I think this could be handled more gracefully, such as with an error message. As it is, the chart is wrong/misleading.

@robinwassen
Copy link

Excel 2013 handle this by using the negative numbers as positive.

I think this can be the a good solution since you might want to make a pie chart that compare incomes vs expenses or something similar
negative-pie
.

@borgar
Copy link
Author

borgar commented Mar 18, 2013

I think Excel is too dumb here (unless there is more to the screenshot).

Abs'ing all values is only a good idea if you label the negatives somehow or explicitly state that this has been done.

Example: Let's say that I am a developer that sets up a dashboard for a department in my company unaware of this "feature". Everything looks good until one day a negative value turns up and without anyone realizing it, a group of people are making decisions on incorrect data.

@nnnick
Copy link
Member

nnnick commented Mar 18, 2013

How would you expect this to render? Highcharts handles this slightly oddly as well... http://jsfiddle.net/E4jg7/

Unless there is something which seems like it would be appropriate for everyone, I think the best approach is to sanitise the data before creating the chart depending on the use case. For example, if people feel the approach Excel takes in abs'ing the value is the best way, that should be done before instantiating the chart. Alternatively, if you wanted to throw an error in your application, maybe the best way of doing that is before you create the chart based off that data.

@borgar
Copy link
Author

borgar commented Mar 18, 2013

I have, in this situation, rendered this as a simple circle (gray outline only) with a message in the center saying something along the lines of "pie charts can't represent negative values".

There really isn't much else you can do without being misleading (or weird like Highcharts). Some chart types simply won't work with some values. Another example of such a thing is a stacked area chart: I don't know that there is anything sane that can be done, if smack in the middle you encounter a big negative value, other than just telling the viewer that this won't work. 😦

@nnnick
Copy link
Member

nnnick commented Mar 18, 2013

Why don't you have some logic in your application that detects negative values before rendering a chart? I think that would make more sense than trying to add partial support for negative values in Chart.js.

@nnnick nnnick closed this as completed Mar 18, 2013
@robinwassen
Copy link

I would suggest that you at least add an exception then if negative values are found to inform the developer that it isn't supported.

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

No branches or pull requests

3 participants