@internetstiftelsen/charts 0.14.1 → 0.14.3

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 CHANGED
@@ -394,8 +394,8 @@ await chart.export('xlsx', { download: true, sheetName: 'Data' });
394
394
  await chart.export('pdf', { download: true, pdfMargin: 16 });
395
395
  ```
396
396
 
397
- `xlsx` and `pdf` are lazy-loaded and require optional dependencies (`xlsx` and
398
- `jspdf`) only when those formats are used.
397
+ `xlsx` and `pdf` are lazy-loaded and require optional dependencies
398
+ (`write-excel-file` and `jspdf`) only when those formats are used.
399
399
 
400
400
  ## Import
401
401
 
@@ -1,4 +1,4 @@
1
1
  import type { ChartData, ExportOptions } from './types.js';
2
- type XlsxLoader = () => Promise<unknown>;
3
- export declare function exportXLSXBlob(data: ChartData, options?: ExportOptions, loader?: XlsxLoader): Promise<Blob>;
2
+ type XlsxWriterLoader = () => Promise<unknown>;
3
+ export declare function exportXLSXBlob(data: ChartData, options?: ExportOptions, loader?: XlsxWriterLoader): Promise<Blob>;
4
4
  export {};
@@ -3,42 +3,38 @@ const XLSX_MIME_TYPE = 'application/vnd.openxmlformats-officedocument.spreadshee
3
3
  function isObject(value) {
4
4
  return typeof value === 'object' && value !== null;
5
5
  }
6
- function resolveXlsxApi(moduleValue) {
6
+ function resolveXlsxWriter(moduleValue) {
7
+ if (typeof moduleValue === 'function') {
8
+ return moduleValue;
9
+ }
7
10
  if (!isObject(moduleValue)) {
8
- throw new Error('Invalid "xlsx" module export');
11
+ throw new Error('Invalid "write-excel-file" module export');
9
12
  }
10
13
  const moduleCandidate = moduleValue;
11
- const xlsxCandidate = moduleCandidate.default && isObject(moduleCandidate.default)
12
- ? moduleCandidate.default
13
- : moduleCandidate;
14
- if (!xlsxCandidate.utils || !xlsxCandidate.write) {
15
- throw new Error('Invalid "xlsx" module export');
14
+ if (typeof moduleCandidate.default === 'function') {
15
+ return moduleCandidate.default;
16
16
  }
17
- return {
18
- utils: xlsxCandidate.utils,
19
- write: xlsxCandidate.write,
20
- };
17
+ throw new Error('Invalid "write-excel-file" module export');
21
18
  }
22
- async function defaultXlsxLoader() {
23
- return import('xlsx');
19
+ async function defaultXlsxWriterLoader() {
20
+ return import('write-excel-file/universal');
24
21
  }
25
- export async function exportXLSXBlob(data, options, loader = defaultXlsxLoader) {
26
- let xlsxModule;
22
+ export async function exportXLSXBlob(data, options, loader = defaultXlsxWriterLoader) {
23
+ let xlsxWriterModule;
27
24
  try {
28
- xlsxModule = await loader();
25
+ xlsxWriterModule = await loader();
29
26
  }
30
27
  catch {
31
- throw new Error('XLSX export requires optional dependency "xlsx". Install optional dependency "xlsx".');
28
+ throw new Error('XLSX export requires optional dependency "write-excel-file". Install optional dependency "write-excel-file".');
32
29
  }
33
- const xlsx = resolveXlsxApi(xlsxModule);
30
+ const writeXlsxFile = resolveXlsxWriter(xlsxWriterModule);
34
31
  const { columns, rows } = toTabularData(data, options?.columns);
35
- const worksheet = xlsx.utils.aoa_to_sheet([columns, ...rows]);
36
- const workbook = xlsx.utils.book_new();
37
32
  const sheetName = options?.sheetName?.trim() || 'Sheet1';
38
- xlsx.utils.book_append_sheet(workbook, worksheet, sheetName);
39
- const buffer = xlsx.write(workbook, {
40
- type: 'array',
41
- bookType: 'xlsx',
42
- });
43
- return new Blob([buffer], { type: XLSX_MIME_TYPE });
33
+ const blob = await writeXlsxFile([columns, ...rows], {
34
+ sheet: sheetName,
35
+ }).toBlob();
36
+ if (blob.type === XLSX_MIME_TYPE) {
37
+ return blob;
38
+ }
39
+ return new Blob([await blob.arrayBuffer()], { type: XLSX_MIME_TYPE });
44
40
  }
package/dist/pie-chart.js CHANGED
@@ -492,9 +492,9 @@ export class PieChart extends RadialChartBase {
492
492
  const insideArc = arc()
493
493
  .innerRadius(insideLabelRadius)
494
494
  .outerRadius(insideLabelRadius);
495
- const fontSize = this.renderTheme.legend.fontSize * fontScale;
496
- const fontFamily = this.renderTheme.axis.fontFamily;
497
- const fontWeight = this.renderTheme.axis.fontWeight ?? 'normal';
495
+ const fontSize = this.renderTheme.valueLabel.fontSize * fontScale;
496
+ const fontFamily = this.renderTheme.valueLabel.fontFamily;
497
+ const fontWeight = this.renderTheme.valueLabel.fontWeight;
498
498
  const labelOverflowOptions = {
499
499
  maxLabelWidth: this.valueLabel.maxLabelWidth,
500
500
  oversizedBehavior: this.valueLabel.oversizedBehavior,
@@ -400,7 +400,7 @@ breakpoints in chart constructor config (see
400
400
  - `svg`
401
401
  - `json`
402
402
  - `csv`
403
- - `xlsx` (lazy-loads optional `xlsx`)
403
+ - `xlsx` (lazy-loads optional `write-excel-file`)
404
404
  - `png`
405
405
  - `jpg`
406
406
  - `pdf` (lazy-loads optional `jspdf`)
package/docs/theming.md CHANGED
@@ -70,6 +70,10 @@ through the `themes` map as `themes.default`, `themes.ruby`,
70
70
  | `tooltip.fontFamily` | `string` | - | Tooltip text font |
71
71
  | `tooltip.fontSize` | `number` | `12` | Tooltip text size in pixels |
72
72
  | `tooltip.fontWeight` | `string` | `'normal'` | Tooltip text weight |
73
+ | `valueLabel.color` | `string` | `'#1f2a36'` | Value label text color |
74
+ | `valueLabel.fontFamily` | `string` | - | Value label text font |
75
+ | `valueLabel.fontSize` | `number` | `12` | Value label text size in pixels |
76
+ | `valueLabel.fontWeight` | `string` | `'600'` | Value label text weight |
73
77
 
74
78
  ---
75
79
 
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.14.1",
2
+ "version": "0.14.3",
3
3
  "name": "@internetstiftelsen/charts",
4
4
  "type": "module",
5
5
  "sideEffects": false,
@@ -39,7 +39,7 @@
39
39
  },
40
40
  "optionalDependencies": {
41
41
  "jspdf": "^4.2.1",
42
- "xlsx": "^0.18.5"
42
+ "write-excel-file": "^4.0.7"
43
43
  },
44
44
  "devDependencies": {
45
45
  "@eslint/js": "^10.0.1",
@@ -57,30 +57,30 @@
57
57
  "@types/d3": "^7.4.3",
58
58
  "@types/d3-cloud": "^1.2.9",
59
59
  "@types/node": "^25.9.1",
60
- "@types/react": "^19.2.15",
60
+ "@types/react": "^19.2.16",
61
61
  "@types/react-dom": "^19.2.3",
62
62
  "@vitejs/plugin-react-swc": "^4.3.1",
63
63
  "class-variance-authority": "^0.7.1",
64
64
  "clsx": "^2.1.1",
65
- "eslint": "^10.4.0",
65
+ "eslint": "^10.4.1",
66
66
  "eslint-plugin-react-hooks": "^7.1.1",
67
67
  "eslint-plugin-react-refresh": "^0.5.2",
68
68
  "globals": "^17.6.0",
69
69
  "handsontable": "^17.1.0",
70
70
  "jsdom": "^29.1.1",
71
- "lucide-react": "^1.16.0",
71
+ "lucide-react": "^1.17.0",
72
72
  "prettier": "3.8.3",
73
73
  "radix-ui": "^1.4.3",
74
- "react": "^19.2.6",
75
- "react-dom": "^19.2.6",
74
+ "react": "^19.2.7",
75
+ "react-dom": "^19.2.7",
76
76
  "sass": "^1.100.0",
77
77
  "tailwind-merge": "^3.6.0",
78
78
  "tailwindcss": "^4.3.0",
79
79
  "tsc-alias": "^1.8.17",
80
80
  "tw-animate-css": "^1.4.0",
81
81
  "typescript": "~6.0.3",
82
- "typescript-eslint": "^8.59.4",
83
- "vite": "^8.0.14",
84
- "vitest": "^4.1.7"
82
+ "typescript-eslint": "^8.60.1",
83
+ "vite": "^8.0.16",
84
+ "vitest": "^4.1.8"
85
85
  }
86
86
  }