@gravity-ui/chartkit 4.20.0 → 5.0.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.
Files changed (107) hide show
  1. package/build/components/ChartKit.css +20 -20
  2. package/build/components/ChartKit.d.ts +2 -2
  3. package/build/components/ErrorBoundary/ErrorBoundary.js +1 -1
  4. package/build/libs/settings/settings.d.ts +1 -1
  5. package/build/libs/settings/settings.js +1 -1
  6. package/build/plugins/d3/examples/area/PercentStacking.js +1 -1
  7. package/build/plugins/d3/examples/area/StackedArea.js +1 -1
  8. package/build/plugins/d3/examples/combined/LineAndBarX.js +1 -1
  9. package/build/plugins/d3/examples/pie/DonutWithTotals.js +1 -1
  10. package/build/plugins/d3/renderer/D3Widget.d.ts +1 -1
  11. package/build/plugins/d3/renderer/D3Widget.js +1 -1
  12. package/build/plugins/d3/renderer/components/AxisX.d.ts +1 -1
  13. package/build/plugins/d3/renderer/components/AxisX.js +2 -2
  14. package/build/plugins/d3/renderer/components/AxisY.js +1 -1
  15. package/build/plugins/d3/renderer/components/Chart.js +4 -4
  16. package/build/plugins/d3/renderer/components/Legend.d.ts +1 -1
  17. package/build/plugins/d3/renderer/components/Legend.js +2 -2
  18. package/build/plugins/d3/renderer/components/Tooltip/DefaultContent.js +1 -1
  19. package/build/plugins/d3/renderer/components/Tooltip/TooltipTriggerArea.js +2 -2
  20. package/build/plugins/d3/renderer/components/Tooltip/index.js +11 -40
  21. package/build/plugins/d3/renderer/components/styles.css +12 -3
  22. package/build/plugins/d3/renderer/hooks/useAxisScales/index.d.ts +1 -1
  23. package/build/plugins/d3/renderer/hooks/useAxisScales/index.js +2 -2
  24. package/build/plugins/d3/renderer/hooks/useChartOptions/types.d.ts +1 -1
  25. package/build/plugins/d3/renderer/hooks/useChartOptions/x-axis.d.ts +1 -1
  26. package/build/plugins/d3/renderer/hooks/useChartOptions/x-axis.js +1 -1
  27. package/build/plugins/d3/renderer/hooks/useChartOptions/y-axis.js +2 -2
  28. package/build/plugins/d3/renderer/hooks/useSeries/index.d.ts +1 -1
  29. package/build/plugins/d3/renderer/hooks/useSeries/index.js +2 -2
  30. package/build/plugins/d3/renderer/hooks/useSeries/prepare-area.d.ts +1 -1
  31. package/build/plugins/d3/renderer/hooks/useSeries/prepare-area.js +1 -1
  32. package/build/plugins/d3/renderer/hooks/useSeries/prepare-bar-x.js +1 -1
  33. package/build/plugins/d3/renderer/hooks/useSeries/prepare-bar-y.js +2 -2
  34. package/build/plugins/d3/renderer/hooks/useSeries/prepare-legend.d.ts +1 -1
  35. package/build/plugins/d3/renderer/hooks/useSeries/prepare-legend.js +1 -1
  36. package/build/plugins/d3/renderer/hooks/useSeries/prepare-line.d.ts +1 -1
  37. package/build/plugins/d3/renderer/hooks/useSeries/prepare-line.js +1 -1
  38. package/build/plugins/d3/renderer/hooks/useSeries/prepare-pie.js +4 -4
  39. package/build/plugins/d3/renderer/hooks/useSeries/prepare-scatter.d.ts +1 -1
  40. package/build/plugins/d3/renderer/hooks/useSeries/prepare-scatter.js +2 -2
  41. package/build/plugins/d3/renderer/hooks/useSeries/prepareSeries.js +2 -2
  42. package/build/plugins/d3/renderer/hooks/useSeries/types.d.ts +2 -2
  43. package/build/plugins/d3/renderer/hooks/useSeries/utils.d.ts +2 -2
  44. package/build/plugins/d3/renderer/hooks/useSeries/utils.js +1 -1
  45. package/build/plugins/d3/renderer/hooks/useShapes/area/index.js +2 -2
  46. package/build/plugins/d3/renderer/hooks/useShapes/area/prepare-data.d.ts +2 -2
  47. package/build/plugins/d3/renderer/hooks/useShapes/area/prepare-data.js +1 -1
  48. package/build/plugins/d3/renderer/hooks/useShapes/area/types.d.ts +1 -1
  49. package/build/plugins/d3/renderer/hooks/useShapes/bar-x/index.js +1 -1
  50. package/build/plugins/d3/renderer/hooks/useShapes/bar-x/types.d.ts +1 -1
  51. package/build/plugins/d3/renderer/hooks/useShapes/bar-y/index.js +1 -1
  52. package/build/plugins/d3/renderer/hooks/useShapes/index.d.ts +6 -6
  53. package/build/plugins/d3/renderer/hooks/useShapes/index.js +6 -6
  54. package/build/plugins/d3/renderer/hooks/useShapes/line/index.js +1 -1
  55. package/build/plugins/d3/renderer/hooks/useShapes/line/prepare-data.d.ts +2 -2
  56. package/build/plugins/d3/renderer/hooks/useShapes/line/prepare-data.js +1 -1
  57. package/build/plugins/d3/renderer/hooks/useShapes/line/types.d.ts +2 -2
  58. package/build/plugins/d3/renderer/hooks/useShapes/marker.d.ts +1 -1
  59. package/build/plugins/d3/renderer/hooks/useShapes/marker.js +2 -2
  60. package/build/plugins/d3/renderer/hooks/useShapes/pie/index.js +2 -3
  61. package/build/plugins/d3/renderer/hooks/useShapes/pie/types.d.ts +2 -2
  62. package/build/plugins/d3/renderer/hooks/useShapes/pie/utils.js +1 -1
  63. package/build/plugins/d3/renderer/hooks/useShapes/scatter/index.js +2 -2
  64. package/build/plugins/d3/renderer/hooks/useShapes/treemap/index.js +1 -1
  65. package/build/plugins/d3/renderer/hooks/useShapes/utils.d.ts +1 -1
  66. package/build/plugins/d3/renderer/hooks/useTooltip/index.d.ts +1 -1
  67. package/build/plugins/d3/renderer/utils/axis-generators/bottom.js +1 -1
  68. package/build/plugins/d3/renderer/utils/axis.d.ts +1 -1
  69. package/build/plugins/d3/renderer/utils/index.js +3 -3
  70. package/build/plugins/d3/renderer/utils/symbol.js +1 -1
  71. package/build/plugins/d3/renderer/validation/index.js +1 -1
  72. package/build/plugins/highcharts/renderer/components/HighchartsComponent.d.ts +1 -1
  73. package/build/plugins/highcharts/renderer/components/HighchartsComponent.js +2 -2
  74. package/build/plugins/highcharts/renderer/components/HighchartsReact.js +7 -1
  75. package/build/plugins/highcharts/renderer/components/StyledSplitPane/StyledSplitPane.css +1 -1
  76. package/build/plugins/highcharts/renderer/helpers/config/config.js +15 -15
  77. package/build/plugins/highcharts/renderer/helpers/config/handleLegendItemClick.js +1 -1
  78. package/build/plugins/highcharts/renderer/helpers/config/options.d.ts +98 -98
  79. package/build/plugins/highcharts/renderer/helpers/config/options.js +1 -1
  80. package/build/plugins/highcharts/renderer/helpers/config/utils/index.d.ts +39 -10
  81. package/build/plugins/highcharts/renderer/helpers/graph.css +4 -4
  82. package/build/plugins/highcharts/renderer/helpers/graph.d.ts +1 -1
  83. package/build/plugins/highcharts/renderer/helpers/graph.js +2 -2
  84. package/build/plugins/highcharts/renderer/helpers/highcharts/highcharts.js +2 -2
  85. package/build/plugins/highcharts/renderer/helpers/prepare-data.js +2 -2
  86. package/build/plugins/highcharts/renderer/helpers/tooltip/index.js +1 -1
  87. package/build/plugins/highcharts/renderer/helpers/tooltip/tooltip.css +6 -7
  88. package/build/plugins/highcharts/types/highcharts-extends.d.ts +1 -0
  89. package/build/plugins/highcharts/types/widget.d.ts +2 -2
  90. package/build/plugins/indicator/renderer/IndicatorWidget.css +1 -1
  91. package/build/plugins/indicator/renderer/IndicatorWidget.js +1 -1
  92. package/build/plugins/shared/format-number/format-number.d.ts +1 -1
  93. package/build/plugins/shared/format-number/format-number.js +2 -2
  94. package/build/plugins/shared/format-number/format-number.test.js +1 -1
  95. package/build/plugins/yagr/renderer/YagrWidget.css +1 -1
  96. package/build/plugins/yagr/renderer/YagrWidget.js +5 -3
  97. package/build/plugins/yagr/renderer/tooltip/tooltip.css +15 -16
  98. package/build/plugins/yagr/renderer/utils.d.ts +1 -1
  99. package/build/plugins/yagr/renderer/utils.js +1 -1
  100. package/build/types/index.d.ts +1 -1
  101. package/build/types/widget-data/bar-x.d.ts +1 -1
  102. package/build/types/widget-data/bar-y.d.ts +1 -1
  103. package/build/types/widget-data/line.d.ts +1 -1
  104. package/build/types/widget-data/series.d.ts +6 -6
  105. package/build/types/widget-data/tooltip.d.ts +3 -3
  106. package/build/types/widget.d.ts +2 -2
  107. package/package.json +23 -24
@@ -8,25 +8,25 @@
8
8
  }
9
9
 
10
10
  .chartkit-theme_common {
11
- --highcarts-navigator-border: var(--yc-color-line-generic);
12
- --highcarts-navigator-track: var(--yc-color-base-generic);
13
- --highcarts-navigator-body: var(--yc-color-scroll-handle);
14
- --highcharts-series-border: var(--yc-color-base-background);
15
- --highcharts-grid-line: var(--yc-color-line-generic);
16
- --highcharts-axis-line: var(--yc-color-line-generic);
17
- --highcharts-tick: var(--yc-color-line-generic);
18
- --highcharts-title: var(--yc-color-text-primary);
19
- --highcharts-axis-labels: var(--yc-color-text-secondary);
20
- --highcharts-data-labels: var(--yc-color-text-complementary);
21
- --highcharts-plot-line-label: var(--yc-color-text-complementary);
22
- --highcharts-legend-item: var(--yc-color-text-secondary);
23
- --highcharts-legend-item-hover: var(--yc-color-text-primary);
24
- --highcharts-legend-item-hidden: var(--yc-color-text-hint);
25
- --highcharts-floating-bg: var(--yc-color-infographics-tooltip-bg);
26
- --highcharts-tooltip-text: var(--yc-color-text-primary);
11
+ --highcarts-navigator-border: var(--g-color-line-generic);
12
+ --highcarts-navigator-track: var(--g-color-base-generic);
13
+ --highcarts-navigator-body: var(--g-color-scroll-handle);
14
+ --highcharts-series-border: var(--g-color-base-background);
15
+ --highcharts-grid-line: var(--g-color-line-generic);
16
+ --highcharts-axis-line: var(--g-color-line-generic);
17
+ --highcharts-tick: var(--g-color-line-generic);
18
+ --highcharts-title: var(--g-color-text-primary);
19
+ --highcharts-axis-labels: var(--g-color-text-secondary);
20
+ --highcharts-data-labels: var(--g-color-text-secondary);
21
+ --highcharts-plot-line-label: var(--g-color-text-secondary);
22
+ --highcharts-legend-item: var(--g-color-text-secondary);
23
+ --highcharts-legend-item-hover: var(--g-color-text-primary);
24
+ --highcharts-legend-item-hidden: var(--g-color-text-hint);
25
+ --highcharts-floating-bg: var(--g-color-infographics-tooltip-bg);
26
+ --highcharts-tooltip-text: var(--g-color-text-primary);
27
27
  --highcharts-tooltip-bg: var(--highcharts-floating-bg);
28
- --highcharts-tooltip-alternate-bg: var(--yc-color-base-generic);
29
- --highcharts-tooltip-text-complementary: var(--yc-color-text-complementary);
30
- --highcharts-holiday-band: var(--yc-color-base-generic);
31
- --d3-data-labels: var(--yc-color-text-complementary);
28
+ --highcharts-tooltip-alternate-bg: var(--g-color-base-generic);
29
+ --highcharts-tooltip-text-complementary: var(--g-color-text-secondary);
30
+ --highcharts-holiday-band: var(--g-color-base-generic);
31
+ --d3-data-labels: var(--g-color-text-secondary);
32
32
  }
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import type { ChartKitType, ChartKitRef, ChartKitProps } from '../types';
2
+ import type { ChartKitProps, ChartKitRef, ChartKitType } from '../types';
3
3
  import './ChartKit.css';
4
4
  type ChartKitComponentProps<T extends ChartKitType> = Omit<ChartKitProps<T>, 'onError'> & {
5
5
  instanceRef?: React.ForwardedRef<ChartKitRef | undefined>;
@@ -16,7 +16,7 @@ export declare const ChartKit: <T extends keyof import("../types").ChartKitWidge
16
16
  onError?: import("../types").ChartKitOnError | undefined;
17
17
  renderError?: import("../types").RenderError | undefined;
18
18
  renderPluginLoader?: import("../types").ChartKitRenderPluginLoader | undefined;
19
- } & (Omit<import("../types").ChartKitWidget[T], "data" | "widget"> extends infer T_1 ? { [key in keyof T_1]: import("../types").ChartKitWidget[T][key]; } : never) & {
19
+ } & { [key in keyof Omit<import("../types").ChartKitWidget[T], "data" | "widget">]: import("../types").ChartKitWidget[T][key]; } & {
20
20
  ref?: React.ForwardedRef<ChartKitRef | undefined> | undefined;
21
21
  }) => ReturnType<typeof ChartKitComponent>;
22
22
  export {};
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
- import { getErrorMessage } from '../../utils/getErrorMessage';
3
2
  import { CHARTKIT_ERROR_CODE } from '../../libs';
3
+ import { getErrorMessage } from '../../utils/getErrorMessage';
4
4
  export class ErrorBoundary extends React.Component {
5
5
  constructor() {
6
6
  super(...arguments);
@@ -1,4 +1,4 @@
1
- import type { ChartKitPlugin, ChartKitLang, ChartKitHolidays } from '../../types';
1
+ import type { ChartKitHolidays, ChartKitLang, ChartKitPlugin } from '../../types';
2
2
  import { EventEmitter } from './eventEmitter';
3
3
  interface Settings {
4
4
  plugins: ChartKitPlugin[];
@@ -1,6 +1,6 @@
1
+ import { configure } from '@gravity-ui/uikit';
1
2
  import get from 'lodash/get';
2
3
  import merge from 'lodash/merge';
3
- import { configure } from '@gravity-ui/uikit';
4
4
  import { i18nFactory } from '../../i18n';
5
5
  import { EventEmitter } from './eventEmitter';
6
6
  export const settingsEventEmitter = new EventEmitter();
@@ -1,5 +1,5 @@
1
- import { groups } from 'd3';
2
1
  import React from 'react';
2
+ import { groups } from 'd3';
3
3
  import { ChartKit } from '../../../../components/ChartKit';
4
4
  import { ExampleWrapper } from '../ExampleWrapper';
5
5
  import nintendoGames from '../nintendoGames';
@@ -1,5 +1,5 @@
1
- import { groups } from 'd3';
2
1
  import React from 'react';
2
+ import { groups } from 'd3';
3
3
  import { ChartKit } from '../../../../components/ChartKit';
4
4
  import { ExampleWrapper } from '../ExampleWrapper';
5
5
  import nintendoGames from '../nintendoGames';
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { groups, max, min, median } from 'd3';
2
+ import { groups, max, median, min } from 'd3';
3
3
  import { ChartKit } from '../../../../components/ChartKit';
4
4
  import { ExampleWrapper } from '../ExampleWrapper';
5
5
  import nintendoGames from '../nintendoGames';
@@ -1,9 +1,9 @@
1
1
  import React from 'react';
2
2
  import { groups } from 'd3';
3
3
  import { ChartKit } from '../../../../components/ChartKit';
4
+ import { CustomShapeRenderer } from '../../utils';
4
5
  import { ExampleWrapper } from '../ExampleWrapper';
5
6
  import nintendoGames from '../nintendoGames';
6
- import { CustomShapeRenderer } from '../../utils';
7
7
  function prepareData() {
8
8
  const gamesByPlatform = groups(nintendoGames, (d) => d.esrb_rating || 'unknown');
9
9
  return gamesByPlatform.map(([value, games]) => ({
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import type { ChartKitWidgetRef } from '../../../types';
3
3
  declare const D3Widget: React.ForwardRefExoticComponent<{
4
4
  type: "d3";
5
- data: import("../../../types").ChartKitWidgetData<any>;
5
+ data: import("../../../types").ChartKitWidgetData;
6
6
  id?: string | undefined;
7
7
  isMobile?: boolean | undefined;
8
8
  onLoad?: ((data?: import("../../../types").ChartKitOnLoadData<"d3"> | undefined) => void) | undefined;
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
+ import afterFrame from 'afterframe';
2
3
  import { select } from 'd3';
3
4
  import debounce from 'lodash/debounce';
4
- import afterFrame from 'afterframe';
5
5
  import { getRandomCKId, measurePerformance } from '../../../utils';
6
6
  import { Chart } from './components';
7
7
  import { validateData } from './validation';
@@ -6,5 +6,5 @@ type Props = {
6
6
  height: number;
7
7
  scale: ChartScale;
8
8
  };
9
- export declare const AxisX: React.MemoExoticComponent<({ axis, width, height, scale }: Props) => React.JSX.Element>;
9
+ export declare const AxisX: React.NamedExoticComponent<Props>;
10
10
  export {};
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { select } from 'd3';
3
3
  import { block } from '../../../../utils/cn';
4
- import { formatAxisTickLabel, getClosestPointsRange, setEllipsisForOverflowText, getTicksCount, getScaleTicks, getMaxTickCount, } from '../utils';
4
+ import { formatAxisTickLabel, getClosestPointsRange, getMaxTickCount, getScaleTicks, getTicksCount, setEllipsisForOverflowText, } from '../utils';
5
5
  import { axisBottom } from '../utils/axis-generators';
6
6
  const b = block('d3-axis');
7
7
  function getLabelFormatter({ axis, scale }) {
@@ -18,7 +18,7 @@ function getLabelFormatter({ axis, scale }) {
18
18
  });
19
19
  };
20
20
  }
21
- export const AxisX = React.memo(({ axis, width, height, scale }) => {
21
+ export const AxisX = React.memo(function AxisX({ axis, width, height, scale }) {
22
22
  const ref = React.useRef(null);
23
23
  React.useEffect(() => {
24
24
  if (!ref.current) {
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { axisLeft, select } from 'd3';
3
3
  import { block } from '../../../../utils/cn';
4
- import { formatAxisTickLabel, getClosestPointsRange, parseTransformStyle, setEllipsisForOverflowText, setEllipsisForOverflowTexts, getTicksCount, getScaleTicks, calculateSin, calculateCos, } from '../utils';
4
+ import { calculateCos, calculateSin, formatAxisTickLabel, getClosestPointsRange, getScaleTicks, getTicksCount, parseTransformStyle, setEllipsisForOverflowText, setEllipsisForOverflowTexts, } from '../utils';
5
5
  const b = block('d3-axis');
6
6
  function transformLabel(node, axis) {
7
7
  let topOffset = axis.labels.lineHeight / 2;
@@ -2,14 +2,14 @@ import React from 'react';
2
2
  import { block } from '../../../../utils/cn';
3
3
  import { getD3Dispatcher } from '../d3-dispatcher';
4
4
  import { useAxisScales, useChartDimensions, useChartOptions, useSeries, useShapes, useTooltip, } from '../hooks';
5
- import { AxisY } from './AxisY';
5
+ import { getWidthOccupiedByYAxis } from '../hooks/useChartDimensions/utils';
6
+ import { getPreparedXAxis } from '../hooks/useChartOptions/x-axis';
7
+ import { getPreparedYAxis } from '../hooks/useChartOptions/y-axis';
6
8
  import { AxisX } from './AxisX';
9
+ import { AxisY } from './AxisY';
7
10
  import { Legend } from './Legend';
8
11
  import { Title } from './Title';
9
12
  import { Tooltip, TooltipTriggerArea } from './Tooltip';
10
- import { getPreparedXAxis } from '../hooks/useChartOptions/x-axis';
11
- import { getWidthOccupiedByYAxis } from '../hooks/useChartDimensions/utils';
12
- import { getPreparedYAxis } from '../hooks/useChartOptions/y-axis';
13
13
  import './styles.css';
14
14
  const b = block('d3');
15
15
  export const Chart = (props) => {
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import type { OnLegendItemClick, PreparedLegend, PreparedSeries, LegendItem, LegendConfig } from '../hooks';
2
+ import type { LegendConfig, LegendItem, OnLegendItemClick, PreparedLegend, PreparedSeries } from '../hooks';
3
3
  type Props = {
4
4
  boundsWidth: number;
5
5
  chartSeries: PreparedSeries[];
@@ -1,8 +1,8 @@
1
1
  import React from 'react';
2
- import { symbol, select, line as lineGenerator } from 'd3';
3
- import { getSymbol } from '../utils';
2
+ import { line as lineGenerator, select, symbol } from 'd3';
4
3
  import { block } from '../../../../utils/cn';
5
4
  import { getLineDashArray } from '../hooks/useShapes/utils';
5
+ import { getSymbol } from '../utils';
6
6
  const b = block('d3-legend');
7
7
  const getLegendPosition = (args) => {
8
8
  const { align, offsetWidth, width, contentWidth } = args;
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
- import get from 'lodash/get';
3
2
  import { dateTime } from '@gravity-ui/date-utils';
3
+ import get from 'lodash/get';
4
4
  import { formatNumber } from '../../../../shared';
5
5
  import { getDataCategoryValue } from '../../utils';
6
6
  const DEFAULT_DATE_FORMAT = 'DD.MM.YY';
@@ -1,8 +1,8 @@
1
1
  import React from 'react';
2
+ import { bisector, group, pointer, sort } from 'd3';
3
+ import get from 'lodash/get';
2
4
  import throttle from 'lodash/throttle';
3
- import { bisector, pointer, sort, group } from 'd3';
4
5
  import { extractD3DataFromNode, isNodeContainsD3Data } from '../../utils';
5
- import get from 'lodash/get';
6
6
  const THROTTLE_DELAY = 50;
7
7
  const isNodeContainsData = (node) => {
8
8
  return isNodeContainsD3Data(node);
@@ -1,40 +1,16 @@
1
1
  import React from 'react';
2
+ import { Popup, useVirtualElementRef } from '@gravity-ui/uikit';
2
3
  import isNil from 'lodash/isNil';
3
4
  import { block } from '../../../../../utils/cn';
4
5
  import { DefaultContent } from './DefaultContent';
5
6
  export * from './TooltipTriggerArea';
6
7
  const b = block('d3-tooltip');
7
- const POINTER_OFFSET_X = 20;
8
8
  export const Tooltip = (props) => {
9
- const { tooltip, svgContainer, xAxis, yAxis, hovered, pointerPosition } = props;
10
- const ref = React.useRef(null);
11
- const size = React.useMemo(() => {
12
- if (ref.current && hovered) {
13
- const { width, height } = ref.current.getBoundingClientRect();
14
- return { width, height };
15
- }
16
- return undefined;
17
- // eslint-disable-next-line react-hooks/exhaustive-deps
18
- }, [hovered, pointerPosition]);
19
- const position = React.useMemo(() => {
20
- if (hovered && pointerPosition && size) {
21
- const { clientWidth } = document.documentElement;
22
- const { width, height } = size;
23
- const rect = (svgContainer === null || svgContainer === void 0 ? void 0 : svgContainer.getBoundingClientRect()) || { left: 0, top: 0 };
24
- const [pointerLeft, pointetTop] = pointerPosition;
25
- const outOfRightBoudary = pointerLeft + width + rect.left + POINTER_OFFSET_X >= clientWidth;
26
- const outOfTopBoundary = pointetTop - height / 2 <= 0;
27
- const left = outOfRightBoudary
28
- ? pointerLeft - width - POINTER_OFFSET_X
29
- : pointerLeft + POINTER_OFFSET_X;
30
- const top = outOfTopBoundary ? 0 : pointetTop - height / 2;
31
- return { left, top };
32
- }
33
- else if (hovered && pointerPosition) {
34
- return { left: -1000, top: -1000 };
35
- }
36
- return undefined;
37
- }, [hovered, pointerPosition, size, svgContainer]);
9
+ const { tooltip, xAxis, yAxis, hovered, svgContainer, pointerPosition } = props;
10
+ const containerRect = (svgContainer === null || svgContainer === void 0 ? void 0 : svgContainer.getBoundingClientRect()) || { left: 0, top: 0 };
11
+ const left = ((pointerPosition === null || pointerPosition === void 0 ? void 0 : pointerPosition[0]) || 0) + containerRect.left;
12
+ const top = ((pointerPosition === null || pointerPosition === void 0 ? void 0 : pointerPosition[1]) || 0) + containerRect.top;
13
+ const anchorRef = useVirtualElementRef({ rect: { top, left } });
38
14
  const content = React.useMemo(() => {
39
15
  var _a;
40
16
  if (!hovered) {
@@ -43,14 +19,9 @@ export const Tooltip = (props) => {
43
19
  const customTooltip = (_a = tooltip.renderer) === null || _a === void 0 ? void 0 : _a.call(tooltip, { hovered });
44
20
  return isNil(customTooltip) ? (React.createElement(DefaultContent, { hovered: hovered, xAxis: xAxis, yAxis: yAxis })) : (customTooltip);
45
21
  }, [hovered, tooltip, xAxis, yAxis]);
46
- if (!position || !hovered) {
47
- return null;
48
- }
49
- const { left, top } = position;
50
- const style = {
51
- position: 'absolute',
52
- top,
53
- left: left,
54
- };
55
- return (React.createElement("div", { ref: ref, className: b(), style: style }, content));
22
+ React.useEffect(() => {
23
+ window.dispatchEvent(new CustomEvent('scroll'));
24
+ }, [left, top]);
25
+ return hovered ? (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 } }] },
26
+ React.createElement("div", { className: b('content') }, content))) : null;
56
27
  };
@@ -75,13 +75,22 @@
75
75
  fill: var(--g-color-text-primary);
76
76
  }
77
77
 
78
- .chartkit-d3-tooltip {
79
- position: absolute;
78
+ .chartkit-d3-tooltip[class] {
79
+ --g-popup-border-width: 0;
80
+ pointer-events: none;
81
+ }
82
+
83
+ .chartkit-d3-tooltip[class] > div {
84
+ animation-duration: unset;
85
+ animation-timing-function: unset;
86
+ animation-fill-mode: unset;
87
+ }
88
+
89
+ .chartkit-d3-tooltip__content {
80
90
  padding: 10px 14px;
81
91
  background-color: var(--g-color-infographics-tooltip-bg);
82
92
  border: 1px solid var(--g-color-line-generic);
83
93
  border-radius: 3px;
84
94
  box-shadow: 0 2px 12px var(--g-color-sfx-shadow);
85
- z-index: 100001;
86
95
  text-wrap: nowrap;
87
96
  }
@@ -1,7 +1,7 @@
1
1
  import type { ScaleBand, ScaleLinear, ScaleTime } from 'd3';
2
+ import { ChartKitWidgetAxis, ChartKitWidgetSeries } from '../../../../../types';
2
3
  import type { PreparedAxis } from '../useChartOptions/types';
3
4
  import { PreparedSeries } from '../useSeries/types';
4
- import { ChartKitWidgetAxis, ChartKitWidgetSeries } from '../../../../../types';
5
5
  export type ChartScale = ScaleLinear<number, number> | ScaleBand<string> | ScaleTime<number, number>;
6
6
  type Args = {
7
7
  boundsWidth: number;
@@ -1,8 +1,8 @@
1
1
  import React from 'react';
2
- import { scaleBand, scaleLinear, scaleUtc, extent } from 'd3';
2
+ import { extent, scaleBand, scaleLinear, scaleUtc } from 'd3';
3
3
  import get from 'lodash/get';
4
- import { getOnlyVisibleSeries, getDataCategoryValue, getDomainDataYBySeries, getDomainDataXBySeries, isAxisRelatedSeries, isSeriesWithCategoryValues, } from '../../utils';
5
4
  import { DEFAULT_AXIS_TYPE } from '../../constants';
5
+ import { getDataCategoryValue, getDomainDataXBySeries, getDomainDataYBySeries, getOnlyVisibleSeries, isAxisRelatedSeries, isSeriesWithCategoryValues, } from '../../utils';
6
6
  const isNumericalArrayData = (data) => {
7
7
  return data.every((d) => typeof d === 'number' || d === null);
8
8
  };
@@ -1,4 +1,4 @@
1
- import type { BaseTextStyle, ChartKitWidgetData, ChartKitWidgetAxis, ChartKitWidgetAxisType, ChartKitWidgetAxisLabels, ChartMargin } from '../../../../../types';
1
+ import type { BaseTextStyle, ChartKitWidgetAxis, ChartKitWidgetAxisLabels, ChartKitWidgetAxisType, ChartKitWidgetData, ChartMargin } from '../../../../../types';
2
2
  type PreparedAxisLabels = Omit<ChartKitWidgetAxisLabels, 'enabled' | 'padding' | 'style' | 'autoRotation'> & Required<Pick<ChartKitWidgetAxisLabels, 'enabled' | 'padding' | 'margin' | 'rotation'>> & {
3
3
  style: BaseTextStyle;
4
4
  rotation: number;
@@ -1,4 +1,4 @@
1
- import type { ChartKitWidgetSeries, ChartKitWidgetAxis } from '../../../../../types';
1
+ import type { ChartKitWidgetAxis, ChartKitWidgetSeries } from '../../../../../types';
2
2
  import type { PreparedAxis } from './types';
3
3
  export declare const getPreparedXAxis: ({ xAxis, series, width, }: {
4
4
  xAxis?: ChartKitWidgetAxis | undefined;
@@ -1,5 +1,5 @@
1
1
  import get from 'lodash/get';
2
- import { axisLabelsDefaults, DEFAULT_AXIS_LABEL_FONT_SIZE, xAxisTitleDefaults, } from '../../constants';
2
+ import { DEFAULT_AXIS_LABEL_FONT_SIZE, axisLabelsDefaults, xAxisTitleDefaults, } from '../../constants';
3
3
  import { calculateCos, formatAxisTickLabel, getClosestPointsRange, getHorisontalSvgTextHeight, getLabelsSize, getMaxTickCount, getTicksCount, getXAxisItems, hasOverlappingLabels, } from '../../utils';
4
4
  import { createXScale } from '../useAxisScales';
5
5
  function getLabelSettings({ axis, series, width, autoRotation = true, }) {
@@ -1,6 +1,6 @@
1
1
  import get from 'lodash/get';
2
- import { axisLabelsDefaults, DEFAULT_AXIS_LABEL_FONT_SIZE, yAxisTitleDefaults, } from '../../constants';
3
- import { getHorisontalSvgTextHeight, formatAxisTickLabel, getClosestPointsRange, getScaleTicks, getLabelsSize, } from '../../utils';
2
+ import { DEFAULT_AXIS_LABEL_FONT_SIZE, axisLabelsDefaults, yAxisTitleDefaults, } from '../../constants';
3
+ import { formatAxisTickLabel, getClosestPointsRange, getHorisontalSvgTextHeight, getLabelsSize, getScaleTicks, } from '../../utils';
4
4
  import { createYScale } from '../useAxisScales';
5
5
  const getAxisLabelMaxWidth = (args) => {
6
6
  const { axis, series } = args;
@@ -1,6 +1,6 @@
1
1
  import type { ChartKitWidgetData } from '../../../../../types';
2
2
  import type { PreparedAxis, PreparedChart } from '../useChartOptions/types';
3
- import type { PreparedSeries, OnLegendItemClick } from './types';
3
+ import type { OnLegendItemClick, PreparedSeries } from './types';
4
4
  type Args = {
5
5
  chartWidth: number;
6
6
  chartHeight: number;
@@ -2,10 +2,10 @@ import React from 'react';
2
2
  import { group, scaleOrdinal } from 'd3';
3
3
  import { DEFAULT_PALETTE } from '../../constants';
4
4
  import { getSeriesNames } from '../../utils';
5
- import { getActiveLegendItems, getAllLegendItems } from './utils';
6
- import { getPreparedLegend, getLegendComponents } from './prepare-legend';
5
+ import { getLegendComponents, getPreparedLegend } from './prepare-legend';
7
6
  import { getPreparedOptions } from './prepare-options';
8
7
  import { prepareSeries } from './prepareSeries';
8
+ import { getActiveLegendItems, getAllLegendItems } from './utils';
9
9
  export const useSeries = (args) => {
10
10
  const { chartWidth, chartHeight, chartMargin, legend, preparedYAxis, series: { data: series, options: seriesOptions }, } = args;
11
11
  const preparedLegend = React.useMemo(() => getPreparedLegend({ legend, series }), [legend, series]);
@@ -1,5 +1,5 @@
1
1
  import { ScaleOrdinal } from 'd3';
2
- import { ChartKitWidgetSeriesOptions, AreaSeries } from '../../../../../types';
2
+ import { AreaSeries, ChartKitWidgetSeriesOptions } from '../../../../../types';
3
3
  import { PreparedAreaSeries, PreparedLegend } from './types';
4
4
  export declare const DEFAULT_LINE_WIDTH = 1;
5
5
  export declare const DEFAULT_MARKER: {
@@ -1,7 +1,7 @@
1
1
  import get from 'lodash/get';
2
2
  import merge from 'lodash/merge';
3
- import { DEFAULT_DATALABELS_PADDING, DEFAULT_DATALABELS_STYLE, DEFAULT_HALO_OPTIONS, DEFAULT_POINT_MARKER_OPTIONS, } from './constants';
4
3
  import { getRandomCKId } from '../../../../../utils';
4
+ import { DEFAULT_DATALABELS_PADDING, DEFAULT_DATALABELS_STYLE, DEFAULT_HALO_OPTIONS, DEFAULT_POINT_MARKER_OPTIONS, } from './constants';
5
5
  import { getSeriesStackId, prepareLegendSymbol } from './utils';
6
6
  export const DEFAULT_LINE_WIDTH = 1;
7
7
  export const DEFAULT_MARKER = Object.assign(Object.assign({}, DEFAULT_POINT_MARKER_OPTIONS), { enabled: false });
@@ -1,7 +1,7 @@
1
1
  import get from 'lodash/get';
2
2
  import { getRandomCKId } from '../../../../../utils';
3
- import { getSeriesStackId, prepareLegendSymbol } from './utils';
4
3
  import { DEFAULT_DATALABELS_PADDING, DEFAULT_DATALABELS_STYLE } from './constants';
4
+ import { getSeriesStackId, prepareLegendSymbol } from './utils';
5
5
  export function prepareBarXSeries(args) {
6
6
  const { colorScale, series: seriesList, legend } = args;
7
7
  return seriesList.map((series) => {
@@ -1,8 +1,8 @@
1
1
  import get from 'lodash/get';
2
2
  import { getRandomCKId } from '../../../../../utils';
3
- import { getSeriesStackId, prepareLegendSymbol } from './utils';
4
- import { DEFAULT_DATALABELS_STYLE } from './constants';
5
3
  import { getLabelsSize } from '../../utils';
4
+ import { DEFAULT_DATALABELS_STYLE } from './constants';
5
+ import { getSeriesStackId, prepareLegendSymbol } from './utils';
6
6
  function prepareDataLabels(series) {
7
7
  var _a;
8
8
  const enabled = get(series, 'dataLabels.enabled', false);
@@ -1,6 +1,6 @@
1
1
  import type { ChartKitWidgetData } from '../../../../../types';
2
2
  import type { PreparedAxis, PreparedChart } from '../useChartOptions/types';
3
- import type { PreparedLegend, PreparedSeries, LegendItem } from './types';
3
+ import type { LegendItem, PreparedLegend, PreparedSeries } from './types';
4
4
  export declare const getPreparedLegend: (args: {
5
5
  legend: ChartKitWidgetData['legend'];
6
6
  series: ChartKitWidgetData['series']['data'];
@@ -1,7 +1,7 @@
1
+ import { select } from 'd3';
1
2
  import clone from 'lodash/clone';
2
3
  import get from 'lodash/get';
3
4
  import merge from 'lodash/merge';
4
- import { select } from 'd3';
5
5
  import { legendDefaults } from '../../constants';
6
6
  import { getHorisontalSvgTextHeight } from '../../utils';
7
7
  import { getBoundsWidth } from '../useChartDimensions';
@@ -1,7 +1,7 @@
1
1
  import { ScaleOrdinal } from 'd3';
2
2
  import { DashStyle } from '../../../../../constants';
3
3
  import { ChartKitWidgetSeriesOptions, LineSeries } from '../../../../../types';
4
- import { PreparedLineSeries, PreparedLegend } from './types';
4
+ import { PreparedLegend, PreparedLineSeries } from './types';
5
5
  export declare const DEFAULT_LEGEND_SYMBOL_SIZE = 16;
6
6
  export declare const DEFAULT_LINE_WIDTH = 1;
7
7
  export declare const DEFAULT_DASH_STYLE = DashStyle.Solid;
@@ -1,8 +1,8 @@
1
1
  import get from 'lodash/get';
2
2
  import merge from 'lodash/merge';
3
3
  import { DashStyle, LineCap } from '../../../../../constants';
4
- import { DEFAULT_DATALABELS_PADDING, DEFAULT_DATALABELS_STYLE, DEFAULT_HALO_OPTIONS, DEFAULT_LEGEND_SYMBOL_PADDING, DEFAULT_POINT_MARKER_OPTIONS, } from './constants';
5
4
  import { getRandomCKId } from '../../../../../utils';
5
+ import { DEFAULT_DATALABELS_PADDING, DEFAULT_DATALABELS_STYLE, DEFAULT_HALO_OPTIONS, DEFAULT_LEGEND_SYMBOL_PADDING, DEFAULT_POINT_MARKER_OPTIONS, } from './constants';
6
6
  export const DEFAULT_LEGEND_SYMBOL_SIZE = 16;
7
7
  export const DEFAULT_LINE_WIDTH = 1;
8
8
  export const DEFAULT_DASH_STYLE = DashStyle.Solid;
@@ -1,7 +1,7 @@
1
1
  import { scaleOrdinal } from 'd3';
2
- import { DEFAULT_PALETTE } from '../../constants';
3
- import { getRandomCKId } from '../../../../../utils';
4
2
  import get from 'lodash/get';
3
+ import { getRandomCKId } from '../../../../../utils';
4
+ import { DEFAULT_PALETTE } from '../../constants';
5
5
  import { DEFAULT_DATALABELS_PADDING, DEFAULT_DATALABELS_STYLE } from './constants';
6
6
  import { prepareLegendSymbol } from './utils';
7
7
  export function preparePieSeries(args) {
@@ -10,7 +10,7 @@ export function preparePieSeries(args) {
10
10
  const colorScale = scaleOrdinal(dataNames, DEFAULT_PALETTE);
11
11
  const stackId = getRandomCKId();
12
12
  const seriesHoverState = get(seriesOptions, 'pie.states.hover');
13
- const preparedSeries = series.data.map((dataItem) => {
13
+ const preparedSeries = series.data.map((dataItem, i) => {
14
14
  var _a, _b, _c;
15
15
  const result = {
16
16
  type: 'pie',
@@ -29,7 +29,7 @@ export function preparePieSeries(args) {
29
29
  value: dataItem.value,
30
30
  visible: typeof dataItem.visible === 'boolean' ? dataItem.visible : true,
31
31
  name: dataItem.name,
32
- id: '',
32
+ id: `Series ${i}`,
33
33
  color: dataItem.color || colorScale(dataItem.name),
34
34
  legend: {
35
35
  enabled: get(series, 'legend.enabled', legend.enabled),
@@ -1,6 +1,6 @@
1
1
  import { ScaleOrdinal } from 'd3';
2
- import type { PreparedLegend, PreparedScatterSeries } from './types';
3
2
  import type { ChartKitWidgetSeriesOptions, ScatterSeries } from '../../../../../types';
3
+ import type { PreparedLegend, PreparedScatterSeries } from './types';
4
4
  interface PrepareScatterSeriesArgs {
5
5
  colorScale: ScaleOrdinal<string, string>;
6
6
  series: ScatterSeries[];
@@ -1,9 +1,9 @@
1
1
  import get from 'lodash/get';
2
2
  import merge from 'lodash/merge';
3
+ import { getRandomCKId } from '../../../../../utils';
3
4
  import { getSymbolType } from '../../utils';
4
- import { prepareLegendSymbol } from './utils';
5
5
  import { DEFAULT_HALO_OPTIONS, DEFAULT_POINT_MARKER_OPTIONS } from './constants';
6
- import { getRandomCKId } from '../../../../../utils';
6
+ import { prepareLegendSymbol } from './utils';
7
7
  function prepareMarker(series, seriesOptions, index) {
8
8
  const seriesHoverState = get(seriesOptions, 'scatter.states.hover');
9
9
  const markerNormalState = Object.assign(Object.assign({}, DEFAULT_POINT_MARKER_OPTIONS), { enabled: true, symbol: series.symbolType || getSymbolType(index) });
@@ -1,9 +1,9 @@
1
1
  import { ChartKitError } from '../../../../../libs';
2
- import { prepareLineSeries } from './prepare-line';
2
+ import { prepareArea } from './prepare-area';
3
3
  import { prepareBarXSeries } from './prepare-bar-x';
4
4
  import { prepareBarYSeries } from './prepare-bar-y';
5
+ import { prepareLineSeries } from './prepare-line';
5
6
  import { preparePieSeries } from './prepare-pie';
6
- import { prepareArea } from './prepare-area';
7
7
  import { prepareScatterSeries } from './prepare-scatter';
8
8
  import { prepareTreemap } from './prepare-treemap';
9
9
  export function prepareSeries(args) {
@@ -1,6 +1,6 @@
1
- import { BarXSeries, BarXSeriesData, BaseTextStyle, ChartKitWidgetLegend, PieSeries, PieSeriesData, RectLegendSymbolOptions, ScatterSeries, ScatterSeriesData, BarYSeries, BarYSeriesData, LineSeries, LineSeriesData, ConnectorShape, ConnectorCurve, PathLegendSymbolOptions, SymbolLegendSymbolOptions, AreaSeries, AreaSeriesData, TreemapSeries, TreemapSeriesData } from '../../../../../types';
2
- import type { SeriesOptionsDefaults } from '../../constants';
3
1
  import { DashStyle, LayoutAlgorithm, LineCap, SymbolType } from '../../../../../constants';
2
+ import { AreaSeries, AreaSeriesData, BarXSeries, BarXSeriesData, BarYSeries, BarYSeriesData, BaseTextStyle, ChartKitWidgetLegend, ConnectorCurve, ConnectorShape, LineSeries, LineSeriesData, PathLegendSymbolOptions, PieSeries, PieSeriesData, RectLegendSymbolOptions, ScatterSeries, ScatterSeriesData, SymbolLegendSymbolOptions, TreemapSeries, TreemapSeriesData } from '../../../../../types';
3
+ import type { SeriesOptionsDefaults } from '../../constants';
4
4
  export type RectLegendSymbol = {
5
5
  shape: 'rect';
6
6
  } & Required<RectLegendSymbolOptions>;
@@ -1,6 +1,6 @@
1
- import { PreparedLegendSymbol, PreparedSeries, StackedSeries } from './types';
2
- import { ChartKitWidgetSeries } from '../../../../../types';
3
1
  import { SymbolType } from '../../../../../constants';
2
+ import { ChartKitWidgetSeries } from '../../../../../types';
3
+ import { PreparedLegendSymbol, PreparedSeries, StackedSeries } from './types';
4
4
  export declare const getActiveLegendItems: (series: PreparedSeries[]) => string[];
5
5
  export declare const getAllLegendItems: (series: PreparedSeries[]) => string[];
6
6
  export declare function prepareLegendSymbol(series: ChartKitWidgetSeries, symbolType?: `${SymbolType}`): PreparedLegendSymbol;
@@ -1,7 +1,7 @@
1
1
  import memoize from 'lodash/memoize';
2
+ import { SymbolType } from '../../../../../constants';
2
3
  import { getRandomCKId } from '../../../../../utils';
3
4
  import { DEFAULT_LEGEND_SYMBOL_PADDING, DEFAULT_LEGEND_SYMBOL_SIZE } from './constants';
4
- import { SymbolType } from '../../../../../constants';
5
5
  export const getActiveLegendItems = (series) => {
6
6
  return series.reduce((acc, s) => {
7
7
  if (s.legend.enabled && s.visible) {
@@ -1,10 +1,10 @@
1
1
  import React from 'react';
2
- import { color, line as lineGenerator, area as areaGenerator, select } from 'd3';
2
+ import { area as areaGenerator, color, line as lineGenerator, select } from 'd3';
3
3
  import get from 'lodash/get';
4
4
  import { block } from '../../../../../../utils/cn';
5
5
  import { filterOverlappingLabels } from '../../../utils';
6
- import { setActiveState } from '../utils';
7
6
  import { getMarkerHaloVisibility, getMarkerVisibility, renderMarker, selectMarkerHalo, selectMarkerSymbol, setMarker, } from '../marker';
7
+ import { setActiveState } from '../utils';
8
8
  const b = block('d3-area');
9
9
  export const AreaSeriesShapes = (args) => {
10
10
  const { dispatcher, preparedData, seriesOptions } = args;