D3 Brush&缩放数据未显示

时间:2017-04-26 09:21:02

标签: javascript asp.net-mvc d3.js

我有这个图表,它没有显示值,只显示了形状。 我从后端加载我的json对象,只有2个字段。 任何帮助都会非常好。 月份和计数

[{"Count":50,"Month":"February 2014"},{"Count":66,"Month":"March 2014"},{"Count":69,"Month":"April 2014"},{"Count":57,"Month":"May 2014"},{"Count":85,"Month":"June 2014"},{"Count":81,"Month":"July 2014"},{"Count":117,"Month":"August 2014"},{"Count":154,"Month":"September 2014"},{"Count":144,"Month":"October 2014"},{"Count":162,"Month":"November 2014"},{"Count":191,"Month":"December 2014"},{"Count":211,"Month":"January 2015"},{"Count":134,"Month":"February 2015"},{"Count":207,"Month":"March 2015"},{"Count":157,"Month":"April 2015"},{"Count":155,"Month":"May 2015"},{"Count":167,"Month":"June 2015"},{"Count":143,"Month":"July 2015"},{"Count":183,"Month":"September 2015"},{"Count":137,"Month":"August 2015"},{"Count":179,"Month":"October 2015"},{"Count":161,"Month":"November 2015"},{"Count":174,"Month":"December 2015"},{"Count":180,"Month":"January 2016"},{"Count":170,"Month":"February 2016"},{"Count":166,"Month":"March 2016"},{"Count":175,"Month":"April 2016"},{"Count":173,"Month":"May 2016"},{"Count":158,"Month":"June 2016"},{"Count":129,"Month":"July 2016"},{"Count":153,"Month":"August 2016"},{"Count":114,"Month":"September 2016"},{"Count":112,"Month":"October 2016"},{"Count":143,"Month":"November 2016"},{"Count":126,"Month":"December 2016"},{"Count":98,"Month":"January 2017"},{"Count":138,"Month":"February 2017"},

我从

复制代码

the link here D3 website

并改变 这一行

d3.csv("sp500.csv", type, function(error, data) {

d3.json('@Url.Action("GetStatistic", "JuraServicing")', function (error, data) {



 data = jsondata;
x.domain(d3.extent(data, function (d) { return d.Month; }));
 y.domain([0, d3.max(data, function (d) { return d.Count; })]);

它还显示了我不理解的错误

  

d3.v4.min.js:2错误:属性d:预期数字," MNaN,NaNCNaN,NaN,......"。

这就是我得到的 This is what i get

1 个答案:

答案 0 :(得分:0)

我认为你还需要更新时间解析器。这一行:

var parseDate = d3.timeParse("%b %Y");

...在Jan 2001表单中解析日期,但您的日期格式为January 2001。您应该将其更改为大写B以获取完整月份名称:

var parseDate = d3.timeParse("%B %Y");

有关d3时间格式说明符的信息,请参阅此页面:https://github.com/d3/d3-time-format#locale_format