[D3] Create Labels from Non-numeric Data with Ordinal Scales in D3 v4

发布时间:2017-2-25 3:26:33 编辑:www.fx114.net 分享查询网我要评论
本篇文章主要介绍了"[D3] Create Labels from Non-numeric Data with Ordinal Scales in D3 v4 ",主要涉及到[D3] Create Labels from Non-numeric Data with Ordinal Scales in D3 v4 方面的内容,对于[D3] Create Labels from Non-numeric Data with Ordinal Scales in D3 v4 感兴趣的同学可以参考一下。

[D3] Create Labels from Non-numeric Data with Ordinal Scales in D3 v4

When your data contains discrete, non-numeric property values that you need to format or convert before displaying, d3.scaleOrdinal() is the API you need. Maybe you need to convert a “pass”/”fail” field to “green”/”red” for coloring your bubble chart? This lesson shows you exactly what to do.

function scaleOrdinal(){
    var ordinalScale = d3.scaleOrdinal()
        .domain(['poor', 'good', 'great'])
        .range(['red', 'white', 'green']);

    console.log(ordinalScale('good'));
    console.log(ordinalScale('great'));
    console.log(ordinalScale('poor'));
}

上一篇:PHP的线性安全和非线性安全的区别
下一篇:Java虚拟机JVM内存分区及代码执行机制

相关文章

相关评论

本站评论功能暂时取消,后续此功能例行通知。

一、不得利用本站危害国家安全、泄露国家秘密,不得侵犯国家社会集体的和公民的合法权益,不得利用本站制作、复制和传播不法有害信息!

二、互相尊重,对自己的言论和行为负责。