更改Google图表中的日期格式

时间:2022-07-21 22:51:49

I've got a problem with changing the date tooltip when hovering over a point in my Google chart. You can find it here: http://jsfiddle.net/5smu5ng7/15/

当我将鼠标悬停在Google图表中的某个点上时,我遇到了更改日期工具提示的问题。你可以在这里找到它:http://jsfiddle.net/5smu5ng7/15/

As you can see, the tooltips read "Feb 1, 2017". I want them to just read "February 2017", but I can't seem to get it right.

如您所见,工具提示显示为“2017年2月1日”。我希望他们只读“2017年2月”,但我似乎无法做到正确。

According to the Google Charts website the following segment, which i have included, should do the trick, but it doesn't:

根据Google Charts网站的说法,我所包含的以下细分应该可以解决问题,但它不会:

      hAxis: {
         format: 'MMMM/yyyy'
      }

How do I get it to work?

我如何让它工作?

1 个解决方案

#1


0  

tooltips use the formatted values from the data table

工具提示使用数据表中的格式化值

use a date formatter to set the date format on the data table column

使用日期格式化程序在数据表列上设置日期格式

to format the first column...

格式化第一列......

var formatDate = new google.visualization.DateFormat({pattern: 'MMMM/yyyy'});
formatDate.format(dataTable, 0);

#1


0  

tooltips use the formatted values from the data table

工具提示使用数据表中的格式化值

use a date formatter to set the date format on the data table column

使用日期格式化程序在数据表列上设置日期格式

to format the first column...

格式化第一列......

var formatDate = new google.visualization.DateFormat({pattern: 'MMMM/yyyy'});
formatDate.format(dataTable, 0);