# How do I get the X axis to center on 0?

« Back to message list

Posted by Lee on 1st January 2016
I have Y-axis with max = 1.00 and min= -20000.00. Both are set as in ymin and ymax.

First, the labels are weird: with top 1.00 and bottom -1.00, and center -20000.00. Below the center are numbers with double negative, such as --1999.0.

I have to set ymin and ymax so that other cases work. In my cases, all numbers are possible.

I would like to always center the chart at 0 (instead of -20000.00). How do I do that?
Posted by Richard on 3rd June 2014
You can use the ymin a ymax to get a quarter axis cxhart like this:

Otherwise the way that I've made quarter axis charts is a little more involved:

www.rgraph.net/demos/line-offset-x-axis.html

Richard
Posted by Lee on 20th June 2014
I followed your sample and it is not working. My chart is a bar chart and I still see double negative in the Y-axis. In addition, the bar is drawn from -20000.00 and below. Could you try with bar chart? Thank you very much.
Posted by Richard on 20th June 2014
Put your chart online so that I can see what you're doing.

Richard
Posted by Lee on 20th June 2014
Thsnks for quick response. Here is an example without re-drawing x-axis.

primeaim.com/public/charts.php?company=ALPC+-+0001565220+-+ALPHALA+CORP.&;concept=NetIncomeLoss&months=3&report_fiscal_year=&report_fiscal_period=&act=1011

In addition to issues mentioned above with redrawing x-axis, the "text-angle" (45 degree) can't work any more.

Any suggestions will be greatly appreciated.
Posted by Richard on 23rd June 2014
Scales are mirrored when the X axis is in the center - so you only need to set the ymax to 20000 (or whatever). In addition the text angle should be a number - not a string - so no quotes:

obj.set('text.angle', 45);

Richard
Posted by Lee on 23rd June 2014
Removing y-min seems to work. Thank you!