In the âas expectedâ notebook, you are using the latest version of Plot (0.5.0). In the ânot as expectedâ notebook, you are using an older version 0.1.0 of Plot. If you delete the Plot cell in the latter notebook, the chart will again function as expected. I would also recommend deleting the d3 cell, as that is too using an old version of D3, and both D3 and Plot are included by default as one of Observableâs recommended libraries.
Using bisection, I determined that it was Plot version 0.4.0 that changed the behavior of the default color scale here. And that is because your drawCalendar function is using channels that define literal colors; 0.4.0 introduced the feature that color scales would default to identity scales when all channel values are literal colors, but prior to that, these values were interpreted as any other categorical value and youâd get a categorical color scale with the default tableau10 scheme instead.
I checked this answer to be the solution as it completely answers question 1.
Question 2 might be of interest for/ known to the observable team as well as for the users but I was not sure if I should have split this question off as a separate one.
Ah, thanks. The problem in Safari is that you are passing a nonstandard date format to the Date constructor. You must use the ISO 8601 date format if you want to pass a string to the Date constructor. Like so:
drawCalendar(new Date("2022-03-08"), new Date("2022-04-13"))
The other problem I see is that you are using local time for your date operations. This is not a good idea as the behavior will vary depending on the viewerâs time zone, and also local time zones have things like daylight saving time changes that can make date computation more complicated. (The Date constructor if you pass an ISO 8601 string as above will also return dates at UTC midnight, not midnight local time. Plot also defaults to UTC for temporal data.)
Hereâs a suggestion that fixes those problems (in the smaller notebook):
Thanks so much! Thatâs great!
I actually went down that path and tried to call UTC function everywhere, at first glance your solution look like what I had. Except I missed one or two calls where I had local dates instead - as a result the calendar was not showing up correctl.
Then I chose to call the local date function and seemingly getting the visual I envisioned I thought that worked for me. So itâs super helpful you pointed that out and provided the solution