[D3] D3 Time Scales

d3.time.scale()

d3.time.scale().domain([date_left, date_right]).range([number_left, number_right]);
var timeScale1 = d3.time.scale().domain([new Date(2020, 0, 1), new Date(2020, 0, 11)]).range([0, 10]);

timeScale1(new Date(2020, 0, 1));
輸出:0

timeScale1(new Date(2020, 0, 11));
輸出:10

[timeScale1(new Date(2020, 0, 3)),
 timeScale1(new Date(2020, 0, 5)),
 timeScale1(new Date(2020, 0, 7))];
輸出:[1.9999999998, 3.99999999, 6]

您可在此處留言

avatar

這個網站採用 Akismet 服務減少垃圾留言。進一步瞭解 Akismet 如何處理網站訪客的留言資料

  Subscribe  
Notify of