简体   繁体   English

Canvas JS导致问题

[英]Canvas JS causing issues

I am creating a line graph in canvas js. 我在canvas js中创建折线图。 It has the following dataset 它具有以下数据集

    dataPoints: [//array
    {x: new Date(Date.UTC (2012, 00, 1, 1,0) ), y: 26 },
    {x: new Date( Date.UTC (2012, 00, 1,2,0) ), y: 38  },
    {x: new Date( Date.UTC(2012, 00, 1,3,0) ), y: 43 },
    {x: new Date( Date.UTC(2012, 00, 1,4,0) ), y: 29},
    {x: new Date( Date.UTC(2012, 00, 1,5,0) ), y: 41},
    {x: new Date( Date.UTC(2012, 00, 1,6,0) ), y: 54},
    {x: new Date( Date.UTC(2012, 00, 1,7,0) ), y: 66},
    {x: new Date( Date.UTC(2012, 00, 1,8,0) ), y: 60},
    {x: new Date( Date.UTC(2012, 00, 1,9,0) ), y: 53},
    {x: new Date( Date.UTC(2012, 00, 1,10,0) ), y: 60}
    ]
  }
  ]

I understand the 1,2,3 parameters in Date.UTC() but I don't understand the 4th and 5th parameters. 我了解Date.UTC()的1,2,3参数,但不了解第4和第5参数。 What are these? 这些是什么? I am using 我在用

http://canvasjs.com/docs/charts/basics-of-creating-html5-chart/date-time-axis/ Under the heading Converting in Local Time http://canvasjs.com/docs/charts/basics-of-creating-html5-chart/date-time-axis/在“ 本地时间转换 ”标题下

Date.UTC() can be under this form: Date.UTC()可以采用以下形式:

Date.UTC(year, month[, day[, hour[, minute[, second[, millisecond]]]]])  

so in your example: 因此在您的示例中:

{x: new Date(Date.UTC (2012, 00, 1, 1,0) ), y: 26

2012 is the year, 2012年
00 is the month, 00是月份
1 is the day, 1是一天,
1 is the hour, 1是小时
0 is the minute. 0是分钟。
Please notice that only year and month are needed while all other parameters are optional. 注意 ,仅需要年份和月份,而所有其他参数都是可选的。

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

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