Open jwhitaker-swiftnav opened 1 year ago
Check out my solution...
https://github.com/nerevu/d3-time/tree/571601395045d81b70b9e7d9ceee1b67b95ea2bd
let utcIntervals = {
"hour": d3.utcHour,
"day": d3.utcDay,
"week": d3.utcWeek,
"month": d3.utcMonth,
}
let localIntervals = {
"hour": d3.timeHour,
"day": d3.timeDay,
"week": d3.timeWeek,
"month": d3.timeMonth,
}
function getTZIntervals(tz) {
return {
"hour": d3time.timezoneHour(tz),
"day": d3time.timezoneDay(tz),
"week": d3time.timezoneWeek(tz),
"month": d3time.timezoneMonth(tz),
}
}
var tz = "America/Chicago"
var bin = "hour"
if (tz.toLowerCase().endsWith("utc")) {
var interval = utcIntervals[bin];
} else if (tz) {
var interval = getTZIntervals(tz)[bin];
} else {
var interval = localIntervals[bin];
}
var binned = interval(new Date());
var converted = d3time.convertDate(binned, tz);
I used my forked time lib to create a timezone aware scale for Plot
Hey guys, Thanks for maintaining this.
Is there any chance of exporting
ticker()
fromsrc/ticks
? There are a few projects around that try to use this machinery to build a timezone-aware scale (e.g. https://github.com/yamass/d3-luxon/blob/main/src/scale/scaleZoned.js) . Withoutticker
being exported, these have to reimplement it from scratch. I'm aware that you probably don't want it part of your stable API, but even exporting it from the internal module insrc
would be appreciated so users can swim with sharks if they accept the risk.Thanks again! Jarrad