有人知道如何使Jqplot中的“y轴”值从0开始吗?默认情况下,它从负值开始,例如:-500、0、500、1000等等...请帮忙解决。
有人知道如何使Jqplot中的“y轴”值从0开始吗?默认情况下,它从负值开始,例如:-500、0、500、1000等等...请帮忙解决。
将对象(最小值)在对象中的轴设置为0。
$(document).ready(function(){
// your code here... //
axes:{
yaxis: {min:0}
}
})
如rsapru建议的那样,推荐使用max:对象(最大值)来限制图表到您想要的范围。例如,如果您希望最小值为0,最大值为7500。
axes:{
yaxis: {min:0, max: 7500}
}
如果你想要指定刻度的间隔,你可以手动使用ticks对象指定刻度,或者让jqPlot自动计算刻度间距(在这种情况下,除了最小值和最大值对象,不需要其他任何对象),又或者使用numberTicks对象来指定特定数量的刻度。 axes:{
yaxis: {min:0, max: 1000, numberTicks: 11}
}
示例:对于间隔为100个单位的刻度,从0到1000,使用11个刻度(0、100、200、300、400、500、600、700、800、900、1000)手动指定:
axes:{
yaxis: {min:0, max: 1000, Ticks: [[0],[100],[200],[300],[400],[500],[600],[700],[800],[900],[1000]]}
}
var plot2 = $.jqplot ('chartdiv', getRequestStats(), {
// Give the plot a title.
title: 'Daily Request Status',
// You can specify options for all axes on the plot at once with
// the axesDefaults object. Here, we're using a canvas renderer
// to draw the axis label which allows rotated text.
axesDefaults: {
labelRenderer: $.jqplot.CanvasAxisLabelRenderer
},
// An axes object holds options for all axes.
// Allowable axes are xaxis, x2axis, yaxis, y2axis, y3axis, ...
// Up to 9 y axes are supported.
axes: {
// options for each axis are specified in seperate option objects.
xaxis: {
label: "Hour",
// Turn off "padding". This will allow data point to lie on the
// edges of the grid. Default padding is 1.2 and will keep all
// points inside the bounds of the grid.
pad: 0
},
yaxis: {
label: "Count",
pad: 0
}
}
});
pad:0会使Y轴从0开始。
}
谢谢 Adnan
yaxis: {
minimum:0
}
在你的y轴上。我试过了,它有效。
axes : { yaxis: {min:0, pad: 0}}
- Tim Cull