eleventy-plugin-uncharted 0.7.3 → 0.7.5
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/css/uncharted.css +19 -21
- package/eleventy.config.js +8 -13
- package/package.json +1 -1
- package/src/config.js +0 -5
- package/src/renderers/donut.js +4 -4
- package/src/renderers/dot.js +3 -3
- package/src/renderers/sankey.js +4 -4
- package/src/renderers/scatter.js +3 -3
- package/src/renderers/stacked-bar.js +3 -3
- package/src/renderers/stacked-column.js +3 -3
package/css/uncharted.css
CHANGED
|
@@ -102,7 +102,6 @@
|
|
|
102
102
|
flex-wrap: wrap;
|
|
103
103
|
column-gap: 1rem;
|
|
104
104
|
row-gap: 0.375rem;
|
|
105
|
-
list-style: none;
|
|
106
105
|
padding: 0;
|
|
107
106
|
margin: 0;
|
|
108
107
|
font-size: 0.875rem;
|
|
@@ -126,33 +125,32 @@
|
|
|
126
125
|
margin-bottom: 1rem;
|
|
127
126
|
}
|
|
128
127
|
|
|
129
|
-
.chart-legend
|
|
128
|
+
.chart-legend-item {
|
|
130
129
|
display: flex;
|
|
131
130
|
align-items: baseline;
|
|
132
131
|
gap: 0.5rem;
|
|
133
132
|
background: transparent;
|
|
134
|
-
margin: 0;
|
|
135
|
-
}
|
|
136
133
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
}
|
|
134
|
+
&::before {
|
|
135
|
+
content: '';
|
|
136
|
+
width: 1cap;
|
|
137
|
+
height: 1cap;
|
|
138
|
+
border-radius: 2px;
|
|
139
|
+
background-color: var(--color);
|
|
140
|
+
flex-shrink: 0;
|
|
141
|
+
}
|
|
145
142
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
border-radius: 50%;
|
|
151
|
-
}
|
|
143
|
+
.legend-value {
|
|
144
|
+
opacity: 0.7;
|
|
145
|
+
margin-left: 0.125rem;
|
|
146
|
+
}
|
|
152
147
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
148
|
+
/* Dot/scatter/line charts use circular legend markers */
|
|
149
|
+
.chart-dot &::before,
|
|
150
|
+
.chart-line &::before,
|
|
151
|
+
.chart-scatter &::before {
|
|
152
|
+
border-radius: 50%;
|
|
153
|
+
}
|
|
156
154
|
}
|
|
157
155
|
|
|
158
156
|
.chart-legend-title {
|
package/eleventy.config.js
CHANGED
|
@@ -11,7 +11,7 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
|
11
11
|
* Uncharted - Eleventy CSS Charts Plugin
|
|
12
12
|
* @param {Object} eleventyConfig - Eleventy configuration object
|
|
13
13
|
* @param {Object} [options] - Plugin options
|
|
14
|
-
* @param {string} [options.dataDir] -
|
|
14
|
+
* @param {string} [options.dataDir] - Data directory path relative to root (e.g., '_data/charts'). Defaults to Eleventy's dir.data config.
|
|
15
15
|
* @param {boolean} [options.animate] - Enable animations globally (individual charts can override)
|
|
16
16
|
* @param {string} [options.cssPath] - Output path for stylesheet (default: '/css/uncharted.css')
|
|
17
17
|
* @param {boolean} [options.injectCss] - Automatically copy and inject CSS (default: true)
|
|
@@ -28,14 +28,9 @@ export default function(eleventyConfig, options = {}) {
|
|
|
28
28
|
eleventyDirs = dirs;
|
|
29
29
|
});
|
|
30
30
|
|
|
31
|
-
// Warn if deprecated dataDir option is used
|
|
32
|
-
if (options.dataDir) {
|
|
33
|
-
console.warn('[uncharted] "dataDir" option is deprecated; the plugin now auto-detects from Eleventy\'s dir.data config');
|
|
34
|
-
}
|
|
35
|
-
|
|
36
31
|
// Helper to resolve data directory
|
|
37
32
|
function getDataDir() {
|
|
38
|
-
// Plugin option takes precedence if explicitly set
|
|
33
|
+
// Plugin option takes precedence if explicitly set
|
|
39
34
|
if (options.dataDir) {
|
|
40
35
|
return path.resolve(process.cwd(), options.dataDir);
|
|
41
36
|
}
|
|
@@ -93,13 +88,13 @@ export default function(eleventyConfig, options = {}) {
|
|
|
93
88
|
});
|
|
94
89
|
}
|
|
95
90
|
|
|
96
|
-
// CSV data passthrough for download links
|
|
91
|
+
// CSV data passthrough for download links
|
|
92
|
+
// When dataDir is set explicitly, use it; otherwise use Eleventy's default _data
|
|
97
93
|
if (dataPassthrough) {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
});
|
|
94
|
+
const dataDirForPassthrough = options.dataDir || '_data';
|
|
95
|
+
const destPath = dataPath.replace(/^\//, '').replace(/\/$/, '');
|
|
96
|
+
eleventyConfig.addPassthroughCopy({
|
|
97
|
+
[dataDirForPassthrough]: destPath
|
|
103
98
|
});
|
|
104
99
|
}
|
|
105
100
|
|
package/package.json
CHANGED
package/src/config.js
CHANGED
|
@@ -68,11 +68,6 @@ export function normalizeConfig(config, chartId = 'unknown') {
|
|
|
68
68
|
// Build y axis config
|
|
69
69
|
normalized.y = buildAxisConfig('y', config, chartId);
|
|
70
70
|
|
|
71
|
-
// Warn for deprecated columns key
|
|
72
|
-
if (config.columns) {
|
|
73
|
-
warnDeprecation(chartId, 'columns', 'x.column / y.columns');
|
|
74
|
-
}
|
|
75
|
-
|
|
76
71
|
// Warn for deprecated legend array (when used for labels, not boolean)
|
|
77
72
|
if (Array.isArray(config.legend)) {
|
|
78
73
|
warnDeprecation(chartId, 'legend (array)', 'y.columns: { key: "Label" }');
|
package/src/renderers/donut.js
CHANGED
|
@@ -118,7 +118,7 @@ export function renderDonut(config) {
|
|
|
118
118
|
// Show if legend !== false (donut always shows legend by default)
|
|
119
119
|
const showLegend = config.legend !== false;
|
|
120
120
|
if (showLegend) {
|
|
121
|
-
html += `<
|
|
121
|
+
html += `<div class="chart-legend">`;
|
|
122
122
|
segments.forEach((segment, i) => {
|
|
123
123
|
const label = getSegmentLabel(segment, i);
|
|
124
124
|
let displayValue;
|
|
@@ -129,12 +129,12 @@ export function renderDonut(config) {
|
|
|
129
129
|
}
|
|
130
130
|
const colorClass = `chart-color-${i + 1}`;
|
|
131
131
|
const seriesClass = `chart-series-${slugify(segment.label)}`;
|
|
132
|
-
html += `<
|
|
132
|
+
html += `<span class="chart-legend-item ${colorClass} ${seriesClass}">`;
|
|
133
133
|
html += `<span class="legend-label">${escapeHtml(label)}</span>`;
|
|
134
134
|
html += `<span class="legend-value">${escapeHtml(String(displayValue))}</span>`;
|
|
135
|
-
html += `</
|
|
135
|
+
html += `</span>`;
|
|
136
136
|
});
|
|
137
|
-
html += `</
|
|
137
|
+
html += `</div>`;
|
|
138
138
|
}
|
|
139
139
|
|
|
140
140
|
html += renderDownloadLink(downloadDataUrl, downloadData);
|
package/src/renderers/dot.js
CHANGED
|
@@ -164,14 +164,14 @@ export function renderDot(config) {
|
|
|
164
164
|
if (legendTitle) {
|
|
165
165
|
html += `<span class="chart-legend-title">${escapeHtml(legendTitle)}</span>`;
|
|
166
166
|
}
|
|
167
|
-
html += `<
|
|
167
|
+
html += `<div class="chart-legend">`;
|
|
168
168
|
seriesKeys.forEach((key, i) => {
|
|
169
169
|
const label = getSeriesLabel(key, i);
|
|
170
170
|
const colorClass = `chart-color-${i + 1}`;
|
|
171
171
|
const seriesClass = `chart-series-${slugify(key)}`;
|
|
172
|
-
html += `<
|
|
172
|
+
html += `<span class="chart-legend-item ${colorClass} ${seriesClass}">${escapeHtml(label)}</span>`;
|
|
173
173
|
});
|
|
174
|
-
html += `</
|
|
174
|
+
html += `</div>`;
|
|
175
175
|
}
|
|
176
176
|
|
|
177
177
|
html += renderDownloadLink(downloadDataUrl, downloadData);
|
package/src/renderers/sankey.js
CHANGED
|
@@ -512,18 +512,18 @@ export function renderSankey(config) {
|
|
|
512
512
|
|
|
513
513
|
// Legend (optional)
|
|
514
514
|
if (legend) {
|
|
515
|
-
html += `<
|
|
515
|
+
html += `<div class="chart-legend">`;
|
|
516
516
|
nodes.forEach((node, i) => {
|
|
517
517
|
const colorClass = `chart-color-${nodeColors.get(node)}`;
|
|
518
518
|
const seriesClass = `chart-series-${slugify(node)}`;
|
|
519
519
|
const throughput = nodeThroughput.get(node);
|
|
520
|
-
html += `<
|
|
520
|
+
html += `<span class="chart-legend-item ${colorClass} ${seriesClass}">${escapeHtml(node)}`;
|
|
521
521
|
if (valueFormat) {
|
|
522
522
|
html += ` <span class="legend-value">${formatNumber(throughput, valueFormat) || throughput}</span>`;
|
|
523
523
|
}
|
|
524
|
-
html += `</
|
|
524
|
+
html += `</span>`;
|
|
525
525
|
});
|
|
526
|
-
html += `</
|
|
526
|
+
html += `</div>`;
|
|
527
527
|
}
|
|
528
528
|
|
|
529
529
|
html += renderDownloadLink(downloadDataUrl, downloadData);
|
package/src/renderers/scatter.js
CHANGED
|
@@ -201,14 +201,14 @@ export function renderScatter(config) {
|
|
|
201
201
|
if (legendTitle) {
|
|
202
202
|
html += `<span class="chart-legend-title">${escapeHtml(legendTitle)}</span>`;
|
|
203
203
|
}
|
|
204
|
-
html += `<
|
|
204
|
+
html += `<div class="chart-legend">`;
|
|
205
205
|
seriesList.forEach((series, i) => {
|
|
206
206
|
const label = legendLabels[i] ?? series;
|
|
207
207
|
const colorClass = `chart-color-${i + 1}`;
|
|
208
208
|
const seriesClass = `chart-series-${slugify(series)}`;
|
|
209
|
-
html += `<
|
|
209
|
+
html += `<span class="chart-legend-item ${colorClass} ${seriesClass}">${escapeHtml(label)}</span>`;
|
|
210
210
|
});
|
|
211
|
-
html += `</
|
|
211
|
+
html += `</div>`;
|
|
212
212
|
}
|
|
213
213
|
|
|
214
214
|
// Size legend (when sizeTitle is specified and size column exists)
|
|
@@ -65,14 +65,14 @@ export function renderStackedBar(config) {
|
|
|
65
65
|
if (legendTitle) {
|
|
66
66
|
html += `<span class="chart-legend-title">${escapeHtml(legendTitle)}</span>`;
|
|
67
67
|
}
|
|
68
|
-
html += `<
|
|
68
|
+
html += `<div class="chart-legend">`;
|
|
69
69
|
seriesKeys.forEach((key, i) => {
|
|
70
70
|
const label = getSeriesLabel(key, i);
|
|
71
71
|
const colorClass = `chart-color-${i + 1}`;
|
|
72
72
|
const seriesClass = `chart-series-${slugify(key)}`;
|
|
73
|
-
html += `<
|
|
73
|
+
html += `<span class="chart-legend-item ${colorClass} ${seriesClass}">${escapeHtml(label)}</span>`;
|
|
74
74
|
});
|
|
75
|
-
html += `</
|
|
75
|
+
html += `</div>`;
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
// Calculate delay step to cap total stagger at 1s
|
|
@@ -199,14 +199,14 @@ export function renderStackedColumn(config) {
|
|
|
199
199
|
// Legend (show if legend !== false and we have series keys)
|
|
200
200
|
const showLegend = config.legend !== false && seriesKeys.length > 0;
|
|
201
201
|
if (showLegend) {
|
|
202
|
-
html += `<
|
|
202
|
+
html += `<div class="chart-legend">`;
|
|
203
203
|
seriesKeys.forEach((key, i) => {
|
|
204
204
|
const label = getSeriesLabel(key, i);
|
|
205
205
|
const colorClass = `chart-color-${i + 1}`;
|
|
206
206
|
const seriesClass = `chart-series-${slugify(key)}`;
|
|
207
|
-
html += `<
|
|
207
|
+
html += `<span class="chart-legend-item ${colorClass} ${seriesClass}">${escapeHtml(label)}</span>`;
|
|
208
208
|
});
|
|
209
|
-
html += `</
|
|
209
|
+
html += `</div>`;
|
|
210
210
|
}
|
|
211
211
|
|
|
212
212
|
html += renderDownloadLink(downloadDataUrl, downloadData);
|