谷歌图表的日期问题

时间:2013-12-12 06:17:19

标签: javascript google-visualization

我在json响应中获取了一个utc日期字符串,我正在转换为区域设置日期对象但是当我将此日期传递给谷歌图表作为日期时我得到 “轴#0的数据列不能是字符串类型”错误

这是我的js代码

var localDate = new Date();
                var localTimeZoneOffset = localDate.getTimezoneOffset();
                var longDateValue = Date.parse(element.dateAndTime);
                var date = new Date(longDateValue);
                alert(date);
                //var dateTime = calculateLocaleDate(element.dateAndTime);
                var jobId = element.jobId;
                var userId = element.userId;
                var status = element.status;
                var jobType = element.jobType;
                data.addRow([date, jobId, userId, status, jobType]);

这是我的表格声明

var data = new google.visualization.DataTable();
        data.addColumn('date', 'Date & Time');
        data.addColumn('string', 'Job Id');
        data.addColumn('string', 'User Id');
        data.addColumn('string', 'Status');
        data.addColumn('string', 'JobType');
        var cssClassNames = {
            'headerCell': 'table-th-td'
        };

实际上我想在日期数据上创建这样的adate范围过滤器

var control = new google.visualization.ControlWrapper({
            'controlType': 'ChartRangeFilter',
        'containerId': 'control1',
        'options': {
               // Filter by the date axis.
            //'filterColumnIndex': 0,
            'filterColumnLabel': 'Date & Time',
            'ui': {
             'chartType': 'LineChart',
             'chartOptions': {
             'chartArea': {'width': '90%'},
             'hAxis': {'baselineColor': 'none'}
                  },
            // Display a single series that shows the closing value of the stock.
            // Thus, this view has two columns: the date (axis) and the stock value (line series).
            'chartView': {
            'columns': [0, 3]
                },
            // 1 day in milliseconds = 24 * 60 * 60 * 1000 = 86,400,000
           'minRangeSize': 86400000
            }
            },
        // Initial range: 2012-02-09 to 2012-03-20.
        'state': {'range': {'start': new Date(2013, 11, 15), 'end': new Date(2013, 11, 20)}}
        }); 

我不确定问题出在哪里,是在表声明,过滤器decalaration还是在行创建中

0 个答案:

没有答案