X scale function in D3.js keeps returning undefined

霸气de小男生 提交于 2019-11-29 15:48:22

In D3, both domain and range have to be an array:

If domain is specified, sets the scale’s domain to the specified array of numbers.

And also:

If range is specified, sets the scale’s range to the specified array of values.

Thus, instead of:

var xScale = d3.scaleTime()
    .domain([minDate, maxDate])
    .range(0,w);

It should be:

var xScale = d3.scaleTime()
    .domain([minDate, maxDate])
    .range([0,w]);//an array here
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!