JQplot barRenderer"y轴"值从负值开始

son*_*iaP 7 javascript jquery jqplot

有没有人知道如何使"y轴"值从Jqplot中的0开始....默认情况下,它以负值开始,例如:-500,0,500,1000等等....请帮助

小智 19

在轴:object中将min:object(minimum)设置为0

$(document).ready(function(){
 // your code here... //
 axes:{
  yaxis: {min:0}
 }
})
Run Code Online (Sandbox Code Playgroud)

正如rsapru建议的那样,建议使用max:object(maximum)值将图形绑定到您的首选范围.例如,如果您希望最小值为0,则最大值为7500

 axes:{
  yaxis: {min:0, max: 7500}
 }
Run Code Online (Sandbox Code Playgroud)

如果要指定刻度的刻度,可以通过使用刻度:对象指定刻度来手动执行此操作,或者让jqPlot自动计算刻度间距(在这种情况下除了最小和最大对象之外)或者通过特定的数字of ticks(使用numberTicks:object)

示例:对于间隔100个单位,从0到1000,使用11个刻度(0,100,200,300,400,500,600,700,800,900,1000)jqPlot自动计算:

 axes:{
  yaxis: {min:0, max: 1000, numberTicks: 11}
 }
Run Code Online (Sandbox Code Playgroud)

示例:对于间隔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]]}
 }
Run Code Online (Sandbox Code Playgroud)


Pac*_*dUp 8

                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
                    }
                }
            });
Run Code Online (Sandbox Code Playgroud)

pad:0将使Y轴加注,从0开始.


rsa*_*pru 3

参考http://www.jqplot.com/docs/files/jqPlotOptions-txt.html

设置 y 轴:{最小值:0,最大值:500,numberTicks:5}