@internetstiftelsen/charts 0.15.0 → 0.17.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 +5 -1
- package/dist/theme.js +6 -0
- package/dist/tooltip/dom.d.ts +60 -0
- package/dist/tooltip/dom.js +457 -0
- package/dist/tooltip/geometry.d.ts +19 -0
- package/dist/tooltip/geometry.js +857 -0
- package/dist/tooltip/types.d.ts +79 -0
- package/dist/tooltip/types.js +24 -0
- package/dist/tooltip/xy-interaction.d.ts +34 -0
- package/dist/tooltip/xy-interaction.js +791 -0
- package/dist/tooltip.d.ts +6 -75
- package/dist/tooltip.js +51 -1445
- package/dist/types.d.ts +7 -3
- package/dist/x-axis.d.ts +11 -1
- package/dist/x-axis.js +150 -10
- package/dist/xy-chart.d.ts +1 -0
- package/dist/xy-chart.js +10 -4
- package/docs/components.md +29 -22
- package/docs/xy-chart.md +3 -10
- package/package.json +1 -1
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type { Selection } from 'd3';
|
|
2
|
+
import type { Bar } from '../bar.js';
|
|
3
|
+
import type { Area } from '../area.js';
|
|
4
|
+
import type { Line } from '../line.js';
|
|
5
|
+
import type { Scatter } from '../scatter.js';
|
|
6
|
+
import type { TooltipTransitionConfig } from '../types.js';
|
|
7
|
+
export declare const TOOLTIP_OFFSET_PX = 12;
|
|
8
|
+
export declare const TOOLTIP_VIEWPORT_PADDING_PX = 10;
|
|
9
|
+
export declare const TOOLTIP_CONNECTOR_INSET_PX = 14;
|
|
10
|
+
export declare const TOOLTIP_CONNECTOR_PADDING_PX = 4;
|
|
11
|
+
export declare const TOOLTIP_CONNECTOR_ELBOW_RATIO = 0.45;
|
|
12
|
+
export declare const TOOLTIP_BORDER_WIDTH_PX = 1;
|
|
13
|
+
export declare const TOOLTIP_BOX_ARROW_LENGTH_PX = 10;
|
|
14
|
+
export declare const TOOLTIP_BOX_ARROW_HALF_HEIGHT_PX = 6;
|
|
15
|
+
export declare const TOOLTIP_CONNECTOR_ALIGNMENT_TOLERANCE_PX = 1;
|
|
16
|
+
export declare const TOOLTIP_CONNECTOR_Z_INDEX = 3;
|
|
17
|
+
export declare const TOOLTIP_ARROW_BORDER_Z_INDEX = 4;
|
|
18
|
+
export declare const TOOLTIP_ARROW_FILL_Z_INDEX = 5;
|
|
19
|
+
export declare const TOOLTIP_BODY_Z_INDEX = 6;
|
|
20
|
+
export declare const TOOLTIP_TOTAL_BORDER_WIDTH_PX: number;
|
|
21
|
+
export declare const TOOLTIP_ROOT_Z_INDEX = 30;
|
|
22
|
+
export declare const SPLIT_TOOLTIP_GAP_PX = 8;
|
|
23
|
+
export declare const DEFAULT_TOOLTIP_MAX_WIDTH_PX = 280;
|
|
24
|
+
export declare const DEFAULT_TOOLTIP_TRANSITION: Required<TooltipTransitionConfig>;
|
|
25
|
+
export declare const TOOLTIP_HIDDEN_TRANSFORM = "translateY(2px)";
|
|
26
|
+
export declare const TOOLTIP_VISIBLE_TRANSFORM = "translateY(0)";
|
|
27
|
+
export type XYTooltipSeries = Line | Bar | Area | Scatter;
|
|
28
|
+
export type TooltipArrowEdge = 'left' | 'right' | 'top' | 'bottom';
|
|
29
|
+
export type TooltipDivSelection = Selection<HTMLDivElement, unknown, HTMLElement, undefined>;
|
|
30
|
+
export type TooltipAnchor = {
|
|
31
|
+
left: number;
|
|
32
|
+
right: number;
|
|
33
|
+
top: number;
|
|
34
|
+
bottom: number;
|
|
35
|
+
centerX: number;
|
|
36
|
+
centerY: number;
|
|
37
|
+
};
|
|
38
|
+
export type TooltipTarget = {
|
|
39
|
+
x: number;
|
|
40
|
+
y: number;
|
|
41
|
+
};
|
|
42
|
+
export type TooltipBoxArrowPosition = {
|
|
43
|
+
x: number;
|
|
44
|
+
y: number;
|
|
45
|
+
};
|
|
46
|
+
export type TooltipConnectorLayout = {
|
|
47
|
+
arrowEdge: TooltipArrowEdge;
|
|
48
|
+
left: number;
|
|
49
|
+
top: number;
|
|
50
|
+
width: number;
|
|
51
|
+
height: number;
|
|
52
|
+
path: string;
|
|
53
|
+
arrowX: number;
|
|
54
|
+
arrowY: number;
|
|
55
|
+
};
|
|
56
|
+
export type SplitTooltipLayout = {
|
|
57
|
+
div: TooltipDivSelection;
|
|
58
|
+
anchor: TooltipAnchor;
|
|
59
|
+
width: number;
|
|
60
|
+
height: number;
|
|
61
|
+
left: number;
|
|
62
|
+
top: number;
|
|
63
|
+
arrowEdge: TooltipArrowEdge;
|
|
64
|
+
targetX: number;
|
|
65
|
+
targetY: number;
|
|
66
|
+
order: number;
|
|
67
|
+
targetMode: 'fixed' | 'auto';
|
|
68
|
+
valueSign: -1 | 0 | 1;
|
|
69
|
+
};
|
|
70
|
+
export type SplitTooltipPlacementCandidate = {
|
|
71
|
+
top: number;
|
|
72
|
+
arrowEdge: TooltipArrowEdge;
|
|
73
|
+
};
|
|
74
|
+
export type SplitTooltipViewportBounds = {
|
|
75
|
+
minLeft: number;
|
|
76
|
+
maxRight: number;
|
|
77
|
+
minTop: number;
|
|
78
|
+
maxBottom: number;
|
|
79
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export const TOOLTIP_OFFSET_PX = 12;
|
|
2
|
+
export const TOOLTIP_VIEWPORT_PADDING_PX = 10;
|
|
3
|
+
export const TOOLTIP_CONNECTOR_INSET_PX = 14;
|
|
4
|
+
export const TOOLTIP_CONNECTOR_PADDING_PX = 4;
|
|
5
|
+
export const TOOLTIP_CONNECTOR_ELBOW_RATIO = 0.45;
|
|
6
|
+
export const TOOLTIP_BORDER_WIDTH_PX = 1;
|
|
7
|
+
export const TOOLTIP_BOX_ARROW_LENGTH_PX = 10;
|
|
8
|
+
export const TOOLTIP_BOX_ARROW_HALF_HEIGHT_PX = 6;
|
|
9
|
+
export const TOOLTIP_CONNECTOR_ALIGNMENT_TOLERANCE_PX = 1;
|
|
10
|
+
export const TOOLTIP_CONNECTOR_Z_INDEX = 3;
|
|
11
|
+
export const TOOLTIP_ARROW_BORDER_Z_INDEX = 4;
|
|
12
|
+
export const TOOLTIP_ARROW_FILL_Z_INDEX = 5;
|
|
13
|
+
export const TOOLTIP_BODY_Z_INDEX = 6;
|
|
14
|
+
export const TOOLTIP_TOTAL_BORDER_WIDTH_PX = TOOLTIP_BORDER_WIDTH_PX * 2;
|
|
15
|
+
export const TOOLTIP_ROOT_Z_INDEX = 30;
|
|
16
|
+
export const SPLIT_TOOLTIP_GAP_PX = 8;
|
|
17
|
+
export const DEFAULT_TOOLTIP_MAX_WIDTH_PX = 280;
|
|
18
|
+
export const DEFAULT_TOOLTIP_TRANSITION = {
|
|
19
|
+
show: false,
|
|
20
|
+
duration: 120,
|
|
21
|
+
easing: 'ease-out',
|
|
22
|
+
};
|
|
23
|
+
export const TOOLTIP_HIDDEN_TRANSFORM = 'translateY(2px)';
|
|
24
|
+
export const TOOLTIP_VISIBLE_TRANSFORM = 'translateY(0)';
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { type Selection } from 'd3';
|
|
2
|
+
import type { ChartTheme, DataItem, DataValue, D3Scale, ScaleType, TooltipBarAnchorPosition, TooltipColorMode, TooltipMode, TooltipPosition } from '../types.js';
|
|
3
|
+
import type { PlotAreaBounds } from '../layout-manager.js';
|
|
4
|
+
import type { TooltipDom } from './dom.js';
|
|
5
|
+
import type { XYTooltipSeries } from './types.js';
|
|
6
|
+
type ResolveSeriesValue = (series: XYTooltipSeries, dataPoint: DataItem, index: number) => number;
|
|
7
|
+
export type XYTooltipAreaConfig = {
|
|
8
|
+
svg: Selection<SVGSVGElement, undefined, null, undefined>;
|
|
9
|
+
data: DataItem[];
|
|
10
|
+
series: XYTooltipSeries[];
|
|
11
|
+
xKey: string;
|
|
12
|
+
x: D3Scale;
|
|
13
|
+
y: D3Scale;
|
|
14
|
+
theme: ChartTheme;
|
|
15
|
+
plotArea: PlotAreaBounds;
|
|
16
|
+
parseValue: (value: unknown) => number;
|
|
17
|
+
isHorizontal: boolean;
|
|
18
|
+
categoryScaleType: ScaleType;
|
|
19
|
+
resolveSeriesValue?: ResolveSeriesValue;
|
|
20
|
+
mode: TooltipMode;
|
|
21
|
+
position: TooltipPosition;
|
|
22
|
+
barAnchorPosition: TooltipBarAnchorPosition;
|
|
23
|
+
colorMode: TooltipColorMode;
|
|
24
|
+
formatter?: (dataKey: string, value: DataValue, data: DataItem) => string;
|
|
25
|
+
labelFormatter?: (label: string, data: DataItem) => string;
|
|
26
|
+
customFormatter?: (data: DataItem, series: {
|
|
27
|
+
dataKey: string;
|
|
28
|
+
stroke?: string;
|
|
29
|
+
fill?: string;
|
|
30
|
+
}[]) => string;
|
|
31
|
+
dom: TooltipDom;
|
|
32
|
+
};
|
|
33
|
+
export declare function attachXYTooltipArea(config: XYTooltipAreaConfig): (() => void) | null;
|
|
34
|
+
export {};
|