@gravity-ui/charts 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/ChartInner/index.d.ts +2 -8
- package/dist/cjs/components/ChartInner/index.js +22 -117
- package/dist/cjs/components/ChartInner/types.d.ts +6 -0
- package/dist/cjs/components/ChartInner/useChartInnerHandlers.d.ts +26 -0
- package/dist/cjs/components/ChartInner/useChartInnerHandlers.js +94 -0
- package/dist/cjs/components/ChartInner/useChartInnerProps.d.ts +43 -0
- package/dist/cjs/components/ChartInner/useChartInnerProps.js +81 -0
- package/dist/cjs/components/ChartInner/useChartInnerState.d.ts +13 -0
- package/dist/cjs/components/ChartInner/useChartInnerState.js +34 -0
- package/dist/cjs/components/Legend/index.d.ts +1 -0
- package/dist/cjs/components/Legend/index.js +3 -2
- package/dist/cjs/components/Tooltip/index.d.ts +2 -0
- package/dist/cjs/components/Tooltip/index.js +9 -3
- package/dist/cjs/components/Tooltip/styles.css +3 -0
- package/dist/cjs/hooks/index.d.ts +2 -1
- package/dist/cjs/hooks/index.js +2 -1
- package/dist/cjs/hooks/usePrevious/index.d.ts +1 -0
- package/dist/cjs/hooks/usePrevious/index.js +8 -0
- package/dist/cjs/hooks/useShapes/area/index.js +8 -2
- package/dist/cjs/hooks/useShapes/bar-x/index.js +8 -2
- package/dist/cjs/hooks/useShapes/bar-y/index.js +8 -2
- package/dist/cjs/hooks/useShapes/line/index.js +8 -2
- package/dist/cjs/hooks/useShapes/scatter/index.js +8 -2
- package/dist/cjs/hooks/useShapes/treemap/index.js +8 -2
- package/dist/cjs/hooks/useShapes/utils.d.ts +2 -2
- package/dist/cjs/hooks/useShapes/utils.js +5 -3
- package/dist/cjs/hooks/useShapes/waterfall/index.js +8 -2
- package/dist/cjs/hooks/useTooltip/index.d.ts +2 -3
- package/dist/cjs/types/chart/chart.d.ts +2 -2
- package/dist/cjs/types/chart/series.d.ts +1 -2
- package/dist/cjs/types/chart/tooltip.d.ts +6 -6
- package/dist/cjs/types/misc.d.ts +1 -0
- package/dist/cjs/utils/misc.d.ts +10 -2
- package/dist/cjs/utils/misc.js +15 -3
- package/dist/esm/components/ChartInner/index.d.ts +2 -8
- package/dist/esm/components/ChartInner/index.js +22 -117
- package/dist/esm/components/ChartInner/types.d.ts +6 -0
- package/dist/esm/components/ChartInner/useChartInnerHandlers.d.ts +26 -0
- package/dist/esm/components/ChartInner/useChartInnerHandlers.js +94 -0
- package/dist/esm/components/ChartInner/useChartInnerProps.d.ts +43 -0
- package/dist/esm/components/ChartInner/useChartInnerProps.js +81 -0
- package/dist/esm/components/ChartInner/useChartInnerState.d.ts +13 -0
- package/dist/esm/components/ChartInner/useChartInnerState.js +34 -0
- package/dist/esm/components/Legend/index.d.ts +1 -0
- package/dist/esm/components/Legend/index.js +3 -2
- package/dist/esm/components/Tooltip/index.d.ts +2 -0
- package/dist/esm/components/Tooltip/index.js +9 -3
- package/dist/esm/components/Tooltip/styles.css +3 -0
- package/dist/esm/hooks/index.d.ts +2 -1
- package/dist/esm/hooks/index.js +2 -1
- package/dist/esm/hooks/usePrevious/index.d.ts +1 -0
- package/dist/esm/hooks/usePrevious/index.js +8 -0
- package/dist/esm/hooks/useShapes/area/index.js +8 -2
- package/dist/esm/hooks/useShapes/bar-x/index.js +8 -2
- package/dist/esm/hooks/useShapes/bar-y/index.js +8 -2
- package/dist/esm/hooks/useShapes/line/index.js +8 -2
- package/dist/esm/hooks/useShapes/scatter/index.js +8 -2
- package/dist/esm/hooks/useShapes/treemap/index.js +8 -2
- package/dist/esm/hooks/useShapes/utils.d.ts +2 -2
- package/dist/esm/hooks/useShapes/utils.js +5 -3
- package/dist/esm/hooks/useShapes/waterfall/index.js +8 -2
- package/dist/esm/hooks/useTooltip/index.d.ts +2 -3
- package/dist/esm/types/chart/chart.d.ts +2 -2
- package/dist/esm/types/chart/series.d.ts +1 -2
- package/dist/esm/types/chart/tooltip.d.ts +6 -6
- package/dist/esm/types/misc.d.ts +1 -0
- package/dist/esm/utils/misc.d.ts +10 -2
- package/dist/esm/utils/misc.js +15 -3
- package/package.json +1 -1
- package/dist/cjs/hooks/useTooltip/types.d.ts +0 -1
- package/dist/esm/hooks/useTooltip/types.d.ts +0 -1
- /package/dist/cjs/{hooks/useTooltip → components/ChartInner}/types.js +0 -0
- /package/dist/esm/{hooks/useTooltip → components/ChartInner}/types.js +0 -0
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import type { Dispatch } from 'd3';
|
|
2
|
-
import type { TooltipDataChunk } from '../../types';
|
|
2
|
+
import type { PointPosition, TooltipDataChunk } from '../../types';
|
|
3
3
|
import type { PreparedTooltip } from '../useChartOptions/types';
|
|
4
|
-
import type { PointerPosition } from './types';
|
|
5
4
|
type Args = {
|
|
6
5
|
dispatcher: Dispatch<object>;
|
|
7
6
|
tooltip: PreparedTooltip;
|
|
8
7
|
};
|
|
9
8
|
export declare const useTooltip: ({ dispatcher, tooltip }: Args) => {
|
|
10
9
|
hovered: TooltipDataChunk[] | undefined;
|
|
11
|
-
pointerPosition:
|
|
10
|
+
pointerPosition: PointPosition | undefined;
|
|
12
11
|
};
|
|
13
12
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { MeaningfulAny } from '../misc';
|
|
2
|
-
import type {
|
|
2
|
+
import type { ChartTooltipRendererArgs } from './tooltip';
|
|
3
3
|
export type ChartMargin = {
|
|
4
4
|
top: number;
|
|
5
5
|
right: number;
|
|
@@ -13,6 +13,6 @@ export type ChartOptions = {
|
|
|
13
13
|
point: MeaningfulAny;
|
|
14
14
|
series: MeaningfulAny;
|
|
15
15
|
}, event: PointerEvent) => void;
|
|
16
|
-
pointermove?: (data:
|
|
16
|
+
pointermove?: (data: ChartTooltipRendererArgs | undefined, event: PointerEvent) => void;
|
|
17
17
|
};
|
|
18
18
|
};
|
|
@@ -16,7 +16,7 @@ export type ChartSeriesData<T = MeaningfulAny> = ScatterSeriesData<T> | PieSerie
|
|
|
16
16
|
export type DataLabelRendererData<T = MeaningfulAny> = {
|
|
17
17
|
data: ChartSeriesData<T>;
|
|
18
18
|
};
|
|
19
|
-
type BasicHoverState = {
|
|
19
|
+
export type BasicHoverState = {
|
|
20
20
|
/**
|
|
21
21
|
* Enable separate styles for the hovered series.
|
|
22
22
|
*
|
|
@@ -223,4 +223,3 @@ export type ChartSeriesOptions = {
|
|
|
223
223
|
};
|
|
224
224
|
};
|
|
225
225
|
};
|
|
226
|
-
export {};
|
|
@@ -59,7 +59,7 @@ export type TooltipDataChunkWaterfall<T = MeaningfulAny> = {
|
|
|
59
59
|
export type TooltipDataChunk<T = MeaningfulAny> = (TooltipDataChunkBarX<T> | TooltipDataChunkBarY<T> | TooltipDataChunkPie<T> | TooltipDataChunkScatter<T> | TooltipDataChunkLine<T> | TooltipDataChunkArea<T> | TooltipDataChunkTreemap<T> | TooltipDataChunkWaterfall<T>) & {
|
|
60
60
|
closest?: boolean;
|
|
61
61
|
};
|
|
62
|
-
export type
|
|
62
|
+
export type ChartTooltipRendererArgs<T = MeaningfulAny> = {
|
|
63
63
|
hovered: TooltipDataChunk<T>[];
|
|
64
64
|
xAxis?: ChartXAxis;
|
|
65
65
|
yAxis?: ChartYAxis;
|
|
@@ -67,9 +67,9 @@ export type ChartTooltipRendererData<T = MeaningfulAny> = {
|
|
|
67
67
|
export type ChartTooltip<T = MeaningfulAny> = {
|
|
68
68
|
enabled?: boolean;
|
|
69
69
|
/** Specifies the renderer for the tooltip. If returned null default tooltip renderer will be used. */
|
|
70
|
-
renderer?: (args:
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
70
|
+
renderer?: (args: ChartTooltipRendererArgs<T>) => React.ReactElement | null;
|
|
71
|
+
pin?: {
|
|
72
|
+
enabled?: boolean;
|
|
73
|
+
modifierKey?: 'altKey' | 'metaKey';
|
|
74
|
+
};
|
|
75
75
|
};
|
package/dist/esm/types/misc.d.ts
CHANGED
package/dist/esm/utils/misc.d.ts
CHANGED
|
@@ -1,2 +1,10 @@
|
|
|
1
|
-
export declare
|
|
2
|
-
export declare
|
|
1
|
+
export declare function randomString(length: number, chars: string): string;
|
|
2
|
+
export declare function getUniqId(): string;
|
|
3
|
+
/**
|
|
4
|
+
* Checks Macintosh hardware is used.
|
|
5
|
+
*
|
|
6
|
+
* Note: there is no better way to get this information as using depricated property `navigator.platform`.
|
|
7
|
+
*
|
|
8
|
+
* More details [here](https://developer.mozilla.org/en-US/docs/Web/API/Navigator/platform#examples).
|
|
9
|
+
*/
|
|
10
|
+
export declare function isMacintosh(): boolean;
|
package/dist/esm/utils/misc.js
CHANGED
|
@@ -1,8 +1,20 @@
|
|
|
1
|
-
export
|
|
1
|
+
export function randomString(length, chars) {
|
|
2
2
|
let result = '';
|
|
3
3
|
for (let i = length; i > 0; --i) {
|
|
4
4
|
result += chars[Math.floor(Math.random() * chars.length)];
|
|
5
5
|
}
|
|
6
6
|
return result;
|
|
7
|
-
}
|
|
8
|
-
export
|
|
7
|
+
}
|
|
8
|
+
export function getUniqId() {
|
|
9
|
+
return `gravity-chart.${randomString(5, '0123456789abcdefghijklmnopqrstuvwxyz')}`;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Checks Macintosh hardware is used.
|
|
13
|
+
*
|
|
14
|
+
* Note: there is no better way to get this information as using depricated property `navigator.platform`.
|
|
15
|
+
*
|
|
16
|
+
* More details [here](https://developer.mozilla.org/en-US/docs/Web/API/Navigator/platform#examples).
|
|
17
|
+
*/
|
|
18
|
+
export function isMacintosh() {
|
|
19
|
+
return typeof navigator === 'undefined' ? false : /Mac|iP(hone|[oa]d)/.test(navigator.platform);
|
|
20
|
+
}
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export type PointerPosition = [number, number];
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export type PointerPosition = [number, number];
|
|
File without changes
|
|
File without changes
|