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

Improve the rendering of negative values in the bar chart. #994

Closed

Conversation

etimberg
Copy link
Member

Inspired by #669, this is a fix for #9. Changed the bar chart drawing so that negative bars are drawn downwards. The animations are changed so that bars flow outward from the base towards the final value in all cases. If the scale has a 0 point, the animations flow from here. I updated the sample file to include both positive and negative values.

When both positive and negative values exist, the chart draws as such:
Negative and positive bar chart

When only positive values exist, the chart draws like this:
Positive chart

When only negative values exist, the chart draws like this:
Negative chart

… all values are negative, draw down from the top. Updated the sample file to allow for negative bars.
@fntneves
Copy link
Contributor

It's a must ! Great and clean PR. +1 to merge.

@etimberg In first case (both negative and positive values), what about highlighting y = 0 ?

@etimberg
Copy link
Member Author

@fntneves sounds like a good idea. I'll look into adding it.

@phpPhil
Copy link

phpPhil commented Mar 26, 2015

fantastic - love your work!

@leighquince
Copy link
Contributor

+1, only thing i can see as not quite right is in the one where it is both negative and positive the fill doesn't quite go down to the 0 line on the positive and goes over the line on the negative. I think this can be fixed by also adding scaleGridLineWidth to the calculated base.

@markomarkovic
Copy link

Notice, Math.sign is part of the ECMAScript 6 proposal and not available on many platforms. See MDN documentation for details.

@kfeine-FR
Copy link

Hi, thank you for the fix. However, like markomarkovic said, it's not working on IE due to "math.sign" compatibility. Is there an alternative way to have this working ? The use of IE is mandatory on my project...

@markomarkovic
Copy link

@kfeine-FR I've successfully used this polyfil on Android. It should work for other platforms too.

@etimberg
Copy link
Member Author

etimberg commented May 2, 2015

@markomarkovic @kfeine-FR I've updated this PR to remove the dependency on Math.sign

@leighquince I've taken your suggestion to move the base point down.

@etimberg
Copy link
Member Author

etimberg commented Jun 7, 2015

Closing since this has been incorporated into v2.0

@etimberg etimberg closed this Jun 7, 2015
@etimberg etimberg deleted the fix/bar_chart_negative_values branch June 14, 2015 13:00
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.

6 participants