0
我有一个折线图,我们将一些数字与x轴上的datetime
值进行比较。因为在列类型上使用datetime
值会使其变为continuous axis
,所以列标签是自动生成的。GVIZ:连续轴的自定义标签(日期时间)
我们只获得时间分量作为列标签,而不是日期。我能做些什么来获取整个日期时间作为标签吗?
(注:我不想改变的数据类型为字符串,因为我不希望即使在数据点间距)
我有一个折线图,我们将一些数字与x轴上的datetime
值进行比较。因为在列类型上使用datetime
值会使其变为continuous axis
,所以列标签是自动生成的。GVIZ:连续轴的自定义标签(日期时间)
我们只获得时间分量作为列标签,而不是日期。我能做些什么来获取整个日期时间作为标签吗?
(注:我不想改变的数据类型为字符串,因为我不希望即使在数据点间距)
是。您需要查看使用ICU SimpleDateFormat子集的formatters。
下面是它们是如何工作的例子:
function drawVisualization() {
// Create and populate the data table.
var data = new google.visualization.DataTable();
data.addColumn('date', 'Date');
data.addRows([
[new Date(2012,1,5)],
[new Date(2012,2,10)],
[new Date(2012,3,15)],
[new Date(2012,4,20)]
]);
alert(data.getFormattedValue(3,0));
var formatter1 = new google.visualization.DateFormat({pattern: 'yyyy, MMM'});
formatter1.format(data,0);
alert(data.getFormattedValue(3,0));
}
调整到适合您的数据和需求,和急!你有它的工作。
感谢您的解决方案。我还发现,使用带有hAxis.format选项的ICU模式集也可以得到理想的结果。 –