@konce-pt/chart 0.11.2 → 0.12.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/dist/accessible.d.ts +17 -0
- package/dist/accessible.js +29 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/types.d.ts +4 -0
- package/package.json +2 -1
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { KptChartConfig } from './types.ts';
|
|
2
|
+
export interface KptChartDataTable {
|
|
3
|
+
/** Nagłówki kolumn wartości — nazwy serii. */
|
|
4
|
+
columns: string[];
|
|
5
|
+
/** Wiersz na kategorię: etykieta i sformatowane wartości kolejnych serii. */
|
|
6
|
+
rows: {
|
|
7
|
+
label: string;
|
|
8
|
+
values: string[];
|
|
9
|
+
}[];
|
|
10
|
+
}
|
|
11
|
+
/** Dane wykresu jako tabela: kategorie w wierszach, serie w kolumnach. */
|
|
12
|
+
export declare function chartDataTable(config: KptChartConfig, locale?: string): KptChartDataTable;
|
|
13
|
+
/**
|
|
14
|
+
* Nazwa dostępna wykresu: jawne `ariaLabel`, potem tytuł, potem podany zapas (np. z i18n).
|
|
15
|
+
* Pusty tytuł albo wyłączony (`display: false`) nie liczy się jako nazwa.
|
|
16
|
+
*/
|
|
17
|
+
export declare function chartAccessibleName(config: KptChartConfig, fallback: string): string;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Alternatywa tekstowa wykresu (WCAG 1.1.1). SVG z `role="img"` musi mieć nazwę, a same dane
|
|
3
|
+
* trafiają do ukrytej tabeli — czytnik przechodzi po niej komórka po komórce, czego obrazek
|
|
4
|
+
* z dymkiem na najechanie nigdy nie da. Wspólne dla obu portów.
|
|
5
|
+
*/
|
|
6
|
+
import { formatNumber } from "./format.js";
|
|
7
|
+
/** Dane wykresu jako tabela: kategorie w wierszach, serie w kolumnach. */
|
|
8
|
+
export function chartDataTable(config, locale) {
|
|
9
|
+
return {
|
|
10
|
+
columns: config.series.map((s) => s.name),
|
|
11
|
+
rows: config.labels.map((label, i) => ({
|
|
12
|
+
label,
|
|
13
|
+
values: config.series.map((s) => {
|
|
14
|
+
const value = s.data[i];
|
|
15
|
+
return typeof value === 'number' ? formatNumber(value, locale) : '';
|
|
16
|
+
}),
|
|
17
|
+
})),
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Nazwa dostępna wykresu: jawne `ariaLabel`, potem tytuł, potem podany zapas (np. z i18n).
|
|
22
|
+
* Pusty tytuł albo wyłączony (`display: false`) nie liczy się jako nazwa.
|
|
23
|
+
*/
|
|
24
|
+
export function chartAccessibleName(config, fallback) {
|
|
25
|
+
if (config.ariaLabel?.trim())
|
|
26
|
+
return config.ariaLabel;
|
|
27
|
+
const title = config.title?.display !== false ? config.title?.text?.trim() : '';
|
|
28
|
+
return title || fallback;
|
|
29
|
+
}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/types.d.ts
CHANGED
|
@@ -83,6 +83,10 @@ export interface KptChartConfig {
|
|
|
83
83
|
innerRadius?: number;
|
|
84
84
|
/** Bar: promień zaokrąglenia rogów w px (domyślnie 4). */
|
|
85
85
|
borderRadius?: number;
|
|
86
|
+
/** Nazwa dostępna wykresu (SVG `role="img"`); bez niej — tekst tytułu albo etykieta z i18n. */
|
|
87
|
+
ariaLabel?: string;
|
|
88
|
+
/** Krótki opis wniosku z wykresu dla czytnika (`aria-describedby`), np. „Sprzedaż rośnie od marca”. */
|
|
89
|
+
description?: string;
|
|
86
90
|
animation?: KptAnimationOptions;
|
|
87
91
|
legend?: KptLegendOptions;
|
|
88
92
|
title?: KptTitleOptions;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@konce-pt/chart",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"description": "Chart geometry core for Koncept UI — scales, line and area paths, bar layout, pie and radar geometry. Framework-free TypeScript, zero runtime dependencies.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "konce.pt",
|
|
@@ -40,6 +40,7 @@
|
|
|
40
40
|
"scripts": {
|
|
41
41
|
"build": "tsc -p tsconfig.build.json",
|
|
42
42
|
"test": "node --test \"src/**/*.test.ts\"",
|
|
43
|
+
"lint": "eslint .",
|
|
43
44
|
"clean": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\""
|
|
44
45
|
}
|
|
45
46
|
}
|