我有一组季度数据。这是数组:
var dataGDP = [
{date: "Q1-2008", GDPreal: "2.8"},
{date: "Q2-2008", GDPreal: "0.6"},
{date: "Q3-2008", GDPreal: "-2.1"},
{date: "Q4-2008", GDPreal: "-4.3"},
{date: "Q1-2009", GDPreal: "-6.8"},
{date: "Q2-2009", GDPreal: "-6.3"},
{date: "Q3-2009", GDPreal: "-5"}
];
Run Code Online (Sandbox Code Playgroud)
我如何让这些日期像 2008 年第一季度、2008 年第二季度、2008 年第三季度一样显示在我的 X 轴上?我的 X 轴使用基于时间的刻度我不确定是否有办法解析这些日期,因为它们现在使用 d3.time.format。但是,如果我使用月份,例如 01/2008、04/2008...,我可以解析它们: parseDate = d3.time.format("%m/%Y").parse;
我应该将数组中的日期写为月份,然后编写一个函数将月份转换为季度吗?或者有没有办法将 Q1..ect 保留在数组中,因为它现在并解析日期?