【问题标题】:JqPlot: Set min/max on date axisJqPlot:在日期轴上设置最小值/最大值
【发布时间】:2013-01-05 04:53:19
【问题描述】:

需要一些关于在 DateAxisRenderer 轴上设置最大值的建议 - 我已经尝试过 pad,但没有运气。假设我希望 xaxis 最大值比我上次的日期大一天,我将如何设置?

       xaxis:{ max:'??', tickInterval: '86400000', renderer:$.jqplot.DateAxisRenderer, tickOptions:{ formatString:'%b %#d' }}

【问题讨论】:

标签: jquery jqplot


【解决方案1】:

您可以使用以下方法获得系列的最大 x 值:

var biggest_day = plot2.axes.xaxis._dataBounds.max.

将此值加 1 天由

完成

biggest_day += 86400000(以毫秒为单位的时间)。

然后您可以将这个新绑定应用到您的情节中

plot1.axes.xaxis.max = biggest_day

最后,不要忘记重新绘制:plot1.replot()

【讨论】:

  • 谢谢 Anthony - 这行得通。自从发布我的问题后,我改变了主意,并且以不同的方式解决了这个问题。还是一样的感谢。
【解决方案2】:

如果您需要从 yaxis 定义最小值和最大值,您可以这样做:[在此处输入链接描述][1]

HTML

<div id="chart" style="height:500px"></div>

脚本

$(document).ready(function(){ 

var line1=[['1', 0.0],['2', 8.3],['3', 10.1],['4', 10.0],['5', 8.3],['6', 8.3],['7', 20.8],['8', 23.8],['9', 27.1],['10', 23.8],['11', 22.3],['12', 24.4]];

var plot1 = $.jqplot('chart', [line1], {
title:'Default Date Axis',
axes:{
    xaxis:{
        renderer: $.jqplot.DateAxisRenderer,
        tickOptions:{formatString:'%b'},
    },
    yaxis:{
        //renderer:$.jqplot.DateAxisRenderer,
        tickOptions:{formatString: '%.1f %'},
        min:0,
        max:100,
        tickInterval:'10'
    }
}, 
 series:[{color:'#5FAB78'}], 
 highlighter: { 
     show: false, 
     sizeAdjust: 1 
 }, 
 cursor: { 
     show: false 
 },
 seriesDefaults: {  
      showMarker:true, 
      pointLabels: { show:true }  
 } 
 });
}); 

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-06-29
    • 1970-01-01
    • 2017-04-30
    • 1970-01-01
    • 1970-01-01
    • 2019-12-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多