Luis Luis - 2 months ago 18
jQuery Question

BarChart does not fit on chart area

By using the code below, the X axis maximum value is only

85000
and that hides the partly the
120k
value, Is there any option to fix this axis rendering behavior?

var s1 = ["84486", "74987", "120249"];
var ticks = ['Length', 'Width', 'Height'];

$.jqplot('revi_chart', [s1], {
seriesDefaults: {
renderer: $.jqplot.BarRenderer,
pointLabels: { show: true, location: 'w'},
rendererOptions: { barDirection: 'horizontal'},
},
axes: {
xaxis: { tickOptions: { showLabel: true, showGridline: false}},
yaxis: { renderer: $.jqplot.CategoryAxisRenderer, ticks: ticks,
tickOptions: { showGridline: false }}
},
highlighter: { show: false}
});


Here is the Fiddle:
http://jsfiddle.net/frelis/x7Lyj5t6/12/

Answer

Make s1 an array of numbers. It expects numbers on the X axis. Change the code from:

var s1 = ["84486", "74987", "120249"];

to

var s1 = [84486, 74987, 120249];

see the working version at: http://jsfiddle.net/x7Lyj5t6/13/

This way X axis will always be automatically setting the maximum value.