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

时间:2022-06-09 20:08:50

The xaxis being rendered does not start from the given hour in the data.

正在渲染的xax不会从数据中的给定小时开始。

PFB the JSFiddle for reference

PFF JSFiddle供参考

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. i am unable to make out the relation between tickInterval and starting point of ticks. Please help

我尝试将tickInterval更改为6小时,然后x轴从6:00开始渲染。我无法弄清楚tickInterval和刻度的起点之间的关系。请帮忙

1 个解决方案

#1


0  

You should remove the tickInterval and set min and max points definition for the xaxis:

您应该删除tickInterval并为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:

我用一个工作示例更新了你的小提琴:

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

If you want to keep the tickInterval, remove the max definition and use only min.

如果要保留tickInterval,请删除最大定义并仅使用min。

#1


0  

You should remove the tickInterval and set min and max points definition for the xaxis:

您应该删除tickInterval并为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:

我用一个工作示例更新了你的小提琴:

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

If you want to keep the tickInterval, remove the max definition and use only min.

如果要保留tickInterval,请删除最大定义并仅使用min。