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

[D3] Create Labels from Non-numeric Data with Ordinal Scales in D3 v4的更多相关文章

  1. [D3] Create Labels from Numeric Data with Quantize Scales in D3 v4

    Sometimes data needs to be converted from a continuous range, like test scores, to a discrete set of ...

  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. pandas报错处理:TypeError: Empty 'DataFrame': no numeric data to plot

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

  4. d3.js 之关联数据:data操作符

    数据可视化 在可视化工作中,一个基本出发点是将不同的数值映射到不同的可视化 元素的属性上,使其表现出各自不同的视觉特征. 比如:以数组中的每一个值为直径分别创建一个圆,我们得到三个圆: 在d3中,可视 ...

  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. CREATE TABLE——数据定义语言 (Data Definition Language, DDL)

    Sql语句分为三大类: 数据定义语言,负责创建,修改,删除表,索引和视图等对象: 数据操作语言,负责数据库中数据的插入,查询,删除等操作: 数据控制语言,用来授予和撤销用户权限. 数据定义语言 (Da ...

  7. Create Oracle Enterprise Manager repository data after restore a database from another server

    1. Set password for SYS in password file: orapwd file=$ORACLE_HOME/dbs/orapw<ORACLE_SID> 2. Dr ...

  8. [D3] Create Chart Axes with D3 v4

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

  9. [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’ ...

随机推荐

  1. 编程精粹--编写高质量C语言代码(4):为子系统设防(一)

    通常,子系统都要对事实上现细节进行隐藏,在进行细节隐藏的同一时候.子系统为用户提供了一些关键入口点. 程序猿通过调用这些关键的入口点来实现与子系统的通信.因此假设在程序中使用这种子系统而且在其调用点加 ...

  2. DIV+CSS两种盒子模型(W3C盒子与IE盒子)

    在辨析两种盒子模型之前.先简单说明一下什么叫盒子模型. 原理: 先说说我们在网页设计中常听的属性名:内容(content).填充(padding).边框(border).边界(margin), CSS ...

  3. bind()和trigger()额外数据

    $(function(){ $('input').click(function(e,data1,data2,data3,data4){ alert(data1 + '|' + data2 + '|' ...

  4. 至顶网推荐-Rpm另类用法加固Linux安全

    http://www.zdnet.com.cn/ 650) this.width=650;" onclick='window.open("http://blog.51cto.com ...

  5. android audio

    package com.javacodegeeks.android.audiocapturetest; import java.io.IOException; import android.media ...

  6. 洛谷—— P1190 接水问题

    https://www.luogu.org/problem/show?pid=1190#sub 题目描述 学校里有一个水房,水房里一共装有 m 个龙头可供同学们打开水,每个龙头每秒钟的 供水量相等,均 ...

  7. Java String对象的经典问题

     先来看一个样例,代码例如以下:  public class Test {       public static void main(String[] args) {           Strin ...

  8. Logstash Json 过滤器插件

    1. Json Filter 功能概述 这是一个JSON解析过滤器.它接受一个包含JSON的现有字段,并将其扩展为Logstash事件中的实际数据结构. 默认情况下,它将把解析过的JSON放在Logs ...

  9. Qt Creator 源码学习 03:qtcreator.pro

    当我们准备好 Qt Creator 的源代码之后,首先进入到它的目录,来看一下它的源代码目录有什么奥秘. 这里一共有 9 个文件夹和 9 个文件.我们来一一看看它们都是干什么用的. .git: 版本控 ...

  10. 利用OBJECT_DEFINITION函数来代码存档

    作为一名数据库管理员,在进行代码迁移之前,总是尽力给提交于开发环境的代码一个完整的面貌.但是,不得不承认,我不能保证不发生任何可能破坏开发系统的事情.当这种情况发生时,可能的补救措施是恢复到目标代码的 ...