@gravity-ui/charts 1.51.7 → 1.52.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/useChartInnerHandlers.d.ts +3 -2
- package/dist/cjs/components/ChartInner/useChartInnerHandlers.js +1 -3
- package/dist/cjs/components/ChartInner/useChartInnerProps.d.ts +3 -2
- package/dist/cjs/components/ChartInner/useDefaultState.d.ts +3 -2
- package/dist/cjs/components/index.d.ts +1 -0
- package/dist/cjs/components/index.js +1 -0
- package/dist/cjs/core/series/plugin.d.ts +47 -2
- package/dist/cjs/core/series/types.d.ts +4 -0
- package/dist/cjs/core/shapes/area/prepare-data.js +29 -19
- package/dist/cjs/core/shapes/area/renderer.d.ts +0 -5
- package/dist/cjs/core/shapes/area/renderer.js +0 -75
- package/dist/cjs/core/shapes/area/types.d.ts +2 -8
- package/dist/cjs/core/shapes/bar-x/prepare-data.js +18 -7
- package/dist/cjs/core/shapes/bar-x/renderer.d.ts +0 -1
- package/dist/cjs/core/shapes/bar-x/renderer.js +0 -18
- package/dist/cjs/core/shapes/bar-x/types.d.ts +2 -1
- package/dist/cjs/core/shapes/bar-y/get-tooltip-data.js +4 -2
- package/dist/cjs/core/shapes/bar-y/prepare-data.js +8 -2
- package/dist/cjs/core/shapes/funnel/prepare-data.js +121 -68
- package/dist/cjs/core/shapes/heatmap/prepare-data.js +11 -2
- package/dist/cjs/core/shapes/line/prepare-data.js +27 -17
- package/dist/cjs/core/shapes/line/renderer.d.ts +0 -5
- package/dist/cjs/core/shapes/line/renderer.js +0 -75
- package/dist/cjs/core/shapes/line/types.d.ts +2 -8
- package/dist/cjs/core/shapes/marker.d.ts +30 -0
- package/dist/cjs/core/shapes/marker.js +68 -0
- package/dist/cjs/core/shapes/pie/prepare-data.js +24 -9
- package/dist/cjs/core/shapes/radar/prepare-data.js +3 -0
- package/dist/cjs/core/shapes/sankey/prepare-data.js +10 -1
- package/dist/cjs/core/shapes/scatter/prepare-data.js +8 -1
- package/dist/cjs/core/shapes/scatter/renderer.js +3 -2
- package/dist/cjs/core/shapes/scatter/types.d.ts +1 -1
- package/dist/cjs/core/shapes/treemap/prepare-data.js +9 -1
- package/dist/cjs/core/shapes/types.d.ts +35 -0
- package/dist/cjs/core/shapes/waterfall/prepare-data.js +5 -2
- package/dist/cjs/core/shapes/x-range/prepare-data.js +7 -2
- package/dist/cjs/core/types/chart/base.d.ts +22 -2
- package/dist/cjs/core/types/chart/funnel.d.ts +25 -1
- package/dist/cjs/core/types/chart/tooltip.d.ts +6 -1
- package/dist/cjs/core/utils/data-labels.d.ts +34 -0
- package/dist/cjs/core/utils/data-labels.js +26 -0
- package/dist/cjs/core/utils/get-closest-data.d.ts +2 -2
- package/dist/cjs/core/utils/get-closest-data.js +14 -34
- package/dist/cjs/core/utils/tooltip-helpers.d.ts +16 -0
- package/dist/cjs/core/utils/tooltip-helpers.js +12 -0
- package/dist/cjs/hooks/useShapes/AnnotationLayer.d.ts +9 -0
- package/dist/cjs/hooks/useShapes/AnnotationLayer.js +17 -0
- package/dist/cjs/hooks/useShapes/HoverMarkerLayer.d.ts +10 -0
- package/dist/cjs/hooks/useShapes/HoverMarkerLayer.js +22 -0
- package/dist/cjs/hooks/useShapes/MarkerLayer.d.ts +7 -0
- package/dist/cjs/hooks/useShapes/MarkerLayer.js +12 -0
- package/dist/cjs/hooks/useShapes/SeriesShapes.d.ts +18 -0
- package/dist/cjs/hooks/useShapes/SeriesShapes.js +32 -0
- package/dist/cjs/hooks/useShapes/index.d.ts +5 -18
- package/dist/cjs/hooks/useShapes/index.js +39 -229
- package/dist/cjs/index.d.ts +0 -1
- package/dist/cjs/index.js +0 -1
- package/dist/cjs/plugins/area/index.js +42 -0
- package/dist/cjs/plugins/bar-x/index.js +42 -0
- package/dist/cjs/plugins/bar-y/index.js +26 -0
- package/dist/cjs/plugins/funnel/index.js +18 -0
- package/dist/cjs/plugins/funnel/prepare.js +17 -12
- package/dist/cjs/plugins/heatmap/index.js +23 -0
- package/dist/cjs/plugins/line/index.js +28 -0
- package/dist/cjs/plugins/pie/index.js +18 -0
- package/dist/cjs/plugins/radar/index.js +18 -0
- package/dist/cjs/plugins/sankey/index.js +18 -0
- package/dist/cjs/plugins/scatter/index.js +26 -0
- package/dist/cjs/plugins/treemap/index.js +18 -0
- package/dist/cjs/plugins/waterfall/index.js +39 -0
- package/dist/cjs/plugins/x-range/index.js +25 -0
- package/dist/cjs/setup-jsdom.d.ts +0 -1
- package/dist/cjs/setup-jsdom.js +1 -1
- package/dist/esm/components/ChartInner/useChartInnerHandlers.d.ts +3 -2
- package/dist/esm/components/ChartInner/useChartInnerHandlers.js +1 -3
- package/dist/esm/components/ChartInner/useChartInnerProps.d.ts +3 -2
- package/dist/esm/components/ChartInner/useDefaultState.d.ts +3 -2
- package/dist/esm/components/index.d.ts +1 -0
- package/dist/esm/components/index.js +1 -0
- package/dist/esm/core/series/plugin.d.ts +47 -2
- package/dist/esm/core/series/types.d.ts +4 -0
- package/dist/esm/core/shapes/area/prepare-data.js +29 -19
- package/dist/esm/core/shapes/area/renderer.d.ts +0 -5
- package/dist/esm/core/shapes/area/renderer.js +0 -75
- package/dist/esm/core/shapes/area/types.d.ts +2 -8
- package/dist/esm/core/shapes/bar-x/prepare-data.js +18 -7
- package/dist/esm/core/shapes/bar-x/renderer.d.ts +0 -1
- package/dist/esm/core/shapes/bar-x/renderer.js +0 -18
- package/dist/esm/core/shapes/bar-x/types.d.ts +2 -1
- package/dist/esm/core/shapes/bar-y/get-tooltip-data.js +4 -2
- package/dist/esm/core/shapes/bar-y/prepare-data.js +8 -2
- package/dist/esm/core/shapes/funnel/prepare-data.js +121 -68
- package/dist/esm/core/shapes/heatmap/prepare-data.js +11 -2
- package/dist/esm/core/shapes/line/prepare-data.js +27 -17
- package/dist/esm/core/shapes/line/renderer.d.ts +0 -5
- package/dist/esm/core/shapes/line/renderer.js +0 -75
- package/dist/esm/core/shapes/line/types.d.ts +2 -8
- package/dist/esm/core/shapes/marker.d.ts +30 -0
- package/dist/esm/core/shapes/marker.js +68 -0
- package/dist/esm/core/shapes/pie/prepare-data.js +24 -9
- package/dist/esm/core/shapes/radar/prepare-data.js +3 -0
- package/dist/esm/core/shapes/sankey/prepare-data.js +10 -1
- package/dist/esm/core/shapes/scatter/prepare-data.js +8 -1
- package/dist/esm/core/shapes/scatter/renderer.js +3 -2
- package/dist/esm/core/shapes/scatter/types.d.ts +1 -1
- package/dist/esm/core/shapes/treemap/prepare-data.js +9 -1
- package/dist/esm/core/shapes/types.d.ts +35 -0
- package/dist/esm/core/shapes/waterfall/prepare-data.js +5 -2
- package/dist/esm/core/shapes/x-range/prepare-data.js +7 -2
- package/dist/esm/core/types/chart/base.d.ts +22 -2
- package/dist/esm/core/types/chart/funnel.d.ts +25 -1
- package/dist/esm/core/types/chart/tooltip.d.ts +6 -1
- package/dist/esm/core/utils/data-labels.d.ts +34 -0
- package/dist/esm/core/utils/data-labels.js +26 -0
- package/dist/esm/core/utils/get-closest-data.d.ts +2 -2
- package/dist/esm/core/utils/get-closest-data.js +14 -34
- package/dist/esm/core/utils/tooltip-helpers.d.ts +16 -0
- package/dist/esm/core/utils/tooltip-helpers.js +12 -0
- package/dist/esm/hooks/useShapes/AnnotationLayer.d.ts +9 -0
- package/dist/esm/hooks/useShapes/AnnotationLayer.js +17 -0
- package/dist/esm/hooks/useShapes/HoverMarkerLayer.d.ts +10 -0
- package/dist/esm/hooks/useShapes/HoverMarkerLayer.js +22 -0
- package/dist/esm/hooks/useShapes/MarkerLayer.d.ts +7 -0
- package/dist/esm/hooks/useShapes/MarkerLayer.js +12 -0
- package/dist/esm/hooks/useShapes/SeriesShapes.d.ts +18 -0
- package/dist/esm/hooks/useShapes/SeriesShapes.js +32 -0
- package/dist/esm/hooks/useShapes/index.d.ts +5 -18
- package/dist/esm/hooks/useShapes/index.js +39 -229
- package/dist/esm/index.d.ts +0 -1
- package/dist/esm/index.js +0 -1
- package/dist/esm/plugins/area/index.js +42 -0
- package/dist/esm/plugins/bar-x/index.js +42 -0
- package/dist/esm/plugins/bar-y/index.js +26 -0
- package/dist/esm/plugins/funnel/index.js +18 -0
- package/dist/esm/plugins/funnel/prepare.js +17 -12
- package/dist/esm/plugins/heatmap/index.js +23 -0
- package/dist/esm/plugins/line/index.js +28 -0
- package/dist/esm/plugins/pie/index.js +18 -0
- package/dist/esm/plugins/radar/index.js +18 -0
- package/dist/esm/plugins/sankey/index.js +18 -0
- package/dist/esm/plugins/scatter/index.js +26 -0
- package/dist/esm/plugins/treemap/index.js +18 -0
- package/dist/esm/plugins/waterfall/index.js +39 -0
- package/dist/esm/plugins/x-range/index.js +25 -0
- package/dist/esm/setup-jsdom.d.ts +0 -1
- package/dist/esm/setup-jsdom.js +1 -1
- package/package.json +2 -3
- package/dist/cjs/hooks/useShapes/area/index.d.ts +0 -15
- package/dist/cjs/hooks/useShapes/area/index.js +0 -52
- package/dist/cjs/hooks/useShapes/bar-x/index.d.ts +0 -16
- package/dist/cjs/hooks/useShapes/bar-x/index.js +0 -45
- package/dist/cjs/hooks/useShapes/bar-y/index.d.ts +0 -13
- package/dist/cjs/hooks/useShapes/bar-y/index.js +0 -19
- package/dist/cjs/hooks/useShapes/funnel/index.d.ts +0 -13
- package/dist/cjs/hooks/useShapes/funnel/index.js +0 -21
- package/dist/cjs/hooks/useShapes/heatmap/index.d.ts +0 -13
- package/dist/cjs/hooks/useShapes/heatmap/index.js +0 -20
- package/dist/cjs/hooks/useShapes/line/index.d.ts +0 -15
- package/dist/cjs/hooks/useShapes/line/index.js +0 -38
- package/dist/cjs/hooks/useShapes/pie/index.d.ts +0 -12
- package/dist/cjs/hooks/useShapes/pie/index.js +0 -20
- package/dist/cjs/hooks/useShapes/radar/index.d.ts +0 -12
- package/dist/cjs/hooks/useShapes/radar/index.js +0 -19
- package/dist/cjs/hooks/useShapes/sankey/index.d.ts +0 -12
- package/dist/cjs/hooks/useShapes/sankey/index.js +0 -18
- package/dist/cjs/hooks/useShapes/scatter/index.d.ts +0 -13
- package/dist/cjs/hooks/useShapes/scatter/index.js +0 -22
- package/dist/cjs/hooks/useShapes/treemap/index.d.ts +0 -12
- package/dist/cjs/hooks/useShapes/treemap/index.js +0 -18
- package/dist/cjs/hooks/useShapes/waterfall/index.d.ts +0 -14
- package/dist/cjs/hooks/useShapes/waterfall/index.js +0 -31
- package/dist/cjs/hooks/useShapes/x-range/index.d.ts +0 -14
- package/dist/cjs/hooks/useShapes/x-range/index.js +0 -20
- package/dist/esm/hooks/useShapes/area/index.d.ts +0 -15
- package/dist/esm/hooks/useShapes/area/index.js +0 -52
- package/dist/esm/hooks/useShapes/bar-x/index.d.ts +0 -16
- package/dist/esm/hooks/useShapes/bar-x/index.js +0 -45
- package/dist/esm/hooks/useShapes/bar-y/index.d.ts +0 -13
- package/dist/esm/hooks/useShapes/bar-y/index.js +0 -19
- package/dist/esm/hooks/useShapes/funnel/index.d.ts +0 -13
- package/dist/esm/hooks/useShapes/funnel/index.js +0 -21
- package/dist/esm/hooks/useShapes/heatmap/index.d.ts +0 -13
- package/dist/esm/hooks/useShapes/heatmap/index.js +0 -20
- package/dist/esm/hooks/useShapes/line/index.d.ts +0 -15
- package/dist/esm/hooks/useShapes/line/index.js +0 -38
- package/dist/esm/hooks/useShapes/pie/index.d.ts +0 -12
- package/dist/esm/hooks/useShapes/pie/index.js +0 -20
- package/dist/esm/hooks/useShapes/radar/index.d.ts +0 -12
- package/dist/esm/hooks/useShapes/radar/index.js +0 -19
- package/dist/esm/hooks/useShapes/sankey/index.d.ts +0 -12
- package/dist/esm/hooks/useShapes/sankey/index.js +0 -18
- package/dist/esm/hooks/useShapes/scatter/index.d.ts +0 -13
- package/dist/esm/hooks/useShapes/scatter/index.js +0 -22
- package/dist/esm/hooks/useShapes/treemap/index.d.ts +0 -12
- package/dist/esm/hooks/useShapes/treemap/index.js +0 -18
- package/dist/esm/hooks/useShapes/waterfall/index.d.ts +0 -14
- package/dist/esm/hooks/useShapes/waterfall/index.js +0 -31
- package/dist/esm/hooks/useShapes/x-range/index.d.ts +0 -14
- package/dist/esm/hooks/useShapes/x-range/index.js +0 -20
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { Dispatch } from 'd3-dispatch';
|
|
3
|
+
import type { SeriesShapeData } from '../../core/shapes/types';
|
|
4
|
+
interface Props {
|
|
5
|
+
preparedData: SeriesShapeData[];
|
|
6
|
+
dispatcher?: Dispatch<object>;
|
|
7
|
+
namespace: string;
|
|
8
|
+
}
|
|
9
|
+
export declare const HoverMarkerLayer: ({ preparedData, dispatcher, namespace }: Props) => React.JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { select } from 'd3-selection';
|
|
3
|
+
import { renderHoverMarkers } from '../../core/shapes/marker';
|
|
4
|
+
export const HoverMarkerLayer = ({ preparedData, dispatcher, namespace }) => {
|
|
5
|
+
const ref = React.useRef(null);
|
|
6
|
+
React.useEffect(() => {
|
|
7
|
+
if (!ref.current)
|
|
8
|
+
return () => { };
|
|
9
|
+
const container = select(ref.current);
|
|
10
|
+
function handleHover(data) {
|
|
11
|
+
var _a;
|
|
12
|
+
const hoveredData = (_a = data === null || data === void 0 ? void 0 : data.map((d) => d.data)) !== null && _a !== void 0 ? _a : [];
|
|
13
|
+
const items = preparedData.flatMap((d) => d.getHoverMarkers(hoveredData));
|
|
14
|
+
renderHoverMarkers(container, items);
|
|
15
|
+
}
|
|
16
|
+
dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.on(`hover-shape.${namespace}`, handleHover);
|
|
17
|
+
return () => {
|
|
18
|
+
dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.on(`hover-shape.${namespace}`, null);
|
|
19
|
+
};
|
|
20
|
+
}, [preparedData, dispatcher, namespace]);
|
|
21
|
+
return React.createElement("g", { ref: ref });
|
|
22
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { select } from 'd3-selection';
|
|
3
|
+
import { renderMarkers } from '../../core/shapes/marker';
|
|
4
|
+
export const MarkerLayer = ({ markers }) => {
|
|
5
|
+
const ref = React.useRef(null);
|
|
6
|
+
React.useEffect(() => {
|
|
7
|
+
if (ref.current) {
|
|
8
|
+
renderMarkers(select(ref.current), markers);
|
|
9
|
+
}
|
|
10
|
+
}, [markers]);
|
|
11
|
+
return React.createElement("g", { ref: ref });
|
|
12
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { Dispatch } from 'd3-dispatch';
|
|
3
|
+
import type { SeriesPlugin } from '../../core/series/plugin';
|
|
4
|
+
import type { PreparedSeriesOptions } from '../../core/series/types';
|
|
5
|
+
import type { SeriesShapeData } from '../../core/shapes/types';
|
|
6
|
+
interface Props {
|
|
7
|
+
boundsHeight: number;
|
|
8
|
+
boundsWidth: number;
|
|
9
|
+
clipPathId?: string;
|
|
10
|
+
dispatcher?: Dispatch<object>;
|
|
11
|
+
htmlLayout: HTMLElement | null;
|
|
12
|
+
namespace: string;
|
|
13
|
+
plugin: SeriesPlugin;
|
|
14
|
+
preparedData: SeriesShapeData[];
|
|
15
|
+
seriesOptions: PreparedSeriesOptions;
|
|
16
|
+
}
|
|
17
|
+
export declare const SeriesShapes: ({ boundsHeight, boundsWidth, clipPathId, dispatcher, htmlLayout, namespace, plugin, preparedData, seriesOptions, }: Props) => React.JSX.Element;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { block } from '../../utils';
|
|
3
|
+
import { AnnotationLayer } from './AnnotationLayer';
|
|
4
|
+
import { HoverMarkerLayer } from './HoverMarkerLayer';
|
|
5
|
+
import { HtmlLayer } from './HtmlLayer';
|
|
6
|
+
import { MarkerLayer } from './MarkerLayer';
|
|
7
|
+
export const SeriesShapes = ({ boundsHeight, boundsWidth, clipPathId, dispatcher, htmlLayout, namespace, plugin, preparedData, seriesOptions, }) => {
|
|
8
|
+
const b = block(plugin.type);
|
|
9
|
+
const ref = React.useRef(null);
|
|
10
|
+
React.useEffect(() => {
|
|
11
|
+
var _a;
|
|
12
|
+
if (!ref.current)
|
|
13
|
+
return () => { };
|
|
14
|
+
return ((_a = plugin.renderShapes({
|
|
15
|
+
plot: ref.current,
|
|
16
|
+
preparedData,
|
|
17
|
+
seriesOptions,
|
|
18
|
+
boundsWidth,
|
|
19
|
+
boundsHeight,
|
|
20
|
+
dispatcher,
|
|
21
|
+
})) !== null && _a !== void 0 ? _a : undefined);
|
|
22
|
+
}, [boundsHeight, boundsWidth, dispatcher, plugin, preparedData, seriesOptions]);
|
|
23
|
+
const markers = React.useMemo(() => preparedData.flatMap((d) => d.markers), [preparedData]);
|
|
24
|
+
const annotations = React.useMemo(() => preparedData.flatMap((d) => d.annotations), [preparedData]);
|
|
25
|
+
const htmlLayerData = React.useMemo(() => ({ htmlElements: preparedData.flatMap((d) => d.htmlLabels) }), [preparedData]);
|
|
26
|
+
return (React.createElement(React.Fragment, null,
|
|
27
|
+
React.createElement("g", { ref: ref, className: b(), clipPath: clipPathId ? `url(#${clipPathId})` : undefined }),
|
|
28
|
+
React.createElement(MarkerLayer, { markers: markers }),
|
|
29
|
+
React.createElement(HoverMarkerLayer, { preparedData: preparedData, dispatcher: dispatcher, namespace: namespace }),
|
|
30
|
+
React.createElement(AnnotationLayer, { annotations: annotations, boundsWidth: boundsWidth, boundsHeight: boundsHeight }),
|
|
31
|
+
React.createElement(HtmlLayer, { preparedData: htmlLayerData, htmlLayout: htmlLayout })));
|
|
32
|
+
};
|
|
@@ -1,26 +1,14 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { Dispatch } from 'd3-dispatch';
|
|
3
|
-
import type { SeriesType } from '../../core/constants';
|
|
4
3
|
import type { PreparedSplit } from '../../core/layout/split-types';
|
|
5
4
|
import type { ChartScale } from '../../core/scales/types';
|
|
6
5
|
import type { PreparedSeries, PreparedSeriesOptions } from '../../core/series/types';
|
|
7
|
-
import type {
|
|
8
|
-
import type { PreparedBarXData } from '../../core/shapes/bar-x/types';
|
|
9
|
-
import type { PreparedBarYData } from '../../core/shapes/bar-y/types';
|
|
10
|
-
import type { PreparedFunnelData } from '../../core/shapes/funnel/types';
|
|
11
|
-
import type { PreparedHeatmapData } from '../../core/shapes/heatmap/types';
|
|
12
|
-
import type { PreparedLineData } from '../../core/shapes/line/types';
|
|
13
|
-
import type { PreparedPieData } from '../../core/shapes/pie/types';
|
|
14
|
-
import type { PreparedRadarData } from '../../core/shapes/radar/types';
|
|
15
|
-
import type { PreparedSankeyData } from '../../core/shapes/sankey/types';
|
|
16
|
-
import type { PreparedScatterData } from '../../core/shapes/scatter/types';
|
|
17
|
-
import type { PreparedWaterfallData } from '../../core/shapes/waterfall/types';
|
|
18
|
-
import type { PreparedXRangeData } from '../../core/shapes/x-range/types';
|
|
6
|
+
import type { TooltipItemData } from '../../core/shapes/types';
|
|
19
7
|
import type { ZoomState } from '../../core/zoom/types';
|
|
20
8
|
import type { PreparedXAxis, PreparedYAxis } from '../useAxis/types';
|
|
21
9
|
import './styles.css';
|
|
22
|
-
export type
|
|
23
|
-
export type ClipPathBySeriesType = Partial<Record<
|
|
10
|
+
export type { TooltipItemData };
|
|
11
|
+
export type ClipPathBySeriesType = Partial<Record<string, boolean>>;
|
|
24
12
|
type Args = {
|
|
25
13
|
boundsWidth: number;
|
|
26
14
|
boundsHeight: number;
|
|
@@ -41,11 +29,10 @@ type Args = {
|
|
|
41
29
|
};
|
|
42
30
|
export declare function getShapes(args: Args): Promise<{
|
|
43
31
|
shapes: React.ReactElement<any, string | React.JSXElementConstructor<any>>[];
|
|
44
|
-
shapesData:
|
|
32
|
+
shapesData: TooltipItemData[];
|
|
45
33
|
}>;
|
|
46
34
|
export declare const useShapes: (args: Args) => {
|
|
47
35
|
shapes: React.ReactElement<any, string | React.JSXElementConstructor<any>>[];
|
|
48
|
-
shapesData:
|
|
36
|
+
shapesData: TooltipItemData[];
|
|
49
37
|
shapesReady: boolean;
|
|
50
38
|
};
|
|
51
|
-
export {};
|
|
@@ -1,35 +1,21 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { group } from 'd3-array';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { prepareLineData } from '../../core/shapes/line/prepare-data';
|
|
6
|
-
import { preparePieData } from '../../core/shapes/pie/prepare-data';
|
|
7
|
-
import { prepareRadarData } from '../../core/shapes/radar/prepare-data';
|
|
8
|
-
import { prepareSankeyData } from '../../core/shapes/sankey/prepare-data';
|
|
9
|
-
import { prepareTreemapData } from '../../core/shapes/treemap/prepare-data';
|
|
3
|
+
import { getSeriesPlugin } from '../../core/series/seriesRegistry';
|
|
4
|
+
import { getSeriesClipPathId } from '../../core/shapes/utils';
|
|
10
5
|
import { getOnlyVisibleSeries } from '../../core/utils';
|
|
11
|
-
import {
|
|
12
|
-
import { AreaSeriesShapes } from './area';
|
|
13
|
-
import { BarXSeriesShapes, prepareBarXData } from './bar-x';
|
|
14
|
-
import { BarYSeriesShapes, prepareBarYData } from './bar-y';
|
|
15
|
-
import { FunnelSeriesShapes, prepareFunnelData } from './funnel';
|
|
16
|
-
import { HeatmapSeriesShapes, prepareHeatmapData } from './heatmap';
|
|
17
|
-
import { LineSeriesShapes } from './line';
|
|
18
|
-
import { PieSeriesShapes } from './pie';
|
|
19
|
-
import { RadarSeriesShapes } from './radar';
|
|
20
|
-
import { SankeySeriesShape } from './sankey';
|
|
21
|
-
import { ScatterSeriesShape, prepareScatterData } from './scatter';
|
|
22
|
-
import { TreemapSeriesShape } from './treemap';
|
|
23
|
-
import { getSeriesClipPathId } from './utils';
|
|
24
|
-
import { WaterfallSeriesShapes, prepareWaterfallData } from './waterfall';
|
|
25
|
-
import { XRangeSeriesShapes, prepareXRangeData } from './x-range';
|
|
6
|
+
import { SeriesShapes } from './SeriesShapes';
|
|
26
7
|
import './styles.css';
|
|
27
8
|
function IS_OUTSIDE_BOUNDS() {
|
|
28
9
|
return false;
|
|
29
10
|
}
|
|
30
|
-
function
|
|
31
|
-
var _a;
|
|
32
|
-
|
|
11
|
+
function resolveClipPathId(args) {
|
|
12
|
+
var _a, _b;
|
|
13
|
+
const { plugin, clipPathId, clipPathBySeriesType, yAxis, zoomState } = args;
|
|
14
|
+
if (plugin.type === 'line') {
|
|
15
|
+
return getSeriesClipPathId({ clipPathId, yAxis, zoomState });
|
|
16
|
+
}
|
|
17
|
+
const useClip = (_b = (_a = clipPathBySeriesType === null || clipPathBySeriesType === void 0 ? void 0 : clipPathBySeriesType[plugin.type]) !== null && _a !== void 0 ? _a : plugin.useClipPath) !== null && _b !== void 0 ? _b : true;
|
|
18
|
+
return useClip ? clipPathId : undefined;
|
|
33
19
|
}
|
|
34
20
|
export async function getShapes(args) {
|
|
35
21
|
const { boundsWidth, boundsHeight, clipPathId, clipPathBySeriesType, dispatcher, htmlLayout, isOutsideBounds = IS_OUTSIDE_BOUNDS, isRangeSlider, series, seriesOptions, split, xAxis, xScale, yAxis, yScale, zoomState, } = args;
|
|
@@ -45,212 +31,36 @@ export async function getShapes(args) {
|
|
|
45
31
|
const layers = [];
|
|
46
32
|
const groupedSeriesItems = Array.from(groupedSeries);
|
|
47
33
|
for (let index = groupedSeriesItems.length - 1; index >= 0; index--) {
|
|
48
|
-
const
|
|
49
|
-
const [groupId, chartSeries] = item;
|
|
34
|
+
const [groupKey, chartSeries] = groupedSeriesItems[index];
|
|
50
35
|
const seriesType = chartSeries[0].type;
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
break;
|
|
70
|
-
}
|
|
71
|
-
case SERIES_TYPE.BarY: {
|
|
72
|
-
if (xAxis && xScale && (yScale === null || yScale === void 0 ? void 0 : yScale.length)) {
|
|
73
|
-
const preparedData = await prepareBarYData({
|
|
74
|
-
boundsHeight,
|
|
75
|
-
boundsWidth,
|
|
76
|
-
series: chartSeries,
|
|
77
|
-
seriesOptions,
|
|
78
|
-
xAxis,
|
|
79
|
-
xScale,
|
|
80
|
-
yAxis,
|
|
81
|
-
yScale,
|
|
82
|
-
});
|
|
83
|
-
shapes[index] = (React.createElement(BarYSeriesShapes, { key: SERIES_TYPE.BarY, dispatcher: dispatcher, seriesOptions: seriesOptions, preparedData: preparedData, htmlLayout: htmlLayout, clipPathId: clipPathId }));
|
|
84
|
-
shapesData.splice(index, 0, ...preparedData.shapes);
|
|
85
|
-
}
|
|
86
|
-
break;
|
|
87
|
-
}
|
|
88
|
-
case SERIES_TYPE.Waterfall: {
|
|
89
|
-
if (xAxis && xScale && (yScale === null || yScale === void 0 ? void 0 : yScale.length)) {
|
|
90
|
-
const preparedData = await prepareWaterfallData({
|
|
91
|
-
series: chartSeries,
|
|
92
|
-
seriesOptions,
|
|
93
|
-
xAxis,
|
|
94
|
-
xScale,
|
|
95
|
-
yAxis,
|
|
96
|
-
yScale,
|
|
97
|
-
});
|
|
98
|
-
shapes[index] = (React.createElement(WaterfallSeriesShapes, { key: SERIES_TYPE.Waterfall, dispatcher: dispatcher, seriesOptions: seriesOptions, preparedData: preparedData, htmlLayout: htmlLayout, clipPathId: clipPathId }));
|
|
99
|
-
shapesData.splice(index, 0, ...preparedData);
|
|
100
|
-
}
|
|
101
|
-
break;
|
|
102
|
-
}
|
|
103
|
-
case SERIES_TYPE.Line: {
|
|
104
|
-
if (xAxis && xScale && (yScale === null || yScale === void 0 ? void 0 : yScale.length)) {
|
|
105
|
-
const preparedData = await prepareLineData({
|
|
106
|
-
series: chartSeries,
|
|
107
|
-
seriesOptions,
|
|
108
|
-
xAxis,
|
|
109
|
-
xScale,
|
|
110
|
-
yAxis,
|
|
111
|
-
yScale,
|
|
112
|
-
split,
|
|
113
|
-
isOutsideBounds,
|
|
114
|
-
isRangeSlider,
|
|
115
|
-
otherLayers: layers,
|
|
116
|
-
});
|
|
117
|
-
const resultClipPathId = getSeriesClipPathId({
|
|
118
|
-
clipPathId,
|
|
119
|
-
yAxis,
|
|
120
|
-
zoomState,
|
|
121
|
-
});
|
|
122
|
-
shapes[index] = (React.createElement(LineSeriesShapes, { key: groupId, boundsHeight: boundsHeight, boundsWidth: boundsWidth, dispatcher: dispatcher, seriesOptions: seriesOptions, preparedData: preparedData, htmlLayout: htmlLayout, clipPathId: resultClipPathId }));
|
|
123
|
-
shapesData.splice(index, 0, ...preparedData);
|
|
124
|
-
layers.push(...preparedData);
|
|
125
|
-
}
|
|
126
|
-
break;
|
|
127
|
-
}
|
|
128
|
-
case SERIES_TYPE.Area: {
|
|
129
|
-
if (xAxis && xScale && (yScale === null || yScale === void 0 ? void 0 : yScale.length)) {
|
|
130
|
-
const preparedData = await prepareAreaData({
|
|
131
|
-
series: chartSeries,
|
|
132
|
-
seriesOptions,
|
|
133
|
-
xAxis,
|
|
134
|
-
xScale,
|
|
135
|
-
yAxis,
|
|
136
|
-
yScale,
|
|
137
|
-
split,
|
|
138
|
-
isOutsideBounds,
|
|
139
|
-
isRangeSlider,
|
|
140
|
-
});
|
|
141
|
-
shapes[index] = (React.createElement(AreaSeriesShapes, { key: SERIES_TYPE.Area, boundsHeight: boundsHeight, boundsWidth: boundsWidth, dispatcher: dispatcher, seriesOptions: seriesOptions, preparedData: preparedData, htmlLayout: htmlLayout, clipPathId: clipPathId }));
|
|
142
|
-
shapesData.splice(index, 0, ...preparedData);
|
|
143
|
-
layers.push(...preparedData);
|
|
144
|
-
}
|
|
145
|
-
break;
|
|
146
|
-
}
|
|
147
|
-
case SERIES_TYPE.Scatter: {
|
|
148
|
-
if (xAxis && xScale && (yScale === null || yScale === void 0 ? void 0 : yScale.length)) {
|
|
149
|
-
const scatterShapeData = await prepareScatterData({
|
|
150
|
-
series: chartSeries,
|
|
151
|
-
xAxis,
|
|
152
|
-
xScale,
|
|
153
|
-
yAxis,
|
|
154
|
-
yScale,
|
|
155
|
-
split,
|
|
156
|
-
isOutsideBounds,
|
|
157
|
-
isRangeSlider,
|
|
158
|
-
});
|
|
159
|
-
shapes[index] = (React.createElement(ScatterSeriesShape, { key: SERIES_TYPE.Scatter, clipPathId: shouldUseClipPathId(SERIES_TYPE.Scatter, clipPathBySeriesType)
|
|
160
|
-
? clipPathId
|
|
161
|
-
: undefined, dispatcher: dispatcher, preparedData: scatterShapeData, seriesOptions: seriesOptions, htmlLayout: htmlLayout }));
|
|
162
|
-
shapesData.splice(index, 0, ...scatterShapeData.markers);
|
|
163
|
-
}
|
|
164
|
-
break;
|
|
165
|
-
}
|
|
166
|
-
case SERIES_TYPE.Pie: {
|
|
167
|
-
const preparedData = await preparePieData({
|
|
168
|
-
series: chartSeries,
|
|
169
|
-
boundsWidth,
|
|
170
|
-
boundsHeight,
|
|
171
|
-
});
|
|
172
|
-
shapes[index] = (React.createElement(PieSeriesShapes, { key: SERIES_TYPE.Pie, dispatcher: dispatcher, preparedData: preparedData, seriesOptions: seriesOptions, htmlLayout: htmlLayout }));
|
|
173
|
-
shapesData.splice(index, 0, ...preparedData);
|
|
174
|
-
break;
|
|
175
|
-
}
|
|
176
|
-
case SERIES_TYPE.Treemap: {
|
|
177
|
-
const preparedData = await prepareTreemapData({
|
|
178
|
-
// We should have exactly one series with "treemap" type
|
|
179
|
-
// Otherwise data validation should emit an error
|
|
180
|
-
series: chartSeries[0],
|
|
181
|
-
width: boundsWidth,
|
|
182
|
-
height: boundsHeight,
|
|
183
|
-
});
|
|
184
|
-
shapes[index] = (React.createElement(TreemapSeriesShape, { key: SERIES_TYPE.Treemap, dispatcher: dispatcher, preparedData: preparedData, seriesOptions: seriesOptions, htmlLayout: htmlLayout }));
|
|
185
|
-
shapesData.splice(index, 0, preparedData);
|
|
186
|
-
break;
|
|
187
|
-
}
|
|
188
|
-
case SERIES_TYPE.Sankey: {
|
|
189
|
-
const preparedData = prepareSankeyData({
|
|
190
|
-
series: chartSeries[0],
|
|
191
|
-
width: boundsWidth,
|
|
192
|
-
height: boundsHeight,
|
|
193
|
-
});
|
|
194
|
-
shapes[index] = (React.createElement(SankeySeriesShape, { key: SERIES_TYPE.Sankey, dispatcher: dispatcher, preparedData: preparedData, seriesOptions: seriesOptions, htmlLayout: htmlLayout }));
|
|
195
|
-
shapesData.splice(index, 0, preparedData);
|
|
196
|
-
break;
|
|
197
|
-
}
|
|
198
|
-
case SERIES_TYPE.Radar: {
|
|
199
|
-
const preparedData = await prepareRadarData({
|
|
200
|
-
series: chartSeries,
|
|
201
|
-
boundsWidth,
|
|
202
|
-
boundsHeight,
|
|
203
|
-
});
|
|
204
|
-
shapes[index] = (React.createElement(RadarSeriesShapes, { key: SERIES_TYPE.Radar, dispatcher: dispatcher, series: preparedData, seriesOptions: seriesOptions, htmlLayout: htmlLayout }));
|
|
205
|
-
shapesData.splice(index, 0, ...preparedData);
|
|
206
|
-
break;
|
|
207
|
-
}
|
|
208
|
-
case SERIES_TYPE.Heatmap: {
|
|
209
|
-
if (xAxis && xScale && (yScale === null || yScale === void 0 ? void 0 : yScale[0])) {
|
|
210
|
-
const preparedData = await prepareHeatmapData({
|
|
211
|
-
series: chartSeries[0],
|
|
212
|
-
xAxis,
|
|
213
|
-
xScale,
|
|
214
|
-
yAxis: yAxis[0],
|
|
215
|
-
yScale: yScale[0],
|
|
216
|
-
});
|
|
217
|
-
shapes[index] = (React.createElement(HeatmapSeriesShapes, { key: SERIES_TYPE.Heatmap, dispatcher: dispatcher, preparedData: preparedData, seriesOptions: seriesOptions, htmlLayout: htmlLayout }));
|
|
218
|
-
shapesData.splice(index, 0, preparedData);
|
|
219
|
-
}
|
|
220
|
-
break;
|
|
221
|
-
}
|
|
222
|
-
case SERIES_TYPE.Funnel: {
|
|
223
|
-
const preparedData = await prepareFunnelData({
|
|
224
|
-
series: chartSeries,
|
|
225
|
-
boundsWidth,
|
|
226
|
-
boundsHeight,
|
|
227
|
-
});
|
|
228
|
-
shapes[index] = (React.createElement(FunnelSeriesShapes, { key: SERIES_TYPE.Funnel, dispatcher: dispatcher, preparedData: preparedData, seriesOptions: seriesOptions, htmlLayout: htmlLayout }));
|
|
229
|
-
shapesData.splice(index, 0, preparedData);
|
|
230
|
-
break;
|
|
231
|
-
}
|
|
232
|
-
case SERIES_TYPE.XRange: {
|
|
233
|
-
if (xAxis && xScale && (yScale === null || yScale === void 0 ? void 0 : yScale.length)) {
|
|
234
|
-
const preparedData = await prepareXRangeData({
|
|
235
|
-
series: chartSeries,
|
|
236
|
-
xAxis,
|
|
237
|
-
xScale,
|
|
238
|
-
yAxis,
|
|
239
|
-
yScale,
|
|
240
|
-
boundsWidth,
|
|
241
|
-
isRangeSlider,
|
|
242
|
-
});
|
|
243
|
-
shapes[index] = (React.createElement(XRangeSeriesShapes, { key: SERIES_TYPE.XRange, dispatcher: dispatcher, preparedData: preparedData, seriesOptions: seriesOptions, htmlLayout: htmlLayout, clipPathId: clipPathId }));
|
|
244
|
-
shapesData.splice(index, 0, ...preparedData);
|
|
245
|
-
}
|
|
246
|
-
break;
|
|
247
|
-
}
|
|
248
|
-
default: {
|
|
249
|
-
throw new ChartError({
|
|
250
|
-
message: `The display method is not defined for a series with type "${seriesType}"`,
|
|
251
|
-
});
|
|
252
|
-
}
|
|
36
|
+
const plugin = getSeriesPlugin(seriesType);
|
|
37
|
+
const { renderData, tooltipItems } = await plugin.prepareShapeData({
|
|
38
|
+
series: chartSeries,
|
|
39
|
+
boundsWidth,
|
|
40
|
+
boundsHeight,
|
|
41
|
+
seriesOptions,
|
|
42
|
+
xAxis,
|
|
43
|
+
yAxis,
|
|
44
|
+
xScale,
|
|
45
|
+
yScale,
|
|
46
|
+
split,
|
|
47
|
+
isOutsideBounds,
|
|
48
|
+
isRangeSlider,
|
|
49
|
+
otherLayers: layers,
|
|
50
|
+
});
|
|
51
|
+
if (renderData.length === 0) {
|
|
52
|
+
continue;
|
|
253
53
|
}
|
|
54
|
+
const resolvedClipPathId = resolveClipPathId({
|
|
55
|
+
plugin,
|
|
56
|
+
clipPathId,
|
|
57
|
+
clipPathBySeriesType,
|
|
58
|
+
yAxis,
|
|
59
|
+
zoomState,
|
|
60
|
+
});
|
|
61
|
+
shapes[index] = (React.createElement(SeriesShapes, { key: groupKey, plugin: plugin, preparedData: renderData, boundsWidth: boundsWidth, boundsHeight: boundsHeight, clipPathId: resolvedClipPathId, seriesOptions: seriesOptions, dispatcher: dispatcher, htmlLayout: htmlLayout, namespace: `hover-markers-${groupKey}` }));
|
|
62
|
+
shapesData.splice(index, 0, ...tooltipItems);
|
|
63
|
+
layers.push(...renderData);
|
|
254
64
|
}
|
|
255
65
|
return { shapes, shapesData };
|
|
256
66
|
}
|
package/dist/cjs/index.d.ts
CHANGED
package/dist/cjs/index.js
CHANGED
|
@@ -1,5 +1,47 @@
|
|
|
1
|
+
import { getTooltipData } from '../../core/shapes/area/get-tooltip-data';
|
|
2
|
+
import { prepareAreaData } from '../../core/shapes/area/prepare-data';
|
|
3
|
+
import { renderArea } from '../../core/shapes/area/renderer';
|
|
4
|
+
import { filterOverlappingLabels } from '../../core/utils';
|
|
1
5
|
import { prepareArea } from './prepare';
|
|
6
|
+
async function prepareShapeData(args) {
|
|
7
|
+
const { series, seriesOptions, xAxis, xScale, yAxis, yScale, split, isOutsideBounds, isRangeSlider, } = args;
|
|
8
|
+
if (!xAxis || !xScale || !(yScale === null || yScale === void 0 ? void 0 : yScale.length) || !split) {
|
|
9
|
+
return { renderData: [], tooltipItems: [] };
|
|
10
|
+
}
|
|
11
|
+
const data = await prepareAreaData({
|
|
12
|
+
series: series,
|
|
13
|
+
seriesOptions,
|
|
14
|
+
xAxis,
|
|
15
|
+
xScale,
|
|
16
|
+
yAxis: yAxis !== null && yAxis !== void 0 ? yAxis : [],
|
|
17
|
+
yScale,
|
|
18
|
+
split,
|
|
19
|
+
isOutsideBounds: isOutsideBounds !== null && isOutsideBounds !== void 0 ? isOutsideBounds : (() => false),
|
|
20
|
+
isRangeSlider,
|
|
21
|
+
});
|
|
22
|
+
const allowOverlap = data.some((d) => d.series.dataLabels.allowOverlap);
|
|
23
|
+
if (!allowOverlap) {
|
|
24
|
+
const filtered = filterOverlappingLabels(data.flatMap((d) => d.htmlLabels));
|
|
25
|
+
const [first, ...rest] = data;
|
|
26
|
+
if (first) {
|
|
27
|
+
const filteredData = [
|
|
28
|
+
Object.assign(Object.assign({}, first), { htmlLabels: filtered }),
|
|
29
|
+
...rest.map((d) => (Object.assign(Object.assign({}, d), { htmlLabels: [] }))),
|
|
30
|
+
];
|
|
31
|
+
return { renderData: filteredData, tooltipItems: filteredData };
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return { renderData: data, tooltipItems: data };
|
|
35
|
+
}
|
|
36
|
+
function renderShapes({ plot, preparedData, seriesOptions, dispatcher }) {
|
|
37
|
+
const data = preparedData;
|
|
38
|
+
const allowOverlap = data.some((d) => d.series.dataLabels.allowOverlap);
|
|
39
|
+
return renderArea({ plot }, data, seriesOptions, allowOverlap, dispatcher);
|
|
40
|
+
}
|
|
2
41
|
export const areaPlugin = {
|
|
3
42
|
type: 'area',
|
|
4
43
|
prepareSeries: ({ series, seriesOptions, legend, colorScale }) => prepareArea({ series: series, seriesOptions, legend, colorScale }),
|
|
44
|
+
prepareShapeData,
|
|
45
|
+
renderShapes,
|
|
46
|
+
getTooltipData: getTooltipData,
|
|
5
47
|
};
|
|
@@ -1,5 +1,47 @@
|
|
|
1
|
+
import { getTooltipData } from '../../core/shapes/bar-x/get-tooltip-data';
|
|
2
|
+
import { prepareBarXData } from '../../core/shapes/bar-x/prepare-data';
|
|
3
|
+
import { renderBarX } from '../../core/shapes/bar-x/renderer';
|
|
4
|
+
import { filterOverlappingLabels } from '../../core/utils';
|
|
1
5
|
import { prepareBarXSeries } from './prepare';
|
|
6
|
+
async function prepareShapeData(args) {
|
|
7
|
+
const { series, seriesOptions, xAxis, xScale, yAxis, yScale, boundsHeight, split, isRangeSlider, } = args;
|
|
8
|
+
if (!xAxis || !xScale || !(yScale === null || yScale === void 0 ? void 0 : yScale.length) || !split) {
|
|
9
|
+
return { renderData: [], tooltipItems: [] };
|
|
10
|
+
}
|
|
11
|
+
const data = await prepareBarXData({
|
|
12
|
+
series: series,
|
|
13
|
+
seriesOptions,
|
|
14
|
+
xAxis,
|
|
15
|
+
xScale,
|
|
16
|
+
yAxis: yAxis !== null && yAxis !== void 0 ? yAxis : [],
|
|
17
|
+
yScale,
|
|
18
|
+
boundsHeight,
|
|
19
|
+
split,
|
|
20
|
+
isRangeSlider,
|
|
21
|
+
});
|
|
22
|
+
const allowOverlap = data.some((d) => d.series.dataLabels.allowOverlap);
|
|
23
|
+
if (!allowOverlap) {
|
|
24
|
+
const filtered = filterOverlappingLabels(data.flatMap((d) => d.htmlLabels));
|
|
25
|
+
const [first, ...rest] = data;
|
|
26
|
+
if (first) {
|
|
27
|
+
const filteredData = [
|
|
28
|
+
Object.assign(Object.assign({}, first), { htmlLabels: filtered }),
|
|
29
|
+
...rest.map((d) => (Object.assign(Object.assign({}, d), { htmlLabels: [] }))),
|
|
30
|
+
];
|
|
31
|
+
return { renderData: filteredData, tooltipItems: filteredData };
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return { renderData: data, tooltipItems: data };
|
|
35
|
+
}
|
|
36
|
+
function renderShapes({ plot, preparedData, seriesOptions, boundsWidth, boundsHeight, dispatcher, }) {
|
|
37
|
+
const data = preparedData;
|
|
38
|
+
const allowOverlap = data.some((d) => d.series.dataLabels.allowOverlap);
|
|
39
|
+
return renderBarX({ plot, boundsWidth, boundsHeight }, data, seriesOptions, allowOverlap, dispatcher);
|
|
40
|
+
}
|
|
2
41
|
export const barXPlugin = {
|
|
3
42
|
type: 'bar-x',
|
|
4
43
|
prepareSeries: ({ series, seriesOptions, legend, colorScale }) => prepareBarXSeries({ series: series, seriesOptions, legend, colorScale }),
|
|
44
|
+
prepareShapeData,
|
|
45
|
+
renderShapes,
|
|
46
|
+
getTooltipData: getTooltipData,
|
|
5
47
|
};
|
|
@@ -1,5 +1,31 @@
|
|
|
1
|
+
import { getTooltipData } from '../../core/shapes/bar-y/get-tooltip-data';
|
|
2
|
+
import { prepareBarYData } from '../../core/shapes/bar-y/prepare-data';
|
|
3
|
+
import { renderBarY } from '../../core/shapes/bar-y/renderer';
|
|
1
4
|
import { prepareBarYSeries } from './prepare';
|
|
5
|
+
async function prepareShapeData(args) {
|
|
6
|
+
const { series, seriesOptions, xAxis, xScale, yAxis, yScale, boundsHeight, boundsWidth } = args;
|
|
7
|
+
if (!xAxis || !xScale || !(yScale === null || yScale === void 0 ? void 0 : yScale.length)) {
|
|
8
|
+
return { renderData: [], tooltipItems: [] };
|
|
9
|
+
}
|
|
10
|
+
const data = await prepareBarYData({
|
|
11
|
+
boundsHeight,
|
|
12
|
+
boundsWidth,
|
|
13
|
+
series: series,
|
|
14
|
+
seriesOptions,
|
|
15
|
+
xAxis,
|
|
16
|
+
xScale,
|
|
17
|
+
yAxis: yAxis !== null && yAxis !== void 0 ? yAxis : [],
|
|
18
|
+
yScale,
|
|
19
|
+
});
|
|
20
|
+
return { renderData: [data], tooltipItems: data.shapes };
|
|
21
|
+
}
|
|
22
|
+
function renderShapes({ plot, preparedData, seriesOptions, dispatcher }) {
|
|
23
|
+
return renderBarY({ plot }, preparedData[0], seriesOptions, dispatcher);
|
|
24
|
+
}
|
|
2
25
|
export const barYPlugin = {
|
|
3
26
|
type: 'bar-y',
|
|
4
27
|
prepareSeries: ({ series, seriesOptions, legend, colorScale }) => prepareBarYSeries({ series: series, seriesOptions, legend, colorScale }),
|
|
28
|
+
prepareShapeData,
|
|
29
|
+
renderShapes,
|
|
30
|
+
getTooltipData: getTooltipData,
|
|
5
31
|
};
|
|
@@ -1,5 +1,23 @@
|
|
|
1
|
+
import { getTooltipData } from '../../core/shapes/funnel/get-tooltip-data';
|
|
2
|
+
import { prepareFunnelData } from '../../core/shapes/funnel/prepare-data';
|
|
3
|
+
import { renderFunnel } from '../../core/shapes/funnel/renderer';
|
|
1
4
|
import { prepareFunnelSeries } from './prepare';
|
|
5
|
+
async function prepareShapeData({ series, boundsWidth, boundsHeight, }) {
|
|
6
|
+
const data = await prepareFunnelData({
|
|
7
|
+
series: series,
|
|
8
|
+
boundsWidth,
|
|
9
|
+
boundsHeight,
|
|
10
|
+
});
|
|
11
|
+
return { renderData: [data], tooltipItems: [data] };
|
|
12
|
+
}
|
|
13
|
+
function renderShapes({ plot, preparedData, seriesOptions, dispatcher }) {
|
|
14
|
+
return renderFunnel({ plot }, preparedData[0], seriesOptions, dispatcher);
|
|
15
|
+
}
|
|
2
16
|
export const funnelPlugin = {
|
|
3
17
|
type: 'funnel',
|
|
18
|
+
useClipPath: false,
|
|
4
19
|
prepareSeries: ({ series, seriesOptions, legend, colors }) => prepareFunnelSeries({ series: series, seriesOptions, legend, colors }),
|
|
20
|
+
prepareShapeData,
|
|
21
|
+
renderShapes,
|
|
22
|
+
getTooltipData: getTooltipData,
|
|
5
23
|
};
|