From 335a6eb8941b90ede75475d114a9180448997513 Mon Sep 17 00:00:00 2001 From: Andrew Michael McNutt Date: Thu, 18 Jan 2024 19:01:57 -0800 Subject: [PATCH] some example ui improvement --- public/examples/line-chart.json | 26 ++++++++++++ src/content-modules/Examples.svelte | 62 +++++++++++++++++++---------- src/stores/example-store.ts | 5 +++ 3 files changed, 73 insertions(+), 20 deletions(-) create mode 100644 public/examples/line-chart.json diff --git a/public/examples/line-chart.json b/public/examples/line-chart.json new file mode 100644 index 00000000..ec7e7174 --- /dev/null +++ b/public/examples/line-chart.json @@ -0,0 +1,26 @@ +{ + "$schema": "https://vega.github.io/schema/vega-lite/v5.json", + "description": "Stock prices of 5 Tech Companies over Time.", + "data": { + "url": "data/stocks.csv" + }, + "mark": { + "type": "line", + "point": true + }, + "encoding": { + "x": { + "timeUnit": "year", + "field": "date" + }, + "y": { + "aggregate": "mean", + "field": "price", + "type": "quantitative" + }, + "color": { + "field": "symbol", + "type": "nominal" + } + } +} \ No newline at end of file diff --git a/src/content-modules/Examples.svelte b/src/content-modules/Examples.svelte index 7369d9e3..bf0ca75e 100644 --- a/src/content-modules/Examples.svelte +++ b/src/content-modules/Examples.svelte @@ -111,7 +111,7 @@ modalState = "input-svg"; }} > - Add Example + Use Example + {#if idx} + + {/if} - - - {/each} + {/each} + +
+ {@html value} +
{/if} diff --git a/src/stores/example-store.ts b/src/stores/example-store.ts index 5759bd5b..f00ccd25 100644 --- a/src/stores/example-store.ts +++ b/src/stores/example-store.ts @@ -52,6 +52,11 @@ export const DEMOS = [ title: "Stacked Area Chart", filename: "./examples/stacked-area-chart.json", }, + { + type: "vega", + title: "Line Chart", + filename: "./examples/line-chart.json", + }, ]; export function modifySVGForExampleStore(