Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/366.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/date/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何更改Google可视化时间线工具箱中的日期格式_Javascript_Date_Google Visualization - Fatal编程技术网

Javascript 如何更改Google可视化时间线工具箱中的日期格式

Javascript 如何更改Google可视化时间线工具箱中的日期格式,javascript,date,google-visualization,Javascript,Date,Google Visualization,我正在用谷歌虚拟化创建一个时间表。这很有效。我唯一的问题是工具箱中显示的日期,当你将鼠标悬停在一个条上时,它就会显示出来 日期格式固定为月-年。 在查看时,我找到了dateformat函数。这正是我需要的。我试图在代码中实现它,但似乎忽略了它 以下是我迄今为止的javascript: 如你所见,我尝试将开始和结束日期格式化为“中等”格式。但绘制图表时,我仍然只看到月-年格式 我如何才能做到这一点?时间线图表似乎没有使用日期的格式化值,也没有公开任何格式化选项。我建议做一个简单的修改来增加支持 v

我正在用谷歌虚拟化创建一个时间表。这很有效。我唯一的问题是工具箱中显示的日期,当你将鼠标悬停在一个条上时,它就会显示出来

日期格式固定为月-年。 在查看时,我找到了dateformat函数。这正是我需要的。我试图在代码中实现它,但似乎忽略了它

以下是我迄今为止的javascript:

如你所见,我尝试将开始和结束日期格式化为“中等”格式。但绘制图表时,我仍然只看到月-年格式


我如何才能做到这一点?

时间线图表似乎没有使用日期的格式化值,也没有公开任何格式化选项。我建议做一个简单的修改来增加支持

var container = document.getElementById('example1');
var chart = new google.visualization.Timeline(container);

var dataTable = new google.visualization.DataTable();
dataTable.addColumn({
    type: 'string',
    id: 'Title'
});
dataTable.addColumn({
    type: 'string',
    id: 'Status'
});
dataTable.addColumn({
    type: 'date',
    id: 'Start'
});
dataTable.addColumn({
    type: 'date',
    id: 'End'
});
dataTable.addRows([
    ["1", "Planning", new Date(2013, 5, 20), new Date(2013, 6, 21)],
    ["2", "Design", new Date(2013, 6, 25), new Date(2013, 7, 25)],
    ["3", "Development", new Date(2013, 7, 25), new Date(2013, 10, 11)],
    ["4", "Implementation", new Date(2013, 10, 15), new Date(2013, 11, 14)],
    ["5", "Testing", new Date(2013, 11, 18), new Date(2013, 12, 10)],
    ["6", "Delivering", new Date(2013, 12, 1), new Date(2013, 12, 21)]
]);

var formatter = new google.visualization.DateFormat({
    formatType: 'medium'
});

formatter.format(dataTable, 2);
formatter.format(dataTable, 3);

var options = {
    timeline: {
        showRowLabels: false,
        barLabelStyle: {
            fontSize: 10
        },
        groupByRowLabel: false,
        colorByRowLabel: false
    },
    avoidOverlappingGridLines: false,
    colors: ['#556270', '#4ECDC4', '#C7F464', '#FF6B6B', '#C44D58', '#A7A7A7']
};

chart.draw(dataTable, options);