This is a starter example for using Layer Cake. It sets you up with the line and area chart as seen in the examples. It also comes with all the other components from the guide so you can mix and match.
To create a new project based on this template using degit:
npx degit mhkeller/layercake-template my-chart
cd my-chart
Note that you will need to have Node.js installed.
Install the dependencies...
npm install
npm run build && npm start
Your app will be running at localhost:5000.
# if you didn't already install, run the install command
npm install
npm run dev
Your app will be running at localhost:5000.
This template also lets you pre-render your project, which will build out the elements that don't rely on any client-side JavaScript.
npm run build:ssr
npm start
Your app will be running at localhost:5000.
Sometimes you want to build out the HTML but your graphic still relies on some client-side JavaScript. In these cases, set hydrate: true
in the config.json
file. That will set the hydratable
compiler option and the hydrate
runtime option to true
. It will also add a script tag to load the build/bundle.js
JavaScript file.
This is a fairly basic setup that has just enough to get you going with LayerCake and SSR rendering. For a more complete Svelte setup, take a look at Russell Goldenberg's svelte-starter.