Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

创建一个均匀的量化的线性比例尺 d3.d3.scaleQuantize #3

Open
ckinmind opened this issue Jul 15, 2017 · 0 comments
Open

Comments

@ckinmind
Copy link
Owner

ckinmind commented Jul 15, 2017

var quantizeScale = d3.scaleQuantize()
    .domain([0, 100])    // 数据范围, 会平均分成三部分对应range的三个值
    .range(['red', 'white', 'green']) // 映射范围

console.log(quantizeScale(22))     // red
console.log(quantizeScale(50))    // white
console.log(quantizeScale(88))   // green

console.log(quantizeScale.invertExtent('white'))
// [33.333333336, 66.666667] , 从颜色倒推回数值范围
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant