Skip to main content
Create new
Introduction
Reactivity
Props
Logic
Events
Bindings
Lifecycle
Stores
Motion
Transitions
Animations
Easing
SVG
Actions
Classes
Component composition
Context API
Special elements
Module context
Debugging
7GUIs
Miscellaneous
App.svelte
Calendar.svelte
Legend.svelte
data.json
<!--
Original plot: https://observablehq.com/@d3/calendar/2
Blog post version: https://tonydang.blog/d3-svelte-calendar/

Notes:
- Thank you to Sebastian Lammers (https://vis.social/@seblammers) for the Legend
implementation. The Legend previously relied on HTMLCanvasElement.getContext()
for creating the gradient which does not allow for SSR. The new Legend
implementation uses SVG rects for the gradient. This allows SSR, which in
turn allows for the chart to be pre-rendered for better performance.
-->

<script>
import data from "./data.json";
import Calendar from "./Calendar.svelte";
</script>

<div style="background: #fff; padding: 25px;">
<Calendar {data} />
</div>

loading Svelte compiler...
/* Select a component to see its compiled code */
result = svelte.compile(source, {
generate: ,
});
/* Select a component to see its compiled code */