@internetstiftelsen/charts 0.5.1 → 0.6.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 +4 -2
- package/area.d.ts +26 -0
- package/area.js +331 -0
- package/base-chart.d.ts +10 -3
- package/base-chart.js +33 -19
- package/chart-interface.d.ts +1 -1
- package/donut-center-content.d.ts +1 -1
- package/donut-center-content.js +7 -6
- package/donut-chart.d.ts +1 -0
- package/donut-chart.js +8 -1
- package/export-tabular.d.ts +4 -4
- package/export-tabular.js +8 -0
- package/export-xlsx.d.ts +2 -2
- package/gauge-chart.d.ts +138 -0
- package/gauge-chart.js +1041 -0
- package/grouped-data.d.ts +19 -0
- package/grouped-data.js +122 -0
- package/grouped-tabular.d.ts +26 -0
- package/grouped-tabular.js +149 -0
- package/package.json +1 -1
- package/pie-chart.d.ts +80 -0
- package/pie-chart.js +665 -0
- package/theme.d.ts +1 -0
- package/theme.js +25 -16
- package/tooltip.d.ts +3 -2
- package/tooltip.js +40 -39
- package/types.d.ts +46 -0
- package/validation.d.ts +4 -0
- package/validation.js +25 -0
- package/x-axis.d.ts +10 -2
- package/x-axis.js +205 -15
- package/xy-chart.d.ts +10 -1
- package/xy-chart.js +307 -90
package/export-tabular.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { isGroupedData } from './grouped-data.js';
|
|
2
|
+
import { toGroupedTabularData } from './grouped-tabular.js';
|
|
1
3
|
function normalizeTableValue(value) {
|
|
2
4
|
if (value === null || value === undefined) {
|
|
3
5
|
return '';
|
|
@@ -27,6 +29,9 @@ function escapeCSVValue(value, delimiter) {
|
|
|
27
29
|
return `"${escaped}"`;
|
|
28
30
|
}
|
|
29
31
|
export function resolveTableColumns(data, requestedColumns) {
|
|
32
|
+
if (isGroupedData(data)) {
|
|
33
|
+
return toGroupedTabularData(data).columns;
|
|
34
|
+
}
|
|
30
35
|
if (requestedColumns && requestedColumns.length > 0) {
|
|
31
36
|
return requestedColumns;
|
|
32
37
|
}
|
|
@@ -43,6 +48,9 @@ export function resolveTableColumns(data, requestedColumns) {
|
|
|
43
48
|
return columns;
|
|
44
49
|
}
|
|
45
50
|
export function toTabularData(data, requestedColumns) {
|
|
51
|
+
if (isGroupedData(data)) {
|
|
52
|
+
return toGroupedTabularData(data, requestedColumns);
|
|
53
|
+
}
|
|
46
54
|
const columns = resolveTableColumns(data, requestedColumns);
|
|
47
55
|
const rows = data.map((item) => columns.map((column) => normalizeTableValue(item[column])));
|
|
48
56
|
return {
|
package/export-xlsx.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ChartData, ExportOptions } from './types.js';
|
|
2
2
|
type XlsxLoader = () => Promise<unknown>;
|
|
3
|
-
export declare function exportXLSXBlob(data:
|
|
3
|
+
export declare function exportXLSXBlob(data: ChartData, options?: ExportOptions, loader?: XlsxLoader): Promise<Blob>;
|
|
4
4
|
export {};
|
package/gauge-chart.d.ts
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import type { DataItem } from './types.js';
|
|
2
|
+
import { BaseChart, type BaseChartConfig } from './base-chart.js';
|
|
3
|
+
import type { ChartComponent, LayoutAwareComponent } from './chart-interface.js';
|
|
4
|
+
export type GaugeSegment = {
|
|
5
|
+
from: number;
|
|
6
|
+
to: number;
|
|
7
|
+
color?: string;
|
|
8
|
+
label?: string;
|
|
9
|
+
};
|
|
10
|
+
export type GaugeNeedleConfig = {
|
|
11
|
+
show?: boolean;
|
|
12
|
+
color?: string;
|
|
13
|
+
width?: number;
|
|
14
|
+
lengthRatio?: number;
|
|
15
|
+
capRadius?: number;
|
|
16
|
+
};
|
|
17
|
+
export type GaugeMarkerConfig = {
|
|
18
|
+
show?: boolean;
|
|
19
|
+
color?: string;
|
|
20
|
+
width?: number;
|
|
21
|
+
};
|
|
22
|
+
export type GaugeTickConfig = {
|
|
23
|
+
count?: number;
|
|
24
|
+
show?: boolean;
|
|
25
|
+
showLines?: boolean;
|
|
26
|
+
showLabels?: boolean;
|
|
27
|
+
size?: number;
|
|
28
|
+
labelOffset?: number;
|
|
29
|
+
formatter?: (value: number) => string;
|
|
30
|
+
labelStyle?: GaugeLabelStyle;
|
|
31
|
+
};
|
|
32
|
+
export type GaugeLabelStyle = {
|
|
33
|
+
fontSize?: number | string;
|
|
34
|
+
fontFamily?: string;
|
|
35
|
+
fontWeight?: number | string;
|
|
36
|
+
color?: string;
|
|
37
|
+
};
|
|
38
|
+
export type GaugeConfig = {
|
|
39
|
+
value?: number;
|
|
40
|
+
min?: number;
|
|
41
|
+
max?: number;
|
|
42
|
+
halfCircle?: boolean;
|
|
43
|
+
startAngle?: number;
|
|
44
|
+
endAngle?: number;
|
|
45
|
+
innerRadius?: number;
|
|
46
|
+
thickness?: number;
|
|
47
|
+
cornerRadius?: number;
|
|
48
|
+
trackColor?: string;
|
|
49
|
+
progressColor?: string;
|
|
50
|
+
targetColor?: string;
|
|
51
|
+
segmentStyle?: 'solid' | 'gradient';
|
|
52
|
+
segments?: GaugeSegment[];
|
|
53
|
+
needle?: boolean | GaugeNeedleConfig;
|
|
54
|
+
marker?: boolean | GaugeMarkerConfig;
|
|
55
|
+
showValue?: boolean;
|
|
56
|
+
valueFormatter?: (value: number) => string;
|
|
57
|
+
valueLabelStyle?: GaugeLabelStyle;
|
|
58
|
+
targetValue?: number;
|
|
59
|
+
ticks?: GaugeTickConfig;
|
|
60
|
+
};
|
|
61
|
+
export type GaugeChartConfig = BaseChartConfig & {
|
|
62
|
+
gauge?: GaugeConfig;
|
|
63
|
+
valueKey?: string;
|
|
64
|
+
targetValueKey?: string;
|
|
65
|
+
};
|
|
66
|
+
export declare class GaugeChart extends BaseChart {
|
|
67
|
+
private readonly configuredValue;
|
|
68
|
+
private readonly configuredTargetValue;
|
|
69
|
+
private readonly configuredSegments;
|
|
70
|
+
private readonly valueKey;
|
|
71
|
+
private readonly targetValueKey;
|
|
72
|
+
private readonly minValue;
|
|
73
|
+
private readonly maxValue;
|
|
74
|
+
private readonly halfCircle;
|
|
75
|
+
private readonly startAngle;
|
|
76
|
+
private readonly endAngle;
|
|
77
|
+
private readonly innerRadiusRatio;
|
|
78
|
+
private readonly thickness;
|
|
79
|
+
private readonly cornerRadius;
|
|
80
|
+
private readonly trackColor;
|
|
81
|
+
private readonly progressColor;
|
|
82
|
+
private readonly targetColor;
|
|
83
|
+
private readonly segmentStyle;
|
|
84
|
+
private readonly valueFormatter;
|
|
85
|
+
private readonly showValue;
|
|
86
|
+
private readonly needle;
|
|
87
|
+
private readonly marker;
|
|
88
|
+
private readonly ticks;
|
|
89
|
+
private readonly tickLabelStyle;
|
|
90
|
+
private readonly valueLabelStyle;
|
|
91
|
+
private segments;
|
|
92
|
+
private value;
|
|
93
|
+
private targetValue;
|
|
94
|
+
constructor(config: GaugeChartConfig);
|
|
95
|
+
private normalizeNeedleConfig;
|
|
96
|
+
private normalizeMarkerConfig;
|
|
97
|
+
private getThemePaletteColor;
|
|
98
|
+
private normalizeTickConfig;
|
|
99
|
+
private normalizeTickLabelStyle;
|
|
100
|
+
private normalizeValueLabelStyle;
|
|
101
|
+
private validateGaugeConfig;
|
|
102
|
+
private validateSegments;
|
|
103
|
+
private refreshResolvedValues;
|
|
104
|
+
private resolveValue;
|
|
105
|
+
private resolveTargetValue;
|
|
106
|
+
private warnIfMultipleRows;
|
|
107
|
+
private parseFiniteNumber;
|
|
108
|
+
private clampToDomain;
|
|
109
|
+
private prepareSegments;
|
|
110
|
+
private defaultFormat;
|
|
111
|
+
addChild(component: ChartComponent): this;
|
|
112
|
+
protected getExportComponents(): ChartComponent[];
|
|
113
|
+
update(data: DataItem[]): void;
|
|
114
|
+
protected getLayoutComponents(): LayoutAwareComponent[];
|
|
115
|
+
protected createExportChart(): BaseChart;
|
|
116
|
+
protected renderChart(): void;
|
|
117
|
+
private buildAriaLabel;
|
|
118
|
+
private findSegmentStatusLabel;
|
|
119
|
+
private getVisibleSegments;
|
|
120
|
+
private resolveProgressColor;
|
|
121
|
+
private valueToAngle;
|
|
122
|
+
private getProgressRadii;
|
|
123
|
+
private pointAt;
|
|
124
|
+
private renderTrack;
|
|
125
|
+
private renderSegments;
|
|
126
|
+
private renderGradientSegments;
|
|
127
|
+
private renderProgress;
|
|
128
|
+
private renderTicks;
|
|
129
|
+
private renderTargetMarker;
|
|
130
|
+
private renderNeedle;
|
|
131
|
+
private renderCurrentValueMarker;
|
|
132
|
+
private renderValueText;
|
|
133
|
+
private attachTooltipLayer;
|
|
134
|
+
private resolveTooltipDiv;
|
|
135
|
+
private buildTooltipContent;
|
|
136
|
+
private positionTooltip;
|
|
137
|
+
private renderLegend;
|
|
138
|
+
}
|