Mapping abstract values to visual representations is what data visualization is all about, and that’s exactly what D3 scales do. This is usually done using pretty straightforward algorithms, but nothing is straightforward when you’re working with Date objects in JavaScript. If you’re plotting temporal data, you need to use a time scale.

function scaleTime(){
var timeScale = d3.scaleTime()
.domain([new Date(2016,0,1), new Date()])
.range([0,100]); console.log(timeScale(new Date(2016,0,15)));
console.log(timeScale(new Date(2016,3,15)));
console.log(timeScale(new Date())); console.log(timeScale.invert(50));
}

[D3] Convert Dates to Numeric Values with Time 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 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’ ...

  3. [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 ...

  4. Restricting Input in HTML Textboxes to Numeric Values

    Ok, here’s a fairly basic one – how to force a textbox to accept only numeric input. Somebody asked ...

  5. d3.js学习笔记(五)——将数据结构化为D3.js可处理的

    目标 在这一章,你将会理解如何对数据进行结构化,来更好的使用D3.js. 我们将会回顾我们之前已经学习的,学习D3.js如何使用选集(selections),JavaScript对象基础,以及如何最优 ...

  6. Spring 4 官方文档学习(五)核心技术之SpEL

    题外话 官方文档用evaluate这个单词来描述从表达式中获得实际内容的过程.如果直译的话,应该是评估.估值之类的意思.个人以为翻译成解析更易懂,但parse已经是解析了,为了避免冲突,就只好保留了e ...

  7. Extjs 源码组成(4.0.7)

    (function(){})()形式的自执行,构建Ext对象(0~584) 1  设置全局对象EXt:global.Ext = {}, 2 实现了Ext对象面向对象编程的基础方法,如,apply,ex ...

  8. 学习笔记之Machine Learning Crash Course | Google Developers

    Machine Learning Crash Course  |  Google Developers https://developers.google.com/machine-learning/c ...

  9. 学习笔记(四): Representation:Feature Engineering/Qualities of Good Features/Cleaning Data/Feature Sets

    目录 Representation Feature Engineering Mapping Raw Data to Features Mapping numeric values Mapping ca ...

随机推荐

  1. 怎样使用 OneAPM 监控微软 Azure Cloud Service ?

    不知不觉微软 Azure 已经进入中国市场近两年的时间.那么 Azure 平台的性能到底怎样?资源载入的延迟.虚拟机的稳定性等问题是否切实满足客户期许.这些都是大家对微软 Azure 这个国外的云服务 ...

  2. Trafodion:Transactional SQL on HBase

    Trafodion: Transactional SQL on HBase HBase上实时分布式事务处理 介绍 HBase的SQL能力一直不足.Phoenix缺乏Join能力,eBay提出的kyli ...

  3. poj 1001 java大精度

    import java.io.* ; import java.math.* ; import java.util.* ; import java.text.* ; public class Main ...

  4. shell date 命令说明

    shell date 命令说明 使用方法:date [选项]... [+格式] 或:date [-u|--utc|--universal] [MMDDhhmm[[CC]YY][.ss]] 以给定的格式 ...

  5. 安卓View的缓冲机制

    View组件显示的内容能够通过cache机制保存为bitmap, 主要有下面方法: void  setDrawingCacheEnabled(boolean flag),  Bitmap  getDr ...

  6. Flume的Collector

    Collector的作用是将多个Agent的数据汇总后,加载到Storage中.它的source和sink与agent类似. 数据源(source),如: collectorSource[(port) ...

  7. 洛谷P1734 最大约数和

    题目描述 选取和不超过S的若干个不同的正整数,使得所有数的约数(不含它本身)之和最大. 输入输出格式 输入格式: 输入一个正整数S. 输出格式: 输出最大的约数之和. 输入输出样例 输入样例#1: 复 ...

  8. BZOJ2244: [SDOI2011]拦截导弹(CDQ分治,二维LIS,计数)

    Description 某国为了防御敌国的导弹袭击,发展出一种导弹拦截系统.但是这种导弹拦截系统有一个缺陷:虽然它的第一发炮弹能够到达任意的高度.并且能够拦截任意速度的导弹,但是以后每一发炮弹都不能高 ...

  9. 3/19 Django框架 url路由配置及模板渲染

    3/19 Django框架 url路由配置及模板渲染 1.路由分配 URL(Uniform Resoure Locato):统一资源定位符是对可以从互联网上得到的资源的位置和访问方法的一种简洁的表示, ...

  10. leetCode解题报告5道题(十)

    题目一:Valid Number Validate if a given string is numeric. Some examples: "0" => true &quo ...