JQplot barRenderer "y-axis" values start from negative values

soniaP picture soniaP · Jun 1, 2011 · Viewed 20.6k times · Source

Does anyone know how to make "y-axis" values start from 0 in Jqplot....by default it starts with negative values for eg: -500, 0, 500, 1000 and so on....Please help

Answer

Nerds of Technology picture Nerds of Technology · Jul 3, 2011

Set min: object (minimum) to 0 within axes: object

$(document).ready(function(){
 // your code here... //
 axes:{
  yaxis: {min:0}
 }
})

As rsapru suggested, a max: object (maximum) value is recommended to bound the graph to your preferred range. For example, if you wanted the minimum to be 0 and maximum to be 7500

 axes:{
  yaxis: {min:0, max: 7500}
 }

If you want to specify the graduations of the ticks you can do so manually by specifying ticks with the ticks: object or have jqPlot calculate tick spacing automatically (nothing other than min and max objects would be needed in that case) or by your specific number of ticks (using numberTicks: object)

Example: For tick 100 units apart, from 0 to 1000, using 11 ticks (0,100,200,300,400,500,600,700,800,900,1000) jqPlot automatic calculation:

 axes:{
  yaxis: {min:0, max: 1000, numberTicks: 11}
 }

Example: For tick 100 units apart, from 0 to 1000, using 11 ticks (0,100,200,300,400,500,600,700,800,900,1000) manual specification:

 axes:{
  yaxis: {min:0, max: 1000, Ticks: [[0],[100],[200],[300],[400],[500],[600],[700],[800],[900],[1000]]}
 }