@internetstiftelsen/charts 0.9.1 → 0.10.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 +136 -2
- package/dist/bar.d.ts +3 -1
- package/dist/bar.js +167 -327
- package/dist/base-chart.d.ts +16 -1
- package/dist/base-chart.js +89 -30
- package/dist/chart-group.d.ts +121 -0
- package/dist/chart-group.js +1097 -0
- package/dist/chart-interface.d.ts +1 -1
- package/dist/donut-chart.js +1 -1
- package/dist/gauge-chart.js +1 -1
- package/dist/grid.d.ts +3 -3
- package/dist/grid.js +15 -9
- package/dist/legend-state.d.ts +19 -0
- package/dist/legend-state.js +81 -0
- package/dist/legend.d.ts +5 -2
- package/dist/legend.js +35 -29
- package/dist/pie-chart.js +1 -1
- package/dist/scatter.d.ts +16 -0
- package/dist/scatter.js +163 -0
- package/dist/tooltip.d.ts +2 -1
- package/dist/tooltip.js +3 -3
- package/dist/types.d.ts +18 -2
- package/dist/validation.d.ts +4 -0
- package/dist/validation.js +19 -0
- package/dist/xy-chart.d.ts +16 -1
- package/dist/xy-chart.js +318 -103
- package/docs/chart-group.md +213 -0
- package/docs/components.md +308 -0
- package/docs/donut-chart.md +193 -0
- package/docs/gauge-chart.md +175 -0
- package/docs/getting-started.md +311 -0
- package/docs/pie-chart.md +123 -0
- package/docs/theming.md +162 -0
- package/docs/word-cloud-chart.md +98 -0
- package/docs/xy-chart.md +502 -0
- package/package.json +2 -1
package/dist/types.d.ts
CHANGED
|
@@ -176,6 +176,7 @@ export type BarValueLabelConfig = ValueLabelConfig & {
|
|
|
176
176
|
position?: 'inside' | 'outside';
|
|
177
177
|
insidePosition?: 'top' | 'middle' | 'bottom';
|
|
178
178
|
};
|
|
179
|
+
export type BarSide = 'left' | 'right';
|
|
179
180
|
export type LineConfigBase = {
|
|
180
181
|
dataKey: string;
|
|
181
182
|
stroke?: string;
|
|
@@ -185,11 +186,21 @@ export type LineConfigBase = {
|
|
|
185
186
|
export type LineConfig = LineConfigBase & {
|
|
186
187
|
exportHooks?: ExportHooks<LineConfigBase>;
|
|
187
188
|
};
|
|
189
|
+
export type ScatterConfigBase = {
|
|
190
|
+
dataKey: string;
|
|
191
|
+
stroke?: string;
|
|
192
|
+
pointSize?: number;
|
|
193
|
+
valueLabel?: LineValueLabelConfig;
|
|
194
|
+
};
|
|
195
|
+
export type ScatterConfig = ScatterConfigBase & {
|
|
196
|
+
exportHooks?: ExportHooks<ScatterConfigBase>;
|
|
197
|
+
};
|
|
188
198
|
export type BarConfigBase = {
|
|
189
199
|
dataKey: string;
|
|
190
200
|
fill?: string;
|
|
191
201
|
colorAdapter?: (data: DataItem, index: number) => string;
|
|
192
202
|
maxBarSize?: number;
|
|
203
|
+
side?: BarSide;
|
|
193
204
|
valueLabel?: BarValueLabelConfig;
|
|
194
205
|
};
|
|
195
206
|
export type BarConfig = BarConfigBase & {
|
|
@@ -258,8 +269,8 @@ export type YAxisConfig = YAxisConfigBase & {
|
|
|
258
269
|
exportHooks?: ExportHooks<YAxisConfigBase>;
|
|
259
270
|
};
|
|
260
271
|
export type GridConfigBase = {
|
|
261
|
-
|
|
262
|
-
|
|
272
|
+
value?: boolean;
|
|
273
|
+
category?: boolean;
|
|
263
274
|
};
|
|
264
275
|
export type GridConfig = GridConfigBase & {
|
|
265
276
|
exportHooks?: ExportHooks<GridConfigBase>;
|
|
@@ -328,6 +339,7 @@ export type ScaleConfig = {
|
|
|
328
339
|
range?: number[];
|
|
329
340
|
padding?: number;
|
|
330
341
|
groupGap?: number;
|
|
342
|
+
reverse?: boolean;
|
|
331
343
|
nice?: boolean;
|
|
332
344
|
min?: number;
|
|
333
345
|
max?: number;
|
|
@@ -344,6 +356,10 @@ export type BarStackingContext = {
|
|
|
344
356
|
totalSeries: number;
|
|
345
357
|
cumulativeData: Map<string, number>;
|
|
346
358
|
totalData: Map<string, number>;
|
|
359
|
+
positiveCumulativeData: Map<string, number>;
|
|
360
|
+
negativeCumulativeData: Map<string, number>;
|
|
361
|
+
positiveTotalData: Map<string, number>;
|
|
362
|
+
negativeTotalData: Map<string, number>;
|
|
347
363
|
gap: number;
|
|
348
364
|
nextLayerData?: Map<string, number>;
|
|
349
365
|
};
|
package/dist/validation.d.ts
CHANGED
|
@@ -26,6 +26,10 @@ export declare class ChartValidator {
|
|
|
26
26
|
* Validates scale configuration
|
|
27
27
|
*/
|
|
28
28
|
static validateScaleConfig(scaleType: string, domain: ScaleDomainValue[] | undefined): void;
|
|
29
|
+
/**
|
|
30
|
+
* Validates that explicit numeric bar domains include zero so bars retain a truthful baseline
|
|
31
|
+
*/
|
|
32
|
+
static validateBarDomainIncludesZero(domain: ScaleDomainValue[] | undefined): void;
|
|
29
33
|
/**
|
|
30
34
|
* Warns about potential issues without throwing errors
|
|
31
35
|
*/
|
package/dist/validation.js
CHANGED
|
@@ -91,6 +91,25 @@ export class ChartValidator {
|
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
|
+
/**
|
|
95
|
+
* Validates that explicit numeric bar domains include zero so bars retain a truthful baseline
|
|
96
|
+
*/
|
|
97
|
+
static validateBarDomainIncludesZero(domain) {
|
|
98
|
+
if (!domain || domain.length < 2) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
const numericDomain = domain.filter((value) => {
|
|
102
|
+
return typeof value === 'number' && Number.isFinite(value);
|
|
103
|
+
});
|
|
104
|
+
if (numericDomain.length < 2) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
const minValue = Math.min(...numericDomain);
|
|
108
|
+
const maxValue = Math.max(...numericDomain);
|
|
109
|
+
if (minValue > 0 || maxValue < 0) {
|
|
110
|
+
throw new ChartValidationError('Bar charts require explicit numeric domains to include 0 so bars can render from a zero baseline');
|
|
111
|
+
}
|
|
112
|
+
}
|
|
94
113
|
/**
|
|
95
114
|
* Warns about potential issues without throwing errors
|
|
96
115
|
*/
|
package/dist/xy-chart.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BaseChart, type BaseChartConfig, type BaseLayoutContext, type BaseRenderContext } from './base-chart.js';
|
|
2
2
|
import type { ChartComponentBase } from './chart-interface.js';
|
|
3
|
-
import { type AreaStackConfig, type BarStackConfig, type LegendSeries, type Orientation } from './types.js';
|
|
3
|
+
import { type AreaStackConfig, type AxisScaleConfig, type BarStackConfig, type LegendSeries, type Orientation, type ScaleType } from './types.js';
|
|
4
4
|
export type XYChartConfig = BaseChartConfig & {
|
|
5
5
|
orientation?: Orientation;
|
|
6
6
|
barStack?: BarStackConfig;
|
|
@@ -13,6 +13,7 @@ export declare class XYChart extends BaseChart {
|
|
|
13
13
|
private barStackReverseSeries;
|
|
14
14
|
private areaStackMode;
|
|
15
15
|
private readonly orientation;
|
|
16
|
+
private scaleConfigOverride;
|
|
16
17
|
constructor(config: XYChartConfig);
|
|
17
18
|
addChild(component: ChartComponentBase): this;
|
|
18
19
|
protected getExportComponents(): ChartComponentBase[];
|
|
@@ -23,18 +24,32 @@ export declare class XYChart extends BaseChart {
|
|
|
23
24
|
private getXKey;
|
|
24
25
|
protected getLegendSeries(): LegendSeries[];
|
|
25
26
|
private getCategoryScaleType;
|
|
27
|
+
getOrientation(): Orientation;
|
|
28
|
+
getValueAxisScaleType(): ScaleType | null;
|
|
29
|
+
getValueAxisDomain(): [number, number] | null;
|
|
30
|
+
getBaseValueAxisDomain(): [number, number] | null;
|
|
31
|
+
setScaleConfigOverride(override: AxisScaleConfig | null, rerender?: boolean): this;
|
|
32
|
+
private resolveValueAxisDomain;
|
|
26
33
|
private getVisibleSeries;
|
|
27
34
|
private getDisplaySeries;
|
|
28
35
|
private resolveSeriesDefaults;
|
|
29
36
|
private shouldReplaceSeriesColor;
|
|
30
37
|
private cloneSeriesWithOverride;
|
|
31
38
|
private setupScales;
|
|
39
|
+
private get resolvedScaleConfig();
|
|
40
|
+
private getResolvedAxisConfigs;
|
|
41
|
+
private getAxisConfigsForScaleConfig;
|
|
32
42
|
private isHorizontalOrientation;
|
|
43
|
+
private getSeriesTypeName;
|
|
33
44
|
private validateSeriesOrientation;
|
|
34
45
|
private collectSeriesValues;
|
|
46
|
+
private getBarPercentDomain;
|
|
47
|
+
private getBarValueDomain;
|
|
35
48
|
private getStackedAreaGroups;
|
|
36
49
|
private buildBandDomainWithGroupGaps;
|
|
50
|
+
private getScaleRange;
|
|
37
51
|
private createScale;
|
|
52
|
+
private resolveScaleDomain;
|
|
38
53
|
private getSeriesTooltipValue;
|
|
39
54
|
private renderSeries;
|
|
40
55
|
private computeStackingData;
|