Archie Sarre Wood commited on
Commit
0ea8cc6
0 Parent(s):

Initial commit

Browse files
.devcontainer/devcontainer.json ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ // This file is only used in Codespaces. If you are developing locally, you can remove the .devcontainer directory without consequences
3
+
4
+ "image": "mcr.microsoft.com/devcontainers/javascript-node:0-18-bullseye",
5
+
6
+ "hostRequirements": {
7
+ "cpus": 4,
8
+ "memory": "4gb",
9
+ "storage": "32gb"
10
+ },
11
+
12
+ // Use 'postCreateCommand' to run commands after the container is created.
13
+ "postCreateCommand": "mkdir .evidence/template && echo '{\"database\":\"duckdb\",\"credentials\":{\"filename\":\"needful_things.duckdb\",\"gitignoreDuckdb\":null}}' > .evidence/template/evidence.settings.json && rm .vscode/extensions.json && rmdir .vscode",
14
+ // Configure tool-specific properties
15
+ "customizations": {
16
+ "vscode": {
17
+ "extensions": [
18
+ // "GitHub.codespaces",
19
+ "evidence.evidence-vscode",
20
+ "svelte.svelte-vscode"
21
+ ]
22
+ },
23
+ "codespaces": {
24
+ "openFiles": [
25
+ "pages/index.md"
26
+ ]
27
+ }
28
+ }
29
+ // "forwardPorts": [3000]
30
+ }
31
+ // For format details, see https://aka.ms/devcontainer.json. For config options, see the
32
+ // README at: https://github.com/devcontainers/templates/tree/main/src/python
.evidence/customization/custom-formatting.json ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ {
2
+ "version": "1.0",
3
+ "customFormats": []
4
+ }
.gitattributes ADDED
@@ -0,0 +1 @@
 
 
1
+ *.duckdb filter=lfs diff=lfs merge=lfs -text
.gitignore ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ .evidence/template
2
+ .svelte-kit
3
+ build
4
+ node_modules
5
+ .DS_Store
6
+ static/data
7
+ *.options.yaml
8
+ .vscode/settings.json
.npmrc ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ loglevel=error
2
+ audit=false
3
+ fund=false
.vscode/extensions.json ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ {
2
+ "recommendations": [
3
+ "evidence.evidence-vscode"
4
+ ]
5
+ }
README.md ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Evidence Template Project
2
+
3
+ Welcome to Evidence. Use this project template to get started.
4
+
5
+ ## Get Started from VS Code
6
+
7
+ The easiest way to get started is using the [VS Code Extension](https://marketplace.visualstudio.com/items?itemName=evidence-dev.evidence), which copies this template.
8
+
9
+ 1. Install the extension from the VS Code Marketplace
10
+ 2. Open the Command Palette (Ctrl/Cmd + Shift + P) and enter `Evidence: New Evidence Project`
11
+ 3. Click `Start Evidence` in the bottom status bar
12
+
13
+ ## Get Started using the CLI
14
+
15
+ ```bash
16
+ npx degit evidence-dev/template my-project
17
+ cd my-project
18
+ npm install
19
+ npm run sources
20
+ npm run dev
21
+ ```
22
+
23
+ Check out the docs for [alternative install methods](https://docs.evidence.dev/getting-started/install-evidence) including Docker, Github Codespaces, and alongside dbt.
24
+
25
+
26
+ ## Codespaces
27
+
28
+ If you are using this template in Codespaces, click the `Start Evidence` button in the bottom status bar.
29
+
30
+ Alternatively, use the following commands to get started:
31
+
32
+ ```bash
33
+ npm install
34
+ npm run sources
35
+ npm run dev -- --host 0.0.0.0
36
+ ```
37
+
38
+ See [the CLI docs](https://docs.evidence.dev/cli/) for more command information.
39
+
40
+ **Note:** Codespaces is much faster on the Desktop app. After the Codespace has booted, select the hamburger menu → Open in VS Code Desktop.
41
+
42
+ ## Connection Issues
43
+
44
+ If you see `✗ orders_by_month Missing database credentials`, you need to add the connection to the demo database:
45
+
46
+ 1. Open the settings menu at [localhost:3000/settings](http://localhost:3000/settings)
47
+ 2. select `DuckDB`
48
+ 3. enter `needful_things`
49
+ 4. select `.duckdb` and save
50
+
51
+ ## Learning More
52
+
53
+ - [Docs](https://docs.evidence.dev/)
54
+ - [Github](https://github.com/evidence-dev/evidence)
55
+ - [Slack Community](https://slack.evidence.dev/)
56
+ - [Evidence Home Page](https://www.evidence.dev)
degit.json ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ [
2
+ {
3
+ "action": "remove",
4
+ "files": [".devcontainer"]
5
+ }
6
+ ]
evidence.plugins.yaml ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ components:
3
+ # This loads all of evidence's core charts and UI components
4
+ # You probably don't want to edit this dependency unless you know what you are doing
5
+ "@evidence-dev/core-components": {}
6
+
7
+ # Loading a plugin:
8
+ # your-component-plugin: {}
9
+ #
10
+ # Adding aliases:
11
+ # your-component-plugin:
12
+ # aliases:
13
+ # SomeLongComponent: Alias
14
+ #
15
+ # Adding overrides:
16
+ # your-component-plugin:
17
+ # aliases:
18
+ # SomeLongChartComponent: BarChart
19
+ # overrides:
20
+ # - BarChart
21
+ #
22
+ # Adding normal Svelte component library:
23
+ # your-svelte-component-library:
24
+ # provides:
25
+ # - SomeComponent
26
+ # - SomeOtherComponent
27
+ #
28
+ # For more info: https://docs.evidence.dev/plugins/using-plugins/
29
+ datasources:
30
+ # You can add additional datasources here by adding npm packages.
31
+ # Make to also add them to `package.json`.
32
+ "@evidence-dev/bigquery": { }
33
+ "@evidence-dev/csv": { }
34
+ "@evidence-dev/databricks": { }
35
+ "@evidence-dev/duckdb": { }
36
+ "@evidence-dev/mssql": { }
37
+ "@evidence-dev/mysql": { }
38
+ "@evidence-dev/postgres": { }
39
+ "@evidence-dev/snowflake": { }
40
+ "@evidence-dev/sqlite": { }
41
+ "@evidence-dev/trino": { }
package-lock.json ADDED
The diff for this file is too large to render. See raw diff
 
package.json ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "my-evidence-project",
3
+ "version": "0.0.1",
4
+ "scripts": {
5
+ "build": "evidence build",
6
+ "build:strict": "evidence build:strict",
7
+ "dev": "evidence dev --open /",
8
+ "test": "evidence build",
9
+ "sources": "evidence sources",
10
+ "preview": "evidence preview"
11
+ },
12
+ "engines": {
13
+ "npm": ">=7.0.0",
14
+ "node": ">=18.0.0"
15
+ },
16
+ "type": "module",
17
+ "dependencies": {
18
+ "@evidence-dev/bigquery": "^2.0.4",
19
+ "@evidence-dev/core-components": "^3.7.3",
20
+ "@evidence-dev/csv": "^1.0.7",
21
+ "@evidence-dev/databricks": "^1.0.3",
22
+ "@evidence-dev/duckdb": "^1.0.7",
23
+ "@evidence-dev/evidence": "^31.0.3",
24
+ "@evidence-dev/mssql": "^1.0.5",
25
+ "@evidence-dev/mysql": "^1.1.0",
26
+ "@evidence-dev/postgres": "^1.0.4",
27
+ "@evidence-dev/snowflake": "^1.0.3",
28
+ "@evidence-dev/sqlite": "^2.0.3",
29
+ "@evidence-dev/trino": "^1.0.4"
30
+ },
31
+ "overrides": {
32
+ "jsonwebtoken": "9.0.0",
33
+ "trim@<0.0.3": ">0.0.3",
34
+ "sqlite3": "5.1.5"
35
+ }
36
+ }
pages/index.md ADDED
@@ -0,0 +1,130 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: Welcome to Evidence
3
+ ---
4
+
5
+ _Build polished data products with SQL and Markdown_
6
+
7
+ This demo [connects](/settings) to a local DuckDB file `needful_things.duckdb`.
8
+
9
+ <LineChart
10
+ data={orders_by_month}
11
+ y=sales
12
+ yFmt=usd0k
13
+ title = "Sales by Month, USD"
14
+ />
15
+
16
+ ## Write in Markdown
17
+
18
+ Evidence renders markdown files into web pages. This page is:
19
+ `[project]/pages/index.md`.
20
+
21
+ ## Run SQL using Code Fences
22
+
23
+ ```sql orders_by_month
24
+ select
25
+ date_trunc('month', order_datetime) as order_month,
26
+ count(*) as number_of_orders,
27
+ sum(sales) as sales,
28
+ sum(sales)/count(*) as average_order_value
29
+ from needful_things.orders
30
+ where order_datetime >= '2020-01-01'
31
+ group by 1 order by 1 desc
32
+ ```
33
+
34
+ In your markdown file, you can include SQL queries in code fences. Evidence will run these queries through your database and return the results to the page.
35
+
36
+ <Alert status=info>
37
+ To see the queries on a page, click the 3-dot menu at the top right of the page and Show Queries. You can see both the SQL and the query results by interacting with the query above.
38
+ </Alert>
39
+
40
+ ## Visualize Data with Components
41
+
42
+ ### Value in Text
43
+
44
+ Last month customers placed **<Value data={orders_by_month} column=number_of_orders/>** orders. The AOV was **<Value data={orders_by_month} column=average_order_value fmt=usd2/>**.
45
+
46
+ ### Big Value
47
+ <BigValue data={orders_by_month} value=sales fmt=usd0/>
48
+ <BigValue data={orders_by_month} value=number_of_orders />
49
+
50
+
51
+ ### Bar Chart
52
+
53
+ <BarChart
54
+ data={orders_by_month}
55
+ x=order_month
56
+ y=number_of_orders
57
+ fillColor="#488f96"
58
+ >
59
+ <ReferenceArea xMin="2020-03-15" xMax="2021-05-15" label="COVID Impacted" color=red/>
60
+ </BarChart>
61
+
62
+ > **Try:** Change the chart to a `<LineChart>`.
63
+
64
+ ### Data Table
65
+
66
+ <DataTable data={orders_by_month} rows=6/>
67
+
68
+ > **More:** See [all components](https://docs.evidence.dev/components/all-components)
69
+
70
+ ## Add Interactive Features
71
+
72
+ The latest version of Evidence includes features that allow you to easily create interactive data visualizations.
73
+
74
+ ### Chart with Filter
75
+
76
+ ```sql categories
77
+ select
78
+ category
79
+ from needful_things.orders
80
+ group by category
81
+ ```
82
+
83
+ <Dropdown data={categories} name=category value=category>
84
+ <DropdownOption value="%" valueLabel="All Categories"/>
85
+ </Dropdown>
86
+
87
+ <Dropdown name=year>
88
+ <DropdownOption value=% valueLabel="All Years"/>
89
+ <DropdownOption value=2019/>
90
+ <DropdownOption value=2020/>
91
+ <DropdownOption value=2021/>
92
+ </Dropdown>
93
+
94
+ ```sql orders_by_category
95
+ select
96
+ date_trunc('month', order_datetime) as month,
97
+ sum(sales) as sales_usd,
98
+ category
99
+ from needful_things.orders
100
+ where category like '${inputs.category.value}'
101
+ and date_part('year', order_datetime) like '${inputs.year.value}'
102
+ group by all
103
+ order by sales_usd desc
104
+ ```
105
+
106
+ <BarChart
107
+ data={orders_by_category}
108
+ title="Sales by Month, {inputs.category.label}"
109
+ x=month
110
+ y=sales_usd
111
+ series=category
112
+ />
113
+
114
+ # Share with Evidence Cloud
115
+
116
+ Evidence Cloud is the easiest way to securely share your project.
117
+
118
+ - Get your project online
119
+ - Authenticate users
120
+ - Schedule data refreshes
121
+
122
+ <BigLink href='https://du3tapwtcbi.typeform.com/waitlist?utm_source=template&typeform-source=template'>Deploy to Evidence Cloud &rarr;</BigLink>
123
+
124
+ You can use Netlify, Vercel or another static hosting provider to [self-host Evidence](https://docs.evidence.dev/deployment/overview).
125
+
126
+ # Get Support
127
+
128
+ - Message us on [Slack](https://slack.evidence.dev/)
129
+ - Read the [Docs](https://docs.evidence.dev/)
130
+ - Open an issue on [Github](https://github.com/evidence-dev/evidence)
sources/needful_things/connection.yaml ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ # This file was automatically generated
2
+ name: needful_things
3
+ type: duckdb
4
+ options:
5
+ filename: needful_things.duckdb
sources/needful_things/needful_things.duckdb ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e7b039bbf18e5d003cf66f1397f76c8bde0384336039d25c3944cf84735b5c3d
3
+ size 1323008
sources/needful_things/orders.sql ADDED
@@ -0,0 +1 @@
 
 
1
+ select * from orders