Basic Concepts
Understand how DataGlass works so you can create any chart you need.
The Code Block
DataGlass reads special code blocks in your notes. Use either dg or data-glass:
```dg
type: bar
x: category
y: value
```The content is YAML - a simple format where each line is property: value.
The Four Essential Properties
Every chart needs these four things:
| Property | What it does | Example |
|---|---|---|
type | The kind of chart | bar, line, scatter, pie |
data | Where the data comes from | file: sales.csv |
x | What goes on the horizontal axis | month, date, category |
y | What goes on the vertical axis | revenue, count, value |
Minimal example:
```dg
type: bar
data:
file: data.csv
x: category
y: amount
```Common Optional Properties
| Property | What it does | Example |
|---|---|---|
title | Chart title | title: Monthly Revenue |
color | Group data by category | color: region |
width | Chart width in pixels | width: 800 |
height | Chart height in pixels | height: 400 |
Data Sources
DataGlass can read data from multiple places:
| Source | Syntax | Best for |
|---|---|---|
| Inline JSON | source: '[{...}]' | Quick demos, small datasets |
| CSV/JSON files | file: data/sales.csv | Your own data files |
| URLs | url: https://... | APIs, remote data |
| Vault queries | query: from:folder | Data from your notes |
| Markdown tables | file: "#Table Heading" | Tables in your notes |
Learn more: Data Sources
Chart Types
DataGlass supports 30+ chart types:
Basic: bar, line, area, scatter, pie, donut
Statistical: boxplot, violin, histogram
Hierarchical: treemap, sunburst, dendrogram
Network: sankey, chord, force-directed
Specialized: heatmap, candlestick, forecast
See all: Chart Gallery
Transformations
Filter, aggregate, and sort your data before charting:
```dg
type: bar
data:
file: orders.csv
transformations:
- type: filter
configuration:
where:
status: { eq: "completed" }
- type: aggregate
configuration:
groupBy: ["region"]
sum: ["amount"]
x: region
y: amount_sum
```Learn more: Transformations
YAML Tips
Indentation matters. Use 2 spaces (not tabs):
# Correct
data:
file: sales.csv
# Wrong - will cause errors
data:
file: sales.csvQuotes are optional for simple values:
title: Monthly Sales # works
title: "Monthly Sales" # also worksUse quotes when values contain special characters:
title: "Sales: Q1 2024" # colon needs quotesNext Steps
- Chart Gallery - See all chart types with examples
- Data Sources - Connect your data
- Transformations - Filter and aggregate
- Reference - Complete property list