d3.js关于比例尺报Cannot read property 'linear' of undefined错误的解决方法
2017-03-23 16:06
501 查看
今天在自学d3js,学到比例尺的使用时,发现报了个错,错误如下所示:
上网搜了好久都百思不得其解,最后还是在一个英文网站找到了原因,为:In D3 v4 it
is no longer named
翻译过来的意思就是:在d3js v4版本以后中的线性比例尺不再使用d3.scale.linear()。而是使用d3.scaleLinear()来代替它。
比如你原来是这样写的:
var dataset2 = [2.5,2.1,1.7,1.3,0.9];
var linear = d3.scale.linear().domain([0,d3.max(dataset2)]).range([0,250]);
现在改成这个样子就可以了。
var dataset2 = [2.5,2.1,1.7,1.3,0.9];
var linear = d3.scaleLinear().domain([0,d3.max(dataset2)]).range([0,250]);这个是极客学院上d3入门教程第六章的错误。不过后来下面的评论区已经有人发现并提出来了,我却后知后觉的去百度上找,哎 尴尬
上网搜了好久都百思不得其解,最后还是在一个英文网站找到了原因,为:In D3 v4 it
is no longer named
d3.scale.linear().Use
d3.scaleLinear()instead.
翻译过来的意思就是:在d3js v4版本以后中的线性比例尺不再使用d3.scale.linear()。而是使用d3.scaleLinear()来代替它。
比如你原来是这样写的:
var dataset2 = [2.5,2.1,1.7,1.3,0.9];
var linear = d3.scale.linear().domain([0,d3.max(dataset2)]).range([0,250]);
现在改成这个样子就可以了。
var dataset2 = [2.5,2.1,1.7,1.3,0.9];
var linear = d3.scaleLinear().domain([0,d3.max(dataset2)]).range([0,250]);这个是极客学院上d3入门教程第六章的错误。不过后来下面的评论区已经有人发现并提出来了,我却后知后觉的去百度上找,哎 尴尬
相关文章推荐
- [jQuery] Cannot read property ‘msie’ of undefined错误的解决方法
- [jQuery] Cannot read property ‘msie’ of undefined错误的解决方法
- 【jQuery】Cannot read property ‘msie’ of undefined错误的解决方法
- jquery升级到新版本报错[jQuery] Cannot read property ‘msie’ of undefined错误的解决方法
- [jQuery]Cannot read property ‘msie’ of undefined错误的解决方法
- [jQuery1.9]Cannot read property ‘msie’ of undefined错误的解决方法
- [jQuery] Cannot read property ‘msie’ of undefined错误的解决方法
- [jQuery1.9]Cannot read property ‘msie’ of undefined错误的解决方法
- [jQuery] Cannot read property ‘msie’ of undefined错误的解决方法
- [jQuery1.9]Cannot read property ‘msie’ of undefined错误的解决方法
- [jQuery] Cannot read property ‘msie’ of undefined错误的解决方法
- jQuery 出现Cannot read property ‘msie’ of undefined错误的解决方法
- [JQUERY] CANNOT READ PROPERTY ‘MSIE’ OF UNDEFINED错误的解决方法
- [jQuery] Cannot read property ‘msie’ of undefined错误的解决方法
- [jQuery] Cannot read property ‘msie’ of undefined错误的解决方法
- [jQuery1.9]Cannot read property ‘msie’ of undefined错误的解决方法
- [jQuery] Cannot read property ‘msie’ of undefined错误的解决方法
- jquery升级到新版本报错[jQuery] Cannot read property ‘msie’ of undefined错误的解决方法(转)
- echarts.min.js:25 Uncaught TypeError: Cannot read property 'features' of undefined 报错解决方法
- 浏览器cannot read property 'msie' of undefined的解决方法