X轴上的jQPlot日期勾选间隔不工作

时间:2014-11-07 12:29:54

标签: javascript php date jqplot

请参阅附图。来自php的日期字符串格式为Y-m-d,绘制在x轴上。但正如你所看到的那样,日期越多,它就越被撤销。我想使用jqplot的tickInterval属性,但它还没有工作!

它完全忽略了这个区间,只是每一天都有。所以如果我有1000天就变得完全不可读了。

enter image description here

var plot1 = $.jqplot("analyse-bottom-left",[yValues],{
            highlighter: { show: true, tooltipAxes: 'both' },
            seriesDefaults:{
                //renderer:$.jqplot.BarRenderer,
                rendererOptions: {fillToZero: true},


            },
            axesDefaults:{
                tickRenderer: $.jqplot.CanvasAxisTickRenderer,

            },
            legend: {
                show: true,
                placement: 'outsideGrid'
            },
            //series:seriesNames,
            axes:{
                xaxis:{
                    renderer: $.jqplot.CategoryAxisRenderer,
                    rendererOptions: { tickRenderer: $.jqplot.dateAxisRenderer },
                    ticks:xValues,
                    tickOptions:{
                        angle:30,
                        formatString:'Y-m-d'
                    },
                    tickInterval:'2 days'

                },
                yaxis:{

                    tickOptions: {formatString: '£%d'}
                }

            }    
        });

1 个答案:

答案 0 :(得分:1)

您的xaxis选项无效。您已将其设置为CategoryAxisRenderer,然后尝试将标记设置为DateAxisRenderer。这不会起作用,因为轴本身需要使用DateAxisRenderer

试试这个:

xaxis:{
    renderer: $.jqplot.DateAxisRenderer,
    ticks: xValues,
    tickOptions:{
        angle: 30,
        formatString: '%Y-%m-%d'
    },
    tickInterval: '2 days',
    min: xValues[0]
}

我创建了一个jsfiddle来演示其用法。 jqPlot有许多怪癖 - 在这种情况下,为了使tickInterval工作,你必须指定' min'值。