JQPlot forces static minimum and maximum values ​​on the y axis

I use jqPlot to render histograms, and I want to do something fairly straightforward, but I'm not sure if the library has one for that.

I have such graphs where the maximum possible value on the y axis can be 42.

enter image description here

Say, if for one case my highest value for any of the bars is 14, then the graph will be displayed only up to 14.

enter image description here

However, I want, IN ALL CASES, I can see that the upper threshold 42 is displayed.

This is what I have now:

var plot3 = $.jqplot('chart3', [line1], { animate: true, animateReplot: true, seriesDefaults: {renderer: $.jqplot.BarRenderer}, series:[{ pointLabels:{ show: true, labels:[depression, anxiety, stress] }, rendererOptions: { animation: { speed: 3500 }, barWidth: 50, barPadding: -15, barMargin: 0, varyBarColor : true, highlightMouseOver: false } }], axes: { xaxis: { renderer:$.jqplot.CategoryAxisRenderer } }, canvasOverlay: { show: true, objects: [{ horizontalLine: { y: 42, lineWidth: 3, color: 'rgb(255,0,0)', shadow: true, xOffset: 0 } }] } }); plot3.replot( { resetAxes: true } ); 
+7
jquery user-interface graph jqplot
source share
1 answer

Add this to your axes:

  axes: { xaxis: { renderer: $.jqplot.CategoryAxisRenderer }, yaxis: { min:0, max:42 } }, 

you can add tickInterval to indicate tickInterval spacing on yaxis

Add these settings to your replot function when you try to reset the axis:

  plot3.replot({axes: { xaxis: { renderer: $.jqplot.CategoryAxisRenderer }, yaxis: { min:0, max:42 } }}); 

OR

you can say

 plot3.replot(false); 

therefore it will not reset your axes.

+21
source share

All Articles