Upcoming event calendar

I wanted a nice visual representation of upcoming multi-day events. I created this Dataview script to turn a simple list of events into a visual calendar representation:

The current day is highlighted (August 17th in this case), and if the event title is a link to a note the link will appear in the calendar (see the Holiday in Bali event).

Step 1:

Make a list of events in this format:

  • 2022-09-05 to 2022-09-16 | Conference in Houston
  • 2022-10-04 to 2022-10-11 | [[Holiday in Bali]] | (this one is a link to a page)
  • 2022-10-20 to 2022-10-23 | Weekend in Vermont
  • 2022-11-14 to 2022-11-20 | Obsidian conference

(Instead of a list, the script can also find your events based on frontmatter fields - details below.)

Step 2:

Download the Dataview script and save it wherever you store your script files:
https://gist.github.com/alangrainger/bd93671d5d6f249bc5c9fd96e4a30fa1

Step 3:

Add this Dataview snippet to the page, changing the location to your location from step 2:

```dataviewjs
dv.view('Scripts/Dataview/trip-calendar')
```

And that’s it, you’re done! The Dataview script will turn that list into a calendar for you.

Alternatively you can provide YAML start-date and end-date fields as a configuration option, and the script will find all notes with those fields, and use the dates for the calendar:

```dataviewjs
dv.view('Scripts/Dataview/trip-calendar', {
  yamlStartField: 'trip_start',
  yamlEndField: 'trip_end'
})
```

Your frontmatter would look like this using the field names above. You can add the date in any format that MomentJS will recognise, but safest to use ISO dates.

---
trip_start: 2022-10-01
trip_end: 2022-10-07
---
9 Likes

this is a nice script. I just wonder if it might be crowdy when many events overlapped with each other

I wrote it specifically for trips that I take, so in my case it’s not possible for 2 things to overlap.

If that’s your use-case you might need to make some modifications.

1 Like

okay, if you are in the context of making a trip plan, then the following plugin might be more suitable for you

1 Like

In light mode (minimal theme) the event text is hard to see because the color is dark on dark. I added a CSS style to make the text white.

line 94:

return `background:${ec[title]};border:${ec[title]};color:#fff;`

@AlanG Is it possible you could show how to format the calendar w/ Sunday as the start of the week? I’ve tried to tweak the code but cannot get the start of the week to line up and it’s beyond my skill-set. Thank you

what would be great is a version that used the api’s to get all tasks and build from that. use due as the end time and the start time as the start (or give the user an option to use start or scheduled). then we’d have a calendar from tasks and I am sure that that would be hugely popular given the number of folks that use the tasks plugin.

took a quick look at the code (not a coding expert) and seems it might not be a huge amount of change. just how you fetch items and get start/end. one last thing is in the dataview add something to pick a date range.

know it is easy for me to say it is no problem for you to add. just a wish/hope/dream