简体   繁体   中英

d3js: time scaling and winter months

I'm working on a scatter plot in d3js which isolates winter months. Is there a quick and easy way to format the x scale such that I do not have a gap in the graph from March to December? I'd prefer the x axis to range from December 21 to March 21:

1901 example http://lmnts.lmnarchitects.com/wp-content/uploads/2014/04/2014-04-01-09_31_30-127.0.0.1_8020_Climate3_seattle-winter-temps.html.jpg

You can extend your dates to have a year, even if you don't want it shown, assigning the months after July the previous year than the months of the first semester:

var data = [
   {date: '2012/12/01', RH: 50, ...},
   {date: '2012/12/02', RH: 55, ...},
   ...
   {date: '2013/03/31', RH: 89, ...}
];

And use d3.extent to set the extents of the date scale. The axis should show a continuous interval between December to March. Regards,

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM