简体   繁体   English

jqplot xaxis不是从给定的小时开始

[英]jqplot xaxis not starting from the given hour

The xaxis being rendered does not start from the given hour in the data. 渲染的xaxis并非从数据中的给定小时开始。

PFB the JSFiddle for reference PFB JSFiddle供参考

https://jsfiddle.net/sonal215/6Lg9f5dx/ https://jsfiddle.net/sonal215/6Lg9f5dx/

the code is as follows: 代码如下:

$(document).ready(function(){

var l1 = [['5/17/2016 10 AM', 78], ['5/17/2016 11 AM', 34], ['5/17/2016 12 PM', 67], ['5/17/2016 1 PM' , 18], ['5/17/2016 2 PM' , 33],['5/17/2016 3 PM', 7],['5/17/2016 4 PM', 13],['5/17/2016 5 PM' , 73],['5/17/2016 6 PM' , 93],['5/17/2016 7 PM' , 43],['5/17/2016 8 PM' , 53],['5/17/2016 9 PM' , 11],['5/17/2016 10 PM' , 83],['5/17/2016 11 PM' , 23]];


targetPlot = $.jqplot('targetAvailability', [l1], {
            seriesDefaults:{
                showMarker: false,
                fill: true,

            },
            tickInset: 0,
            axes: {
                xaxis:
                {
                    renderer:$.jqplot.DateAxisRenderer,
                    tickRenderer:$.jqplot.AxisTickRenderer,
                    tickOptions:
                    {
                        showGridline: false,
                        fontSize: '11px',
                        fontFamily: 'CiscoSansTTLight' ,

                    },
                    tickInterval: '8 hour',
                    min: '5/17/2016 11 AM',

                },
                yaxis: {
                    tickOptions:
                    {
                        fontSize: '11px',
                        fontFamily: 'CiscoSansTTLight' ,
                    },
                    min: 0,
                    max: 100,
                    tickInterval: 25
                }
            },


            cursor: {
                show: true,
                zoom: true,
                showTooltip: false
            }
        });   //end of targetPlot


}); //end of document ready

I tried changing the tickInterval to 6 hour, the x-axis then starts rendering from 6:00. 我尝试将tickInterval更改为6小时,然后x轴从6:00开始渲染。 i am unable to make out the relation between tickInterval and starting point of ticks. 我无法确定tickInterval和刻度线起点之间的关系。 Please help 请帮忙

You should remove the tickInterval and set min and max points definition for the xaxis : 您应该删除tickInterval并设置minmax点定义的xaxis

xaxis:
{
    min:'5/17/2016 10 AM',
    max:'5/17/2016 11 PM',
    ...rest of the code

I've updated your Fiddle with a working example: 我用一个有效的例子更新了您的Fiddle:

https://jsfiddle.net/6Lg9f5dx/4/ https://jsfiddle.net/6Lg9f5dx/4/

If you want to keep the tickInterval , remove the max definition and use only min . 如果要保留tickInterval ,请删除max定义并仅使用min

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM