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

Bar charts don't support negative values #9

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

Bar charts don't support negative values #9

borgar opened this issue Mar 18, 2013 · 24 comments

Comments

@borgar
Copy link

borgar commented Mar 18, 2013

Bar charts turn very strange when negative values exist in the data.

Test: http://jsfiddle.net/egMGx/

@nnnick
Copy link
Member

nnnick commented Mar 18, 2013

I'll take a look at nice ways of showing negative scales for both bar and line charts.

@kkush33
Copy link

kkush33 commented Mar 30, 2013

Could, we enhance the bar charts for the horizontal look and provide it also as an option?? I would also like to know how to contribute to the library with new chart types as an option.

@sebfischer83
Copy link

anything new on this?

@WimAtIHomer
Copy link

In my fork (https://github.com/WimAtIHomer/Chart.js) I have made changes to support negative values

@Xaviju
Copy link

Xaviju commented May 7, 2013

Did you do a pull-request? It would be awesome to have it for everybody in the main chartjs!

@WimAtIHomer
Copy link

The changes are part of my pull-request "BarAndLine Chart added". Don't know if will ever be part of the main chartjs, never had a reply on that pull-request. The project looks kind of dead.

@nicotroia
Copy link

Any progress on this? PS. Thank you WimAtIHomer, your version works great.

Edit: I had to remove ".toFixed(getDecimalPlaces(stepValue))" from the populateLabels function in order to set correct labels on -1, 0, 1, etc values.

@kurtseebauer
Copy link

still no progress with negative numbers?

@FVANCOP
Copy link

FVANCOP commented Apr 2, 2014

Bars with negative numbers works on the alternative version available at https://github.com/FVANCOP/ChartNew.js . This version is down compatible with nnnick version.

@kurtseebauer
Copy link

thank you very much!

@nnnick
Copy link
Member

nnnick commented Jun 29, 2014

Haven't had a chance to put that into the new version just yet. I'll leave this open as an enhancement, if anyone wants to take a look at incorporating their changes into the Chart.Scale class that'd be winning.

@ahrex
Copy link

ahrex commented Oct 1, 2014

I've proposed a fix, and wrapped it up as a pull request. This change works for my use case, but feel free to take it and generalize it.

@tannerlinsley
Copy link
Contributor

Hey guys, how is this going? is @ahrex 's pull request good to go? I'm looking to use a lot of these charts in production soon, and this is one of the biggies ;)

@ahrex
Copy link

ahrex commented Nov 12, 2014

Hey @tannerlinsley,

There's a bug with my proposed fix where the scale will look wonky upon resize (responsive == true). I'm testing out @3xmo's potential fix he provided at #669 (comment). I'll let you know how it goes.

EDIT: fixed.

@tannerlinsley
Copy link
Contributor

@ahrex Awesome. If you need some help, let me know.

@chrisfromredfin
Copy link

I've not tested with responsive: true, but the previous PR is a win.

@ahrex
Copy link

ahrex commented Nov 14, 2014

@tannerlinsley, @chrisfromredfin,

I've cleaned up my pull request. The tip of ahrex/Chart.js now has the alternative origin wrapped up in a method, and I've replaced all areas that were calling the old origin with this method. It works for me, but I haven't tested all cases so feel free to comment on anything unusual you see.

@tannerlinsley
Copy link
Contributor

Everything so far seems to look amazing with @ahrex 's modifications. I'd love to see this merged in asap.

@tannerlinsley
Copy link
Contributor

@ahrex - I checked out the pending pull request here, and changed some of the bar values to negative values, but this resulted in the negative bar flowing outside of the scale and canvas. Can you confirm?

@m1ga
Copy link

m1ga commented Mar 19, 2015

👍 please include #994

@fulldecent
Copy link
Contributor

I am moving to axis milestone as it may be related

@fulldecent fulldecent modified the milestones: Rewrite axis/scale code, 1.1 Apr 16, 2015
@ahrex
Copy link

ahrex commented May 2, 2015

Moved my PR from #669 to #1094.

Working example at https://jsfiddle.net/ahrex/jy8nnaem/.

Thanks,
Alex

@ahrex
Copy link

ahrex commented May 2, 2015

@tannerlinsley: the negative values overflowing are due to the option being specific to a bar chart, I believe. You have to pass in a bar-specific object during creation in order to get it working.

@etimberg etimberg modified the milestones: v2.0, Rewrite axis/scale code May 12, 2015
@etimberg etimberg self-assigned this May 20, 2015
@derekperkins
Copy link
Contributor

@borgar Huzzah! The first alpha of Chart.js 2.0 has landed and should fix this issue. Check out the release and try it out! We've got a lot of momentum right now, so please help us test so we can launch 2.0 Gold by the end of the month.
https://github.com/nnnick/Chart.js/releases/tag/v2.0-alpha

I'm closing this issue for now, but if you have implementation questions or find bugs, please create a jsfiddle and post the link here and we'll reopen this issue and get it fixed.

Armarr added a commit to Armarr/usgwebapp that referenced this issue Dec 10, 2015
starting from this fork of Chart.js
chartjs/Chart.js#9
and further modified to add an alwaysShowZero option
kurkle referenced this issue in kurkle/Chart.js Apr 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests