@coinbase/cds-web-visualization 3.3.0 → 3.4.0-beta.2
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 +30 -0
- package/dts/chart/CartesianChart.d.ts +36 -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 +34 -0
- package/dts/chart/Path.d.ts.map +1 -0
- package/dts/chart/PeriodSelector.d.ts +61 -0
- package/dts/chart/PeriodSelector.d.ts.map +1 -0
- package/dts/chart/Point.d.ts +153 -0
- package/dts/chart/Point.d.ts.map +1 -0
- package/dts/chart/area/Area.d.ts +48 -0
- package/dts/chart/area/Area.d.ts.map +1 -0
- package/dts/chart/area/AreaChart.d.ts +52 -0
- package/dts/chart/area/AreaChart.d.ts.map +1 -0
- package/dts/chart/area/DottedArea.d.ts +68 -0
- package/dts/chart/area/DottedArea.d.ts.map +1 -0
- package/dts/chart/area/GradientArea.d.ts +30 -0
- package/dts/chart/area/GradientArea.d.ts.map +1 -0
- package/dts/chart/area/SolidArea.d.ts +8 -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 +208 -0
- package/dts/chart/axis/Axis.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 +4 -0
- package/dts/chart/axis/index.d.ts.map +1 -0
- package/dts/chart/bar/Bar.d.ts +91 -0
- package/dts/chart/bar/Bar.d.ts.map +1 -0
- package/dts/chart/bar/BarChart.d.ts +53 -0
- package/dts/chart/bar/BarChart.d.ts.map +1 -0
- package/dts/chart/bar/BarPlot.d.ts +29 -0
- package/dts/chart/bar/BarPlot.d.ts.map +1 -0
- package/dts/chart/bar/BarStack.d.ts +111 -0
- package/dts/chart/bar/BarStack.d.ts.map +1 -0
- package/dts/chart/bar/BarStackGroup.d.ts +35 -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/index.d.ts +13 -0
- package/dts/chart/index.d.ts.map +1 -0
- package/dts/chart/line/DottedLine.d.ts +14 -0
- package/dts/chart/line/DottedLine.d.ts.map +1 -0
- package/dts/chart/line/GradientLine.d.ts +42 -0
- package/dts/chart/line/GradientLine.d.ts.map +1 -0
- package/dts/chart/line/Line.d.ts +80 -0
- package/dts/chart/line/Line.d.ts.map +1 -0
- package/dts/chart/line/LineChart.d.ts +59 -0
- package/dts/chart/line/LineChart.d.ts.map +1 -0
- package/dts/chart/line/ReferenceLine.d.ts +131 -0
- package/dts/chart/line/ReferenceLine.d.ts.map +1 -0
- package/dts/chart/line/SolidLine.d.ts +14 -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/scrubber/Scrubber.d.ts +149 -0
- package/dts/chart/scrubber/Scrubber.d.ts.map +1 -0
- package/dts/chart/scrubber/ScrubberBeacon.d.ts +93 -0
- package/dts/chart/scrubber/ScrubberBeacon.d.ts.map +1 -0
- package/dts/chart/scrubber/ScrubberBeaconLabel.d.ts +7 -0
- package/dts/chart/scrubber/ScrubberBeaconLabel.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 +2 -0
- package/dts/chart/scrubber/index.d.ts.map +1 -0
- package/dts/chart/text/ChartText.d.ts +114 -0
- package/dts/chart/text/ChartText.d.ts.map +1 -0
- package/dts/chart/text/SmartChartTextGroup.d.ts +55 -0
- package/dts/chart/text/SmartChartTextGroup.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 +97 -0
- package/dts/chart/utils/chart.d.ts.map +1 -0
- package/dts/chart/utils/context.d.ts +95 -0
- package/dts/chart/utils/context.d.ts.map +1 -0
- package/dts/chart/utils/index.d.ts +8 -0
- package/dts/chart/utils/index.d.ts.map +1 -0
- package/dts/chart/utils/path.d.ts +107 -0
- package/dts/chart/utils/path.d.ts.map +1 -0
- package/dts/chart/utils/point.d.ts +75 -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/index.d.ts +2 -1
- package/dts/index.d.ts.map +1 -1
- package/dts/sparkline/Counter.d.ts +7 -2
- package/dts/sparkline/Sparkline.d.ts +61 -16
- package/dts/sparkline/Sparkline.d.ts.map +1 -1
- package/dts/sparkline/SparklineArea.d.ts +12 -4
- package/dts/sparkline/SparklineArea.d.ts.map +1 -1
- package/dts/sparkline/SparklineAreaPattern.d.ts +12 -4
- package/dts/sparkline/SparklineAreaPattern.d.ts.map +1 -1
- package/dts/sparkline/SparklineGradient.d.ts +21 -10
- package/dts/sparkline/SparklineGradient.d.ts.map +1 -1
- package/dts/sparkline/SparklinePath.d.ts +8 -6
- package/dts/sparkline/__figma__/Sparkline.figma.d.ts +1 -1
- package/dts/sparkline/generateSparklineWithId.d.ts +8 -2
- package/dts/sparkline/generateSparklineWithId.d.ts.map +1 -1
- package/dts/sparkline/index.d.ts +1 -1
- package/dts/sparkline/sparkline-interactive/InnerSparklineInteractiveProvider.d.ts +9 -5
- package/dts/sparkline/sparkline-interactive/SparklineInteractive.d.ts +168 -118
- package/dts/sparkline/sparkline-interactive/SparklineInteractive.d.ts.map +1 -1
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveAnimatedPath.d.ts +22 -9
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveAnimatedPath.d.ts.map +1 -1
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveHoverDate.d.ts +4 -2
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveHoverPrice.d.ts +4 -2
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveLineVertical.d.ts +5 -3
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveMarkerDates.d.ts +11 -6
- package/dts/sparkline/sparkline-interactive/SparklineInteractivePaths.d.ts +21 -7
- package/dts/sparkline/sparkline-interactive/SparklineInteractivePaths.d.ts.map +1 -1
- package/dts/sparkline/sparkline-interactive/SparklineInteractivePeriodSelector.d.ts +21 -16
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveProvider.d.ts +17 -12
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveScrubHandler.d.ts +23 -10
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveScrubProvider.d.ts +12 -12
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveTimeseriesPaths.d.ts +22 -14
- package/dts/sparkline/sparkline-interactive/__figma__/SparklineInteractive.figma.d.ts +1 -1
- package/dts/sparkline/sparkline-interactive/fade.d.ts +1 -1
- package/dts/sparkline/sparkline-interactive/useSparklineInteractiveConstants.d.ts +11 -11
- package/dts/sparkline/sparkline-interactive-header/SparklineInteractiveHeader.d.ts +101 -93
- package/dts/sparkline/sparkline-interactive-header/__figma__/SparklineInteractiveHeader.figma.d.ts +1 -1
- package/esm/chart/CartesianChart.css +1 -0
- package/esm/chart/CartesianChart.js +258 -0
- package/esm/chart/ChartProvider.js +10 -0
- package/esm/chart/Path.js +89 -0
- package/esm/chart/PeriodSelector.css +1 -0
- package/esm/chart/PeriodSelector.js +126 -0
- package/esm/chart/Point.css +2 -0
- package/esm/chart/Point.js +171 -0
- package/esm/chart/area/Area.js +85 -0
- package/esm/chart/area/AreaChart.js +164 -0
- package/esm/chart/area/DottedArea.js +141 -0
- package/esm/chart/area/GradientArea.js +111 -0
- package/esm/chart/area/SolidArea.js +29 -0
- package/esm/chart/area/index.js +7 -0
- package/esm/chart/axis/Axis.js +46 -0
- package/esm/chart/axis/XAxis.css +2 -0
- package/esm/chart/axis/XAxis.js +195 -0
- package/esm/chart/axis/YAxis.css +2 -0
- package/esm/chart/axis/YAxis.js +183 -0
- package/esm/chart/axis/index.js +5 -0
- package/esm/chart/bar/Bar.js +59 -0
- package/esm/chart/bar/BarChart.js +147 -0
- package/esm/chart/bar/BarPlot.js +96 -0
- package/esm/chart/bar/BarStack.js +519 -0
- package/esm/chart/bar/BarStackGroup.js +96 -0
- package/esm/chart/bar/DefaultBar.js +64 -0
- package/esm/chart/bar/DefaultBarStack.js +60 -0
- package/esm/chart/bar/index.js +9 -0
- package/esm/chart/index.js +14 -0
- package/esm/chart/line/DottedLine.js +38 -0
- package/esm/chart/line/GradientLine.js +58 -0
- package/esm/chart/line/Line.js +159 -0
- package/esm/chart/line/LineChart.js +120 -0
- package/esm/chart/line/ReferenceLine.js +142 -0
- package/esm/chart/line/SolidLine.js +34 -0
- package/esm/chart/line/index.js +8 -0
- package/esm/chart/scrubber/Scrubber.js +483 -0
- package/esm/chart/scrubber/ScrubberBeacon.js +195 -0
- package/esm/chart/scrubber/ScrubberBeaconLabel.js +33 -0
- package/esm/chart/scrubber/ScrubberProvider.js +228 -0
- package/esm/chart/scrubber/index.js +2 -0
- package/esm/chart/text/ChartText.js +236 -0
- package/esm/chart/text/SmartChartTextGroup.js +226 -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 +229 -0
- package/esm/chart/utils/context.js +15 -0
- package/esm/chart/utils/index.js +9 -0
- package/esm/chart/utils/path.js +204 -0
- package/esm/chart/utils/point.js +118 -0
- package/esm/chart/utils/scale.js +48 -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/SparklineInteractivePaths.js +4 -0
- package/package.json +15 -11
- package/dts/sparkline/sparkline-interactive/__stories__/SparklineInteractive.stories.d.ts +0 -374
- package/dts/sparkline/sparkline-interactive/__stories__/SparklineInteractive.stories.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive/__tests__/SparklineInteractive.test.d.ts +0 -2
- package/dts/sparkline/sparkline-interactive/__tests__/SparklineInteractive.test.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive/__tests__/SparklineInteractivePeriodSelector.test.d.ts +0 -2
- package/dts/sparkline/sparkline-interactive/__tests__/SparklineInteractivePeriodSelector.test.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive-header/__stories__/SparklineInteractiveHeader.stories.d.ts +0 -87
- package/dts/sparkline/sparkline-interactive-header/__stories__/SparklineInteractiveHeader.stories.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive-header/__tests__/SparklineInteractiveHeader.test.d.ts +0 -2
- package/dts/sparkline/sparkline-interactive-header/__tests__/SparklineInteractiveHeader.test.d.ts.map +0 -1
|
@@ -1,17 +1,30 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { ChartGetMarker } from '@coinbase/cds-common';
|
|
3
3
|
import type { SparklineInteractiveBaseProps } from './SparklineInteractive';
|
|
4
|
-
export declare const scrubHandlerStaticClassName =
|
|
4
|
+
export declare const scrubHandlerStaticClassName = 'cds-sparkline--scrubhandler';
|
|
5
5
|
export declare function fadeInMask(domNode?: HTMLElement | null): void;
|
|
6
|
-
type SparklineInteractiveScrubHandlerWebProps<Period extends string> = Pick<
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
type SparklineInteractiveScrubHandlerWebProps<Period extends string> = Pick<
|
|
7
|
+
SparklineInteractiveBaseProps<Period>,
|
|
8
|
+
'onScrub' | 'formatHoverDate' | 'formatHoverPrice'
|
|
9
|
+
> & {
|
|
10
|
+
getMarker: ChartGetMarker;
|
|
11
|
+
selectedPeriod: Period;
|
|
12
|
+
onScrubEnd?: () => void;
|
|
13
|
+
onScrubStart?: () => void;
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
children: React.ReactNode;
|
|
13
16
|
};
|
|
14
|
-
declare const SparklineInteractiveScrubHandlerWithGeneric: <Period extends string>({
|
|
17
|
+
declare const SparklineInteractiveScrubHandlerWithGeneric: <Period extends string>({
|
|
18
|
+
onScrubEnd,
|
|
19
|
+
onScrubStart,
|
|
20
|
+
children,
|
|
21
|
+
disabled,
|
|
22
|
+
onScrub,
|
|
23
|
+
getMarker,
|
|
24
|
+
selectedPeriod,
|
|
25
|
+
formatHoverDate,
|
|
26
|
+
formatHoverPrice,
|
|
27
|
+
}: SparklineInteractiveScrubHandlerWebProps<Period>) => import('react/jsx-runtime').JSX.Element;
|
|
15
28
|
export declare const SparklineInteractiveScrubHandler: typeof SparklineInteractiveScrubHandlerWithGeneric;
|
|
16
29
|
export {};
|
|
17
|
-
//# sourceMappingURL=SparklineInteractiveScrubHandler.d.ts.map
|
|
30
|
+
//# sourceMappingURL=SparklineInteractiveScrubHandler.d.ts.map
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { Dispatch, SetStateAction } from 'react';
|
|
3
3
|
type SparklineInteractiveScrubContextInterface = {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
4
|
+
setLineDOMNode: Dispatch<SetStateAction<HTMLDivElement | null>>;
|
|
5
|
+
setMaskDOMNode: Dispatch<SetStateAction<HTMLDivElement | null>>;
|
|
6
|
+
setHoverDateDOMNode: Dispatch<SetStateAction<HTMLSpanElement | null>>;
|
|
7
|
+
setHoverPriceDOMNode: Dispatch<SetStateAction<HTMLSpanElement | null>>;
|
|
8
|
+
lineDOMNode: HTMLDivElement | null;
|
|
9
|
+
maskDOMNode: HTMLDivElement | null;
|
|
10
|
+
hoverDateDOMNode: HTMLSpanElement | null;
|
|
11
|
+
hoverPriceDOMNode: HTMLSpanElement | null;
|
|
12
12
|
};
|
|
13
|
-
export declare const SparklineInteractiveScrubProvider: React.MemoExoticComponent<
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
export declare const SparklineInteractiveScrubProvider: React.MemoExoticComponent<
|
|
14
|
+
({ children }: { children: React.ReactNode }) => import('react/jsx-runtime').JSX.Element
|
|
15
|
+
>;
|
|
16
16
|
export declare function useSparklineInteractiveScrubContext(): SparklineInteractiveScrubContextInterface;
|
|
17
17
|
export {};
|
|
18
|
-
//# sourceMappingURL=SparklineInteractiveScrubProvider.d.ts.map
|
|
18
|
+
//# sourceMappingURL=SparklineInteractiveScrubProvider.d.ts.map
|
|
@@ -2,22 +2,30 @@ import React from 'react';
|
|
|
2
2
|
import type { ChartDataPoint, ChartTimeseries } from '@coinbase/cds-common/types';
|
|
3
3
|
import type { Area, Line } from 'd3-shape';
|
|
4
4
|
export type TimeseriesPathOnRenderParams = {
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
path: string;
|
|
6
|
+
area: string;
|
|
7
7
|
};
|
|
8
8
|
export type TimeseriesPathProps = {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
lineFn: Line<ChartDataPoint>;
|
|
10
|
+
areaFn: Area<ChartDataPoint>;
|
|
11
|
+
timeseries: ChartTimeseries;
|
|
12
|
+
initialPath: string;
|
|
13
|
+
onRender?: ({ path, area }: TimeseriesPathOnRenderParams) => void;
|
|
14
14
|
};
|
|
15
15
|
export type SparklineInteractiveTimeseriesPathsProps = {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
initialPath: string;
|
|
17
|
+
data: ChartTimeseries[];
|
|
18
|
+
width: number;
|
|
19
|
+
height: number;
|
|
20
|
+
onRender: ({ path, area }: TimeseriesPathOnRenderParams) => void;
|
|
21
21
|
};
|
|
22
|
-
export declare const SparklineInteractiveTimeseriesPaths: React.MemoExoticComponent<
|
|
23
|
-
|
|
22
|
+
export declare const SparklineInteractiveTimeseriesPaths: React.MemoExoticComponent<
|
|
23
|
+
({
|
|
24
|
+
data,
|
|
25
|
+
width,
|
|
26
|
+
height,
|
|
27
|
+
initialPath,
|
|
28
|
+
onRender,
|
|
29
|
+
}: SparklineInteractiveTimeseriesPathsProps) => import('react/jsx-runtime').JSX.Element
|
|
30
|
+
>;
|
|
31
|
+
//# sourceMappingURL=SparklineInteractiveTimeseriesPaths.d.ts.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export {};
|
|
2
|
-
//# sourceMappingURL=SparklineInteractive.figma.d.ts.map
|
|
2
|
+
//# sourceMappingURL=SparklineInteractive.figma.d.ts.map
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
export declare function useSparklineInteractiveConstants(): {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
2
|
+
chartWidth: number;
|
|
3
|
+
chartHeight: number;
|
|
4
|
+
chartDimensionStyles: {
|
|
5
|
+
height: number;
|
|
6
|
+
width: number;
|
|
7
|
+
};
|
|
8
|
+
xRange: number[];
|
|
9
|
+
yRange: number[];
|
|
10
|
+
startX: number;
|
|
11
|
+
endX: number;
|
|
12
12
|
};
|
|
13
|
-
//# sourceMappingURL=useSparklineInteractiveConstants.d.ts.map
|
|
13
|
+
//# sourceMappingURL=useSparklineInteractiveConstants.d.ts.map
|
|
@@ -1,104 +1,112 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import type {
|
|
2
|
+
import type {
|
|
3
|
+
SharedProps,
|
|
4
|
+
SparklineInteractiveHeaderSignVariant,
|
|
5
|
+
SparklineInteractiveHeaderVariant,
|
|
6
|
+
} from '@coinbase/cds-common/types';
|
|
3
7
|
export * from '@coinbase/cds-common/types/SparklineInteractiveHeaderBaseProps';
|
|
4
8
|
export type SparklineInteractiveSubHead = {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
9
|
+
/**
|
|
10
|
+
* Free form percentage change
|
|
11
|
+
*/
|
|
12
|
+
percent: string;
|
|
13
|
+
/**
|
|
14
|
+
* Sign to denote the change in price
|
|
15
|
+
*/
|
|
16
|
+
sign: SparklineInteractiveHeaderSignVariant;
|
|
17
|
+
/**
|
|
18
|
+
* The variant to use for the price and percentage change
|
|
19
|
+
*/
|
|
20
|
+
variant: SparklineInteractiveHeaderVariant;
|
|
21
|
+
/**
|
|
22
|
+
* Show the dollar amount of price change
|
|
23
|
+
*/
|
|
24
|
+
priceChange?: string;
|
|
25
|
+
/**
|
|
26
|
+
* The accessoryText to show after the price and / or percentage change. An example is "All time"
|
|
27
|
+
*/
|
|
28
|
+
accessoryText?: string;
|
|
29
|
+
/**
|
|
30
|
+
* The accessibilityLabel to show for the price and / or percentage change. This should be localized
|
|
31
|
+
* @example
|
|
32
|
+
* // First, configure your i18n strings
|
|
33
|
+
* const messages = defineMessages({
|
|
34
|
+
* subHeadPrefix: {
|
|
35
|
+
* id: `${i18nKey}.subHeadPrefix`,
|
|
36
|
+
* defaultMessage: 'Price increase in the amount of',
|
|
37
|
+
* description: 'A prefix to make it clear which direction the price action was moving',
|
|
38
|
+
* }
|
|
39
|
+
* });
|
|
40
|
+
*
|
|
41
|
+
* // then provide the translated string the accessibilityLabel prop
|
|
42
|
+
* messages.subHeadPrefix
|
|
43
|
+
*/
|
|
44
|
+
accessibilityLabel?: string;
|
|
41
45
|
};
|
|
42
46
|
export type SparklineInteractiveHeaderValues = {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
47
|
+
/**
|
|
48
|
+
* Describes what the Header represents e.g. Bitcoin Price
|
|
49
|
+
*/
|
|
50
|
+
label?: string;
|
|
51
|
+
/**
|
|
52
|
+
* Main content of header, this is usually the price
|
|
53
|
+
*/
|
|
54
|
+
title?: React.ReactNode;
|
|
55
|
+
/**
|
|
56
|
+
* Provides additional information about the title, such as a price change
|
|
57
|
+
*/
|
|
58
|
+
subHead?: SparklineInteractiveSubHead;
|
|
55
59
|
};
|
|
56
60
|
export type SparklineInteractiveHeaderRef = {
|
|
57
|
-
|
|
61
|
+
update: (params: SparklineInteractiveHeaderValues) => void;
|
|
58
62
|
};
|
|
59
63
|
export type SparklineInteractiveHeaderProps = SharedProps & {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
64
|
+
/**
|
|
65
|
+
* Default title, changing this prop has no effect once the default is rendered. If you use a ReactNode that is not a string, then you cannot use the text based label that supports updates.
|
|
66
|
+
*/
|
|
67
|
+
defaultTitle: React.ReactNode;
|
|
68
|
+
/**
|
|
69
|
+
* Default label, changing this prop has no effect once the default is rendered.
|
|
70
|
+
*/
|
|
71
|
+
defaultLabel?: string;
|
|
72
|
+
/**
|
|
73
|
+
* Default SubHead, changing this prop has no effect once the default is rendered.
|
|
74
|
+
*/
|
|
75
|
+
defaultSubHead?: SparklineInteractiveSubHead;
|
|
76
|
+
/**
|
|
77
|
+
* Adds a label node that allows React components. If you use this node then you cannot use the text based label that supports updates.
|
|
78
|
+
*/
|
|
79
|
+
labelNode?: React.ReactNode;
|
|
80
|
+
/**
|
|
81
|
+
* Reduce the font size used for the header itself.
|
|
82
|
+
*/
|
|
83
|
+
compact?: boolean;
|
|
80
84
|
};
|
|
81
85
|
export declare const interpolateSubHeadText: (subHead: SparklineInteractiveSubHead) => string;
|
|
82
|
-
export declare const SparklineInteractiveHeader: React.MemoExoticComponent<
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
86
|
+
export declare const SparklineInteractiveHeader: React.MemoExoticComponent<
|
|
87
|
+
React.ForwardRefExoticComponent<
|
|
88
|
+
SharedProps & {
|
|
89
|
+
/**
|
|
90
|
+
* Default title, changing this prop has no effect once the default is rendered. If you use a ReactNode that is not a string, then you cannot use the text based label that supports updates.
|
|
91
|
+
*/
|
|
92
|
+
defaultTitle: React.ReactNode;
|
|
93
|
+
/**
|
|
94
|
+
* Default label, changing this prop has no effect once the default is rendered.
|
|
95
|
+
*/
|
|
96
|
+
defaultLabel?: string;
|
|
97
|
+
/**
|
|
98
|
+
* Default SubHead, changing this prop has no effect once the default is rendered.
|
|
99
|
+
*/
|
|
100
|
+
defaultSubHead?: SparklineInteractiveSubHead;
|
|
101
|
+
/**
|
|
102
|
+
* Adds a label node that allows React components. If you use this node then you cannot use the text based label that supports updates.
|
|
103
|
+
*/
|
|
104
|
+
labelNode?: React.ReactNode;
|
|
105
|
+
/**
|
|
106
|
+
* Reduce the font size used for the header itself.
|
|
107
|
+
*/
|
|
108
|
+
compact?: boolean;
|
|
109
|
+
} & React.RefAttributes<SparklineInteractiveHeaderRef>
|
|
110
|
+
>
|
|
111
|
+
>;
|
|
112
|
+
//# sourceMappingURL=SparklineInteractiveHeader.d.ts.map
|
package/dts/sparkline/sparkline-interactive-header/__figma__/SparklineInteractiveHeader.figma.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export {};
|
|
2
|
-
//# sourceMappingURL=SparklineInteractiveHeader.figma.d.ts.map
|
|
2
|
+
//# sourceMappingURL=SparklineInteractiveHeader.figma.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.cds-focusStylesCss-f4oy7ru:focus{outline:none;}.cds-focusStylesCss-f4oy7ru:focus-visible{outline:2px solid var(--color-bgPrimary);outline-offset:2px;}
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
const _excluded = ["series", "children", "animate", "xAxis", "yAxis", "inset", "enableScrubbing", "onScrubberPositionChange", "width", "height", "className", "style"];
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
6
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
|
+
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
8
|
+
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
9
|
+
import React, { forwardRef, memo, useCallback, useMemo, useRef } from 'react';
|
|
10
|
+
import { cx } from '@coinbase/cds-web';
|
|
11
|
+
import { useDimensions } from '@coinbase/cds-web/hooks/useDimensions';
|
|
12
|
+
import { Box } from '@coinbase/cds-web/layout';
|
|
13
|
+
import { ScrubberProvider } from './scrubber/ScrubberProvider';
|
|
14
|
+
import { CartesianChartProvider } from './ChartProvider';
|
|
15
|
+
import { defaultAxisId, defaultChartInset, getAxisConfig, getAxisDomain, getAxisRange, getAxisScale, getChartInset, getStackedSeriesData as calculateStackedSeriesData, useTotalAxisPadding } from './utils';
|
|
16
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
17
|
+
const focusStylesCss = "cds-focusStylesCss-f4oy7ru";
|
|
18
|
+
export const CartesianChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) => {
|
|
19
|
+
let {
|
|
20
|
+
series,
|
|
21
|
+
children,
|
|
22
|
+
animate = true,
|
|
23
|
+
xAxis: xAxisConfigInput,
|
|
24
|
+
yAxis: yAxisConfigInput,
|
|
25
|
+
inset: insetInput,
|
|
26
|
+
enableScrubbing,
|
|
27
|
+
onScrubberPositionChange,
|
|
28
|
+
width = '100%',
|
|
29
|
+
height = '100%',
|
|
30
|
+
className,
|
|
31
|
+
style
|
|
32
|
+
} = _ref,
|
|
33
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
34
|
+
const {
|
|
35
|
+
observe,
|
|
36
|
+
width: chartWidth,
|
|
37
|
+
height: chartHeight
|
|
38
|
+
} = useDimensions();
|
|
39
|
+
const internalSvgRef = useRef(null);
|
|
40
|
+
const userInset = useMemo(() => {
|
|
41
|
+
return getChartInset(insetInput, defaultChartInset);
|
|
42
|
+
}, [insetInput]);
|
|
43
|
+
|
|
44
|
+
// Axis configs store the properties of each axis, such as id, scale type, domain limit, etc.
|
|
45
|
+
// We only support 1 x axis but allow for multiple y axes.
|
|
46
|
+
const xAxisConfig = useMemo(() => getAxisConfig('x', xAxisConfigInput)[0], [xAxisConfigInput]);
|
|
47
|
+
const yAxisConfig = useMemo(() => getAxisConfig('y', yAxisConfigInput), [yAxisConfigInput]);
|
|
48
|
+
const {
|
|
49
|
+
renderedAxes,
|
|
50
|
+
registerAxis,
|
|
51
|
+
unregisterAxis,
|
|
52
|
+
axisPadding
|
|
53
|
+
} = useTotalAxisPadding();
|
|
54
|
+
const chartRect = useMemo(() => {
|
|
55
|
+
if (chartWidth <= 0 || chartHeight <= 0) return {
|
|
56
|
+
x: 0,
|
|
57
|
+
y: 0,
|
|
58
|
+
width: 0,
|
|
59
|
+
height: 0
|
|
60
|
+
};
|
|
61
|
+
const totalInset = {
|
|
62
|
+
top: userInset.top + axisPadding.top,
|
|
63
|
+
right: userInset.right + axisPadding.right,
|
|
64
|
+
bottom: userInset.bottom + axisPadding.bottom,
|
|
65
|
+
left: userInset.left + axisPadding.left
|
|
66
|
+
};
|
|
67
|
+
const availableWidth = chartWidth - totalInset.left - totalInset.right;
|
|
68
|
+
const availableHeight = chartHeight - totalInset.top - totalInset.bottom;
|
|
69
|
+
return {
|
|
70
|
+
x: totalInset.left,
|
|
71
|
+
y: totalInset.top,
|
|
72
|
+
width: availableWidth > 0 ? availableWidth : 0,
|
|
73
|
+
height: availableHeight > 0 ? availableHeight : 0
|
|
74
|
+
};
|
|
75
|
+
}, [chartHeight, chartWidth, userInset, axisPadding]);
|
|
76
|
+
|
|
77
|
+
// Axes contain the config along with domain and range, which get calculated here.
|
|
78
|
+
const xAxis = useMemo(() => {
|
|
79
|
+
if (!chartRect || chartRect.width <= 0 || chartRect.height <= 0) return undefined;
|
|
80
|
+
const domain = getAxisDomain(xAxisConfig, series !== null && series !== void 0 ? series : [], 'x');
|
|
81
|
+
const range = getAxisRange(xAxisConfig, chartRect, 'x');
|
|
82
|
+
const axisConfig = {
|
|
83
|
+
scaleType: xAxisConfig.scaleType,
|
|
84
|
+
domain,
|
|
85
|
+
range,
|
|
86
|
+
data: xAxisConfig.data,
|
|
87
|
+
categoryPadding: xAxisConfig.categoryPadding,
|
|
88
|
+
domainLimit: xAxisConfig.domainLimit
|
|
89
|
+
};
|
|
90
|
+
return axisConfig;
|
|
91
|
+
}, [xAxisConfig, series, chartRect]);
|
|
92
|
+
const yAxes = useMemo(() => {
|
|
93
|
+
const axes = new Map();
|
|
94
|
+
if (!chartRect || chartRect.width <= 0 || chartRect.height <= 0) return axes;
|
|
95
|
+
yAxisConfig.forEach(axisParam => {
|
|
96
|
+
var _axisParam$id, _series$filter, _axisParam$domainLimi;
|
|
97
|
+
const axisId = (_axisParam$id = axisParam.id) !== null && _axisParam$id !== void 0 ? _axisParam$id : defaultAxisId;
|
|
98
|
+
|
|
99
|
+
// Get relevant series data
|
|
100
|
+
const relevantSeries = (_series$filter = series === null || series === void 0 ? void 0 : series.filter(s => {
|
|
101
|
+
var _s$yAxisId;
|
|
102
|
+
return ((_s$yAxisId = s.yAxisId) !== null && _s$yAxisId !== void 0 ? _s$yAxisId : defaultAxisId) === axisId;
|
|
103
|
+
})) !== null && _series$filter !== void 0 ? _series$filter : [];
|
|
104
|
+
|
|
105
|
+
// Calculate domain and range in one pass
|
|
106
|
+
const domain = getAxisDomain(axisParam, relevantSeries, 'y');
|
|
107
|
+
const range = getAxisRange(axisParam, chartRect, 'y');
|
|
108
|
+
axes.set(axisId, {
|
|
109
|
+
scaleType: axisParam.scaleType,
|
|
110
|
+
domain,
|
|
111
|
+
range,
|
|
112
|
+
data: axisParam.data,
|
|
113
|
+
categoryPadding: axisParam.categoryPadding,
|
|
114
|
+
domainLimit: (_axisParam$domainLimi = axisParam.domainLimit) !== null && _axisParam$domainLimi !== void 0 ? _axisParam$domainLimi : 'nice'
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
return axes;
|
|
118
|
+
}, [yAxisConfig, series, chartRect]);
|
|
119
|
+
|
|
120
|
+
// Scales are the functions that convert data values to visual positions.
|
|
121
|
+
// They are calculated here based on the above axes.
|
|
122
|
+
const xScale = useMemo(() => {
|
|
123
|
+
if (!chartRect || chartRect.width <= 0 || chartRect.height <= 0 || xAxis === undefined) return undefined;
|
|
124
|
+
return getAxisScale({
|
|
125
|
+
config: xAxis,
|
|
126
|
+
type: 'x',
|
|
127
|
+
range: xAxis.range,
|
|
128
|
+
dataDomain: xAxis.domain
|
|
129
|
+
});
|
|
130
|
+
}, [chartRect, xAxis]);
|
|
131
|
+
const yScales = useMemo(() => {
|
|
132
|
+
const scales = new Map();
|
|
133
|
+
if (!chartRect || chartRect.width <= 0 || chartRect.height <= 0) return scales;
|
|
134
|
+
yAxes.forEach((axisConfig, axisId) => {
|
|
135
|
+
const scale = getAxisScale({
|
|
136
|
+
config: axisConfig,
|
|
137
|
+
type: 'y',
|
|
138
|
+
range: axisConfig.range,
|
|
139
|
+
dataDomain: axisConfig.domain
|
|
140
|
+
});
|
|
141
|
+
if (scale) {
|
|
142
|
+
scales.set(axisId, scale);
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
return scales;
|
|
146
|
+
}, [chartRect, yAxes]);
|
|
147
|
+
const getXAxis = useCallback(() => xAxis, [xAxis]);
|
|
148
|
+
const getYAxis = useCallback(id => yAxes.get(id !== null && id !== void 0 ? id : defaultAxisId), [yAxes]);
|
|
149
|
+
const getXScale = useCallback(() => xScale, [xScale]);
|
|
150
|
+
const getYScale = useCallback(id => yScales.get(id !== null && id !== void 0 ? id : defaultAxisId), [yScales]);
|
|
151
|
+
const getSeries = useCallback(seriesId => series === null || series === void 0 ? void 0 : series.find(s => s.id === seriesId), [series]);
|
|
152
|
+
const stackedDataMap = useMemo(() => {
|
|
153
|
+
if (!series) return new Map();
|
|
154
|
+
return calculateStackedSeriesData(series);
|
|
155
|
+
}, [series]);
|
|
156
|
+
const getStackedSeriesData = useCallback(seriesId => {
|
|
157
|
+
if (!seriesId) return undefined;
|
|
158
|
+
return stackedDataMap.get(seriesId);
|
|
159
|
+
}, [stackedDataMap]);
|
|
160
|
+
const getAxisBounds = useCallback(axisId => {
|
|
161
|
+
const axis = renderedAxes.get(axisId);
|
|
162
|
+
if (!axis || !chartRect) return;
|
|
163
|
+
const axesAtPosition = Array.from(renderedAxes.values()).filter(a => a.position === axis.position).sort((a, b) => a.id.localeCompare(b.id));
|
|
164
|
+
const axisIndex = axesAtPosition.findIndex(a => a.id === axisId);
|
|
165
|
+
if (axisIndex === -1) return;
|
|
166
|
+
|
|
167
|
+
// Calculate offset from previous axes at the same position
|
|
168
|
+
const offsetFromPreviousAxes = axesAtPosition.slice(0, axisIndex).reduce((sum, a) => sum + a.size, 0);
|
|
169
|
+
if (axis.position === 'top') {
|
|
170
|
+
// Position above the chart rect, accounting for user inset
|
|
171
|
+
const startY = userInset.top + offsetFromPreviousAxes;
|
|
172
|
+
return {
|
|
173
|
+
x: chartRect.x,
|
|
174
|
+
y: startY,
|
|
175
|
+
width: chartRect.width,
|
|
176
|
+
height: axis.size
|
|
177
|
+
};
|
|
178
|
+
} else if (axis.position === 'bottom') {
|
|
179
|
+
// Position below the chart rect, accounting for user inset
|
|
180
|
+
const startY = chartRect.y + chartRect.height + offsetFromPreviousAxes;
|
|
181
|
+
return {
|
|
182
|
+
x: chartRect.x,
|
|
183
|
+
y: startY,
|
|
184
|
+
width: chartRect.width,
|
|
185
|
+
height: axis.size
|
|
186
|
+
};
|
|
187
|
+
} else if (axis.position === 'left') {
|
|
188
|
+
// Position to the left of the chart rect, accounting for user inset
|
|
189
|
+
const startX = userInset.left + offsetFromPreviousAxes;
|
|
190
|
+
return {
|
|
191
|
+
x: startX,
|
|
192
|
+
y: chartRect.y,
|
|
193
|
+
width: axis.size,
|
|
194
|
+
height: chartRect.height
|
|
195
|
+
};
|
|
196
|
+
} else {
|
|
197
|
+
// right - position to the right of the chart rect, accounting for user inset
|
|
198
|
+
const startX = chartRect.x + chartRect.width + offsetFromPreviousAxes;
|
|
199
|
+
return {
|
|
200
|
+
x: startX,
|
|
201
|
+
y: chartRect.y,
|
|
202
|
+
width: axis.size,
|
|
203
|
+
height: chartRect.height
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
}, [renderedAxes, chartRect, userInset]);
|
|
207
|
+
const contextValue = useMemo(() => ({
|
|
208
|
+
series: series !== null && series !== void 0 ? series : [],
|
|
209
|
+
getSeries,
|
|
210
|
+
getSeriesData: getStackedSeriesData,
|
|
211
|
+
animate,
|
|
212
|
+
width: chartWidth,
|
|
213
|
+
height: chartHeight,
|
|
214
|
+
getXAxis,
|
|
215
|
+
getYAxis,
|
|
216
|
+
getXScale,
|
|
217
|
+
getYScale,
|
|
218
|
+
drawingArea: chartRect,
|
|
219
|
+
registerAxis,
|
|
220
|
+
unregisterAxis,
|
|
221
|
+
getAxisBounds
|
|
222
|
+
}), [series, getSeries, getStackedSeriesData, animate, chartWidth, chartHeight, getXAxis, getYAxis, getXScale, getYScale, chartRect, registerAxis, unregisterAxis, getAxisBounds]);
|
|
223
|
+
return /*#__PURE__*/_jsx(Box, _objectSpread(_objectSpread({
|
|
224
|
+
ref: node => {
|
|
225
|
+
// Handle the observe ref, internal ref, and forwarded ref
|
|
226
|
+
observe(node);
|
|
227
|
+
if (internalSvgRef.current !== node) {
|
|
228
|
+
internalSvgRef.current = node;
|
|
229
|
+
}
|
|
230
|
+
if (ref) {
|
|
231
|
+
if (typeof ref === 'function') {
|
|
232
|
+
ref(node);
|
|
233
|
+
} else {
|
|
234
|
+
ref.current = node;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
},
|
|
238
|
+
"aria-live": "polite",
|
|
239
|
+
as: "svg",
|
|
240
|
+
className: cx(enableScrubbing && focusStylesCss, className),
|
|
241
|
+
height: height,
|
|
242
|
+
role: "figure",
|
|
243
|
+
style: style,
|
|
244
|
+
tabIndex: enableScrubbing ? 0 : undefined,
|
|
245
|
+
width: width
|
|
246
|
+
}, props), {}, {
|
|
247
|
+
children: /*#__PURE__*/_jsx(CartesianChartProvider, {
|
|
248
|
+
value: contextValue,
|
|
249
|
+
children: /*#__PURE__*/_jsx(ScrubberProvider, {
|
|
250
|
+
enableScrubbing: !!enableScrubbing,
|
|
251
|
+
onScrubberPositionChange: onScrubberPositionChange,
|
|
252
|
+
svgRef: internalSvgRef,
|
|
253
|
+
children: children
|
|
254
|
+
})
|
|
255
|
+
})
|
|
256
|
+
}));
|
|
257
|
+
}));
|
|
258
|
+
import "./CartesianChart.css";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { createContext, useContext } from 'react';
|
|
2
|
+
const CartesianChartContext = /*#__PURE__*/createContext(undefined);
|
|
3
|
+
export const useCartesianChartContext = () => {
|
|
4
|
+
const context = useContext(CartesianChartContext);
|
|
5
|
+
if (!context) {
|
|
6
|
+
throw new Error('useCartesianChartContext must be used within a CartesianChart component. See http://cds.coinbase.com/components/graphs/CartesianChart.');
|
|
7
|
+
}
|
|
8
|
+
return context;
|
|
9
|
+
};
|
|
10
|
+
export const CartesianChartProvider = CartesianChartContext.Provider;
|