@gravity-ui/charts 0.5.0 → 0.6.1-beta.1
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/README.md +2 -2
- package/dist/cjs/components/Axis/AxisY.d.ts +1 -0
- package/dist/cjs/components/Axis/AxisY.js +55 -13
- package/dist/cjs/components/ChartInner/index.d.ts +2 -8
- package/dist/cjs/components/ChartInner/index.js +25 -119
- 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 +98 -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 +4 -4
- package/dist/cjs/components/PlotTitle/index.js +1 -1
- package/dist/cjs/components/PlotTitle/styles.css +1 -1
- package/dist/cjs/components/Tooltip/ChartTooltipContent.d.ts +2 -2
- package/dist/cjs/components/Tooltip/DefaultContent.js +19 -3
- package/dist/cjs/components/Tooltip/index.d.ts +2 -0
- package/dist/cjs/components/Tooltip/index.js +10 -4
- package/dist/cjs/components/Tooltip/styles.css +13 -8
- package/dist/cjs/components/index.d.ts +10 -9
- package/dist/cjs/constants/index.d.ts +1 -0
- package/dist/cjs/constants/index.js +1 -0
- package/dist/cjs/hooks/index.d.ts +2 -1
- package/dist/cjs/hooks/index.js +2 -1
- package/dist/cjs/hooks/useChartOptions/types.d.ts +11 -1
- package/dist/cjs/hooks/useChartOptions/x-axis.js +1 -0
- package/dist/cjs/hooks/useChartOptions/y-axis.js +9 -1
- package/dist/cjs/hooks/usePrevious/index.d.ts +1 -0
- package/dist/cjs/hooks/usePrevious/index.js +8 -0
- package/dist/cjs/hooks/useSeries/prepare-area.d.ts +1 -1
- package/dist/cjs/hooks/useSeries/prepare-bar-x.d.ts +2 -1
- package/dist/cjs/hooks/useSeries/prepare-bar-x.js +2 -1
- package/dist/cjs/hooks/useSeries/prepare-bar-y.d.ts +2 -1
- package/dist/cjs/hooks/useSeries/prepare-bar-y.js +3 -1
- package/dist/cjs/hooks/useSeries/prepare-line.d.ts +1 -1
- package/dist/cjs/hooks/useSeries/prepare-pie.js +2 -2
- package/dist/cjs/hooks/useSeries/prepare-sankey.d.ts +11 -0
- package/dist/cjs/hooks/useSeries/prepare-sankey.js +38 -0
- package/dist/cjs/hooks/useSeries/prepareSeries.js +21 -2
- package/dist/cjs/hooks/useSeries/types.d.ts +12 -2
- package/dist/cjs/hooks/useSeries/utils.js +1 -1
- package/dist/cjs/hooks/useShapes/area/index.js +8 -2
- package/dist/cjs/hooks/useShapes/area/prepare-data.js +4 -0
- package/dist/cjs/hooks/useShapes/bar-x/index.js +24 -4
- package/dist/cjs/hooks/useShapes/bar-x/prepare-data.js +3 -1
- package/dist/cjs/hooks/useShapes/bar-x/types.d.ts +1 -0
- package/dist/cjs/hooks/useShapes/bar-y/index.js +24 -4
- package/dist/cjs/hooks/useShapes/bar-y/prepare-data.js +3 -1
- package/dist/cjs/hooks/useShapes/bar-y/types.d.ts +1 -0
- package/dist/cjs/hooks/useShapes/index.d.ts +2 -1
- package/dist/cjs/hooks/useShapes/index.js +19 -0
- package/dist/cjs/hooks/useShapes/line/index.js +10 -4
- package/dist/cjs/hooks/useShapes/line/prepare-data.js +1 -0
- package/dist/cjs/hooks/useShapes/pie/index.js +5 -4
- package/dist/cjs/hooks/useShapes/pie/prepare-data.js +168 -118
- package/dist/cjs/hooks/useShapes/pie/types.d.ts +2 -2
- package/dist/cjs/hooks/useShapes/sankey/index.d.ts +12 -0
- package/dist/cjs/hooks/useShapes/sankey/index.js +67 -0
- package/dist/cjs/hooks/useShapes/sankey/prepare-data.d.ts +7 -0
- package/dist/cjs/hooks/useShapes/sankey/prepare-data.js +72 -0
- package/dist/cjs/hooks/useShapes/sankey/types.d.ts +33 -0
- package/dist/cjs/hooks/useShapes/scatter/index.js +8 -2
- package/dist/cjs/hooks/useShapes/styles.css +2 -2
- package/dist/cjs/hooks/useShapes/treemap/index.js +8 -2
- package/dist/cjs/hooks/useShapes/treemap/prepare-data.js +1 -0
- package/dist/cjs/hooks/useShapes/utils.d.ts +8 -3
- package/dist/cjs/hooks/useShapes/utils.js +26 -19
- package/dist/cjs/hooks/useShapes/waterfall/index.js +9 -4
- package/dist/cjs/hooks/useTooltip/index.d.ts +2 -3
- package/dist/cjs/types/chart/area.d.ts +6 -6
- package/dist/cjs/types/chart/axis.d.ts +32 -7
- package/dist/cjs/types/chart/bar-x.d.ts +9 -4
- package/dist/cjs/types/chart/bar-y.d.ts +10 -6
- package/dist/cjs/types/chart/base.d.ts +6 -6
- package/dist/cjs/types/chart/chart.d.ts +6 -6
- package/dist/cjs/types/chart/halo.d.ts +2 -2
- package/dist/cjs/types/chart/legend.d.ts +10 -10
- package/dist/cjs/types/chart/line.d.ts +4 -4
- package/dist/cjs/types/chart/marker.d.ts +2 -2
- package/dist/cjs/types/chart/pie.d.ts +6 -4
- package/dist/cjs/types/chart/sankey.d.ts +22 -0
- package/dist/cjs/types/chart/sankey.js +1 -0
- package/dist/cjs/types/chart/scatter.d.ts +4 -4
- package/dist/cjs/types/chart/series.d.ts +21 -11
- package/dist/cjs/types/chart/split.d.ts +4 -4
- package/dist/cjs/types/chart/title.d.ts +2 -2
- package/dist/cjs/types/chart/tooltip.d.ts +32 -26
- package/dist/cjs/types/chart/treemap.d.ts +4 -4
- package/dist/cjs/types/chart/waterfall.d.ts +4 -4
- package/dist/cjs/types/chart-ui.d.ts +10 -6
- package/dist/cjs/types/formatter.d.ts +4 -4
- package/dist/cjs/types/index.d.ts +35 -4
- package/dist/cjs/types/index.js +1 -0
- package/dist/cjs/types/misc.d.ts +1 -0
- package/dist/cjs/utils/chart/get-closest-data.d.ts +2 -0
- package/dist/cjs/utils/chart/get-closest-data.js +39 -3
- package/dist/cjs/utils/chart/index.js +1 -1
- package/dist/cjs/utils/chart/series/index.d.ts +1 -0
- package/dist/cjs/utils/chart/series/index.js +1 -0
- package/dist/cjs/utils/chart/series/line.d.ts +2 -0
- package/dist/cjs/utils/chart/series/line.js +17 -0
- package/dist/cjs/utils/misc.d.ts +10 -2
- package/dist/cjs/utils/misc.js +15 -3
- package/dist/esm/components/Axis/AxisY.d.ts +1 -0
- package/dist/esm/components/Axis/AxisY.js +55 -13
- package/dist/esm/components/ChartInner/index.d.ts +2 -8
- package/dist/esm/components/ChartInner/index.js +25 -119
- package/dist/esm/components/ChartInner/types.d.ts +6 -0
- package/dist/esm/components/ChartInner/types.js +1 -0
- package/dist/esm/components/ChartInner/useChartInnerHandlers.d.ts +26 -0
- package/dist/esm/components/ChartInner/useChartInnerHandlers.js +98 -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 +4 -4
- package/dist/esm/components/PlotTitle/index.js +1 -1
- package/dist/esm/components/PlotTitle/styles.css +1 -1
- package/dist/esm/components/Tooltip/ChartTooltipContent.d.ts +2 -2
- package/dist/esm/components/Tooltip/DefaultContent.js +19 -3
- package/dist/esm/components/Tooltip/index.d.ts +2 -0
- package/dist/esm/components/Tooltip/index.js +10 -4
- package/dist/esm/components/Tooltip/styles.css +13 -8
- package/dist/esm/components/index.d.ts +10 -9
- package/dist/esm/constants/index.d.ts +1 -0
- package/dist/esm/constants/index.js +1 -0
- package/dist/esm/hooks/index.d.ts +2 -1
- package/dist/esm/hooks/index.js +2 -1
- package/dist/esm/hooks/useChartOptions/types.d.ts +11 -1
- package/dist/esm/hooks/useChartOptions/x-axis.js +1 -0
- package/dist/esm/hooks/useChartOptions/y-axis.js +9 -1
- package/dist/esm/hooks/usePrevious/index.d.ts +1 -0
- package/dist/esm/hooks/usePrevious/index.js +8 -0
- package/dist/esm/hooks/useSeries/prepare-area.d.ts +1 -1
- package/dist/esm/hooks/useSeries/prepare-bar-x.d.ts +2 -1
- package/dist/esm/hooks/useSeries/prepare-bar-x.js +2 -1
- package/dist/esm/hooks/useSeries/prepare-bar-y.d.ts +2 -1
- package/dist/esm/hooks/useSeries/prepare-bar-y.js +3 -1
- package/dist/esm/hooks/useSeries/prepare-line.d.ts +1 -1
- package/dist/esm/hooks/useSeries/prepare-pie.js +2 -2
- package/dist/esm/hooks/useSeries/prepare-sankey.d.ts +11 -0
- package/dist/esm/hooks/useSeries/prepare-sankey.js +38 -0
- package/dist/esm/hooks/useSeries/prepareSeries.js +21 -2
- package/dist/esm/hooks/useSeries/types.d.ts +12 -2
- package/dist/esm/hooks/useSeries/utils.js +1 -1
- package/dist/esm/hooks/useShapes/area/index.js +8 -2
- package/dist/esm/hooks/useShapes/area/prepare-data.js +4 -0
- package/dist/esm/hooks/useShapes/bar-x/index.js +24 -4
- package/dist/esm/hooks/useShapes/bar-x/prepare-data.js +3 -1
- package/dist/esm/hooks/useShapes/bar-x/types.d.ts +1 -0
- package/dist/esm/hooks/useShapes/bar-y/index.js +24 -4
- package/dist/esm/hooks/useShapes/bar-y/prepare-data.js +3 -1
- package/dist/esm/hooks/useShapes/bar-y/types.d.ts +1 -0
- package/dist/esm/hooks/useShapes/index.d.ts +2 -1
- package/dist/esm/hooks/useShapes/index.js +19 -0
- package/dist/esm/hooks/useShapes/line/index.js +10 -4
- package/dist/esm/hooks/useShapes/line/prepare-data.js +1 -0
- package/dist/esm/hooks/useShapes/pie/index.js +5 -4
- package/dist/esm/hooks/useShapes/pie/prepare-data.js +168 -118
- package/dist/esm/hooks/useShapes/pie/types.d.ts +2 -2
- package/dist/esm/hooks/useShapes/sankey/index.d.ts +12 -0
- package/dist/esm/hooks/useShapes/sankey/index.js +67 -0
- package/dist/esm/hooks/useShapes/sankey/prepare-data.d.ts +7 -0
- package/dist/esm/hooks/useShapes/sankey/prepare-data.js +72 -0
- package/dist/esm/hooks/useShapes/sankey/types.d.ts +33 -0
- package/dist/esm/hooks/useShapes/sankey/types.js +1 -0
- package/dist/esm/hooks/useShapes/scatter/index.js +8 -2
- package/dist/esm/hooks/useShapes/styles.css +2 -2
- package/dist/esm/hooks/useShapes/treemap/index.js +8 -2
- package/dist/esm/hooks/useShapes/treemap/prepare-data.js +1 -0
- package/dist/esm/hooks/useShapes/utils.d.ts +8 -3
- package/dist/esm/hooks/useShapes/utils.js +26 -19
- package/dist/esm/hooks/useShapes/waterfall/index.js +9 -4
- package/dist/esm/hooks/useTooltip/index.d.ts +2 -3
- package/dist/esm/types/chart/area.d.ts +6 -6
- package/dist/esm/types/chart/axis.d.ts +32 -7
- package/dist/esm/types/chart/bar-x.d.ts +9 -4
- package/dist/esm/types/chart/bar-y.d.ts +10 -6
- package/dist/esm/types/chart/base.d.ts +6 -6
- package/dist/esm/types/chart/chart.d.ts +6 -6
- package/dist/esm/types/chart/halo.d.ts +2 -2
- package/dist/esm/types/chart/legend.d.ts +10 -10
- package/dist/esm/types/chart/line.d.ts +4 -4
- package/dist/esm/types/chart/marker.d.ts +2 -2
- package/dist/esm/types/chart/pie.d.ts +6 -4
- package/dist/esm/types/chart/sankey.d.ts +22 -0
- package/dist/esm/types/chart/sankey.js +1 -0
- package/dist/esm/types/chart/scatter.d.ts +4 -4
- package/dist/esm/types/chart/series.d.ts +21 -11
- package/dist/esm/types/chart/split.d.ts +4 -4
- package/dist/esm/types/chart/title.d.ts +2 -2
- package/dist/esm/types/chart/tooltip.d.ts +32 -26
- package/dist/esm/types/chart/treemap.d.ts +4 -4
- package/dist/esm/types/chart/waterfall.d.ts +4 -4
- package/dist/esm/types/chart-ui.d.ts +10 -6
- package/dist/esm/types/formatter.d.ts +4 -4
- package/dist/esm/types/index.d.ts +35 -4
- package/dist/esm/types/index.js +1 -0
- package/dist/esm/types/misc.d.ts +1 -0
- package/dist/esm/utils/chart/get-closest-data.d.ts +2 -0
- package/dist/esm/utils/chart/get-closest-data.js +39 -3
- package/dist/esm/utils/chart/index.js +1 -1
- package/dist/esm/utils/chart/series/index.d.ts +1 -0
- package/dist/esm/utils/chart/series/index.js +1 -0
- package/dist/esm/utils/chart/series/line.d.ts +2 -0
- package/dist/esm/utils/chart/series/line.js +17 -0
- package/dist/esm/utils/misc.d.ts +10 -2
- package/dist/esm/utils/misc.js +15 -3
- package/package.json +7 -2
- 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 → cjs/hooks/useShapes/sankey}/types.js +0 -0
|
@@ -4,18 +4,24 @@ import { useTooltip } from '../../hooks';
|
|
|
4
4
|
import { block } from '../../utils';
|
|
5
5
|
import { ChartTooltipContent } from './ChartTooltipContent';
|
|
6
6
|
import './styles.css';
|
|
7
|
-
const b = block('
|
|
7
|
+
const b = block('tooltip');
|
|
8
8
|
export const Tooltip = (props) => {
|
|
9
|
-
const { tooltip, xAxis, yAxis, svgContainer, dispatcher } = props;
|
|
9
|
+
const { tooltip, xAxis, yAxis, svgContainer, dispatcher, tooltipPinned, onOutsideClick } = props;
|
|
10
10
|
const { hovered, pointerPosition } = useTooltip({ dispatcher, tooltip });
|
|
11
11
|
const containerRect = (svgContainer === null || svgContainer === void 0 ? void 0 : svgContainer.getBoundingClientRect()) || { left: 0, top: 0 };
|
|
12
12
|
const left = ((pointerPosition === null || pointerPosition === void 0 ? void 0 : pointerPosition[0]) || 0) + containerRect.left;
|
|
13
13
|
const top = ((pointerPosition === null || pointerPosition === void 0 ? void 0 : pointerPosition[1]) || 0) + containerRect.top;
|
|
14
|
-
const anchorRef = useVirtualElementRef({ rect: {
|
|
14
|
+
const anchorRef = useVirtualElementRef({ rect: { left, top } });
|
|
15
|
+
const handleOutsideClick = (e) => {
|
|
16
|
+
if (svgContainer === null || svgContainer === void 0 ? void 0 : svgContainer.contains(e.target)) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
onOutsideClick === null || onOutsideClick === void 0 ? void 0 : onOutsideClick();
|
|
20
|
+
};
|
|
15
21
|
React.useEffect(() => {
|
|
16
22
|
window.dispatchEvent(new CustomEvent('scroll'));
|
|
17
23
|
}, [left, top]);
|
|
18
|
-
return (hovered === null || hovered === void 0 ? void 0 : hovered.length) ? (React.createElement(Popup, { className: b(), open: true, anchorRef: anchorRef, offset: [0, 20], placement: ['right', 'left', 'top', 'bottom'], modifiers: [{ name: 'preventOverflow', options: { padding: 10, altAxis: true } }] },
|
|
24
|
+
return (hovered === null || hovered === void 0 ? void 0 : hovered.length) ? (React.createElement(Popup, { className: b({ pinned: tooltipPinned }), contentClassName: b('popup-content'), open: true, anchorRef: anchorRef, offset: [0, 20], placement: ['right', 'left', 'top', 'bottom'], modifiers: [{ name: 'preventOverflow', options: { padding: 10, altAxis: true } }], onOutsideClick: tooltipPinned ? handleOutsideClick : undefined },
|
|
19
25
|
React.createElement("div", { className: b('content') },
|
|
20
26
|
React.createElement(ChartTooltipContent, { hovered: hovered, xAxis: xAxis, yAxis: yAxis, renderer: tooltip.renderer })))) : null;
|
|
21
27
|
};
|
|
@@ -1,25 +1,30 @@
|
|
|
1
|
-
.gcharts-
|
|
1
|
+
.gcharts-tooltip[class] {
|
|
2
2
|
--g-popup-border-width: 0;
|
|
3
3
|
pointer-events: none;
|
|
4
4
|
}
|
|
5
|
-
.gcharts-
|
|
5
|
+
.gcharts-tooltip[class] > div {
|
|
6
6
|
animation-duration: unset;
|
|
7
7
|
animation-timing-function: unset;
|
|
8
8
|
animation-fill-mode: unset;
|
|
9
9
|
}
|
|
10
|
-
.gcharts-
|
|
11
|
-
|
|
10
|
+
.gcharts-tooltip[class].gcharts-tooltip_pinned {
|
|
11
|
+
pointer-events: inherit;
|
|
12
|
+
}
|
|
13
|
+
.gcharts-tooltip__popup-content {
|
|
14
|
+
box-shadow: none;
|
|
15
|
+
}
|
|
16
|
+
.gcharts-tooltip__content {
|
|
17
|
+
padding: 8px 14px;
|
|
12
18
|
text-wrap: nowrap;
|
|
13
|
-
border:
|
|
14
|
-
border-radius: 3px;
|
|
19
|
+
border-radius: 4px;
|
|
15
20
|
background-color: var(--g-color-infographics-tooltip-bg);
|
|
16
21
|
box-shadow: 0 2px 12px var(--g-color-sfx-shadow);
|
|
17
22
|
}
|
|
18
|
-
.gcharts-
|
|
23
|
+
.gcharts-tooltip__content-row {
|
|
19
24
|
display: flex;
|
|
20
25
|
align-items: center;
|
|
21
26
|
}
|
|
22
|
-
.gcharts-
|
|
27
|
+
.gcharts-tooltip__color {
|
|
23
28
|
display: inline-block;
|
|
24
29
|
width: 16px;
|
|
25
30
|
height: 8px;
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { ChartData } from '../types';
|
|
3
3
|
export * from './Tooltip/ChartTooltipContent';
|
|
4
|
-
export
|
|
4
|
+
export interface ChartRef {
|
|
5
5
|
reflow: () => void;
|
|
6
|
-
}
|
|
7
|
-
|
|
6
|
+
}
|
|
7
|
+
export interface ChartDimentions {
|
|
8
8
|
height: number;
|
|
9
9
|
width: number;
|
|
10
|
-
}
|
|
11
|
-
export type
|
|
10
|
+
}
|
|
11
|
+
export type ChartOnResize = (args: {
|
|
12
|
+
dimensions?: ChartDimentions;
|
|
13
|
+
}) => void;
|
|
14
|
+
export interface ChartProps {
|
|
12
15
|
data: ChartData;
|
|
13
16
|
lang?: string;
|
|
14
|
-
onResize?:
|
|
15
|
-
|
|
16
|
-
}) => void;
|
|
17
|
-
};
|
|
17
|
+
onResize?: ChartOnResize;
|
|
18
|
+
}
|
|
18
19
|
export declare const Chart: React.ForwardRefExoticComponent<ChartProps & React.RefAttributes<ChartRef>>;
|
|
@@ -2,9 +2,10 @@ export * from './useChartDimensions';
|
|
|
2
2
|
export * from './useChartOptions';
|
|
3
3
|
export * from './useChartOptions/types';
|
|
4
4
|
export * from './useAxisScales';
|
|
5
|
+
export * from './usePrevious';
|
|
5
6
|
export * from './useSeries';
|
|
6
7
|
export * from './useSeries/types';
|
|
7
8
|
export * from './useShapes';
|
|
8
9
|
export * from './useTooltip';
|
|
9
|
-
export * from './
|
|
10
|
+
export * from './useSplit';
|
|
10
11
|
export * from './useSplit/types';
|
package/dist/esm/hooks/index.js
CHANGED
|
@@ -2,9 +2,10 @@ export * from './useChartDimensions';
|
|
|
2
2
|
export * from './useChartOptions';
|
|
3
3
|
export * from './useChartOptions/types';
|
|
4
4
|
export * from './useAxisScales';
|
|
5
|
+
export * from './usePrevious';
|
|
5
6
|
export * from './useSeries';
|
|
6
7
|
export * from './useSeries/types';
|
|
7
8
|
export * from './useShapes';
|
|
8
9
|
export * from './useTooltip';
|
|
9
|
-
export * from './
|
|
10
|
+
export * from './useSplit';
|
|
10
11
|
export * from './useSplit/types';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { DashStyle } from 'src/constants';
|
|
2
|
+
import type { AxisPlotLine, BaseTextStyle, ChartAxis, ChartAxisLabels, ChartAxisTitleAlignment, ChartAxisType, ChartData, ChartMargin } from '../../types';
|
|
2
3
|
type PreparedAxisLabels = Omit<ChartAxisLabels, 'enabled' | 'padding' | 'style' | 'autoRotation'> & Required<Pick<ChartAxisLabels, 'enabled' | 'padding' | 'margin' | 'rotation'>> & {
|
|
3
4
|
style: BaseTextStyle;
|
|
4
5
|
rotation: number;
|
|
@@ -10,6 +11,14 @@ type PreparedAxisLabels = Omit<ChartAxisLabels, 'enabled' | 'padding' | 'style'
|
|
|
10
11
|
export type PreparedChart = {
|
|
11
12
|
margin: ChartMargin;
|
|
12
13
|
};
|
|
14
|
+
export type PreparedAxisPlotLine = {
|
|
15
|
+
value: number;
|
|
16
|
+
color: string;
|
|
17
|
+
width: number;
|
|
18
|
+
dashStyle: DashStyle;
|
|
19
|
+
opacity: number;
|
|
20
|
+
layerPlacement: AxisPlotLine['layerPlacement'];
|
|
21
|
+
};
|
|
13
22
|
export type PreparedAxis = Omit<ChartAxis, 'type' | 'labels'> & {
|
|
14
23
|
type: ChartAxisType;
|
|
15
24
|
labels: PreparedAxisLabels;
|
|
@@ -32,6 +41,7 @@ export type PreparedAxis = Omit<ChartAxis, 'type' | 'labels'> & {
|
|
|
32
41
|
};
|
|
33
42
|
position: 'left' | 'right' | 'top' | 'bottom';
|
|
34
43
|
plotIndex: number;
|
|
44
|
+
plotLines: PreparedAxisPlotLine[];
|
|
35
45
|
};
|
|
36
46
|
export type PreparedTitle = ChartData['title'] & {
|
|
37
47
|
height: number;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import get from 'lodash/get';
|
|
2
|
-
import { DEFAULT_AXIS_LABEL_FONT_SIZE, DEFAULT_AXIS_TYPE, axisLabelsDefaults, yAxisTitleDefaults, } from '../../constants';
|
|
2
|
+
import { DEFAULT_AXIS_LABEL_FONT_SIZE, DEFAULT_AXIS_TYPE, DashStyle, axisLabelsDefaults, yAxisTitleDefaults, } from '../../constants';
|
|
3
3
|
import { CHART_SERIES_WITH_VOLUME_ON_Y_AXIS, formatAxisTickLabel, getClosestPointsRange, getHorisontalSvgTextHeight, getLabelsSize, getScaleTicks, getWaterfallPointSubtotal, wrapText, } from '../../utils';
|
|
4
4
|
import { createYScale } from '../useAxisScales';
|
|
5
5
|
const getAxisLabelMaxWidth = (args) => {
|
|
@@ -108,6 +108,14 @@ export const getPreparedYAxis = ({ series, yAxis, height, }) => {
|
|
|
108
108
|
},
|
|
109
109
|
position: get(axisItem, 'position', defaultAxisPosition),
|
|
110
110
|
plotIndex: get(axisItem, 'plotIndex', 0),
|
|
111
|
+
plotLines: get(axisItem, 'plotLines', []).map((d) => ({
|
|
112
|
+
value: get(d, 'value', 0),
|
|
113
|
+
color: get(d, 'color', 'var(--g-color-base-brand)'),
|
|
114
|
+
width: get(d, 'width', 1),
|
|
115
|
+
dashStyle: get(d, 'dashStyle', DashStyle.Solid),
|
|
116
|
+
opacity: get(d, 'opacity', 1),
|
|
117
|
+
layerPlacement: get(d, 'layerPlacement', 'before'),
|
|
118
|
+
})),
|
|
111
119
|
};
|
|
112
120
|
if (labelsEnabled) {
|
|
113
121
|
preparedAxis.labels.width = getAxisLabelMaxWidth({ axis: preparedAxis, series });
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function usePrevious<T>(value: T): T | undefined;
|
|
@@ -5,9 +5,9 @@ export declare const DEFAULT_LINE_WIDTH = 1;
|
|
|
5
5
|
export declare const DEFAULT_MARKER: {
|
|
6
6
|
enabled: boolean;
|
|
7
7
|
symbol: `${import("../../constants").SymbolType}`;
|
|
8
|
+
radius: number;
|
|
8
9
|
borderColor: string;
|
|
9
10
|
borderWidth: number;
|
|
10
|
-
radius: number;
|
|
11
11
|
};
|
|
12
12
|
type PrepareAreaSeriesArgs = {
|
|
13
13
|
colorScale: ScaleOrdinal<string, string>;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { ScaleOrdinal } from 'd3';
|
|
2
|
-
import type { BarXSeries } from '../../types';
|
|
2
|
+
import type { BarXSeries, ChartSeriesOptions } from '../../types';
|
|
3
3
|
import type { PreparedLegend, PreparedSeries } from './types';
|
|
4
4
|
type PrepareBarXSeriesArgs = {
|
|
5
5
|
colorScale: ScaleOrdinal<string, string>;
|
|
6
6
|
series: BarXSeries[];
|
|
7
7
|
legend: PreparedLegend;
|
|
8
|
+
seriesOptions?: ChartSeriesOptions;
|
|
8
9
|
};
|
|
9
10
|
export declare function prepareBarXSeries(args: PrepareBarXSeriesArgs): PreparedSeries[];
|
|
10
11
|
export {};
|
|
@@ -3,7 +3,7 @@ import { getUniqId } from '../../utils';
|
|
|
3
3
|
import { DEFAULT_DATALABELS_PADDING, DEFAULT_DATALABELS_STYLE } from './constants';
|
|
4
4
|
import { getSeriesStackId, prepareLegendSymbol } from './utils';
|
|
5
5
|
export function prepareBarXSeries(args) {
|
|
6
|
-
const { colorScale, series: seriesList, legend } = args;
|
|
6
|
+
const { colorScale, series: seriesList, seriesOptions, legend } = args;
|
|
7
7
|
return seriesList.map((series) => {
|
|
8
8
|
var _a, _b, _c, _d, _e;
|
|
9
9
|
const name = series.name || '';
|
|
@@ -33,6 +33,7 @@ export function prepareBarXSeries(args) {
|
|
|
33
33
|
},
|
|
34
34
|
cursor: get(series, 'cursor', null),
|
|
35
35
|
yAxis: get(series, 'yAxis', 0),
|
|
36
|
+
borderRadius: get(series, 'borderRadius', get(seriesOptions, 'bar-x.borderRadius', 0)),
|
|
36
37
|
};
|
|
37
38
|
}, []);
|
|
38
39
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { ScaleOrdinal } from 'd3';
|
|
2
|
-
import type { BarYSeries } from '../../types';
|
|
2
|
+
import type { BarYSeries, ChartSeriesOptions } from '../../types';
|
|
3
3
|
import type { PreparedLegend, PreparedSeries } from './types';
|
|
4
4
|
type PrepareBarYSeriesArgs = {
|
|
5
5
|
colorScale: ScaleOrdinal<string, string>;
|
|
6
6
|
series: BarYSeries[];
|
|
7
7
|
legend: PreparedLegend;
|
|
8
|
+
seriesOptions?: ChartSeriesOptions;
|
|
8
9
|
};
|
|
9
10
|
export declare function prepareBarYSeries(args: PrepareBarYSeriesArgs): PreparedSeries[];
|
|
10
11
|
export {};
|
|
@@ -24,8 +24,9 @@ function prepareDataLabels(series) {
|
|
|
24
24
|
};
|
|
25
25
|
}
|
|
26
26
|
export function prepareBarYSeries(args) {
|
|
27
|
-
const { colorScale, series: seriesList, legend } = args;
|
|
27
|
+
const { colorScale, series: seriesList, seriesOptions, legend } = args;
|
|
28
28
|
return seriesList.map((series) => {
|
|
29
|
+
var _a, _b, _c;
|
|
29
30
|
const name = series.name || '';
|
|
30
31
|
const color = series.color || colorScale(name);
|
|
31
32
|
return {
|
|
@@ -43,6 +44,7 @@ export function prepareBarYSeries(args) {
|
|
|
43
44
|
stackId: getSeriesStackId(series),
|
|
44
45
|
dataLabels: prepareDataLabels(series),
|
|
45
46
|
cursor: get(series, 'cursor', null),
|
|
47
|
+
borderRadius: (_c = (_a = series.borderRadius) !== null && _a !== void 0 ? _a : (_b = seriesOptions === null || seriesOptions === void 0 ? void 0 : seriesOptions['bar-y']) === null || _b === void 0 ? void 0 : _b.borderRadius) !== null && _c !== void 0 ? _c : 0,
|
|
46
48
|
};
|
|
47
49
|
}, []);
|
|
48
50
|
}
|
|
@@ -8,9 +8,9 @@ export declare const DEFAULT_DASH_STYLE = DashStyle.Solid;
|
|
|
8
8
|
export declare const DEFAULT_MARKER: {
|
|
9
9
|
enabled: boolean;
|
|
10
10
|
symbol: `${import("../../constants").SymbolType}`;
|
|
11
|
+
radius: number;
|
|
11
12
|
borderColor: string;
|
|
12
13
|
borderWidth: number;
|
|
13
|
-
radius: number;
|
|
14
14
|
};
|
|
15
15
|
type PrepareLineSeriesArgs = {
|
|
16
16
|
colorScale: ScaleOrdinal<string, string>;
|
|
@@ -11,7 +11,7 @@ export function preparePieSeries(args) {
|
|
|
11
11
|
const stackId = getUniqId();
|
|
12
12
|
const seriesHoverState = get(seriesOptions, 'pie.states.hover');
|
|
13
13
|
const preparedSeries = series.data.map((dataItem, i) => {
|
|
14
|
-
var _a, _b, _c;
|
|
14
|
+
var _a, _b, _c, _d, _e;
|
|
15
15
|
const result = {
|
|
16
16
|
type: 'pie',
|
|
17
17
|
data: dataItem,
|
|
@@ -40,7 +40,7 @@ export function preparePieSeries(args) {
|
|
|
40
40
|
borderColor: series.borderColor || '',
|
|
41
41
|
borderRadius: (_b = series.borderRadius) !== null && _b !== void 0 ? _b : 0,
|
|
42
42
|
borderWidth: (_c = series.borderWidth) !== null && _c !== void 0 ? _c : 1,
|
|
43
|
-
radius: series.radius
|
|
43
|
+
radius: (_e = (_d = dataItem.radius) !== null && _d !== void 0 ? _d : series.radius) !== null && _e !== void 0 ? _e : '100%',
|
|
44
44
|
innerRadius: series.innerRadius || 0,
|
|
45
45
|
stackId,
|
|
46
46
|
states: {
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ScaleOrdinal } from 'd3';
|
|
2
|
+
import type { ChartSeriesOptions, SankeySeries } from '../../types';
|
|
3
|
+
import type { PreparedLegend, PreparedSankeySeries } from './types';
|
|
4
|
+
type PrepareSankeySeriesArgs = {
|
|
5
|
+
colorScale: ScaleOrdinal<string, string>;
|
|
6
|
+
legend: PreparedLegend;
|
|
7
|
+
series: SankeySeries[];
|
|
8
|
+
seriesOptions?: ChartSeriesOptions;
|
|
9
|
+
};
|
|
10
|
+
export declare function prepareSankeySeries(args: PrepareSankeySeriesArgs): PreparedSankeySeries[];
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import get from 'lodash/get';
|
|
2
|
+
import { getUniqId } from '../../utils';
|
|
3
|
+
import { DEFAULT_DATALABELS_STYLE } from './constants';
|
|
4
|
+
import { prepareLegendSymbol } from './utils';
|
|
5
|
+
export function prepareSankeySeries(args) {
|
|
6
|
+
const { colorScale, legend, series } = args;
|
|
7
|
+
return series.map((s) => {
|
|
8
|
+
var _a;
|
|
9
|
+
const id = getUniqId();
|
|
10
|
+
const name = s.name || '';
|
|
11
|
+
const color = colorScale(name);
|
|
12
|
+
const preparedSeries = {
|
|
13
|
+
color,
|
|
14
|
+
data: s.data.map((d) => {
|
|
15
|
+
var _a;
|
|
16
|
+
return ({
|
|
17
|
+
name: d.name,
|
|
18
|
+
color: (_a = d.color) !== null && _a !== void 0 ? _a : colorScale(d.name),
|
|
19
|
+
links: d.links,
|
|
20
|
+
});
|
|
21
|
+
}),
|
|
22
|
+
dataLabels: {
|
|
23
|
+
enabled: get(s, 'dataLabels.enabled', true),
|
|
24
|
+
style: Object.assign({}, DEFAULT_DATALABELS_STYLE, (_a = s.dataLabels) === null || _a === void 0 ? void 0 : _a.style),
|
|
25
|
+
},
|
|
26
|
+
id,
|
|
27
|
+
type: s.type,
|
|
28
|
+
name,
|
|
29
|
+
visible: get(s, 'visible', true),
|
|
30
|
+
legend: {
|
|
31
|
+
enabled: get(s, 'legend.enabled', legend.enabled),
|
|
32
|
+
symbol: prepareLegendSymbol(s),
|
|
33
|
+
},
|
|
34
|
+
cursor: get(s, 'cursor', null),
|
|
35
|
+
};
|
|
36
|
+
return preparedSeries;
|
|
37
|
+
});
|
|
38
|
+
}
|
|
@@ -4,6 +4,7 @@ import { prepareBarXSeries } from './prepare-bar-x';
|
|
|
4
4
|
import { prepareBarYSeries } from './prepare-bar-y';
|
|
5
5
|
import { prepareLineSeries } from './prepare-line';
|
|
6
6
|
import { preparePieSeries } from './prepare-pie';
|
|
7
|
+
import { prepareSankeySeries } from './prepare-sankey';
|
|
7
8
|
import { prepareScatterSeries } from './prepare-scatter';
|
|
8
9
|
import { prepareTreemap } from './prepare-treemap';
|
|
9
10
|
import { prepareWaterfallSeries } from './prepare-waterfall';
|
|
@@ -17,10 +18,20 @@ export function prepareSeries(args) {
|
|
|
17
18
|
}, []);
|
|
18
19
|
}
|
|
19
20
|
case 'bar-x': {
|
|
20
|
-
return prepareBarXSeries({
|
|
21
|
+
return prepareBarXSeries({
|
|
22
|
+
series: series,
|
|
23
|
+
legend,
|
|
24
|
+
colorScale,
|
|
25
|
+
seriesOptions,
|
|
26
|
+
});
|
|
21
27
|
}
|
|
22
28
|
case 'bar-y': {
|
|
23
|
-
return prepareBarYSeries({
|
|
29
|
+
return prepareBarYSeries({
|
|
30
|
+
series: series,
|
|
31
|
+
legend,
|
|
32
|
+
colorScale,
|
|
33
|
+
seriesOptions,
|
|
34
|
+
});
|
|
24
35
|
}
|
|
25
36
|
case 'scatter': {
|
|
26
37
|
return prepareScatterSeries({ series: series, legend, colorScale });
|
|
@@ -56,6 +67,14 @@ export function prepareSeries(args) {
|
|
|
56
67
|
colorScale,
|
|
57
68
|
});
|
|
58
69
|
}
|
|
70
|
+
case 'sankey': {
|
|
71
|
+
return prepareSankeySeries({
|
|
72
|
+
series: series,
|
|
73
|
+
seriesOptions,
|
|
74
|
+
colorScale,
|
|
75
|
+
legend,
|
|
76
|
+
});
|
|
77
|
+
}
|
|
59
78
|
default: {
|
|
60
79
|
throw new ChartError({
|
|
61
80
|
message: `Series type "${type}" does not support data preparation for series that do not support the presence of axes`,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { DashStyle, LayoutAlgorithm, LineCap, SeriesOptionsDefaults, SymbolType } from '../../constants';
|
|
2
|
-
import type { AreaSeries, AreaSeriesData, BarXSeries, BarXSeriesData, BarYSeries, BarYSeriesData, BaseTextStyle, ChartLegend, ConnectorCurve, ConnectorShape, LineSeries, LineSeriesData, PathLegendSymbolOptions, PieSeries, PieSeriesData, RectLegendSymbolOptions, ScatterSeries, ScatterSeriesData, SymbolLegendSymbolOptions, TreemapSeries, TreemapSeriesData, WaterfallSeries, WaterfallSeriesData } from '../../types';
|
|
2
|
+
import type { AreaSeries, AreaSeriesData, BarXSeries, BarXSeriesData, BarYSeries, BarYSeriesData, BaseTextStyle, ChartLegend, ConnectorCurve, ConnectorShape, LineSeries, LineSeriesData, PathLegendSymbolOptions, PieSeries, PieSeriesData, RectLegendSymbolOptions, SankeySeries, SankeySeriesData, ScatterSeries, ScatterSeriesData, SymbolLegendSymbolOptions, TreemapSeries, TreemapSeriesData, WaterfallSeries, WaterfallSeriesData } from '../../types';
|
|
3
3
|
export type RectLegendSymbol = {
|
|
4
4
|
shape: 'rect';
|
|
5
5
|
} & Required<RectLegendSymbolOptions>;
|
|
@@ -107,6 +107,7 @@ export type PreparedBarXSeries = {
|
|
|
107
107
|
padding: number;
|
|
108
108
|
html: boolean;
|
|
109
109
|
};
|
|
110
|
+
borderRadius: number;
|
|
110
111
|
yAxis: number;
|
|
111
112
|
} & BasePreparedSeries;
|
|
112
113
|
export type PreparedBarYSeries = {
|
|
@@ -122,6 +123,7 @@ export type PreparedBarYSeries = {
|
|
|
122
123
|
maxWidth: number;
|
|
123
124
|
html: boolean;
|
|
124
125
|
};
|
|
126
|
+
borderRadius: number;
|
|
125
127
|
} & BasePreparedSeries;
|
|
126
128
|
export type PreparedPieSeries = {
|
|
127
129
|
type: PieSeries['type'];
|
|
@@ -248,7 +250,15 @@ export type PreparedWaterfallSeries = {
|
|
|
248
250
|
positiveColor: string;
|
|
249
251
|
negativeColor: string;
|
|
250
252
|
} & BasePreparedSeries;
|
|
251
|
-
export type
|
|
253
|
+
export type PreparedSankeySeries = {
|
|
254
|
+
type: SankeySeries['type'];
|
|
255
|
+
data: SankeySeriesData[];
|
|
256
|
+
dataLabels: {
|
|
257
|
+
enabled: boolean;
|
|
258
|
+
style: BaseTextStyle;
|
|
259
|
+
};
|
|
260
|
+
} & BasePreparedSeries & Omit<SankeySeries, keyof BasePreparedSeries>;
|
|
261
|
+
export type PreparedSeries = PreparedScatterSeries | PreparedBarXSeries | PreparedBarYSeries | PreparedPieSeries | PreparedLineSeries | PreparedAreaSeries | PreparedTreemapSeries | PreparedWaterfallSeries | PreparedSankeySeries;
|
|
252
262
|
export type PreparedSeriesOptions = SeriesOptionsDefaults;
|
|
253
263
|
export type StackedSeries = BarXSeries | AreaSeries | BarYSeries;
|
|
254
264
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import memoize from 'lodash/memoize';
|
|
2
2
|
import { SymbolType } from '../../constants';
|
|
3
|
-
import { getUniqId } from '../../utils';
|
|
3
|
+
import { getUniqId } from '../../utils/misc';
|
|
4
4
|
import { DEFAULT_LEGEND_SYMBOL_PADDING, DEFAULT_LEGEND_SYMBOL_SIZE } from './constants';
|
|
5
5
|
export const getActiveLegendItems = (series) => {
|
|
6
6
|
return series.reduce((acc, s) => {
|
|
@@ -8,6 +8,7 @@ import { setActiveState } from '../utils';
|
|
|
8
8
|
const b = block('d3-area');
|
|
9
9
|
export const AreaSeriesShapes = (args) => {
|
|
10
10
|
const { dispatcher, preparedData, seriesOptions, htmlLayout } = args;
|
|
11
|
+
const hoveredDataRef = React.useRef(null);
|
|
11
12
|
const ref = React.useRef(null);
|
|
12
13
|
React.useEffect(() => {
|
|
13
14
|
var _a;
|
|
@@ -72,7 +73,8 @@ export const AreaSeriesShapes = (args) => {
|
|
|
72
73
|
.call(renderMarker);
|
|
73
74
|
const hoverEnabled = hoverOptions === null || hoverOptions === void 0 ? void 0 : hoverOptions.enabled;
|
|
74
75
|
const inactiveEnabled = inactiveOptions === null || inactiveOptions === void 0 ? void 0 : inactiveOptions.enabled;
|
|
75
|
-
|
|
76
|
+
function handleShapeHover(data) {
|
|
77
|
+
hoveredDataRef.current = data;
|
|
76
78
|
const selected = (data === null || data === void 0 ? void 0 : data.filter((d) => d.series.type === 'area')) || [];
|
|
77
79
|
const selectedDataItems = selected.map((d) => d.data);
|
|
78
80
|
const selectedSeriesIds = selected.map((d) => { var _a; return (_a = d.series) === null || _a === void 0 ? void 0 : _a.id; });
|
|
@@ -132,7 +134,11 @@ export const AreaSeriesShapes = (args) => {
|
|
|
132
134
|
}
|
|
133
135
|
return d;
|
|
134
136
|
});
|
|
135
|
-
}
|
|
137
|
+
}
|
|
138
|
+
if (hoveredDataRef.current !== null) {
|
|
139
|
+
handleShapeHover(hoveredDataRef.current);
|
|
140
|
+
}
|
|
141
|
+
dispatcher.on('hover-shape.area', handleShapeHover);
|
|
136
142
|
return () => {
|
|
137
143
|
dispatcher.on('hover-shape.area', null);
|
|
138
144
|
};
|
|
@@ -102,10 +102,14 @@ export const prepareAreaData = (args) => {
|
|
|
102
102
|
const labelItems = points.map((p) => getLabelData(p, s, xMax));
|
|
103
103
|
if (s.dataLabels.html) {
|
|
104
104
|
const htmlLabels = labelItems.map((l) => {
|
|
105
|
+
var _a;
|
|
106
|
+
const style = (_a = l.style) !== null && _a !== void 0 ? _a : s.dataLabels.style;
|
|
107
|
+
const labelSize = getLabelsSize({ labels: [l.text], style, html: true });
|
|
105
108
|
return {
|
|
106
109
|
x: l.x - l.size.width / 2,
|
|
107
110
|
y: l.y,
|
|
108
111
|
content: l.text,
|
|
112
|
+
size: { width: labelSize.maxWidth, height: labelSize.maxHeight },
|
|
109
113
|
};
|
|
110
114
|
});
|
|
111
115
|
htmlElements.push(...htmlLabels);
|
|
@@ -3,11 +3,13 @@ import { color, select } from 'd3';
|
|
|
3
3
|
import get from 'lodash/get';
|
|
4
4
|
import { block, filterOverlappingLabels } from '../../../utils';
|
|
5
5
|
import { HtmlLayer } from '../HtmlLayer';
|
|
6
|
+
import { getRectPath } from '../utils';
|
|
6
7
|
export { prepareBarXData } from './prepare-data';
|
|
7
8
|
export * from './types';
|
|
8
|
-
const b = block('
|
|
9
|
+
const b = block('bar-x');
|
|
9
10
|
export const BarXSeriesShapes = (args) => {
|
|
10
11
|
const { dispatcher, preparedData, seriesOptions, htmlLayout } = args;
|
|
12
|
+
const hoveredDataRef = React.useRef(null);
|
|
11
13
|
const ref = React.useRef(null);
|
|
12
14
|
React.useEffect(() => {
|
|
13
15
|
var _a;
|
|
@@ -21,7 +23,20 @@ export const BarXSeriesShapes = (args) => {
|
|
|
21
23
|
const rectSelection = svgElement
|
|
22
24
|
.selectAll('allRects')
|
|
23
25
|
.data(preparedData)
|
|
24
|
-
.join('
|
|
26
|
+
.join('path')
|
|
27
|
+
.attr('d', (d) => {
|
|
28
|
+
const borderRadius = d.isLastStackItem
|
|
29
|
+
? Math.min(d.height, d.width / 2, d.series.borderRadius)
|
|
30
|
+
: 0;
|
|
31
|
+
const p = getRectPath({
|
|
32
|
+
x: d.x,
|
|
33
|
+
y: d.y,
|
|
34
|
+
width: d.width,
|
|
35
|
+
height: d.height,
|
|
36
|
+
borderRadius: [borderRadius, borderRadius, 0, 0],
|
|
37
|
+
});
|
|
38
|
+
return p.toString();
|
|
39
|
+
})
|
|
25
40
|
.attr('class', b('segment'))
|
|
26
41
|
.attr('x', (d) => d.x)
|
|
27
42
|
.attr('y', (d) => d.y)
|
|
@@ -46,7 +61,8 @@ export const BarXSeriesShapes = (args) => {
|
|
|
46
61
|
.style('font-size', (d) => d.style.fontSize)
|
|
47
62
|
.style('font-weight', (d) => d.style.fontWeight || null)
|
|
48
63
|
.style('fill', (d) => d.style.fontColor || null);
|
|
49
|
-
|
|
64
|
+
function handleShapeHover(data) {
|
|
65
|
+
hoveredDataRef.current = data;
|
|
50
66
|
const hoverEnabled = hoverOptions === null || hoverOptions === void 0 ? void 0 : hoverOptions.enabled;
|
|
51
67
|
const inactiveEnabled = inactiveOptions === null || inactiveOptions === void 0 ? void 0 : inactiveOptions.enabled;
|
|
52
68
|
if (!data) {
|
|
@@ -84,7 +100,11 @@ export const BarXSeriesShapes = (args) => {
|
|
|
84
100
|
: (inactiveOptions === null || inactiveOptions === void 0 ? void 0 : inactiveOptions.opacity) || null;
|
|
85
101
|
});
|
|
86
102
|
}
|
|
87
|
-
}
|
|
103
|
+
}
|
|
104
|
+
if (hoveredDataRef.current !== null) {
|
|
105
|
+
handleShapeHover(hoveredDataRef.current);
|
|
106
|
+
}
|
|
107
|
+
dispatcher.on('hover-shape.bar-x', handleShapeHover);
|
|
88
108
|
return () => {
|
|
89
109
|
dispatcher.on('hover-shape.bar-x', null);
|
|
90
110
|
};
|
|
@@ -103,7 +103,7 @@ export const prepareBarXData = (args) => {
|
|
|
103
103
|
const sortedData = sortKey
|
|
104
104
|
? sort(yValues, (a, b) => comparator(get(a, sortKey), get(b, sortKey)))
|
|
105
105
|
: yValues;
|
|
106
|
-
sortedData.forEach((yValue) => {
|
|
106
|
+
sortedData.forEach((yValue, yValueIndex) => {
|
|
107
107
|
const yAxisIndex = yValue.series.yAxis;
|
|
108
108
|
const seriesYScale = yScale[yAxisIndex];
|
|
109
109
|
let xCenter;
|
|
@@ -129,6 +129,7 @@ export const prepareBarXData = (args) => {
|
|
|
129
129
|
data: yValue.data,
|
|
130
130
|
series: yValue.series,
|
|
131
131
|
htmlElements: [],
|
|
132
|
+
isLastStackItem: yValueIndex === sortedData.length - 1,
|
|
132
133
|
};
|
|
133
134
|
const label = getLabelData(barData);
|
|
134
135
|
if (yValue.series.dataLabels.html && label) {
|
|
@@ -136,6 +137,7 @@ export const prepareBarXData = (args) => {
|
|
|
136
137
|
x: label.x,
|
|
137
138
|
y: label.y,
|
|
138
139
|
content: label.text,
|
|
140
|
+
size: label.size,
|
|
139
141
|
});
|
|
140
142
|
}
|
|
141
143
|
else {
|