jQPlot强制y轴上的静态最小值和最大值 [英] jQPlot force static minimum and maximum values on y-axis

查看:375
本文介绍了jQPlot强制y轴上的静态最小值和最大值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 jqPlot 呈现条形图,并且正在寻找相当直接的事情,但我不确定如果图书馆有这个选项。



我有这样的图表,其中y轴的最大可能值可以是42。 b
$ b



比方说,如果有一种情况,我的任何一个柱的最高值是14,那么这个图就会显示为只能显示14个。





这就是我现在的情况:

  var plot3 = $ .jqplot('chart3',[line1],{
animate:true,
animateReplot:true,
series默认值:{渲染器:$ .jqplot.BarRenderer},
系列:[{
pointLabels:{
show:true,
labels:[depression,anxiety,stress]
},
rendererOptions:{
动画:{
速度:3500
},
barWidth:50,
barPadding:-15,
barMargin: 0,
varyBarColor:true,
highlightMouseOver:false
}
}],
轴:{
xaxis:{
渲染器:$ .jqplot.CategoryAxisRenderer


canvasOverlay {
show:true,
objects:[{
horizo​​ntalLine:{
y: 42,
lineWidth:3,
color:'rgb(255 ,0,0)',
shadow:true,
xOffset:0
}
}]
}
});
plot3.replot(({resetAxes:true});


解决方案

添加到您的轴:

 轴:{
xaxis:{
渲染器:$。 jqplot.CategoryAxisRenderer
},
yaxis:{
min:0,
max:42
}
},
tickInterval
来指定 yaxis



请在尝试时将这些设置添加到 replot 函数中重置轴:

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

OR



你可以说 p>

  plot3.replot(false); 

所以它不会重置您的坐标轴。


I am using jqPlot to render bar charts and am looking to do something fairly straightforward but I am not sure if the library has an option for this.

I have graphs like this one, where the maximum possible value on the y-axis can be 42.

Let's say if for one case, my highest value for any of the bars is 14, then the graph will be rendered to show only up to 14.

However, I want it so that, IN ALL CASES, I can see that upper threshold of 42 rendered.

This is what I have for 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 } );

解决方案

Add this to your axes:

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

you can add tickInterval to specify the interval between the ticks on yaxis

Please add these setting to your replot function as you are trying to reset the axis:

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

OR

You can say

plot3.replot(false);

so it will not reset your axes.

这篇关于jQPlot强制y轴上的静态最小值和最大值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆