@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,117 @@
|
|
|
1
|
+
import type { GradientDefinition } from './gradient';
|
|
2
|
+
export declare const defaultStackId = 'DEFAULT_STACK_ID';
|
|
3
|
+
export type AxisBounds = {
|
|
4
|
+
min: number;
|
|
5
|
+
max: number;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Type guard to check if bounds are complete with both min and max values.
|
|
9
|
+
* @param bounds - The bounds to validate
|
|
10
|
+
* @returns True if bounds has both min and max defined
|
|
11
|
+
*/
|
|
12
|
+
export declare const isValidBounds: (bounds: Partial<AxisBounds>) => bounds is AxisBounds;
|
|
13
|
+
export type Series = {
|
|
14
|
+
/**
|
|
15
|
+
* Id of the series.
|
|
16
|
+
*/
|
|
17
|
+
id: string;
|
|
18
|
+
/**
|
|
19
|
+
* Data array for this series. Use null values to create gaps in the visualization.
|
|
20
|
+
*
|
|
21
|
+
* Can be either:
|
|
22
|
+
* - Array of numbers: `[10, -5, 20]`
|
|
23
|
+
* - Array of tuples: `[[0, 10], [0, -5], [0, 20]]` [baseline, value] pairs
|
|
24
|
+
*/
|
|
25
|
+
data?: Array<number | null> | Array<[number, number] | null>;
|
|
26
|
+
/**
|
|
27
|
+
* Label of the series.
|
|
28
|
+
* Used for scrubber beacon labels.
|
|
29
|
+
*/
|
|
30
|
+
label?: string;
|
|
31
|
+
/**
|
|
32
|
+
* Color of the series.
|
|
33
|
+
* If gradient is provided, that will be used for chart components
|
|
34
|
+
* Color will still be used by scrubber beacon labels
|
|
35
|
+
*/
|
|
36
|
+
color?: string;
|
|
37
|
+
/**
|
|
38
|
+
* Color gradient configuration.
|
|
39
|
+
* Takes precedence over color except for scrubber beacon labels.
|
|
40
|
+
*/
|
|
41
|
+
gradient?: GradientDefinition;
|
|
42
|
+
/**
|
|
43
|
+
* Id of the y-axis this series uses.
|
|
44
|
+
* Defaults to defaultAxisId if not specified.
|
|
45
|
+
*/
|
|
46
|
+
yAxisId?: string;
|
|
47
|
+
/**
|
|
48
|
+
* Id of the stack group this series belongs to.
|
|
49
|
+
* Series with the same stackId value will be stacked together.
|
|
50
|
+
* If not specified, the series will not be stacked.
|
|
51
|
+
*/
|
|
52
|
+
stackId?: string;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Calculates the domain of a chart from series data.
|
|
56
|
+
* Domain represents the range of x-values from the data.
|
|
57
|
+
*/
|
|
58
|
+
export declare const getChartDomain: (
|
|
59
|
+
series: Series[],
|
|
60
|
+
min?: number,
|
|
61
|
+
max?: number,
|
|
62
|
+
) => Partial<AxisBounds>;
|
|
63
|
+
/**
|
|
64
|
+
* Transforms series data into stacked data using D3's stack algorithm.
|
|
65
|
+
* Returns a map of series ID to transformed [baseline, value] tuples.
|
|
66
|
+
*
|
|
67
|
+
* @param series - Array of series with potential stack properties
|
|
68
|
+
* @returns Map of series ID to stacked data arrays
|
|
69
|
+
*/
|
|
70
|
+
export declare const getStackedSeriesData: (
|
|
71
|
+
series: Series[],
|
|
72
|
+
) => Map<string, Array<[number, number] | null>>;
|
|
73
|
+
/**
|
|
74
|
+
* Extracts line data values from series data that may contain tuples.
|
|
75
|
+
* For tuple data [[baseline, value]], extracts the last value.
|
|
76
|
+
* For numeric data [value], returns as-is.
|
|
77
|
+
*
|
|
78
|
+
* @param data - Array of numbers, tuples, or null values
|
|
79
|
+
* @returns Array of numbers or null values
|
|
80
|
+
*/
|
|
81
|
+
export declare const getLineData: (
|
|
82
|
+
data?: Array<number | null> | Array<[number, number] | null>,
|
|
83
|
+
) => Array<number | null>;
|
|
84
|
+
/**
|
|
85
|
+
* Calculates the range of a chart from series data.
|
|
86
|
+
* Range represents the range of y-values from the data.
|
|
87
|
+
* Handles stacking by transforming data when series have stack properties.
|
|
88
|
+
*/
|
|
89
|
+
export declare const getChartRange: (
|
|
90
|
+
series: Series[],
|
|
91
|
+
min?: number,
|
|
92
|
+
max?: number,
|
|
93
|
+
) => Partial<AxisBounds>;
|
|
94
|
+
export type ChartInset = {
|
|
95
|
+
top: number;
|
|
96
|
+
left: number;
|
|
97
|
+
bottom: number;
|
|
98
|
+
right: number;
|
|
99
|
+
};
|
|
100
|
+
export declare const defaultChartInset: ChartInset;
|
|
101
|
+
/**
|
|
102
|
+
* Normalize padding to include all sides with a value.
|
|
103
|
+
* @param padding - The padding to get.
|
|
104
|
+
* @param defaults - Optional complete default values to use instead of 0.
|
|
105
|
+
* @returns The calculated padding.
|
|
106
|
+
*/
|
|
107
|
+
/**
|
|
108
|
+
* Normalize inset to include all sides with a value.
|
|
109
|
+
* @param inset - The inset to get.
|
|
110
|
+
* @param defaults - Optional complete default values to use instead of 0.
|
|
111
|
+
* @returns The calculated inset.
|
|
112
|
+
*/
|
|
113
|
+
export declare const getChartInset: (
|
|
114
|
+
inset?: number | Partial<ChartInset>,
|
|
115
|
+
defaults?: ChartInset,
|
|
116
|
+
) => ChartInset;
|
|
117
|
+
//# sourceMappingURL=chart.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chart.d.ts","sourceRoot":"","sources":["../../../src/chart/utils/chart.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAErD,eAAO,MAAM,cAAc,qBAAqB,CAAC;AAEjD,MAAM,MAAM,UAAU,GAAG;IACvB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,aAAa,GAAI,QAAQ,OAAO,CAAC,UAAU,CAAC,KAAG,MAAM,IAAI,UAChB,CAAC;AAEvD,MAAM,MAAM,MAAM,GAAG;IACnB;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IACX;;;;;;OAMG;IACH,IAAI,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC;IAC7D;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,QAAQ,CAAC,EAAE,kBAAkB,CAAC;IAC9B;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,cAAc,GACzB,QAAQ,MAAM,EAAE,EAChB,MAAM,MAAM,EACZ,MAAM,MAAM,KACX,OAAO,CAAC,UAAU,CAoBpB,CAAC;AAcF;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,GAC/B,QAAQ,MAAM,EAAE,KACf,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC,CA0E5C,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,WAAW,GACtB,OAAO,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC,KAC3D,KAAK,CAAC,MAAM,GAAG,IAAI,CAerB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,aAAa,GACxB,QAAQ,MAAM,EAAE,EAChB,MAAM,MAAM,EACZ,MAAM,MAAM,KACX,OAAO,CAAC,UAAU,CA2EpB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACvB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,UAK/B,CAAC;AAEF;;;;;GAKG;AACH;;;;;GAKG;AACH,eAAO,MAAM,aAAa,GACxB,QAAQ,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,EACpC,WAAW,UAAU,KACpB,UAuBF,CAAC"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import type { Rect } from '@coinbase/cds-common/types';
|
|
2
|
+
import type { AxisConfig } from './axis';
|
|
3
|
+
import type { Series } from './chart';
|
|
4
|
+
import type { ChartScaleFunction } from './scale';
|
|
5
|
+
/**
|
|
6
|
+
* Context value for Cartesian (X/Y) coordinate charts.
|
|
7
|
+
* Contains axis-specific methods and properties for rectangular coordinate systems.
|
|
8
|
+
*/
|
|
9
|
+
export type CartesianChartContextValue = {
|
|
10
|
+
/**
|
|
11
|
+
* The series data for the chart.
|
|
12
|
+
*/
|
|
13
|
+
series: Series[];
|
|
14
|
+
/**
|
|
15
|
+
* Returns the series which matches the seriesId or undefined.
|
|
16
|
+
* @param seriesId - A series' id
|
|
17
|
+
*/
|
|
18
|
+
getSeries: (seriesId?: string) => Series | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* Returns the data for a series
|
|
21
|
+
* @param seriesId - A series' id
|
|
22
|
+
* @returns data for series, if series exists
|
|
23
|
+
*/
|
|
24
|
+
getSeriesData: (seriesId?: string) => Array<[number, number] | null> | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* Whether to animate the chart.
|
|
27
|
+
*/
|
|
28
|
+
animate: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Width of the chart SVG.
|
|
31
|
+
*/
|
|
32
|
+
width: number;
|
|
33
|
+
/**
|
|
34
|
+
* Height of the chart SVG.
|
|
35
|
+
*/
|
|
36
|
+
height: number;
|
|
37
|
+
/**
|
|
38
|
+
* Get x-axis configuration.
|
|
39
|
+
*/
|
|
40
|
+
getXAxis: () => AxisConfig | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* Get y-axis configuration by ID.
|
|
43
|
+
* @param id - The axis ID. Defaults to defaultAxisId.
|
|
44
|
+
*/
|
|
45
|
+
getYAxis: (id?: string) => AxisConfig | undefined;
|
|
46
|
+
/**
|
|
47
|
+
* Get x-axis scale function.
|
|
48
|
+
*/
|
|
49
|
+
getXScale: () => ChartScaleFunction | undefined;
|
|
50
|
+
/**
|
|
51
|
+
* Get y-axis scale function by ID.
|
|
52
|
+
* @param id - The axis ID. Defaults to defaultAxisId.
|
|
53
|
+
*/
|
|
54
|
+
getYScale: (id?: string) => ChartScaleFunction | undefined;
|
|
55
|
+
/**
|
|
56
|
+
* Drawing area of the chart.
|
|
57
|
+
*/
|
|
58
|
+
drawingArea: Rect;
|
|
59
|
+
/**
|
|
60
|
+
* Length of the data domain.
|
|
61
|
+
* This is equal to the length of xAxis.data or the longest series data length
|
|
62
|
+
* This equals the number of possible scrubber positions
|
|
63
|
+
*/
|
|
64
|
+
dataLength: number;
|
|
65
|
+
/**
|
|
66
|
+
* Registers an axis.
|
|
67
|
+
* Used by axis components to reserve space in the chart, preventing overlap with the drawing area.
|
|
68
|
+
* @param id - The axis ID
|
|
69
|
+
* @param position - The axis position ('top'/'bottom' for x-axis, 'left'/'right' for y-axis)
|
|
70
|
+
* @param size - The size of the axis in pixels
|
|
71
|
+
*/
|
|
72
|
+
registerAxis: (id: string, position: 'top' | 'bottom' | 'left' | 'right', size: number) => void;
|
|
73
|
+
/**
|
|
74
|
+
* Unregisters an axis.
|
|
75
|
+
*/
|
|
76
|
+
unregisterAxis: (id: string) => void;
|
|
77
|
+
/**
|
|
78
|
+
* Gets the rectangle bounds of a requested axis.
|
|
79
|
+
* Computes the bounds of the axis based on the chart's drawing area chart/axis config, and axis position.
|
|
80
|
+
*/
|
|
81
|
+
getAxisBounds: (id: string) => Rect | undefined;
|
|
82
|
+
};
|
|
83
|
+
export type ScrubberContextValue = {
|
|
84
|
+
/**
|
|
85
|
+
* Enables scrubbing interactions.
|
|
86
|
+
* When true, allows scrubbing and makes scrubber components interactive.
|
|
87
|
+
*/
|
|
88
|
+
enableScrubbing: boolean;
|
|
89
|
+
/**
|
|
90
|
+
* The current position of the scrubber.
|
|
91
|
+
*/
|
|
92
|
+
scrubberPosition?: number;
|
|
93
|
+
/**
|
|
94
|
+
* Callback fired when the scrubber position changes.
|
|
95
|
+
* Receives the dataIndex of the scrubber or undefined when not scrubbing.
|
|
96
|
+
*/
|
|
97
|
+
onScrubberPositionChange: (index: number | undefined) => void;
|
|
98
|
+
};
|
|
99
|
+
export declare const ScrubberContext: import('react').Context<ScrubberContextValue | undefined>;
|
|
100
|
+
export declare const useScrubberContext: () => ScrubberContextValue;
|
|
101
|
+
//# sourceMappingURL=context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/chart/utils/context.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAEvD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACzC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAElD;;;GAGG;AACH,MAAM,MAAM,0BAA0B,GAAG;IACvC;;OAEG;IACH,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB;;;OAGG;IACH,SAAS,EAAE,CAAC,QAAQ,CAAC,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAC;IACrD;;;;OAIG;IACH,aAAa,EAAE,CAAC,QAAQ,CAAC,EAAE,MAAM,KAAK,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,SAAS,CAAC;IACjF;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC;IACjB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,QAAQ,EAAE,MAAM,UAAU,GAAG,SAAS,CAAC;IACvC;;;OAGG;IACH,QAAQ,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,KAAK,UAAU,GAAG,SAAS,CAAC;IAClD;;OAEG;IACH,SAAS,EAAE,MAAM,kBAAkB,GAAG,SAAS,CAAC;IAChD;;;OAGG;IACH,SAAS,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,KAAK,kBAAkB,GAAG,SAAS,CAAC;IAC3D;;OAEG;IACH,WAAW,EAAE,IAAI,CAAC;IAClB;;;;OAIG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB;;;;;;OAMG;IACH,YAAY,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAChG;;OAEG;IACH,cAAc,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IACrC;;;OAGG;IACH,aAAa,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,GAAG,SAAS,CAAC;CACjD,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC;;;OAGG;IACH,eAAe,EAAE,OAAO,CAAC;IACzB;;OAEG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;;OAGG;IACH,wBAAwB,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI,CAAC;CAC/D,CAAC;AAEF,eAAO,MAAM,eAAe,2DAA6D,CAAC;AAE1F,eAAO,MAAM,kBAAkB,QAAO,oBAMrC,CAAC"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import type { AxisBounds } from './chart';
|
|
2
|
+
import { type ChartScaleFunction } from './scale';
|
|
3
|
+
/**
|
|
4
|
+
* Defines a color transition point in the gradient
|
|
5
|
+
*/
|
|
6
|
+
export type GradientStop = {
|
|
7
|
+
/**
|
|
8
|
+
* Position in data space.
|
|
9
|
+
* Multiple stops at the same offset create hard color transitions.
|
|
10
|
+
*/
|
|
11
|
+
offset: number;
|
|
12
|
+
/** Color at the stop (any valid CSS color) */
|
|
13
|
+
color: string;
|
|
14
|
+
/** Optional opacity (0-1). Defaults to 1. */
|
|
15
|
+
opacity?: number;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Defines a gradient.
|
|
19
|
+
*/
|
|
20
|
+
export type GradientDefinition = {
|
|
21
|
+
/**
|
|
22
|
+
* Axis that the gradient maps to.
|
|
23
|
+
* @default 'y'
|
|
24
|
+
*/
|
|
25
|
+
axis?: 'x' | 'y';
|
|
26
|
+
/**
|
|
27
|
+
* Gradient stops with colors and positions.
|
|
28
|
+
* Can be an array of stop objects or a function that receives domain bounds.
|
|
29
|
+
*/
|
|
30
|
+
stops: GradientStop[] | ((domain: AxisBounds) => GradientStop[]);
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Evaluates the color at a specific data value based on the gradient stops, ignoring opacity.
|
|
34
|
+
* @param stops - The gradient stops configuration
|
|
35
|
+
* @param dataValue - The data value to evaluate (for band scales, this is the index)
|
|
36
|
+
* @param scale - The scale to use for value mapping (handles log scales correctly)
|
|
37
|
+
* @returns The color string at this data value, or undefined if invalid
|
|
38
|
+
*/
|
|
39
|
+
export declare const evaluateGradientAtValue: (
|
|
40
|
+
stops: GradientStop[],
|
|
41
|
+
dataValue: number,
|
|
42
|
+
scale: ChartScaleFunction,
|
|
43
|
+
) => string | undefined;
|
|
44
|
+
/**
|
|
45
|
+
* Creates a gradient configuration for SVG components.
|
|
46
|
+
* Processes a GradientDefinition into a renderable GradientConfig.
|
|
47
|
+
* Supports both numeric scales (linear, log) and categorical scales (band).
|
|
48
|
+
*
|
|
49
|
+
* @param gradient - GradientDefinition configuration (required)
|
|
50
|
+
* @param xScale - X-axis scale (required)
|
|
51
|
+
* @param yScale - Y-axis scale (required)
|
|
52
|
+
* @returns GradientConfig or null if gradient processing fails
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* const gradientConfig = useMemo(() => {
|
|
56
|
+
* if (!gradient || !xScale || !yScale) return;
|
|
57
|
+
* return getGradientConfig(gradient, xScale, yScale);
|
|
58
|
+
* }, [gradient, xScale, yScale]);
|
|
59
|
+
*
|
|
60
|
+
* if (gradientConfig) {
|
|
61
|
+
* return (
|
|
62
|
+
* <defs>
|
|
63
|
+
* <Gradient
|
|
64
|
+
* config={gradientConfig}
|
|
65
|
+
* direction={gradient.axis === 'x' ? 'horizontal' : 'vertical'}
|
|
66
|
+
* id={gradientId}
|
|
67
|
+
* />
|
|
68
|
+
* </defs>
|
|
69
|
+
* );
|
|
70
|
+
* }
|
|
71
|
+
*/
|
|
72
|
+
export declare const getGradientConfig: (
|
|
73
|
+
gradient: GradientDefinition,
|
|
74
|
+
xScale: ChartScaleFunction,
|
|
75
|
+
yScale: ChartScaleFunction,
|
|
76
|
+
) => GradientStop[] | undefined;
|
|
77
|
+
/**
|
|
78
|
+
* Determines the baseline value for the gradient area by finding the value
|
|
79
|
+
* within the axis bounds that is closest to the target baseline.
|
|
80
|
+
*
|
|
81
|
+
* @param axisBounds - The min and max bounds of the axis
|
|
82
|
+
* @param baseline - The target baseline value (defaults to 0)
|
|
83
|
+
* @returns The value within bounds closest to the baseline
|
|
84
|
+
*/
|
|
85
|
+
export declare const getBaseline: (axisBounds: AxisBounds, baseline?: number) => number;
|
|
86
|
+
/**
|
|
87
|
+
* Generates a gradient definition for the area chart based on the axis bounds
|
|
88
|
+
* and styling parameters. Ensures gradient stops are in ascending order.
|
|
89
|
+
*
|
|
90
|
+
* @param axisBounds - The min and max bounds of the axis
|
|
91
|
+
* @param baselineValue - The baseline value for the gradient
|
|
92
|
+
* @param fill - The color to use for the gradient
|
|
93
|
+
* @param peakOpacity - Opacity at the peak of the gradient
|
|
94
|
+
* @param baselineOpacity - Opacity at the baseline
|
|
95
|
+
* @returns A gradient definition with y-axis stops in ascending order
|
|
96
|
+
*/
|
|
97
|
+
export declare const createGradient: (
|
|
98
|
+
axisBounds: AxisBounds,
|
|
99
|
+
baselineValue: number,
|
|
100
|
+
fill: string,
|
|
101
|
+
peakOpacity: number,
|
|
102
|
+
baselineOpacity: number,
|
|
103
|
+
) => GradientDefinition;
|
|
104
|
+
//# sourceMappingURL=gradient.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gradient.d.ts","sourceRoot":"","sources":["../../../src/chart/utils/gradient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,EAAE,KAAK,kBAAkB,EAAsB,MAAM,SAAS,CAAC;AAEtE;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAC;IACf,+CAA+C;IAC/C,KAAK,EAAE,MAAM,CAAC;IACd,6CAA6C;IAC7C,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B;;;OAGG;IACH,IAAI,CAAC,EAAE,GAAG,GAAG,GAAG,CAAC;IACjB;;;OAGG;IACH,KAAK,EAAE,YAAY,EAAE,GAAG,CAAC,CAAC,MAAM,EAAE,UAAU,KAAK,YAAY,EAAE,CAAC,CAAC;CAClE,CAAC;AA8DF;;;;;;GAMG;AACH,eAAO,MAAM,uBAAuB,GAClC,OAAO,YAAY,EAAE,EACrB,WAAW,MAAM,EACjB,OAAO,kBAAkB,KACxB,MAAM,GAAG,SAiEX,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,iBAAiB,GAC5B,UAAU,kBAAkB,EAC5B,QAAQ,kBAAkB,EAC1B,QAAQ,kBAAkB,KACzB,YAAY,EAAE,GAAG,SAqBnB,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,WAAW,GAAI,YAAY,UAAU,EAAE,WAAU,MAAU,KAAG,MAc1E,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,cAAc,GACzB,YAAY,UAAU,EACtB,eAAe,MAAM,EACrB,MAAM,MAAM,EACZ,aAAa,MAAM,EACnB,iBAAiB,MAAM,KACtB,kBA0BF,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export * from './axis';
|
|
2
|
+
export * from './bar';
|
|
3
|
+
export * from './chart';
|
|
4
|
+
export * from './context';
|
|
5
|
+
export * from './gradient';
|
|
6
|
+
export * from './interpolate';
|
|
7
|
+
export * from './path';
|
|
8
|
+
export * from './point';
|
|
9
|
+
export * from './scale';
|
|
10
|
+
export * from './scrubber';
|
|
11
|
+
export * from './transition';
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/chart/utils/index.ts"],"names":[],"mappings":"AACA,cAAc,QAAQ,CAAC;AACvB,cAAc,OAAO,CAAC;AACtB,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
type CommandType =
|
|
2
|
+
| 'M'
|
|
3
|
+
| 'L'
|
|
4
|
+
| 'H'
|
|
5
|
+
| 'V'
|
|
6
|
+
| 'C'
|
|
7
|
+
| 'S'
|
|
8
|
+
| 'Q'
|
|
9
|
+
| 'T'
|
|
10
|
+
| 'A'
|
|
11
|
+
| 'Z'
|
|
12
|
+
| 'm'
|
|
13
|
+
| 'l'
|
|
14
|
+
| 'h'
|
|
15
|
+
| 'v'
|
|
16
|
+
| 'c'
|
|
17
|
+
| 's'
|
|
18
|
+
| 'q'
|
|
19
|
+
| 't'
|
|
20
|
+
| 'a'
|
|
21
|
+
| 'z';
|
|
22
|
+
type PathCommand = {
|
|
23
|
+
type: CommandType;
|
|
24
|
+
x?: number;
|
|
25
|
+
y?: number;
|
|
26
|
+
x1?: number;
|
|
27
|
+
y1?: number;
|
|
28
|
+
x2?: number;
|
|
29
|
+
y2?: number;
|
|
30
|
+
rx?: number;
|
|
31
|
+
ry?: number;
|
|
32
|
+
xAxisRotation?: number;
|
|
33
|
+
largeArcFlag?: number;
|
|
34
|
+
sweepFlag?: number;
|
|
35
|
+
[key: string]: any;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Convert command objects to arrays of points, run de Casteljau's algorithm on it
|
|
39
|
+
* to split into to the desired number of segments.
|
|
40
|
+
*
|
|
41
|
+
* @param {Object} commandStart The start command object
|
|
42
|
+
* @param {Object} commandEnd The end command object
|
|
43
|
+
* @param {Number} segmentCount The number of segments to create
|
|
44
|
+
* @return {Object[]} An array of commands representing the segments in sequence
|
|
45
|
+
*/
|
|
46
|
+
export declare function splitCurve(
|
|
47
|
+
commandStart: PathCommand,
|
|
48
|
+
commandEnd: PathCommand,
|
|
49
|
+
segmentCount?: number,
|
|
50
|
+
): PathCommand[];
|
|
51
|
+
type ExcludeSegmentFn = (commandStart: PathCommand, commandEnd: PathCommand) => boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Takes a path `d` string and converts it into an array of command
|
|
54
|
+
* objects. Drops the `Z` character.
|
|
55
|
+
*
|
|
56
|
+
* @param {String|null} d A path `d` string
|
|
57
|
+
*/
|
|
58
|
+
export declare function pathCommandsFromString(d: string | null | undefined): PathCommand[];
|
|
59
|
+
type InterpolateOptions = {
|
|
60
|
+
excludeSegment?: ExcludeSegmentFn;
|
|
61
|
+
snapEndsToInput?: boolean;
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Interpolate from A to B by extending A and B during interpolation to have
|
|
65
|
+
* the same number of points. This allows for a smooth transition when they
|
|
66
|
+
* have a different number of points.
|
|
67
|
+
*
|
|
68
|
+
* Ignores the `Z` command in paths unless both A and B end with it.
|
|
69
|
+
*
|
|
70
|
+
* This function works directly with arrays of command objects instead of with
|
|
71
|
+
* path `d` strings (see interpolatePath for working with `d` strings).
|
|
72
|
+
*
|
|
73
|
+
* @param {Object[]} aCommandsInput Array of path commands
|
|
74
|
+
* @param {Object[]} bCommandsInput Array of path commands
|
|
75
|
+
* @param {(Function|Object)} interpolateOptions
|
|
76
|
+
* @param {Function} interpolateOptions.excludeSegment a function that takes a start command object and
|
|
77
|
+
* end command object and returns true if the segment should be excluded from splitting.
|
|
78
|
+
* @param {Boolean} interpolateOptions.snapEndsToInput a boolean indicating whether end of input should
|
|
79
|
+
* be sourced from input argument or computed.
|
|
80
|
+
* @returns {Function} Interpolation function that maps t ([0, 1]) to an array of path commands.
|
|
81
|
+
*/
|
|
82
|
+
export declare function interpolatePathCommands(
|
|
83
|
+
aCommandsInput: PathCommand[] | null | undefined,
|
|
84
|
+
bCommandsInput: PathCommand[] | null | undefined,
|
|
85
|
+
interpolateOptions?: ExcludeSegmentFn | InterpolateOptions,
|
|
86
|
+
): (t: number) => PathCommand[];
|
|
87
|
+
/**
|
|
88
|
+
* Interpolate from A to B by extending A and B during interpolation to have
|
|
89
|
+
* the same number of points. This allows for a smooth transition when they
|
|
90
|
+
* have a different number of points.
|
|
91
|
+
*
|
|
92
|
+
* Ignores the `Z` character in paths unless both A and B end with it.
|
|
93
|
+
*
|
|
94
|
+
* @param {String} a The `d` attribute for a path
|
|
95
|
+
* @param {String} b The `d` attribute for a path
|
|
96
|
+
* @param {((command1, command2) => boolean|{
|
|
97
|
+
* excludeSegment?: (command1, command2) => boolean;
|
|
98
|
+
* snapEndsToInput?: boolean
|
|
99
|
+
* })} interpolateOptions The excludeSegment function or an options object
|
|
100
|
+
* - interpolateOptions.excludeSegment a function that takes a start command object and
|
|
101
|
+
* end command object and returns true if the segment should be excluded from splitting.
|
|
102
|
+
* - interpolateOptions.snapEndsToInput a boolean indicating whether end of input should
|
|
103
|
+
* be sourced from input argument or computed.
|
|
104
|
+
* @returns {Function} Interpolation function that maps t ([0, 1]) to a path `d` string.
|
|
105
|
+
*/
|
|
106
|
+
export declare function interpolatePath(
|
|
107
|
+
a: string | null | undefined,
|
|
108
|
+
b: string | null | undefined,
|
|
109
|
+
interpolateOptions?: ExcludeSegmentFn | InterpolateOptions,
|
|
110
|
+
): (t: number) => string;
|
|
111
|
+
export {};
|
|
112
|
+
//# sourceMappingURL=interpolate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interpolate.d.ts","sourceRoot":"","sources":["../../../src/chart/utils/interpolate.ts"],"names":[],"mappings":"AAIA,KAAK,WAAW,GACZ,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,CAAC;AAER,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,WAAW,CAAC;IAClB,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB,CAAC;AAoIF;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CACxB,YAAY,EAAE,WAAW,EACzB,UAAU,EAAE,WAAW,EACvB,YAAY,CAAC,EAAE,MAAM,GACpB,WAAW,EAAE,CAWf;AAkJD,KAAK,gBAAgB,GAAG,CAAC,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,WAAW,KAAK,OAAO,CAAC;AAmHxF;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,WAAW,EAAE,CA+BlF;AAED,KAAK,kBAAkB,GAAG;IACxB,cAAc,CAAC,EAAE,gBAAgB,CAAC;IAClC,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B,CAAC;AAEF;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,uBAAuB,CACrC,cAAc,EAAE,WAAW,EAAE,GAAG,IAAI,GAAG,SAAS,EAChD,cAAc,EAAE,WAAW,EAAE,GAAG,IAAI,GAAG,SAAS,EAChD,kBAAkB,CAAC,EAAE,gBAAgB,GAAG,kBAAkB,GACzD,CAAC,CAAC,EAAE,MAAM,KAAK,WAAW,EAAE,CAoG9B;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,eAAe,CAC7B,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAC5B,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAC5B,kBAAkB,CAAC,EAAE,gBAAgB,GAAG,kBAAkB,GACzD,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAgDvB"}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { type ChartScaleFunction } from './scale';
|
|
2
|
+
export type ChartPathCurveType =
|
|
3
|
+
| 'bump'
|
|
4
|
+
| 'catmullRom'
|
|
5
|
+
| 'linear'
|
|
6
|
+
| 'linearClosed'
|
|
7
|
+
| 'monotone'
|
|
8
|
+
| 'natural'
|
|
9
|
+
| 'step'
|
|
10
|
+
| 'stepBefore'
|
|
11
|
+
| 'stepAfter';
|
|
12
|
+
/**
|
|
13
|
+
* Get the d3 curve function for a path.
|
|
14
|
+
* See https://d3js.org/d3-shape/curve
|
|
15
|
+
* @param curve - The curve type. Defaults to 'linear'.
|
|
16
|
+
* @returns The d3 curve function.
|
|
17
|
+
*/
|
|
18
|
+
export declare const getPathCurveFunction: (
|
|
19
|
+
curve?: ChartPathCurveType,
|
|
20
|
+
) => import('d3-shape').CurveFactory;
|
|
21
|
+
/**
|
|
22
|
+
* Generates an SVG line path string from data using chart scale functions.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```typescript
|
|
26
|
+
* const chartScale = getChartScale({ chartRect, domain, range, xScale, yScale });
|
|
27
|
+
* const path = getLinePath({ data: [1, 2, 3], chartScale, curve: 'bump' });
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export declare const getLinePath: ({
|
|
31
|
+
data,
|
|
32
|
+
curve,
|
|
33
|
+
xScale,
|
|
34
|
+
yScale,
|
|
35
|
+
xData,
|
|
36
|
+
connectNulls,
|
|
37
|
+
}: {
|
|
38
|
+
data: (
|
|
39
|
+
| number
|
|
40
|
+
| null
|
|
41
|
+
| {
|
|
42
|
+
x: number;
|
|
43
|
+
y: number;
|
|
44
|
+
}
|
|
45
|
+
)[];
|
|
46
|
+
curve?: ChartPathCurveType;
|
|
47
|
+
xScale: ChartScaleFunction;
|
|
48
|
+
yScale: ChartScaleFunction;
|
|
49
|
+
xData?: number[];
|
|
50
|
+
/**
|
|
51
|
+
* When true, null values are skipped and the line connects across gaps.
|
|
52
|
+
* By default, null values create gaps in the line.
|
|
53
|
+
*/
|
|
54
|
+
connectNulls?: boolean;
|
|
55
|
+
}) => string;
|
|
56
|
+
/**
|
|
57
|
+
* Generates an SVG area path string from data using chart scale functions.
|
|
58
|
+
* Supports both single values (area from baseline to value) and tuples ([baseline, value]).
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```typescript
|
|
62
|
+
* // Single values - area from baseline to value
|
|
63
|
+
* const area = getAreaPath({
|
|
64
|
+
* data: [1, 2, 3],
|
|
65
|
+
* xScale,
|
|
66
|
+
* yScale,
|
|
67
|
+
* });
|
|
68
|
+
*
|
|
69
|
+
* // Range values - area from low to high
|
|
70
|
+
* const rangeArea = getAreaPath({
|
|
71
|
+
* data: [[0, 3], [2, 4], [1, 5]],
|
|
72
|
+
* xScale,
|
|
73
|
+
* yScale,
|
|
74
|
+
* curve: 'monotone'
|
|
75
|
+
* });
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
export declare const getAreaPath: ({
|
|
79
|
+
data,
|
|
80
|
+
curve,
|
|
81
|
+
xScale,
|
|
82
|
+
yScale,
|
|
83
|
+
xData,
|
|
84
|
+
connectNulls,
|
|
85
|
+
}: {
|
|
86
|
+
data: (number | null)[] | Array<[number, number] | null>;
|
|
87
|
+
xScale: ChartScaleFunction;
|
|
88
|
+
yScale: ChartScaleFunction;
|
|
89
|
+
curve: ChartPathCurveType;
|
|
90
|
+
xData?: number[];
|
|
91
|
+
/**
|
|
92
|
+
* When true, null values are skipped and the area connects across gaps.
|
|
93
|
+
* By default null values create gaps in the area.
|
|
94
|
+
*/
|
|
95
|
+
connectNulls?: boolean;
|
|
96
|
+
}) => string;
|
|
97
|
+
/**
|
|
98
|
+
* Converts line coordinates to an SVG path string.
|
|
99
|
+
* Useful for rendering axis lines and tick marks.
|
|
100
|
+
*
|
|
101
|
+
* @example
|
|
102
|
+
* ```typescript
|
|
103
|
+
* const path = lineToPath(0, 0, 100, 100);
|
|
104
|
+
* // Returns: "M 0 0 L 100 100"
|
|
105
|
+
* ```
|
|
106
|
+
*/
|
|
107
|
+
export declare const lineToPath: (x1: number, y1: number, x2: number, y2: number) => string;
|
|
108
|
+
/**
|
|
109
|
+
* Creates an SVG path string for a rectangle with selective corner rounding.
|
|
110
|
+
* Useful for creating bars in charts with optional rounded corners.
|
|
111
|
+
*
|
|
112
|
+
* @example
|
|
113
|
+
* ```typescript
|
|
114
|
+
* // Simple rectangle bar
|
|
115
|
+
* const barPath = getBarPath(10, 20, 50, 100, 0, false, false);
|
|
116
|
+
*
|
|
117
|
+
* // Bar with rounded top corners
|
|
118
|
+
* const roundedPath = getBarPath(10, 20, 50, 100, 8, true, false);
|
|
119
|
+
* ```
|
|
120
|
+
*/
|
|
121
|
+
export declare const getBarPath: (
|
|
122
|
+
x: number,
|
|
123
|
+
y: number,
|
|
124
|
+
width: number,
|
|
125
|
+
height: number,
|
|
126
|
+
radius: number,
|
|
127
|
+
roundTop: boolean,
|
|
128
|
+
roundBottom: boolean,
|
|
129
|
+
) => string;
|
|
130
|
+
//# sourceMappingURL=path.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path.d.ts","sourceRoot":"","sources":["../../../src/chart/utils/path.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,KAAK,kBAAkB,EAAsB,MAAM,SAAS,CAAC;AAEtE,MAAM,MAAM,kBAAkB,GAC1B,MAAM,GACN,YAAY,GACZ,QAAQ,GACR,cAAc,GACd,UAAU,GACV,SAAS,GACT,MAAM,GACN,YAAY,GACZ,WAAW,CAAC;AAEhB;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,GAAI,QAAO,kBAA6B,oCAsBxE,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,WAAW,GAAI,uDAOzB;IACD,IAAI,EAAE,CAAC,MAAM,GAAG,IAAI,GAAG;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,EAAE,CAAC;IACnD,KAAK,CAAC,EAAE,kBAAkB,CAAC;IAC3B,MAAM,EAAE,kBAAkB,CAAC;IAC3B,MAAM,EAAE,kBAAkB,CAAC;IAC3B,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB,KAAG,MAoBH,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,WAAW,GAAI,uDAOzB;IACD,IAAI,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,GAAG,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC;IACzD,MAAM,EAAE,kBAAkB,CAAC;IAC3B,MAAM,EAAE,kBAAkB,CAAC;IAC3B,KAAK,EAAE,kBAAkB,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB,KAAG,MAoFH,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,UAAU,GAAI,IAAI,MAAM,EAAE,IAAI,MAAM,EAAE,IAAI,MAAM,EAAE,IAAI,MAAM,KAAG,MAE3E,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,UAAU,GACrB,GAAG,MAAM,EACT,GAAG,MAAM,EACT,OAAO,MAAM,EACb,QAAQ,MAAM,EACd,QAAQ,MAAM,EACd,UAAU,OAAO,EACjB,aAAa,OAAO,KACnB,MA0BF,CAAC"}
|