Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用 NVD3 显示线加条形图,但是将日期作为字符串传递到 X 轴时遇到了一些麻烦。
有没有办法做到这一点?
我在对象中传递字符串,如下所示:
"06-2013"
我只想在图表上显示月份年份,如果不需要格式化,我会知道的。
您没有义务使用类似d3.formator的东西d3.time.format。您可以在tickFormat函数的处理程序中返回您喜欢的任何值或类型。
d3.format
d3.time.format
tickFormat
如果您的数据中有要用作标签的字符串,只需返回它们而不进行格式化:
chart.xAxis.tickFormat(function(d) { return data[0].values[d][0]; // example, depends on data structure });