[D3] Convert Dates to Numeric Values with Time Scales in D3 v4
2024-08-27 21:08:27
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));
}
最新文章
- android Json Gson FastJson 解析
- javascript 之 prototype继承机制
- sql-exists和not exists
- Can't find keyplane that supports type 4 for keyboard iPhone-Portrait-NumberPad; using 3876877096_Portrait_iPhone-Simple-Pad_Default
- tomcat如何按站点调试本机程序
- thinkphp 3+ 观后详解 (2)
- Oracle 11g AMM与ASMM切换
- Codeforces Round #333 (Div. 2) A. Two Bases 水题
- Constructor JavaScript构造器模式。
- Linux Mysql 总结
- Windows Azure Camp---漫步云端,创意无限
- android五种布局模式
- 内功心法 -- java.util.ArrayList<;E>; (1)
- 微软Visual Studio二十周年:VS2017于3月7日发布
- 《MySQL必知必会》读书笔记_2
- Redishelp
- Byte数组和字符串相互转换的问题
- HP-Socket v5.0.1:支持 IPv6 及多 SSL 证书
- python css盒子型 浮动
- [AIR] AIR程序调用本地默认应用程序打开本地文件