Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jqPlot bar chart width

I currently have a bar chart in jquery. If the results show only 1 bar the issues is that the bar fills the space of the whole graph. How can I adjust the width of the bar so that it doesn't look like a log.

like image 243
Nate Pet Avatar asked Oct 19 '11 19:10

Nate Pet


2 Answers

try setting the barWidth in the BarRenderer:

http://www.jqplot.com/docs/files/plugins/jqplot-barRenderer-js.html

like image 103
MandoMando Avatar answered Oct 11 '22 15:10

MandoMando


If you still want your chart bars to size dynamically with number of bars / size of chart then use the barMargin and barPadding values to adjust the width of your bars.

seriesDefaults: {
  renderer: $.jqplot.BarRenderer,
  rendererOptions: { 
    barPadding: 4,
    barMargin: 5
},

The default values are 8 and 10 respectively so the above values will actually make your bar larger. Make the values larger than default to reduce the size of your bars.

barMargin is the width between bars. barPadding is the width between bars within a category if your bar chart is representing multiple series.

See http://www.jqplot.com/docs/files/plugins/jqplot-barRenderer-js.html for more info.

like image 24
Giles Roberts Avatar answered Oct 11 '22 13:10

Giles Roberts