@coinbase/cds-web-visualization 3.3.2 → 3.4.0-beta.10
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/CHANGELOG.md +50 -2
- package/dts/chart/CartesianChart.d.ts +72 -0
- package/dts/chart/CartesianChart.d.ts.map +1 -0
- package/dts/chart/ChartProvider.d.ts +6 -0
- package/dts/chart/ChartProvider.d.ts.map +1 -0
- package/dts/chart/Path.d.ts +54 -0
- package/dts/chart/Path.d.ts.map +1 -0
- package/dts/chart/PeriodSelector.d.ts +57 -0
- package/dts/chart/PeriodSelector.d.ts.map +1 -0
- package/dts/chart/area/Area.d.ts +78 -0
- package/dts/chart/area/Area.d.ts.map +1 -0
- package/dts/chart/area/AreaChart.d.ts +79 -0
- package/dts/chart/area/AreaChart.d.ts.map +1 -0
- package/dts/chart/area/DottedArea.d.ts +45 -0
- package/dts/chart/area/DottedArea.d.ts.map +1 -0
- package/dts/chart/area/GradientArea.d.ts +39 -0
- package/dts/chart/area/GradientArea.d.ts.map +1 -0
- package/dts/chart/area/SolidArea.d.ts +23 -0
- package/dts/chart/area/SolidArea.d.ts.map +1 -0
- package/dts/chart/area/index.d.ts +6 -0
- package/dts/chart/area/index.d.ts.map +1 -0
- package/dts/chart/axis/Axis.d.ts +255 -0
- package/dts/chart/axis/Axis.d.ts.map +1 -0
- package/dts/chart/axis/DefaultAxisTickLabel.d.ts +8 -0
- package/dts/chart/axis/DefaultAxisTickLabel.d.ts.map +1 -0
- package/dts/chart/axis/XAxis.d.ts +16 -0
- package/dts/chart/axis/XAxis.d.ts.map +1 -0
- package/dts/chart/axis/YAxis.d.ts +21 -0
- package/dts/chart/axis/YAxis.d.ts.map +1 -0
- package/dts/chart/axis/index.d.ts +5 -0
- package/dts/chart/axis/index.d.ts.map +1 -0
- package/dts/chart/bar/Bar.d.ts +94 -0
- package/dts/chart/bar/Bar.d.ts.map +1 -0
- package/dts/chart/bar/BarChart.d.ts +62 -0
- package/dts/chart/bar/BarChart.d.ts.map +1 -0
- package/dts/chart/bar/BarPlot.d.ts +30 -0
- package/dts/chart/bar/BarPlot.d.ts.map +1 -0
- package/dts/chart/bar/BarStack.d.ts +103 -0
- package/dts/chart/bar/BarStack.d.ts.map +1 -0
- package/dts/chart/bar/BarStackGroup.d.ts +36 -0
- package/dts/chart/bar/BarStackGroup.d.ts.map +1 -0
- package/dts/chart/bar/DefaultBar.d.ts +17 -0
- package/dts/chart/bar/DefaultBar.d.ts.map +1 -0
- package/dts/chart/bar/DefaultBarStack.d.ts +16 -0
- package/dts/chart/bar/DefaultBarStack.d.ts.map +1 -0
- package/dts/chart/bar/index.d.ts +8 -0
- package/dts/chart/bar/index.d.ts.map +1 -0
- package/dts/chart/gradient/Gradient.d.ts +35 -0
- package/dts/chart/gradient/Gradient.d.ts.map +1 -0
- package/dts/chart/gradient/index.d.ts +2 -0
- package/dts/chart/gradient/index.d.ts.map +1 -0
- package/dts/chart/index.d.ts +14 -0
- package/dts/chart/index.d.ts.map +1 -0
- package/dts/chart/line/DefaultReferenceLineLabel.d.ts +9 -0
- package/dts/chart/line/DefaultReferenceLineLabel.d.ts.map +1 -0
- package/dts/chart/line/DottedLine.d.ts +26 -0
- package/dts/chart/line/DottedLine.d.ts.map +1 -0
- package/dts/chart/line/Line.d.ts +122 -0
- package/dts/chart/line/Line.d.ts.map +1 -0
- package/dts/chart/line/LineChart.d.ts +77 -0
- package/dts/chart/line/LineChart.d.ts.map +1 -0
- package/dts/chart/line/ReferenceLine.d.ts +178 -0
- package/dts/chart/line/ReferenceLine.d.ts.map +1 -0
- package/dts/chart/line/SolidLine.d.ts +25 -0
- package/dts/chart/line/SolidLine.d.ts.map +1 -0
- package/dts/chart/line/index.d.ts +7 -0
- package/dts/chart/line/index.d.ts.map +1 -0
- package/dts/chart/point/DefaultPointLabel.d.ts +10 -0
- package/dts/chart/point/DefaultPointLabel.d.ts.map +1 -0
- package/dts/chart/point/Point.d.ts +201 -0
- package/dts/chart/point/Point.d.ts.map +1 -0
- package/dts/chart/point/index.d.ts +3 -0
- package/dts/chart/point/index.d.ts.map +1 -0
- package/dts/chart/scrubber/DefaultScrubberBeacon.d.ts +24 -0
- package/dts/chart/scrubber/DefaultScrubberBeacon.d.ts.map +1 -0
- package/dts/chart/scrubber/DefaultScrubberBeaconLabel.d.ts +12 -0
- package/dts/chart/scrubber/DefaultScrubberBeaconLabel.d.ts.map +1 -0
- package/dts/chart/scrubber/DefaultScrubberLabel.d.ts +10 -0
- package/dts/chart/scrubber/DefaultScrubberLabel.d.ts.map +1 -0
- package/dts/chart/scrubber/Scrubber.d.ts +290 -0
- package/dts/chart/scrubber/Scrubber.d.ts.map +1 -0
- package/dts/chart/scrubber/ScrubberBeaconGroup.d.ts +70 -0
- package/dts/chart/scrubber/ScrubberBeaconGroup.d.ts.map +1 -0
- package/dts/chart/scrubber/ScrubberBeaconLabelGroup.d.ts +32 -0
- package/dts/chart/scrubber/ScrubberBeaconLabelGroup.d.ts.map +1 -0
- package/dts/chart/scrubber/ScrubberProvider.d.ts +17 -0
- package/dts/chart/scrubber/ScrubberProvider.d.ts.map +1 -0
- package/dts/chart/scrubber/index.d.ts +5 -0
- package/dts/chart/scrubber/index.d.ts.map +1 -0
- package/dts/chart/text/ChartText.d.ts +117 -0
- package/dts/chart/text/ChartText.d.ts.map +1 -0
- package/dts/chart/text/ChartTextGroup.d.ts +61 -0
- package/dts/chart/text/ChartTextGroup.d.ts.map +1 -0
- package/dts/chart/text/index.d.ts +3 -0
- package/dts/chart/text/index.d.ts.map +1 -0
- package/dts/chart/utils/axis.d.ts +342 -0
- package/dts/chart/utils/axis.d.ts.map +1 -0
- package/dts/chart/utils/bar.d.ts +20 -0
- package/dts/chart/utils/bar.d.ts.map +1 -0
- package/dts/chart/utils/chart.d.ts +117 -0
- package/dts/chart/utils/chart.d.ts.map +1 -0
- package/dts/chart/utils/context.d.ts +101 -0
- package/dts/chart/utils/context.d.ts.map +1 -0
- package/dts/chart/utils/gradient.d.ts +104 -0
- package/dts/chart/utils/gradient.d.ts.map +1 -0
- package/dts/chart/utils/index.d.ts +12 -0
- package/dts/chart/utils/index.d.ts.map +1 -0
- package/dts/chart/utils/interpolate.d.ts +112 -0
- package/dts/chart/utils/interpolate.d.ts.map +1 -0
- package/dts/chart/utils/path.d.ts +130 -0
- package/dts/chart/utils/path.d.ts.map +1 -0
- package/dts/chart/utils/point.d.ts +104 -0
- package/dts/chart/utils/point.d.ts.map +1 -0
- package/dts/chart/utils/scale.d.ts +43 -0
- package/dts/chart/utils/scale.d.ts.map +1 -0
- package/dts/chart/utils/scrubber.d.ts +39 -0
- package/dts/chart/utils/scrubber.d.ts.map +1 -0
- package/dts/chart/utils/transition.d.ts +65 -0
- package/dts/chart/utils/transition.d.ts.map +1 -0
- package/dts/index.d.ts +1 -0
- package/dts/index.d.ts.map +1 -1
- package/dts/sparkline/Sparkline.d.ts +44 -9
- package/dts/sparkline/Sparkline.d.ts.map +1 -1
- package/dts/sparkline/SparklineArea.d.ts +4 -0
- package/dts/sparkline/SparklineArea.d.ts.map +1 -1
- package/dts/sparkline/SparklineAreaPattern.d.ts +5 -0
- package/dts/sparkline/SparklineAreaPattern.d.ts.map +1 -1
- package/dts/sparkline/SparklineGradient.d.ts +5 -0
- package/dts/sparkline/SparklineGradient.d.ts.map +1 -1
- package/dts/sparkline/generateSparklineWithId.d.ts +1 -0
- package/dts/sparkline/generateSparklineWithId.d.ts.map +1 -1
- package/dts/sparkline/sparkline-interactive/SparklineInteractive.d.ts +9 -0
- package/dts/sparkline/sparkline-interactive/SparklineInteractive.d.ts.map +1 -1
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveAnimatedPath.d.ts +3 -0
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveAnimatedPath.d.ts.map +1 -1
- package/dts/sparkline/sparkline-interactive/SparklineInteractivePaths.d.ts +2 -1
- package/dts/sparkline/sparkline-interactive/SparklineInteractivePaths.d.ts.map +1 -1
- package/esm/chart/CartesianChart.css +1 -0
- package/esm/chart/CartesianChart.js +313 -0
- package/esm/chart/ChartProvider.js +10 -0
- package/esm/chart/Path.js +95 -0
- package/esm/chart/PeriodSelector.css +1 -0
- package/esm/chart/PeriodSelector.js +112 -0
- package/esm/chart/area/Area.js +75 -0
- package/esm/chart/area/AreaChart.js +173 -0
- package/esm/chart/area/DottedArea.js +87 -0
- package/esm/chart/area/GradientArea.js +65 -0
- package/esm/chart/area/SolidArea.js +47 -0
- package/esm/chart/area/index.js +7 -0
- package/esm/chart/axis/Axis.js +25 -0
- package/esm/chart/axis/DefaultAxisTickLabel.js +15 -0
- package/esm/chart/axis/XAxis.css +2 -0
- package/esm/chart/axis/XAxis.js +219 -0
- package/esm/chart/axis/YAxis.css +2 -0
- package/esm/chart/axis/YAxis.js +214 -0
- package/esm/chart/axis/index.js +6 -0
- package/esm/chart/bar/Bar.js +61 -0
- package/esm/chart/bar/BarChart.js +130 -0
- package/esm/chart/bar/BarPlot.js +97 -0
- package/esm/chart/bar/BarStack.js +561 -0
- package/esm/chart/bar/BarStackGroup.js +86 -0
- package/esm/chart/bar/DefaultBar.js +61 -0
- package/esm/chart/bar/DefaultBarStack.js +58 -0
- package/esm/chart/bar/index.js +9 -0
- package/esm/chart/gradient/Gradient.js +104 -0
- package/esm/chart/gradient/index.js +1 -0
- package/esm/chart/index.js +15 -0
- package/esm/chart/line/DefaultReferenceLineLabel.js +81 -0
- package/esm/chart/line/DottedLine.js +59 -0
- package/esm/chart/line/Line.js +185 -0
- package/esm/chart/line/LineChart.js +132 -0
- package/esm/chart/line/ReferenceLine.js +140 -0
- package/esm/chart/line/SolidLine.js +55 -0
- package/esm/chart/line/index.js +8 -0
- package/esm/chart/point/DefaultPointLabel.js +44 -0
- package/esm/chart/point/Point.css +2 -0
- package/esm/chart/point/Point.js +180 -0
- package/esm/chart/point/index.js +2 -0
- package/esm/chart/scrubber/DefaultScrubberBeacon.js +155 -0
- package/esm/chart/scrubber/DefaultScrubberBeaconLabel.js +46 -0
- package/esm/chart/scrubber/DefaultScrubberLabel.js +30 -0
- package/esm/chart/scrubber/Scrubber.js +189 -0
- package/esm/chart/scrubber/ScrubberBeaconGroup.js +166 -0
- package/esm/chart/scrubber/ScrubberBeaconLabelGroup.js +186 -0
- package/esm/chart/scrubber/ScrubberProvider.js +228 -0
- package/esm/chart/scrubber/index.js +4 -0
- package/esm/chart/text/ChartText.js +230 -0
- package/esm/chart/text/ChartTextGroup.js +227 -0
- package/esm/chart/text/index.js +4 -0
- package/esm/chart/utils/axis.js +593 -0
- package/esm/chart/utils/bar.js +24 -0
- package/esm/chart/utils/chart.js +255 -0
- package/esm/chart/utils/context.js +15 -0
- package/esm/chart/utils/gradient.js +257 -0
- package/esm/chart/utils/index.js +13 -0
- package/esm/chart/utils/interpolate.js +644 -0
- package/esm/chart/utils/path.js +227 -0
- package/esm/chart/utils/point.js +187 -0
- package/esm/chart/utils/scale.js +48 -0
- package/esm/chart/utils/scrubber.js +132 -0
- package/esm/chart/utils/transition.js +111 -0
- package/esm/index.js +4 -1
- package/esm/sparkline/Sparkline.js +129 -15
- package/esm/sparkline/SparklineArea.js +7 -2
- package/esm/sparkline/SparklineAreaPattern.js +4 -2
- package/esm/sparkline/SparklineGradient.js +16 -58
- package/esm/sparkline/generateSparklineWithId.js +3 -2
- package/esm/sparkline/sparkline-interactive/SparklineInteractive.js +5 -1
- package/esm/sparkline/sparkline-interactive/SparklineInteractiveAnimatedPath.js +5 -2
- package/esm/sparkline/sparkline-interactive/SparklineInteractiveMarkerDates.js +1 -1
- package/esm/sparkline/sparkline-interactive/SparklineInteractivePaths.js +4 -0
- package/package.json +13 -9
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ScrubberBeaconLabelGroup.d.ts","sourceRoot":"","sources":["../../../src/chart/scrubber/ScrubberBeaconLabelGroup.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAG9D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAW9C,OAAO,KAAK,EAAE,4BAA4B,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AAsDzF,MAAM,MAAM,iCAAiC,GAAG,WAAW,GAAG;IAC5D;;OAEG;IACH,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,wBAAwB,EAAE,UAAU,GAAG,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC;IAC9E;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B;;OAEG;IACH,SAAS,CAAC,EAAE,cAAc,CAAC,MAAM,CAAC,CAAC;CACpC,CAAC;AAEF,MAAM,MAAM,6BAA6B,GAAG,iCAAiC,GAAG;IAC9E;;;OAGG;IACH,oBAAoB,CAAC,EAAE,4BAA4B,CAAC;CACrD,CAAC;AAEF,eAAO,MAAM,wBAAwB,qEA0KpC,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type ScrubberContextValue } from '../utils';
|
|
3
|
+
export type ScrubberProviderProps = Partial<
|
|
4
|
+
Pick<ScrubberContextValue, 'enableScrubbing' | 'onScrubberPositionChange'>
|
|
5
|
+
> & {
|
|
6
|
+
children: React.ReactNode;
|
|
7
|
+
/**
|
|
8
|
+
* A reference to the root SVG element, where interaction event handlers will be attached.
|
|
9
|
+
*/
|
|
10
|
+
svgRef: React.RefObject<SVGSVGElement> | null;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* A component which encapsulates the ScrubberContext.
|
|
14
|
+
* It depends on a ChartContext in order to provide accurate mouse tracking.
|
|
15
|
+
*/
|
|
16
|
+
export declare const ScrubberProvider: React.FC<ScrubberProviderProps>;
|
|
17
|
+
//# sourceMappingURL=ScrubberProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ScrubberProvider.d.ts","sourceRoot":"","sources":["../../../src/chart/scrubber/ScrubberProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoD,MAAM,OAAO,CAAC;AAGzE,OAAO,EAAuC,KAAK,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAE1F,MAAM,MAAM,qBAAqB,GAAG,OAAO,CACzC,IAAI,CAAC,oBAAoB,EAAE,iBAAiB,GAAG,0BAA0B,CAAC,CAC3E,GAAG;IACF,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B;;OAEG;IACH,MAAM,EAAE,KAAK,CAAC,SAAS,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC;CAC/C,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,qBAAqB,CAsQ5D,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/chart/scrubber/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,wBAAwB,CAAC;AACvC,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { Rect, SharedProps } from '@coinbase/cds-common/types';
|
|
3
|
+
import { type BoxProps } from '@coinbase/cds-web/layout';
|
|
4
|
+
import { type ChartInset } from '../utils';
|
|
5
|
+
type ValidChartTextChildElements =
|
|
6
|
+
| React.ReactElement<React.SVGProps<SVGTSpanElement>, 'tspan'>
|
|
7
|
+
| React.ReactElement<React.SVGProps<SVGTextPathElement>, 'textPath'>;
|
|
8
|
+
/**
|
|
9
|
+
* The supported content types for ChartText.
|
|
10
|
+
*/
|
|
11
|
+
export type ChartTextChildren =
|
|
12
|
+
| string
|
|
13
|
+
| number
|
|
14
|
+
| null
|
|
15
|
+
| undefined
|
|
16
|
+
| ValidChartTextChildElements
|
|
17
|
+
| ValidChartTextChildElements[];
|
|
18
|
+
/**
|
|
19
|
+
* Horizontal alignment options for chart text.
|
|
20
|
+
*/
|
|
21
|
+
export type TextHorizontalAlignment = 'left' | 'center' | 'right';
|
|
22
|
+
/**
|
|
23
|
+
* Vertical alignment options for chart text.
|
|
24
|
+
*/
|
|
25
|
+
export type TextVerticalAlignment = 'top' | 'middle' | 'bottom';
|
|
26
|
+
export type ChartTextBaseProps = SharedProps & {
|
|
27
|
+
/**
|
|
28
|
+
* The text color.
|
|
29
|
+
* @default 'var(--color-fgMuted)'
|
|
30
|
+
*/
|
|
31
|
+
color?: string;
|
|
32
|
+
/**
|
|
33
|
+
* The background color of the text's background rectangle.
|
|
34
|
+
* @default 'var(--color-bg)' if elevated, otherwise 'transparent'
|
|
35
|
+
*/
|
|
36
|
+
background?: string;
|
|
37
|
+
/**
|
|
38
|
+
* Whether the text should have an elevated appearance with a shadow.
|
|
39
|
+
* @default false
|
|
40
|
+
*/
|
|
41
|
+
elevated?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* When true, disables automatic repositioning to fit within bounds.
|
|
44
|
+
*/
|
|
45
|
+
disableRepositioning?: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Optional bounds rectangle to constrain the text within. If provided, text will be positioned
|
|
48
|
+
* to stay within these bounds. Defaults to the full chart bounds when not provided.
|
|
49
|
+
*/
|
|
50
|
+
bounds?: Rect;
|
|
51
|
+
/**
|
|
52
|
+
* Callback fired when text dimensions change.
|
|
53
|
+
* Used for collision detection and smart positioning.
|
|
54
|
+
* Returns the adjusted position and dimensions.
|
|
55
|
+
*/
|
|
56
|
+
onDimensionsChange?: (rect: Rect) => void;
|
|
57
|
+
/**
|
|
58
|
+
* Inset around the text content for the background rect.
|
|
59
|
+
* Only affects the background, text position remains unchanged.
|
|
60
|
+
*/
|
|
61
|
+
inset?: number | ChartInset;
|
|
62
|
+
/**
|
|
63
|
+
* Border radius for the background rectangle.
|
|
64
|
+
* @default 4
|
|
65
|
+
*/
|
|
66
|
+
borderRadius?: number;
|
|
67
|
+
};
|
|
68
|
+
export type ChartTextProps = ChartTextBaseProps &
|
|
69
|
+
Pick<BoxProps<'g'>, 'font' | 'fontFamily' | 'fontSize' | 'fontWeight' | 'opacity'> & {
|
|
70
|
+
/**
|
|
71
|
+
* The desired x offset in SVG pixels.
|
|
72
|
+
*/
|
|
73
|
+
dx?: number;
|
|
74
|
+
/**
|
|
75
|
+
* The desired y offset in SVG pixels.
|
|
76
|
+
*/
|
|
77
|
+
dy?: number;
|
|
78
|
+
/**
|
|
79
|
+
* The text content to display.
|
|
80
|
+
*/
|
|
81
|
+
children: ChartTextChildren;
|
|
82
|
+
/**
|
|
83
|
+
* The desired x position in SVG pixels.
|
|
84
|
+
* @note Text will be automatically positioned to fit within bounds unless `disableRepositioning` is true.
|
|
85
|
+
*/
|
|
86
|
+
x: number;
|
|
87
|
+
/**
|
|
88
|
+
* The desired y position in SVG pixels.
|
|
89
|
+
* @note Text will be automatically positioned to fit within bounds unless `disableRepositioning` is true.
|
|
90
|
+
*/
|
|
91
|
+
y: number;
|
|
92
|
+
/**
|
|
93
|
+
* Horizontal alignment of the component.
|
|
94
|
+
* @default 'center'
|
|
95
|
+
*/
|
|
96
|
+
horizontalAlignment?: TextHorizontalAlignment;
|
|
97
|
+
/**
|
|
98
|
+
* Vertical alignment of the component.
|
|
99
|
+
* @default 'middle'
|
|
100
|
+
*/
|
|
101
|
+
verticalAlignment?: TextVerticalAlignment;
|
|
102
|
+
style?: React.CSSProperties;
|
|
103
|
+
styles?: {
|
|
104
|
+
root?: React.CSSProperties;
|
|
105
|
+
text?: React.CSSProperties;
|
|
106
|
+
backgroundRect?: React.CSSProperties;
|
|
107
|
+
};
|
|
108
|
+
className?: string;
|
|
109
|
+
classNames?: {
|
|
110
|
+
root?: string;
|
|
111
|
+
text?: string;
|
|
112
|
+
backgroundRect?: string;
|
|
113
|
+
};
|
|
114
|
+
};
|
|
115
|
+
export declare const ChartText: React.NamedExoticComponent<ChartTextProps>;
|
|
116
|
+
export {};
|
|
117
|
+
//# sourceMappingURL=ChartText.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChartText.d.ts","sourceRoot":"","sources":["../../../src/chart/text/ChartText.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqD,MAAM,OAAO,CAAC;AAC1E,OAAO,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAEpE,OAAO,EAAO,KAAK,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAK9D,OAAO,EAAE,KAAK,UAAU,EAAiB,MAAM,UAAU,CAAC;AAE1D,KAAK,2BAA2B,GAC5B,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC,QAAQ,CAAC,eAAe,CAAC,EAAE,OAAO,CAAC,GAC5D,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC,QAAQ,CAAC,kBAAkB,CAAC,EAAE,UAAU,CAAC,CAAC;AAEvE;;GAEG;AACH,MAAM,MAAM,iBAAiB,GACzB,MAAM,GACN,MAAM,GACN,IAAI,GACJ,SAAS,GACT,2BAA2B,GAC3B,2BAA2B,EAAE,CAAC;AAElC;;GAEG;AACH,MAAM,MAAM,uBAAuB,GAAG,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC;AAElE;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG,KAAK,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAEhE,MAAM,MAAM,kBAAkB,GAAG,WAAW,GAAG;IAC7C;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;OAEG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B;;;OAGG;IACH,MAAM,CAAC,EAAE,IAAI,CAAC;IACd;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;IAC1C;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC;IAC5B;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,kBAAkB,GAC7C,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,YAAY,GAAG,UAAU,GAAG,YAAY,GAAG,SAAS,CAAC,GAAG;IACnF;;OAEG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ;;OAEG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ;;OAEG;IACH,QAAQ,EAAE,iBAAiB,CAAC;IAC5B;;;OAGG;IACH,CAAC,EAAE,MAAM,CAAC;IACV;;;OAGG;IACH,CAAC,EAAE,MAAM,CAAC;IACV;;;OAGG;IACH,mBAAmB,CAAC,EAAE,uBAAuB,CAAC;IAC9C;;;OAGG;IACH,iBAAiB,CAAC,EAAE,qBAAqB,CAAC;IAC1C,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IAC5B,MAAM,CAAC,EAAE;QACP,IAAI,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;QAC3B,IAAI,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;QAC3B,cAAc,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;KACtC,CAAC;IACF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE;QACX,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,cAAc,CAAC,EAAE,MAAM,CAAC;KACzB,CAAC;CACH,CAAC;AAkCJ,eAAO,MAAM,SAAS,4CA0MrB,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { type ChartTextChildren, type ChartTextProps } from './ChartText';
|
|
2
|
+
/**
|
|
3
|
+
* Configuration for a single text label in the display list
|
|
4
|
+
*/
|
|
5
|
+
export type TextLabelData = {
|
|
6
|
+
/**
|
|
7
|
+
* The text content to display
|
|
8
|
+
*/
|
|
9
|
+
label: ChartTextChildren;
|
|
10
|
+
/**
|
|
11
|
+
* X coordinate where the text should be positioned
|
|
12
|
+
*/
|
|
13
|
+
x: number;
|
|
14
|
+
/**
|
|
15
|
+
* Y coordinate where the text should be positioned
|
|
16
|
+
*/
|
|
17
|
+
y: number;
|
|
18
|
+
/**
|
|
19
|
+
* Additional props to pass to the ChartText component for this specific label
|
|
20
|
+
*/
|
|
21
|
+
chartTextProps?: Partial<ChartTextProps>;
|
|
22
|
+
};
|
|
23
|
+
export type TextLabelDataWithKey = TextLabelData & {
|
|
24
|
+
key: string;
|
|
25
|
+
};
|
|
26
|
+
export type ChartTextGroupBaseProps = {
|
|
27
|
+
/**
|
|
28
|
+
* Array of text labels to display
|
|
29
|
+
*/
|
|
30
|
+
labels: TextLabelData[];
|
|
31
|
+
/**
|
|
32
|
+
* Minimum gap between labels in pixels
|
|
33
|
+
* @default 8
|
|
34
|
+
*/
|
|
35
|
+
minGap?: number;
|
|
36
|
+
/**
|
|
37
|
+
* Whether to always show first and last labels
|
|
38
|
+
* @default true
|
|
39
|
+
*/
|
|
40
|
+
prioritizeEndLabels?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Common props to apply to all ChartText components
|
|
43
|
+
*/
|
|
44
|
+
chartTextProps?: Partial<ChartTextProps>;
|
|
45
|
+
/**
|
|
46
|
+
* Custom component to render each label
|
|
47
|
+
* @default ChartText
|
|
48
|
+
*/
|
|
49
|
+
LabelComponent?: React.FC<ChartTextProps>;
|
|
50
|
+
};
|
|
51
|
+
export type ChartTextGroupProps = ChartTextGroupBaseProps;
|
|
52
|
+
/**
|
|
53
|
+
* A smart text display component that prevents label overlap through collision detection.
|
|
54
|
+
*
|
|
55
|
+
* This component renders a list of ChartText components and automatically hides overlapping elements
|
|
56
|
+
* to ensure readability.
|
|
57
|
+
*
|
|
58
|
+
* The component focuses solely on overlap prevention logic for better separation of concerns.
|
|
59
|
+
*/
|
|
60
|
+
export declare const ChartTextGroup: import('react').NamedExoticComponent<ChartTextGroupBaseProps>;
|
|
61
|
+
//# sourceMappingURL=ChartTextGroup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChartTextGroup.d.ts","sourceRoot":"","sources":["../../../src/chart/text/ChartTextGroup.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAa,KAAK,iBAAiB,EAAE,KAAK,cAAc,EAAE,MAAM,aAAa,CAAC;AAErF;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B;;OAEG;IACH,KAAK,EAAE,iBAAiB,CAAC;IACzB;;OAEG;IACH,CAAC,EAAE,MAAM,CAAC;IACV;;OAEG;IACH,CAAC,EAAE,MAAM,CAAC;IACV;;OAEG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,CAAC;CAC1C,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG,aAAa,GAAG;IAAE,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC;AAEnE,MAAM,MAAM,uBAAuB,GAAG;IACpC;;OAEG;IACH,MAAM,EAAE,aAAa,EAAE,CAAC;IACxB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B;;OAEG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,CAAC;IACzC;;;OAGG;IACH,cAAc,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CAAC,CAAC;CAC3C,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG,uBAAuB,CAAC;AAiB1D;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc,+DA0M1B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/chart/text/index.ts"],"names":[],"mappings":"AACA,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import type { Rect } from '@coinbase/cds-common/types';
|
|
3
|
+
import { type AxisBounds, type Series } from './chart';
|
|
4
|
+
import { type ChartAxisScaleType, type ChartScaleFunction } from './scale';
|
|
5
|
+
export declare const defaultAxisId = 'DEFAULT_AXIS_ID';
|
|
6
|
+
export declare const defaultAxisScaleType = 'linear';
|
|
7
|
+
/**
|
|
8
|
+
* Axis configuration with computed bounds
|
|
9
|
+
*/
|
|
10
|
+
export type AxisConfig = {
|
|
11
|
+
/** The type of scale to use */
|
|
12
|
+
scaleType: ChartAxisScaleType;
|
|
13
|
+
/**
|
|
14
|
+
* Domain bounds for the axis (data space)
|
|
15
|
+
*/
|
|
16
|
+
domain: AxisBounds;
|
|
17
|
+
/**
|
|
18
|
+
* Range bounds for the axis (visual space in pixels)
|
|
19
|
+
*/
|
|
20
|
+
range: AxisBounds;
|
|
21
|
+
/**
|
|
22
|
+
* Data for the axis
|
|
23
|
+
*/
|
|
24
|
+
data?: string[] | number[];
|
|
25
|
+
/**
|
|
26
|
+
* Padding between categories for band scales (0-1, where 0.1 = 10% spacing)
|
|
27
|
+
* Only used when scaleType is 'band'
|
|
28
|
+
* @default 0.1
|
|
29
|
+
*/
|
|
30
|
+
categoryPadding?: number;
|
|
31
|
+
/**
|
|
32
|
+
* Domain limit type for numeric scales
|
|
33
|
+
* - 'nice': Rounds the domain to human-friendly values
|
|
34
|
+
* - 'strict': Uses the exact min/max values from the data
|
|
35
|
+
*/
|
|
36
|
+
domainLimit: 'nice' | 'strict';
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Axis configuration without computed bounds (used for input)
|
|
40
|
+
*/
|
|
41
|
+
export type AxisConfigProps = Omit<AxisConfig, 'domain' | 'range'> & {
|
|
42
|
+
/**
|
|
43
|
+
* Unique identifier for this axis.
|
|
44
|
+
*/
|
|
45
|
+
id: string;
|
|
46
|
+
/**
|
|
47
|
+
* Domain configuration for the axis (data space).
|
|
48
|
+
*
|
|
49
|
+
* The domainLimit parameter (inherited from AxisConfig) controls how initial domain bounds are calculated:
|
|
50
|
+
* - 'nice' (default for y axes): Rounds the domain to human-friendly values (e.g., 0-100 instead of 1.2-97.8)
|
|
51
|
+
* - 'strict' (default for x axes): Uses the exact min/max values from the data
|
|
52
|
+
*
|
|
53
|
+
* The domain can be:
|
|
54
|
+
* - A partial bounds object to override specific min/max values
|
|
55
|
+
* - A function that receives the limit-processed bounds and allows further customization
|
|
56
|
+
*
|
|
57
|
+
* This allows you to first apply nice/strict processing, then optionally transform the result.
|
|
58
|
+
*/
|
|
59
|
+
domain?: Partial<AxisBounds> | ((bounds: AxisBounds) => AxisBounds);
|
|
60
|
+
/**
|
|
61
|
+
* Range configuration for the axis (visual space in pixels).
|
|
62
|
+
* Can be a partial bounds object to override specific values, or a function that transforms the calculated range.
|
|
63
|
+
*
|
|
64
|
+
* When using a function, it receives the initial calculated range bounds and allows you to adjust them.
|
|
65
|
+
* This replaces the previous rangeOffset approach and provides more flexibility for range customization.
|
|
66
|
+
*/
|
|
67
|
+
range?: Partial<AxisBounds> | ((bounds: AxisBounds) => AxisBounds);
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* Gets a D3 scale based on the axis configuration.
|
|
71
|
+
* Handles both numeric (linear/log) and categorical (band) scales.
|
|
72
|
+
*
|
|
73
|
+
* For numeric scales, the domain limit controls whether bounds are "nice" (human-friendly)
|
|
74
|
+
* or "strict" (exact min/max). Range can be customized using function-based configuration.
|
|
75
|
+
*
|
|
76
|
+
* @param params - Scale parameters
|
|
77
|
+
* @returns The D3 scale function
|
|
78
|
+
* @throws An Error if bounds are invalid
|
|
79
|
+
*/
|
|
80
|
+
export declare const getAxisScale: ({
|
|
81
|
+
config,
|
|
82
|
+
type,
|
|
83
|
+
range,
|
|
84
|
+
dataDomain,
|
|
85
|
+
}: {
|
|
86
|
+
config?: AxisConfig;
|
|
87
|
+
type: 'x' | 'y';
|
|
88
|
+
range: AxisBounds;
|
|
89
|
+
dataDomain: AxisBounds;
|
|
90
|
+
}) => ChartScaleFunction;
|
|
91
|
+
/**
|
|
92
|
+
* Formats the array of user-provided axis configs with default values and validates axis ids.
|
|
93
|
+
* Ensures at least one axis config exists if no input is provided.
|
|
94
|
+
* Requires specific axis ids when there are more than 1 axes.
|
|
95
|
+
* Defaults the axis id for a single axis config if there is no id.
|
|
96
|
+
* @param type - the type of axis, 'x' or 'y'
|
|
97
|
+
* @param axes - array of axis configs or single axis config
|
|
98
|
+
* @param defaultId - the default id to use for the axis
|
|
99
|
+
* @param defaultScaleType - the default scale type to use for the axis
|
|
100
|
+
* @returns array of axis configs with IDs
|
|
101
|
+
*/
|
|
102
|
+
export declare const getAxisConfig: (
|
|
103
|
+
type: 'x' | 'y',
|
|
104
|
+
axes: Partial<AxisConfigProps> | Partial<AxisConfigProps>[] | undefined,
|
|
105
|
+
defaultId?: string,
|
|
106
|
+
defaultScaleType?: ChartAxisScaleType,
|
|
107
|
+
) => AxisConfigProps[];
|
|
108
|
+
/**
|
|
109
|
+
* Calculates the data domain for an axis based on its configuration and series data.
|
|
110
|
+
* Handles both x and y axes, categorical data, custom domain configurations, and stacking.
|
|
111
|
+
*
|
|
112
|
+
* @param axisParam - The axis configuration
|
|
113
|
+
* @param series - Array of series objects (for stacking support)
|
|
114
|
+
* @param axisType - Whether this is an 'x' or 'y' axis
|
|
115
|
+
* @returns The calculated axis bounds
|
|
116
|
+
*/
|
|
117
|
+
export declare const getAxisDomain: (
|
|
118
|
+
axisParam: AxisConfigProps,
|
|
119
|
+
series: Series[],
|
|
120
|
+
axisType: 'x' | 'y',
|
|
121
|
+
) => AxisBounds;
|
|
122
|
+
/**
|
|
123
|
+
* Calculates the visual range for an axis based on the chart rectangle and configuration.
|
|
124
|
+
* Handles custom range configurations including functions and partial bounds.
|
|
125
|
+
*
|
|
126
|
+
* @param axisParam - The axis configuration
|
|
127
|
+
* @param chartRect - The chart drawing area rectangle
|
|
128
|
+
* @param axisType - Whether this is an 'x' or 'y' axis
|
|
129
|
+
* @returns The calculated axis range bounds
|
|
130
|
+
*/
|
|
131
|
+
export declare const getAxisRange: (
|
|
132
|
+
axisParam: AxisConfigProps,
|
|
133
|
+
chartRect: Rect,
|
|
134
|
+
axisType: 'x' | 'y',
|
|
135
|
+
) => AxisBounds;
|
|
136
|
+
/**
|
|
137
|
+
* Options for tick generation behavior
|
|
138
|
+
*/
|
|
139
|
+
type TickGenerationOptions = {
|
|
140
|
+
/**
|
|
141
|
+
* Minimum step size allowed for ticks.
|
|
142
|
+
* Prevents the step from being smaller than this value.
|
|
143
|
+
* @example 1 // Prevents fractional steps like 0.5
|
|
144
|
+
*/
|
|
145
|
+
minStep?: number;
|
|
146
|
+
/**
|
|
147
|
+
* Maximum step size allowed for ticks.
|
|
148
|
+
* Prevents the step from being larger than this value.
|
|
149
|
+
* @example 100 // Prevents steps larger than 100
|
|
150
|
+
*/
|
|
151
|
+
maxStep?: number;
|
|
152
|
+
/**
|
|
153
|
+
* Minimum number of ticks to generate when using tickInterval.
|
|
154
|
+
* @default 4
|
|
155
|
+
*/
|
|
156
|
+
minTickCount?: number;
|
|
157
|
+
};
|
|
158
|
+
export type GetAxisTicksDataProps = {
|
|
159
|
+
/**
|
|
160
|
+
* Custom tick configuration for the axis.
|
|
161
|
+
* - **Array**: Uses these exact values for tick positioning and labels.
|
|
162
|
+
* - For numeric scales: exact values to display
|
|
163
|
+
* - For band scales: category indices to display
|
|
164
|
+
* - **Function**: Filters based on the predicate function.
|
|
165
|
+
* - For numeric scales: filters generated tick values
|
|
166
|
+
* - For band scales: filters category indices
|
|
167
|
+
*/
|
|
168
|
+
ticks?: number[] | ((value: number) => boolean);
|
|
169
|
+
/**
|
|
170
|
+
* The scale function to use for positioning and tick generation.
|
|
171
|
+
* Can be either a numeric scale or a band scale.
|
|
172
|
+
*/
|
|
173
|
+
scaleFunction: ChartScaleFunction;
|
|
174
|
+
/**
|
|
175
|
+
* Requested number of ticks to display (only used for numeric scales).
|
|
176
|
+
* For band/categorical scales, use the `ticks` parameter to control which categories are shown.
|
|
177
|
+
*/
|
|
178
|
+
requestedTickCount?: number;
|
|
179
|
+
/**
|
|
180
|
+
* Categories for band scales
|
|
181
|
+
*/
|
|
182
|
+
categories?: string[];
|
|
183
|
+
/**
|
|
184
|
+
* Possible tick values to filter from when using function-based ticks.
|
|
185
|
+
* Used for discrete data (such as 'band' scale indices).
|
|
186
|
+
*/
|
|
187
|
+
possibleTickValues?: number[];
|
|
188
|
+
/**
|
|
189
|
+
* Interval at which to show ticks in pixels.
|
|
190
|
+
* When provided, calculates tick count based on available space and generates
|
|
191
|
+
* evenly distributed ticks that always include first and last domain values.
|
|
192
|
+
* Only applies to numeric scales and overrides requestedTickCount.
|
|
193
|
+
*
|
|
194
|
+
* @example
|
|
195
|
+
* // For a chart with 400px width, tickInterval: 64 would generate ~6 ticks
|
|
196
|
+
* // evenly distributed across the data range, always including first and last values
|
|
197
|
+
* getAxisTicksData({
|
|
198
|
+
* scaleFunction: numericScale,
|
|
199
|
+
* tickInterval: 32,
|
|
200
|
+
* possibleTickValues: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
|
|
201
|
+
* });
|
|
202
|
+
* // Result: ticks at indices [0, 2, 4, 6, 8, 10] with their corresponding positions
|
|
203
|
+
*/
|
|
204
|
+
tickInterval?: number;
|
|
205
|
+
/**
|
|
206
|
+
* Options for tick generation behavior
|
|
207
|
+
*/
|
|
208
|
+
options?: TickGenerationOptions;
|
|
209
|
+
};
|
|
210
|
+
/**
|
|
211
|
+
* Formats a tick value for display on an axis.
|
|
212
|
+
* Consolidates the identical formatting logic shared between XAxis and YAxis.
|
|
213
|
+
*
|
|
214
|
+
* @param value - The raw tick value to format
|
|
215
|
+
* @param tickFormatter - Optional custom formatter function
|
|
216
|
+
* @returns The formatted tick value as a React node
|
|
217
|
+
*/
|
|
218
|
+
export declare const formatAxisTick: (
|
|
219
|
+
value: any,
|
|
220
|
+
tickFormatter?: (value: any) => React.ReactNode,
|
|
221
|
+
) => React.ReactNode;
|
|
222
|
+
/**
|
|
223
|
+
* Processes tick configuration and returns tick data with positions.
|
|
224
|
+
*
|
|
225
|
+
* **Parameter Precedence by Scale Type:**
|
|
226
|
+
*
|
|
227
|
+
* **For Numeric Scales (linear/log):**
|
|
228
|
+
* 1. `ticks` (array) - Explicit tick values override all other options
|
|
229
|
+
* 2. `ticks` (function) - Filter function for tick selection
|
|
230
|
+
* 3. `ticks` (boolean) - Show/hide all possible ticks
|
|
231
|
+
* 4. `requestedTickCount` - D3 automatic tick generation (overrides tickInterval)
|
|
232
|
+
* 5. `tickInterval` - Pixel-based spacing (fallback)
|
|
233
|
+
*
|
|
234
|
+
* **For Categorical Scales (band):**
|
|
235
|
+
* 1. `ticks` (array) - Explicit category indices to display
|
|
236
|
+
* 2. `ticks` (function) - Filter function for category selection
|
|
237
|
+
* 3. `ticks` (boolean) - Show/hide all categories
|
|
238
|
+
* 4. Default - Show all categories (requestedTickCount and tickInterval are ignored)
|
|
239
|
+
*
|
|
240
|
+
* @param params - Tick processing parameters
|
|
241
|
+
* @param params.ticks - Custom tick configuration with multiple formats:
|
|
242
|
+
* - **Array**: For numeric scales: exact tick values; For band scales: category indices
|
|
243
|
+
* - **Function**: Predicate to filter tick values or category indices
|
|
244
|
+
* - **Boolean**: Show all (true) or no ticks (false) for both scale types
|
|
245
|
+
* @param params.scaleFunction - D3 scale function (numeric or band scale)
|
|
246
|
+
* @param params.requestedTickCount - Number of ticks for D3 generation (**numeric scales only**, overrides tickInterval)
|
|
247
|
+
* @param params.categories - Category labels (**band scales only**)
|
|
248
|
+
* @param params.possibleTickValues - Available tick values for filtering/selection (**numeric scales only**)
|
|
249
|
+
* @param params.tickInterval - Pixel spacing between ticks (**numeric scales only**, fallback option)
|
|
250
|
+
* @returns Array of tick data with values and positions
|
|
251
|
+
*
|
|
252
|
+
* @example
|
|
253
|
+
* // Basic usage with tickInterval for pixel-based spacing
|
|
254
|
+
* import { scaleLinear } from 'd3-scale';
|
|
255
|
+
*
|
|
256
|
+
* const numericScale = scaleLinear().domain([0, 10]).range([0, 400]);
|
|
257
|
+
* const result = getAxisTicksData({
|
|
258
|
+
* scaleFunction: numericScale,
|
|
259
|
+
* tickInterval: 80, // 80 pixels between ticks
|
|
260
|
+
* possibleTickValues: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
|
|
261
|
+
* });
|
|
262
|
+
* // Returns: [
|
|
263
|
+
* // { tick: 0, position: 0 }, // Always includes first
|
|
264
|
+
* // { tick: 2, position: 80 },
|
|
265
|
+
* // { tick: 5, position: 200 },
|
|
266
|
+
* // { tick: 7, position: 280 },
|
|
267
|
+
* // { tick: 10, position: 400 } // Always includes last
|
|
268
|
+
* // ]
|
|
269
|
+
*
|
|
270
|
+
* @example
|
|
271
|
+
* // Using requestedTickCount for D3-generated ticks
|
|
272
|
+
* const result = getAxisTicksData({
|
|
273
|
+
* scaleFunction: numericScale,
|
|
274
|
+
* requestedTickCount: 5
|
|
275
|
+
* });
|
|
276
|
+
* // Uses D3's tick generation algorithm
|
|
277
|
+
*
|
|
278
|
+
* @example
|
|
279
|
+
* // Using explicit tick values
|
|
280
|
+
* const result = getAxisTicksData({
|
|
281
|
+
* scaleFunction: numericScale,
|
|
282
|
+
* ticks: [0, 2.5, 5, 7.5, 10]
|
|
283
|
+
* });
|
|
284
|
+
* // Returns exact positions for specified values
|
|
285
|
+
*
|
|
286
|
+
* @example
|
|
287
|
+
* // Using tick filter function
|
|
288
|
+
* const result = getAxisTicksData({
|
|
289
|
+
* scaleFunction: numericScale,
|
|
290
|
+
* ticks: (value) => value % 2 === 0, // Only even numbers
|
|
291
|
+
* possibleTickValues: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
|
|
292
|
+
* });
|
|
293
|
+
* // Returns: [0, 2, 4, 6, 8, 10] with their positions
|
|
294
|
+
*
|
|
295
|
+
* @example
|
|
296
|
+
* // Band scale with categories (requestedTickCount and tickInterval are ignored)
|
|
297
|
+
* import { scaleBand } from 'd3-scale';
|
|
298
|
+
*
|
|
299
|
+
* const bandScale = scaleBand().domain([0, 1, 2, 3, 4]).range([0, 400]).padding(0.1);
|
|
300
|
+
* const result = getAxisTicksData({
|
|
301
|
+
* scaleFunction: bandScale,
|
|
302
|
+
* categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May'],
|
|
303
|
+
* ticks: [0, 2, 4], // Show only Jan (index 0), Mar (index 2), May (index 4)
|
|
304
|
+
* requestedTickCount: 10, // IGNORED for band scales
|
|
305
|
+
* tickInterval: 50 // IGNORED for band scales
|
|
306
|
+
* });
|
|
307
|
+
* // Returns tick positions centered in each selected band
|
|
308
|
+
*/
|
|
309
|
+
export declare const getAxisTicksData: ({
|
|
310
|
+
ticks,
|
|
311
|
+
scaleFunction,
|
|
312
|
+
requestedTickCount,
|
|
313
|
+
categories,
|
|
314
|
+
possibleTickValues,
|
|
315
|
+
tickInterval,
|
|
316
|
+
options,
|
|
317
|
+
}: GetAxisTicksDataProps) => Array<{
|
|
318
|
+
tick: number;
|
|
319
|
+
position: number;
|
|
320
|
+
}>;
|
|
321
|
+
export type RegisteredAxis = {
|
|
322
|
+
id: string;
|
|
323
|
+
position: 'top' | 'bottom' | 'left' | 'right';
|
|
324
|
+
size: number;
|
|
325
|
+
};
|
|
326
|
+
/**
|
|
327
|
+
* Calculates the total amount of padding needed to render a set of axes on the main drawing area of the chart.
|
|
328
|
+
* Returns the registed axes, an API for adding/removing axes as well as the total calculated padding that must be reserved in the drawing area.
|
|
329
|
+
*/
|
|
330
|
+
export declare const useTotalAxisPadding: () => {
|
|
331
|
+
renderedAxes: Map<string, RegisteredAxis>;
|
|
332
|
+
axisPadding: {
|
|
333
|
+
top: number;
|
|
334
|
+
right: number;
|
|
335
|
+
bottom: number;
|
|
336
|
+
left: number;
|
|
337
|
+
};
|
|
338
|
+
registerAxis: (id: string, position: 'top' | 'bottom' | 'left' | 'right', size: number) => void;
|
|
339
|
+
unregisterAxis: (id: string) => void;
|
|
340
|
+
};
|
|
341
|
+
export {};
|
|
342
|
+
//# sourceMappingURL=axis.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"axis.d.ts","sourceRoot":"","sources":["../../../src/chart/utils/axis.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calculates the size adjustment needed for bars when accounting for gaps between them.
|
|
3
|
+
* This function helps determine how much to reduce each bar's width to accommodate
|
|
4
|
+
* the specified gap size between multiple bars in a group.
|
|
5
|
+
*
|
|
6
|
+
* @param barCount - The number of bars in the group
|
|
7
|
+
* @param gapSize - The desired gap size between bars
|
|
8
|
+
* @returns The amount to reduce each bar's size by, or 0 if there's only one bar
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* // For 3 bars with 12px gaps, each bar should be reduced by 8px
|
|
13
|
+
* const adjustment = getBarSizeAdjustment(3, 12);
|
|
14
|
+
*
|
|
15
|
+
* // Single bar needs no adjustment
|
|
16
|
+
* const singleBarAdjustment = getBarSizeAdjustment(1, 10);
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export declare function getBarSizeAdjustment(barCount: number, gapSize: number): number;
|
|
20
|
+
//# sourceMappingURL=bar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bar.d.ts","sourceRoot":"","sources":["../../../src/chart/utils/bar.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAM9E"}
|