eleventy-plugin-uncharted 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,203 @@
1
+ # Uncharted
2
+
3
+ A CSS-based charting plugin for Eleventy. Renders charts as pure HTML/CSS with no JavaScript dependencies.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install uncharted
9
+ ```
10
+
11
+ ## Setup
12
+
13
+ ```javascript
14
+ // eleventy.config.js
15
+ import uncharted from 'uncharted';
16
+
17
+ export default function(eleventyConfig) {
18
+ eleventyConfig.addPlugin(uncharted);
19
+ }
20
+ ```
21
+
22
+ That's it! The plugin automatically copies the CSS to your output directory and injects the stylesheet link into pages that contain charts.
23
+
24
+ ### Options
25
+
26
+ ```javascript
27
+ eleventyConfig.addPlugin(uncharted, {
28
+ dataDir: '_data', // where to find CSV files (default: '_data')
29
+ animate: true, // enable animations globally (default: false)
30
+ cssPath: '/css/uncharted.css', // output path for stylesheet (default: '/css/uncharted.css')
31
+ injectCss: false // disable automatic CSS handling (default: true)
32
+ });
33
+ ```
34
+
35
+ If you set `injectCss: false`, you'll need to manually include the stylesheet in your layout:
36
+
37
+ ```html
38
+ <link rel="stylesheet" href="/css/uncharted.css">
39
+ ```
40
+
41
+ ## Chart Types
42
+
43
+ | Type | Description |
44
+ |------|-------------|
45
+ | `donut` | Pie/donut chart using conic-gradient |
46
+ | `stacked-bar` | Horizontal bars with stacked segments |
47
+ | `stacked-column` | Vertical columns with stacked segments |
48
+ | `dot` | Categorical dot chart with Y-axis positioning |
49
+ | `scatter` | XY scatter plot with continuous axes |
50
+
51
+ ## Usage
52
+
53
+ ### Page Frontmatter
54
+
55
+ Define charts in your page's frontmatter and reference them with the `chart` shortcode:
56
+
57
+ ```markdown
58
+ ---
59
+ charts:
60
+ growth:
61
+ type: stacked-bar
62
+ title: Platform Growth
63
+ subtitle: Models by domain
64
+ max: 25
65
+ file: charts/platform-growth.csv
66
+ ---
67
+
68
+ {% chart "growth" %}
69
+ ```
70
+
71
+ ### Global Data Files
72
+
73
+ Define charts in `_data/charts.json` or `_data/charts.yaml`:
74
+
75
+ ```json
76
+ {
77
+ "releases": {
78
+ "type": "stacked-column",
79
+ "title": "Release Cadence",
80
+ "file": "charts/releases.csv",
81
+ "legend": ["Production", "Hotfix", "Beta"]
82
+ }
83
+ }
84
+ ```
85
+
86
+ ```markdown
87
+ {% chart "releases" %}
88
+ ```
89
+
90
+ ### Inline Data
91
+
92
+ Embed data directly in frontmatter:
93
+
94
+ ```yaml
95
+ charts:
96
+ issues:
97
+ type: donut
98
+ title: Issue Types
99
+ center:
100
+ value: total
101
+ label: Issues
102
+ data:
103
+ - label: Features
104
+ value: 33
105
+ - label: Bugs
106
+ value: 21
107
+ - label: Other
108
+ value: 4
109
+ ```
110
+
111
+ ## CSV Format
112
+
113
+ CSV files use the first column as labels and subsequent columns as data series:
114
+
115
+ ```csv
116
+ label,existing,new
117
+ Finance,11,11
118
+ Sales,16,2
119
+ Core,8,0
120
+ ```
121
+
122
+ For scatter plots, use `label`, `x`, `y`, and optionally `series`:
123
+
124
+ ```csv
125
+ label,x,y,series
126
+ Point A,10,45,alpha
127
+ Point B,25,78,alpha
128
+ Point C,15,32,beta
129
+ ```
130
+
131
+ ## Configuration Options
132
+
133
+ | Option | Type | Description |
134
+ |--------|------|-------------|
135
+ | `type` | string | Chart type (required) |
136
+ | `title` | string | Chart title |
137
+ | `subtitle` | string | Subtitle below title |
138
+ | `file` | string | Path to CSV file (relative to dataDir) |
139
+ | `data` | array | Inline data array |
140
+ | `max` | number | Maximum value for scaling |
141
+ | `maxX` | number | Maximum X value (scatter only) |
142
+ | `maxY` | number | Maximum Y value (scatter only) |
143
+ | `legend` | array | Custom legend labels |
144
+ | `center` | object | Donut center content (`value`, `label`) |
145
+ | `animate` | boolean | Override global animation setting |
146
+
147
+ ## Styling
148
+
149
+ ### CSS Custom Properties
150
+
151
+ Override the default color palette:
152
+
153
+ ```css
154
+ :root {
155
+ --chart-color-1: #2196f3;
156
+ --chart-color-2: #4caf50;
157
+ --chart-color-3: #ffc107;
158
+ --chart-color-4: #ff7043;
159
+ --chart-color-5: #9c27b0;
160
+ --chart-color-6: #e91e63;
161
+ --chart-color-7: #009688;
162
+ --chart-color-8: #78909c;
163
+ --chart-bg: rgba(128, 128, 128, 0.15);
164
+ }
165
+ ```
166
+
167
+ ### Dual Class System
168
+
169
+ Each chart element gets two classes for styling flexibility:
170
+
171
+ 1. **Ordinal**: `.chart-color-1`, `.chart-color-2`, etc.
172
+ 2. **Semantic**: `.chart-series-{slugified-name}`
173
+
174
+ ```css
175
+ /* Style by position */
176
+ .chart-color-1 { --color: #ff6b6b; }
177
+
178
+ /* Style by series name */
179
+ .chart-series-production { --color: #51cf66; }
180
+ ```
181
+
182
+ ## Animations
183
+
184
+ Animations are CSS-based with staggered reveals. Enable globally or per-chart:
185
+
186
+ ```javascript
187
+ // Global
188
+ eleventyConfig.addPlugin(uncharted, { animate: true });
189
+ ```
190
+
191
+ ```yaml
192
+ # Per-chart override
193
+ charts:
194
+ static-chart:
195
+ type: donut
196
+ animate: false
197
+ ```
198
+
199
+ For scroll-triggered animations, add your own Intersection Observer to toggle the `.chart-animate` class.
200
+
201
+ ## License
202
+
203
+ MIT