[D3] Create Labels from Numeric Data with Quantize Scales in D3 v4
2024-09-02 00:29:11
Sometimes data needs to be converted from a continuous range, like test scores, to a discrete set of output values, like letter grades. In this lesson we’ll see how to use d3.scaleQuantize()
to do exactly that.
function scaleQuantize(){
var quantizeScale = d3.scaleQuantize()
.domain([0, 100])
.range(["red", "white", "green"]); console.log(quantizeScale(22)); // red
console.log(quantizeScale(50)); // white
console.log(quantizeScale(88)); // green // Get the boundaries domain for "white" color
console.log(quantizeScale.invertExtent('white'));
}
最新文章
- c 语言的位运算符复习
- TFS2012 自动生成与部署
- kubernetes Ubuntu部署
- Angularjs,WebAPI 搭建一个简易权限管理系统 —— 系统业务与实现(三)
- 由fdopen和fopen想到的
- Ext.Net学习笔记24:在ASP.NET MVC中使用Ext.Net
- iOS 开发一年总结
- Java实现Linux下服务器程序的双守护进程
- log4jdbc
- Linux学习之chkconfig命令
- ASP.NET Core 1.0 部署 HTTPS
- Django 学习笔记(三)模板导入
- NOIP 2017 day -1 杂记
- #Java学习之路——第一部分总结
- Spring Data Jpa接口简介
- django.db.utils.OperationalError: (1045, ";Access denied for user 'root'@'localhost' (using password: ...
- 中间件 activeMQ Jms Java Demo
- div添加cursor:pointer;失效问题。
- 适配ipad Pro
- WordPress无插件实现SMTP给评论用户发送邮件提醒