Skip to content

Commit 857466a

Browse files
committed
Add inline Chart.js support with 14 color palettes and CDL theming
1 parent 8b4de6f commit 857466a

18 files changed

Lines changed: 916 additions & 20 deletions

README.md

Lines changed: 92 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,17 @@ Compile Markdown files into beautiful CDL-themed [Marp](https://marp.app/) prese
2424
|:-----------------:|:------------:|:--------------:|
2525
| ![Two-Column](https://raw.githubusercontent.com/ContextLab/cdl-slides/main/docs/screenshots/09-two-column.png) | ![Table](https://raw.githubusercontent.com/ContextLab/cdl-slides/main/docs/screenshots/10-simple-table.png) | ![Formats](https://raw.githubusercontent.com/ContextLab/cdl-slides/main/docs/screenshots/11-output-formats.png) |
2626

27-
| Academic Poster |
28-
|:---------------:|
29-
| ![Poster](https://raw.githubusercontent.com/ContextLab/cdl-slides/main/docs/screenshots/poster-sample.png) |
27+
| Bar Chart | Line Chart | Grouped Bar |
28+
|:---------:|:----------:|:-----------:|
29+
| ![Bar](https://raw.githubusercontent.com/ContextLab/cdl-slides/main/docs/screenshots/chart-02-bar.png) | ![Line](https://raw.githubusercontent.com/ContextLab/cdl-slides/main/docs/screenshots/chart-03-line.png) | ![Grouped](https://raw.githubusercontent.com/ContextLab/cdl-slides/main/docs/screenshots/chart-04-grouped-bar.png) |
30+
31+
| Pie Chart | Doughnut Chart | Radar Chart |
32+
|:---------:|:--------------:|:-----------:|
33+
| ![Pie](https://raw.githubusercontent.com/ContextLab/cdl-slides/main/docs/screenshots/chart-05-pie.png) | ![Doughnut](https://raw.githubusercontent.com/ContextLab/cdl-slides/main/docs/screenshots/chart-06-doughnut.png) | ![Radar](https://raw.githubusercontent.com/ContextLab/cdl-slides/main/docs/screenshots/chart-08-radar.png) |
34+
35+
| Scatter Plot | Academic Poster |
36+
|:------------:|:---------------:|
37+
| ![Scatter](https://raw.githubusercontent.com/ContextLab/cdl-slides/main/docs/screenshots/chart-07-scatter.png) | ![Poster](https://raw.githubusercontent.com/ContextLab/cdl-slides/main/docs/screenshots/poster-sample.png) |
3038

3139
## Table of contents
3240

@@ -44,6 +52,7 @@ Compile Markdown files into beautiful CDL-themed [Marp](https://marp.app/) prese
4452
- [Scale directives](#scale-directives)
4553
- [Emoji figures](#emoji-figures)
4654
- [Math (KaTeX)](#math-katex)
55+
- [Inline charts](#inline-charts)
4756
- [Code blocks](#code-blocks)
4857
- [Tables](#tables)
4958
- [Arrow syntax](#arrow-syntax)
@@ -69,6 +78,8 @@ Compile Markdown files into beautiful CDL-themed [Marp](https://marp.app/) prese
6978
- **Syntax highlighting**: Code blocks with line numbers via Pygments
7079
- **Math support**: KaTeX for inline and display equations
7180
- **Callout boxes**: Note, tip, warning, definition, example, and important boxes
81+
- **Inline charts**: Embed Chart.js charts with ```` ```chart ```` blocks — bar, line, scatter, pie, doughnut, radar, and more
82+
- **Color palettes**: 14 built-in palettes including CDL, seaborn, matplotlib, and colorblind-friendly options
7283
- **Academic posters**: Compile poster markdown with ASCII grid layouts to HTML or PDF
7384

7485
## Installation
@@ -497,6 +508,84 @@ Display:
497508
$$\int_0^\infty e^{-x^2} dx = \frac{\sqrt{\pi}}{2}$$
498509
```
499510

511+
### Inline charts
512+
513+
Embed interactive Chart.js charts directly in your slides using ```` ```chart ```` blocks. Charts are automatically styled with CDL theme colors and fonts.
514+
515+
**Basic example:**
516+
517+
````markdown
518+
```chart
519+
type: bar
520+
labels: Q1, Q2, Q3, Q4
521+
data: 120, 95, 140, 110
522+
caption: Quarterly revenue
523+
```
524+
````
525+
526+
**Multi-dataset example:**
527+
528+
````markdown
529+
```chart
530+
type: line
531+
labels: Jan, Feb, Mar, Apr, May
532+
datasets:
533+
- label: Model A
534+
data: 82, 87, 91, 88, 93
535+
- label: Model B
536+
data: 75, 80, 85, 89, 92
537+
palette: colorblind
538+
caption: Model accuracy over time
539+
```
540+
````
541+
542+
**Supported chart types:**
543+
544+
| Type | Description |
545+
|------|-------------|
546+
| `bar` | Vertical bar chart |
547+
| `line` | Line chart with smooth curves |
548+
| `scatter` | Scatter plot |
549+
| `pie` | Pie chart |
550+
| `doughnut` | Doughnut chart |
551+
| `radar` | Radar/spider chart |
552+
553+
For grouped bars, use multiple datasets with `type: bar`.
554+
555+
**Chart options:**
556+
557+
| Field | Default | Description |
558+
|-------|---------|-------------|
559+
| `type` | `bar` | Chart type (see above) |
560+
| `labels` || Comma-separated axis labels |
561+
| `data` || Comma-separated values (single dataset) |
562+
| `datasets` || Multiple datasets (see multi-dataset example) |
563+
| `palette` | `cdl` | Color palette name |
564+
| `caption` || Caption text below the chart |
565+
| `width` | `85%` | Chart container width |
566+
| `height` | `350px` | Chart container height |
567+
568+
**Available palettes:**
569+
570+
| Palette | Description |
571+
|---------|-------------|
572+
| `cdl` | CDL/Dartmouth brand colors (default) |
573+
| `tab10` | Matplotlib Tab10 |
574+
| `seaborn` | Seaborn default |
575+
| `deep` | Seaborn deep |
576+
| `muted` | Seaborn muted |
577+
| `bright` | Seaborn bright |
578+
| `colorblind` | Colorblind-friendly (seaborn) |
579+
| `pastel` | Seaborn pastel |
580+
| `dark` | Seaborn dark |
581+
| `matplotlib` | Matplotlib default |
582+
| `Set1` | ColorBrewer Set1 |
583+
| `Set2` | ColorBrewer Set2 |
584+
| `Set3` | ColorBrewer Set3 |
585+
| `Paired` | ColorBrewer Paired |
586+
587+
Charts also work inside poster sections — just use the same ```` ```chart ```` syntax in your poster markdown.
588+
500589
### Code Blocks
501590

502591
Code blocks are automatically:
177 KB
Loading

docs/screenshots/chart-02-bar.png

133 KB
Loading

docs/screenshots/chart-03-line.png

163 KB
Loading
143 KB
Loading

docs/screenshots/chart-05-pie.png

142 KB
Loading
146 KB
Loading
165 KB
Loading
181 KB
Loading

examples/sample_charts.md

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
---
2+
marp: true
3+
theme: cdl-theme
4+
math: katex
5+
transition: fade 0.25s
6+
author: Contextual Dynamics Lab
7+
---
8+
9+
# Chart examples
10+
### Inline Chart.js charts with CDL theming
11+
12+
Contextual Dynamics Lab
13+
14+
---
15+
16+
# Language model parameters
17+
18+
```chart
19+
type: bar
20+
labels: GPT-2, LLaMA, Mistral, Claude, LLaMA-2
21+
data: 1.5, 70, 7, 52, 70
22+
caption: Parameter counts in billions
23+
```
24+
25+
---
26+
27+
# Training loss over epochs
28+
29+
```chart
30+
type: line
31+
labels: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
32+
datasets:
33+
- label: Baseline
34+
data: 2.8, 2.1, 1.7, 1.4, 1.2, 1.05, 0.95, 0.88, 0.83, 0.80
35+
- label: Optimized
36+
data: 2.5, 1.6, 1.1, 0.8, 0.65, 0.55, 0.48, 0.43, 0.40, 0.38
37+
caption: Cross-entropy loss by training epoch
38+
```
39+
40+
---
41+
42+
# Model performance comparison
43+
44+
```chart
45+
type: bar
46+
labels: GPT-4, Claude, Gemini, LLaMA-3
47+
datasets:
48+
- label: Accuracy
49+
data: 92, 90, 88, 82
50+
- label: F1 score
51+
data: 89, 88, 85, 79
52+
- label: Recall
53+
data: 87, 91, 83, 76
54+
caption: Benchmark scores across models (%)
55+
```
56+
57+
---
58+
59+
# Research funding distribution
60+
61+
```chart
62+
type: pie
63+
labels: Federal grants, Industry, Foundation, University
64+
data: 45, 25, 18, 12
65+
caption: Funding sources for fiscal year 2025
66+
```
67+
68+
---
69+
70+
# Faculty time allocation
71+
72+
```chart
73+
type: doughnut
74+
labels: Research, Teaching, Service, Administration
75+
data: 40, 25, 20, 15
76+
caption: Average faculty time distribution
77+
```
78+
79+
---
80+
81+
# Model size vs. accuracy
82+
83+
```chart
84+
type: scatter
85+
datasets:
86+
- label: Transformer models
87+
data: 1.5 78, 7 85, 13 87, 52 91, 70 90, 175 93
88+
- label: RNN baselines
89+
data: 0.5 62, 2 68, 5 72, 10 74, 20 76
90+
caption: Parameters (B) vs. benchmark accuracy (%)
91+
```
92+
93+
---
94+
95+
# Model capabilities
96+
97+
```chart
98+
type: radar
99+
labels: Reasoning, Coding, Math, Writing, Analysis, Creativity
100+
datasets:
101+
- label: GPT-4
102+
data: 95, 92, 90, 93, 91, 88
103+
- label: Claude
104+
data: 93, 90, 88, 95, 94, 90
105+
- label: Open source
106+
data: 78, 82, 75, 80, 76, 72
107+
caption: Capability scores across evaluation dimensions
108+
```

0 commit comments

Comments
 (0)