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'));
}

[D3] Create Labels from Numeric Data with Quantize Scales in D3 v4的更多相关文章

  1. [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 bef ...

  2. [D3] Convert Dates to Numeric Values with Time Scales in D3 v4

    Mapping abstract values to visual representations is what data visualization is all about, and that’ ...

  3. [问题解决] initAndListen: 10309 Unable to create/open lock file: /data/db/mongod.lock

    错误: 在linux下开启mongoDB的 $ >bin: ./mongod 时报错:initAndListen: 10309 Unable to create/open lock file: ...

  4. pandas报错处理:TypeError: Empty 'DataFrame': no numeric data to plot

    Tushare返回的是pandas的DataFrame格式,但是执行以下代码时报错:TypeError: Empty 'DataFrame': no numeric data to plot impo ...

  5. [D3] Create DOM Elements with D3 v4

    Change is good, but creating from scratch is even better. This lesson shows you how to create DOM el ...

  6. [D3] Create Chart Axes with D3 v4

    Most charts aren’t complete without axes to provide context and labeling for the graphical elements ...

  7. [D3] Convert Input Data to Output Values with Linear Scales in D3

    Mapping abstract values to visual representations is what data visualization is all about, and that’ ...

  8. pandas 读csv文件 TypeError: Empty 'DataFrame': no numeric data to plot

    简单的代码,利用pandas模块读csv数据文件,这里有两种方式,一种是被新版本pandas遗弃的Series.from_csv:另一种就是pandas.read_csv 先说一下问题这个问题就是在读 ...

  9. mongo [initandlisten] exception in initAndListen: 98 Unable to create/open lock file: /data/db/mongod.lock errno:13 Permission denied Is a mongod instance already running?, terminating 2019-09-23T16:

    解决方法: 加权 sudo chmod -Rf 777 /data/db

随机推荐

  1. 【原创】k8s源代码分析-----EndpointController

    转自本人空间 http://user.qzone.qq.com/29185807/blog/1459325937 一.controller manager创建endpointController 代码 ...

  2. 当Java代码遇上抽象、重载加重写,一切都不美好了

    当Java代码遇上抽象.重载加重写.一切都不美好了 前几天调程序遇上个奇怪的bug.一直没找到问题,今天最终发现问题所在了,不说了先上代码(下面代码是演示样例代码,经測试,Java不存在这问题,安卓存 ...

  3. Fedora 13 Alpha测试手记横空出世

    本文转载在:http://www.linux521.com/2009/system/201004/10719.html   本文是继<Fedora 11-Alpha试用手记>文章(http ...

  4. c#中文字符串与byte数组互相转化

    因为中文字符串一个字符占两个字节,所以不能用正常的方式与byte之间进行互相转化 中文字符串转成byte[] byte[] ping = Encoding.UTF8.GetBytes("你的 ...

  5. SPOJ 3899. Finding Fractions 连分数

    连分数乱搞,我反正是一眼没看出结果 某巨巨把这题讲解的比较详细 : http://blog.csdn.net/gogdizzy/article/details/8727386 令k = [a/b] 然 ...

  6. Node.js安装+环境配置【Windows版】

    Node.js安装及环境配置之Windows篇  一.安装环境 1.本机系统:Windows 10 Pro(64位)2.Node.js:v6.9.2LTS(64位) 二.安装Node.js步骤 1.下 ...

  7. vue项目使用axios

    使用: npm install axios --save-dev 在main.js中import: 使用: (1):POST方式 let data= [{receiveAdd:receiveAddVa ...

  8. Direct2D 图形计算

    D2D不仅可以绘制,还可以对多个几何图形对象进行空间运算.这功能应该在GIS界比较吃香. 这些计算包括: 合并几何对象,可以设置求交还是求并,CombineWithGeometry 边界,加宽边界,查 ...

  9. Boost 解析xml——插入Item

    XML格式为 <?xml version="1.0" encoding="utf-8"?> <Config> <Item name ...

  10. 洛谷 P2384 最短路

    洛谷 P2384 最短路 题目背景 狗哥做烂了最短路,突然机智的考了Bosh一道,没想到把Bosh考住了...你能帮Bosh解决吗? 他会给你10000000000000000000000000000 ...