Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
306 views
in Technique[技术] by (71.8m points)

javascript - d3.scale.linear() vs d3.scaleLinear()

Hi I'm looking at the documentation for scales and it shows a format like this var x = d3.scaleLinear([10,130]).range([0,960]) I feel like this is strange because most examples that I see online use something like this:

var x = d3.scale.linear().domain([10,130]).range([0,960]) and it works.

If I use var x = d3.scaleLinear([10,130]).range([0,960]); I get an error like

TypeError: d3.scaleLinear is not a function

Why do you think there is a discrepancy between the examples in the documentation and what I see in examples online? maybe I don't understand how to read documentation.

EDIT : This is the current documentation for scales.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

To create a linear scale with d3.js version 3 use API d3.scale.linear()

and to create a linear scale with version 4 and 5 use API d3.scaleLinear()

API references for creating a linear scale for both the versions can be found here:

v3.x scale.linear

v4.x scaleLinear


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...