@gravity-ui/chartkit 4.20.1 → 5.1.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 (118) 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 +13 -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 +19 -7
  20. package/build/plugins/d3/renderer/components/Tooltip/index.js +1 -1
  21. package/build/plugins/d3/renderer/components/styles.css +1 -1
  22. package/build/plugins/d3/renderer/d3-dispatcher.js +1 -1
  23. package/build/plugins/d3/renderer/hooks/useAxisScales/index.d.ts +1 -1
  24. package/build/plugins/d3/renderer/hooks/useAxisScales/index.js +2 -2
  25. package/build/plugins/d3/renderer/hooks/useChartOptions/types.d.ts +1 -1
  26. package/build/plugins/d3/renderer/hooks/useChartOptions/x-axis.d.ts +1 -1
  27. package/build/plugins/d3/renderer/hooks/useChartOptions/x-axis.js +1 -1
  28. package/build/plugins/d3/renderer/hooks/useChartOptions/y-axis.js +2 -2
  29. package/build/plugins/d3/renderer/hooks/useSeries/index.d.ts +1 -1
  30. package/build/plugins/d3/renderer/hooks/useSeries/index.js +2 -2
  31. package/build/plugins/d3/renderer/hooks/useSeries/prepare-area.d.ts +1 -1
  32. package/build/plugins/d3/renderer/hooks/useSeries/prepare-area.js +1 -1
  33. package/build/plugins/d3/renderer/hooks/useSeries/prepare-bar-x.js +1 -1
  34. package/build/plugins/d3/renderer/hooks/useSeries/prepare-bar-y.js +2 -2
  35. package/build/plugins/d3/renderer/hooks/useSeries/prepare-legend.d.ts +1 -1
  36. package/build/plugins/d3/renderer/hooks/useSeries/prepare-legend.js +1 -1
  37. package/build/plugins/d3/renderer/hooks/useSeries/prepare-line.d.ts +1 -1
  38. package/build/plugins/d3/renderer/hooks/useSeries/prepare-line.js +2 -1
  39. package/build/plugins/d3/renderer/hooks/useSeries/prepare-pie.js +3 -2
  40. package/build/plugins/d3/renderer/hooks/useSeries/prepare-scatter.d.ts +1 -1
  41. package/build/plugins/d3/renderer/hooks/useSeries/prepare-scatter.js +2 -2
  42. package/build/plugins/d3/renderer/hooks/useSeries/prepareSeries.js +2 -2
  43. package/build/plugins/d3/renderer/hooks/useSeries/types.d.ts +4 -2
  44. package/build/plugins/d3/renderer/hooks/useSeries/utils.d.ts +2 -2
  45. package/build/plugins/d3/renderer/hooks/useSeries/utils.js +1 -1
  46. package/build/plugins/d3/renderer/hooks/useShapes/area/index.js +2 -2
  47. package/build/plugins/d3/renderer/hooks/useShapes/area/prepare-data.d.ts +2 -2
  48. package/build/plugins/d3/renderer/hooks/useShapes/area/prepare-data.js +1 -1
  49. package/build/plugins/d3/renderer/hooks/useShapes/area/types.d.ts +1 -1
  50. package/build/plugins/d3/renderer/hooks/useShapes/bar-x/index.js +3 -2
  51. package/build/plugins/d3/renderer/hooks/useShapes/bar-x/prepare-data.js +1 -0
  52. package/build/plugins/d3/renderer/hooks/useShapes/bar-x/types.d.ts +2 -1
  53. package/build/plugins/d3/renderer/hooks/useShapes/bar-y/index.js +3 -2
  54. package/build/plugins/d3/renderer/hooks/useShapes/bar-y/prepare-data.js +1 -0
  55. package/build/plugins/d3/renderer/hooks/useShapes/bar-y/types.d.ts +1 -0
  56. package/build/plugins/d3/renderer/hooks/useShapes/index.d.ts +6 -6
  57. package/build/plugins/d3/renderer/hooks/useShapes/index.js +6 -6
  58. package/build/plugins/d3/renderer/hooks/useShapes/line/index.js +3 -2
  59. package/build/plugins/d3/renderer/hooks/useShapes/line/prepare-data.d.ts +2 -2
  60. package/build/plugins/d3/renderer/hooks/useShapes/line/prepare-data.js +2 -1
  61. package/build/plugins/d3/renderer/hooks/useShapes/line/types.d.ts +3 -2
  62. package/build/plugins/d3/renderer/hooks/useShapes/marker.d.ts +1 -1
  63. package/build/plugins/d3/renderer/hooks/useShapes/marker.js +10 -3
  64. package/build/plugins/d3/renderer/hooks/useShapes/pie/index.js +20 -11
  65. package/build/plugins/d3/renderer/hooks/useShapes/pie/prepare-data.js +1 -0
  66. package/build/plugins/d3/renderer/hooks/useShapes/pie/types.d.ts +3 -2
  67. package/build/plugins/d3/renderer/hooks/useShapes/pie/utils.js +1 -1
  68. package/build/plugins/d3/renderer/hooks/useShapes/scatter/index.js +14 -4
  69. package/build/plugins/d3/renderer/hooks/useShapes/scatter/prepare-data.js +2 -0
  70. package/build/plugins/d3/renderer/hooks/useShapes/scatter/types.d.ts +1 -0
  71. package/build/plugins/d3/renderer/hooks/useShapes/treemap/index.js +11 -4
  72. package/build/plugins/d3/renderer/hooks/useShapes/utils.d.ts +1 -1
  73. package/build/plugins/d3/renderer/hooks/useTooltip/index.d.ts +1 -1
  74. package/build/plugins/d3/renderer/utils/axis-generators/bottom.js +1 -1
  75. package/build/plugins/d3/renderer/utils/axis.d.ts +1 -1
  76. package/build/plugins/d3/renderer/utils/index.js +3 -3
  77. package/build/plugins/d3/renderer/utils/symbol.js +1 -1
  78. package/build/plugins/d3/renderer/validation/index.js +1 -1
  79. package/build/plugins/highcharts/renderer/components/HighchartsComponent.d.ts +1 -1
  80. package/build/plugins/highcharts/renderer/components/HighchartsComponent.js +2 -2
  81. package/build/plugins/highcharts/renderer/components/HighchartsReact.js +7 -1
  82. package/build/plugins/highcharts/renderer/components/StyledSplitPane/StyledSplitPane.css +1 -1
  83. package/build/plugins/highcharts/renderer/helpers/config/config.js +15 -15
  84. package/build/plugins/highcharts/renderer/helpers/config/handleLegendItemClick.js +1 -1
  85. package/build/plugins/highcharts/renderer/helpers/config/options.d.ts +98 -98
  86. package/build/plugins/highcharts/renderer/helpers/config/options.js +1 -1
  87. package/build/plugins/highcharts/renderer/helpers/config/utils/index.d.ts +39 -10
  88. package/build/plugins/highcharts/renderer/helpers/graph.css +4 -4
  89. package/build/plugins/highcharts/renderer/helpers/graph.d.ts +1 -1
  90. package/build/plugins/highcharts/renderer/helpers/graph.js +2 -2
  91. package/build/plugins/highcharts/renderer/helpers/highcharts/highcharts.js +2 -2
  92. package/build/plugins/highcharts/renderer/helpers/prepare-data.js +2 -2
  93. package/build/plugins/highcharts/renderer/helpers/tooltip/index.js +1 -1
  94. package/build/plugins/highcharts/renderer/helpers/tooltip/tooltip.css +6 -7
  95. package/build/plugins/highcharts/types/highcharts-extends.d.ts +1 -0
  96. package/build/plugins/highcharts/types/widget.d.ts +2 -2
  97. package/build/plugins/indicator/renderer/IndicatorWidget.css +1 -1
  98. package/build/plugins/indicator/renderer/IndicatorWidget.js +1 -1
  99. package/build/plugins/shared/format-number/format-number.d.ts +1 -1
  100. package/build/plugins/shared/format-number/format-number.js +2 -2
  101. package/build/plugins/shared/format-number/format-number.test.js +1 -1
  102. package/build/plugins/yagr/renderer/YagrWidget.css +1 -1
  103. package/build/plugins/yagr/renderer/YagrWidget.js +5 -3
  104. package/build/plugins/yagr/renderer/tooltip/tooltip.css +15 -16
  105. package/build/plugins/yagr/renderer/utils.d.ts +1 -1
  106. package/build/plugins/yagr/renderer/utils.js +1 -1
  107. package/build/types/index.d.ts +1 -1
  108. package/build/types/widget-data/area.d.ts +15 -0
  109. package/build/types/widget-data/bar-x.d.ts +3 -1
  110. package/build/types/widget-data/bar-y.d.ts +3 -1
  111. package/build/types/widget-data/chart.d.ts +6 -0
  112. package/build/types/widget-data/line.d.ts +10 -1
  113. package/build/types/widget-data/pie.d.ts +2 -0
  114. package/build/types/widget-data/scatter.d.ts +3 -0
  115. package/build/types/widget-data/series.d.ts +6 -6
  116. package/build/types/widget-data/tooltip.d.ts +3 -3
  117. package/build/types/widget.d.ts +2 -2
  118. package/package.json +23 -24
@@ -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;
@@ -1,6 +1,6 @@
1
- import type { PreparedAreaSeries } from '../../useSeries/types';
2
- import type { PreparedAxis } from '../../useChartOptions/types';
3
1
  import type { ChartScale } from '../../useAxisScales';
2
+ import type { PreparedAxis } from '../../useChartOptions/types';
3
+ import type { PreparedAreaSeries } from '../../useSeries/types';
4
4
  import type { PreparedAreaData } from './types';
5
5
  export declare const prepareAreaData: (args: {
6
6
  series: PreparedAreaSeries[];
@@ -1,6 +1,6 @@
1
1
  import { group, sort } from 'd3';
2
- import { getXValue, getYValue } from '../utils';
3
2
  import { getLabelsSize, getLeftPosition } from '../../../utils';
3
+ import { getXValue, getYValue } from '../utils';
4
4
  function getLabelData(point, series, xMax) {
5
5
  const text = String(point.data.label || point.data.y);
6
6
  const style = series.dataLabels.style;
@@ -1,6 +1,6 @@
1
- import { PreparedAreaSeries } from '../../useSeries/types';
2
1
  import { AreaSeriesData } from '../../../../../../types';
3
2
  import { LabelData } from '../../../types';
3
+ import { PreparedAreaSeries } from '../../useSeries/types';
4
4
  export type PointData = {
5
5
  y0: number;
6
6
  x: number;
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
- import get from 'lodash/get';
3
2
  import { color, select } from 'd3';
3
+ import get from 'lodash/get';
4
4
  import { block } from '../../../../../../utils/cn';
5
5
  import { filterOverlappingLabels } from '../../../utils';
6
6
  export { prepareBarXData } from './prepare-data';
@@ -27,7 +27,8 @@ export const BarXSeriesShapes = (args) => {
27
27
  .attr('y', (d) => d.y)
28
28
  .attr('height', (d) => d.height)
29
29
  .attr('width', (d) => d.width)
30
- .attr('fill', (d) => d.data.color || d.series.color);
30
+ .attr('fill', (d) => d.data.color || d.series.color)
31
+ .attr('opacity', (d) => d.opacity);
31
32
  let dataLabels = preparedData.map((d) => d.label).filter(Boolean);
32
33
  if (!((_a = preparedData[0]) === null || _a === void 0 ? void 0 : _a.series.dataLabels.allowOverlap)) {
33
34
  dataLabels = filterOverlappingLabels(dataLabels);
@@ -117,6 +117,7 @@ export const prepareBarXData = (args) => {
117
117
  y: y - stackHeight,
118
118
  width: rectWidth,
119
119
  height,
120
+ opacity: get(yValue.data, 'opacity', null),
120
121
  data: yValue.data,
121
122
  series: yValue.series,
122
123
  };
@@ -1,11 +1,12 @@
1
1
  import { TooltipDataChunkBarX } from '../../../../../../types';
2
- import { PreparedBarXSeries } from '../../useSeries/types';
3
2
  import { LabelData } from '../../../types';
3
+ import { PreparedBarXSeries } from '../../useSeries/types';
4
4
  export type PreparedBarXData = Omit<TooltipDataChunkBarX, 'series'> & {
5
5
  x: number;
6
6
  y: number;
7
7
  width: number;
8
8
  height: number;
9
+ opacity: number | null;
9
10
  series: PreparedBarXSeries;
10
11
  label?: LabelData;
11
12
  };
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
- import get from 'lodash/get';
3
2
  import { color, select } from 'd3';
3
+ import get from 'lodash/get';
4
4
  import { block } from '../../../../../../utils/cn';
5
5
  export { prepareBarYData } from './prepare-data';
6
6
  const DEFAULT_LABEL_PADDING = 7;
@@ -23,7 +23,8 @@ export const BarYSeriesShapes = (args) => {
23
23
  .attr('y', (d) => d.y)
24
24
  .attr('height', (d) => d.height)
25
25
  .attr('width', (d) => d.width)
26
- .attr('fill', (d) => d.color);
26
+ .attr('fill', (d) => d.color)
27
+ .attr('opacity', (d) => d.data.opacity || null);
27
28
  const dataLabels = preparedData.filter((d) => d.series.dataLabels.enabled);
28
29
  const labelSelection = svgElement
29
30
  .selectAll('text')
@@ -104,6 +104,7 @@ export const prepareBarYData = (args) => {
104
104
  width,
105
105
  height: barHeight,
106
106
  color: data.color || s.color,
107
+ opacity: get(data, 'opacity', null),
107
108
  data,
108
109
  series: s,
109
110
  });
@@ -6,5 +6,6 @@ export type PreparedBarYData = Omit<TooltipDataChunkBarX, 'series'> & {
6
6
  width: number;
7
7
  height: number;
8
8
  color: string;
9
+ opacity: number | null;
9
10
  series: PreparedBarYSeries;
10
11
  };
@@ -1,16 +1,16 @@
1
1
  import React from 'react';
2
2
  import { Dispatch } from 'd3';
3
- import type { PreparedAxis } from '../useChartOptions/types';
4
- import type { ChartScale } from '../useAxisScales';
5
3
  import type { PreparedSeries, PreparedSeriesOptions } from '../';
4
+ import type { ChartScale } from '../useAxisScales';
5
+ import type { PreparedAxis } from '../useChartOptions/types';
6
+ import type { PreparedAreaData } from './area/types';
6
7
  import type { PreparedBarXData } from './bar-x';
7
- import type { PreparedScatterData } from './scatter/types';
8
- import type { PreparedPieData } from './pie/types';
9
- import type { PreparedLineData } from './line/types';
10
8
  import type { PreparedBarYData } from './bar-y/types';
9
+ import type { PreparedLineData } from './line/types';
10
+ import type { PreparedPieData } from './pie/types';
11
+ import type { PreparedScatterData } from './scatter/types';
11
12
  export type { PreparedBarXData } from './bar-x';
12
13
  export type { PreparedScatterData } from './scatter/types';
13
- import type { PreparedAreaData } from './area/types';
14
14
  import './styles.css';
15
15
  export type ShapeData = PreparedBarXData | PreparedBarYData | PreparedScatterData | PreparedLineData | PreparedPieData | PreparedAreaData;
16
16
  type Args = {
@@ -1,15 +1,15 @@
1
1
  import React from 'react';
2
2
  import { group } from 'd3';
3
3
  import { getOnlyVisibleSeries } from '../../utils';
4
+ import { AreaSeriesShapes } from './area';
5
+ import { prepareAreaData } from './area/prepare-data';
4
6
  import { BarXSeriesShapes, prepareBarXData } from './bar-x';
5
- import { ScatterSeriesShape, prepareScatterData } from './scatter';
7
+ import { BarYSeriesShapes, prepareBarYData } from './bar-y';
8
+ import { LineSeriesShapes } from './line';
9
+ import { prepareLineData } from './line/prepare-data';
6
10
  import { PieSeriesShapes } from './pie';
7
11
  import { preparePieData } from './pie/prepare-data';
8
- import { prepareLineData } from './line/prepare-data';
9
- import { LineSeriesShapes } from './line';
10
- import { BarYSeriesShapes, prepareBarYData } from './bar-y';
11
- import { AreaSeriesShapes } from './area';
12
- import { prepareAreaData } from './area/prepare-data';
12
+ import { ScatterSeriesShape, prepareScatterData } from './scatter';
13
13
  import { TreemapSeriesShape } from './treemap';
14
14
  import { prepareTreemapData } from './treemap/prepare-data';
15
15
  import './styles.css';
@@ -3,8 +3,8 @@ import { 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 { getLineDashArray, setActiveState } from '../utils';
7
6
  import { getMarkerHaloVisibility, getMarkerVisibility, renderMarker, selectMarkerHalo, selectMarkerSymbol, setMarker, } from '../marker';
7
+ import { getLineDashArray, setActiveState } from '../utils';
8
8
  const b = block('d3-line');
9
9
  export const LineSeriesShapes = (args) => {
10
10
  const { dispatcher, preparedData, seriesOptions } = args;
@@ -31,7 +31,8 @@ export const LineSeriesShapes = (args) => {
31
31
  .attr('stroke-width', (d) => d.width)
32
32
  .attr('stroke-linejoin', (d) => d.linecap)
33
33
  .attr('stroke-linecap', (d) => d.linecap)
34
- .attr('stroke-dasharray', (d) => getLineDashArray(d.dashStyle, d.width));
34
+ .attr('stroke-dasharray', (d) => getLineDashArray(d.dashStyle, d.width))
35
+ .attr('opacity', (d) => d.opacity);
35
36
  let dataLabels = preparedData.reduce((acc, d) => {
36
37
  return acc.concat(d.labels);
37
38
  }, []);
@@ -1,6 +1,6 @@
1
- import { PreparedLineSeries } from '../../useSeries/types';
2
- import { PreparedAxis } from '../../useChartOptions/types';
3
1
  import { ChartScale } from '../../useAxisScales';
2
+ import { PreparedAxis } from '../../useChartOptions/types';
3
+ import { PreparedLineSeries } from '../../useSeries/types';
4
4
  import { PreparedLineData } from './types';
5
5
  export declare const prepareLineData: (args: {
6
6
  series: PreparedLineSeries[];
@@ -1,5 +1,5 @@
1
- import { getXValue, getYValue } from '../utils';
2
1
  import { getLabelsSize, getLeftPosition } from '../../../utils';
2
+ import { getXValue, getYValue } from '../utils';
3
3
  function getLabelData(point, series, xMax) {
4
4
  const text = String(point.data.label || point.data.y);
5
5
  const style = series.dataLabels.style;
@@ -63,6 +63,7 @@ export const prepareLineData = (args) => {
63
63
  id: s.id,
64
64
  dashStyle: s.dashStyle,
65
65
  linecap: s.linecap,
66
+ opacity: s.opacity,
66
67
  };
67
68
  acc.push(result);
68
69
  return acc;
@@ -1,7 +1,7 @@
1
- import { PreparedLineSeries } from '../../useSeries/types';
1
+ import { DashStyle, LineCap } from '../../../../../../constants';
2
2
  import { LineSeriesData } from '../../../../../../types';
3
3
  import { LabelData } from '../../../types';
4
- import { DashStyle, LineCap } from '../../../../../../constants';
4
+ import { PreparedLineSeries } from '../../useSeries/types';
5
5
  export type PointData = {
6
6
  x: number;
7
7
  y: number;
@@ -25,4 +25,5 @@ export type PreparedLineData = {
25
25
  labels: LabelData[];
26
26
  dashStyle: DashStyle;
27
27
  linecap: LineCap;
28
+ opacity: number | null;
28
29
  };
@@ -1,6 +1,6 @@
1
1
  import { BaseType, Selection } from 'd3';
2
- import { MarkerData as LineMarkerData } from './line/types';
3
2
  import { MarkerData as AreaMarkerData } from './area/types';
3
+ import { MarkerData as LineMarkerData } from './line/types';
4
4
  import { MarkerData as ScatterMarkerData } from './scatter/types';
5
5
  type MarkerData = LineMarkerData | AreaMarkerData | ScatterMarkerData;
6
6
  export declare function renderMarker<T extends MarkerData>(selection: Selection<BaseType | SVGGElement, T, SVGGElement, unknown>): Selection<BaseType | SVGGElement, T, SVGGElement, unknown>;
@@ -1,8 +1,8 @@
1
1
  import { symbol } from 'd3';
2
- import { block } from '../../../../../utils/cn';
2
+ import get from 'lodash/get';
3
3
  import { SymbolType } from '../../../../../constants';
4
+ import { block } from '../../../../../utils/cn';
4
5
  import { getSymbol } from '../../utils';
5
- import get from 'lodash/get';
6
6
  const b = block('d3-marker');
7
7
  const haloClassName = b('halo');
8
8
  const symbolClassName = b('symbol');
@@ -36,7 +36,14 @@ export function renderMarker(selection) {
36
36
  }
37
37
  export function getMarkerVisibility(d) {
38
38
  const markerStates = d.point.series.marker.states;
39
- const enabled = (markerStates.hover.enabled && d.hovered) || markerStates.normal.enabled;
39
+ let enabled;
40
+ if (d.hovered) {
41
+ enabled = markerStates.hover.enabled && d.hovered;
42
+ }
43
+ else {
44
+ enabled =
45
+ markerStates.normal.enabled || get(d.point.data, 'marker.states.normal.enabled', false);
46
+ }
40
47
  return enabled ? '' : 'hidden';
41
48
  }
42
49
  export function getMarkerHaloVisibility(d) {
@@ -1,10 +1,9 @@
1
1
  import React from 'react';
2
+ import { arc, color, line as lineGenerator, pointer, select } from 'd3';
2
3
  import get from 'lodash/get';
3
- import { arc, color, pointer, select } from 'd3';
4
4
  import { block } from '../../../../../../utils/cn';
5
- import { setActiveState } from '../utils';
6
- import { line as lineGenerator } from 'd3-shape';
7
5
  import { setEllipsisForOverflowTexts } from '../../../utils';
6
+ import { setActiveState } from '../utils';
8
7
  import { getCurveFactory } from './utils';
9
8
  const b = block('d3-pie');
10
9
  export function getHaloVisibility(d) {
@@ -69,7 +68,8 @@ export function PieSeriesShapes(args) {
69
68
  return arcGenerator(d);
70
69
  })
71
70
  .attr('class', b('segment'))
72
- .attr('fill', (d) => d.data.color);
71
+ .attr('fill', (d) => d.data.color)
72
+ .attr('opacity', (d) => d.data.opacity);
73
73
  shapesSelection
74
74
  .selectAll('text')
75
75
  .data((pieData) => pieData.labels)
@@ -115,17 +115,20 @@ export function PieSeriesShapes(args) {
115
115
  nodes[index].append(customShape);
116
116
  }
117
117
  });
118
+ const getSelectedSegment = (element) => {
119
+ const datum = select(element).datum();
120
+ const seriesId = get(datum, 'data.series.id', get(datum, 'series.id'));
121
+ return preparedData.reduce((result, pie) => {
122
+ var _a;
123
+ return result || ((_a = pie.segments.find((s) => s.data.series.id === seriesId)) === null || _a === void 0 ? void 0 : _a.data);
124
+ }, undefined);
125
+ };
118
126
  const eventName = `hover-shape.pie`;
119
127
  const hoverOptions = get(seriesOptions, 'pie.states.hover');
120
128
  const inactiveOptions = get(seriesOptions, 'pie.states.inactive');
121
129
  svgElement
122
130
  .on('mousemove', (e) => {
123
- const datum = select(e.target).datum();
124
- const seriesId = get(datum, 'data.series.id', get(datum, 'series.id'));
125
- const currentSegment = preparedData.reduce((result, pie) => {
126
- var _a;
127
- return (result || ((_a = pie.segments.find((s) => s.data.series.id === seriesId)) === null || _a === void 0 ? void 0 : _a.data));
128
- }, undefined);
131
+ const currentSegment = getSelectedSegment(e.target);
129
132
  if (currentSegment) {
130
133
  const data = {
131
134
  series: {
@@ -133,13 +136,19 @@ export function PieSeriesShapes(args) {
133
136
  type: 'pie',
134
137
  name: currentSegment.series.name,
135
138
  },
136
- data: currentSegment.series,
139
+ data: currentSegment.series.data,
137
140
  };
138
141
  dispatcher.call('hover-shape', {}, [data], pointer(e, svgContainer));
139
142
  }
140
143
  })
141
144
  .on('mouseleave', () => {
142
145
  dispatcher.call('hover-shape', {}, undefined);
146
+ })
147
+ .on('click', (e) => {
148
+ const selectedSegment = getSelectedSegment(e.target);
149
+ if (selectedSegment) {
150
+ dispatcher.call('click-chart', undefined, { point: selectedSegment.series.data, series: selectedSegment.series }, e);
151
+ }
143
152
  });
144
153
  dispatcher.on(eventName, (data) => {
145
154
  const selectedSeriesId = data === null || data === void 0 ? void 0 : data[0].series.id;
@@ -45,6 +45,7 @@ export function preparePieData(args) {
45
45
  return {
46
46
  value: item.value,
47
47
  color: item.color,
48
+ opacity: item.opacity,
48
49
  series: item,
49
50
  hovered: false,
50
51
  active: true,
@@ -1,10 +1,11 @@
1
1
  import type { PieArcDatum } from 'd3';
2
- import { PreparedPieSeries } from '../../useSeries/types';
3
- import { LabelData } from '../../../types';
4
2
  import { ConnectorCurve } from '../../../../../../types';
3
+ import { LabelData } from '../../../types';
4
+ import { PreparedPieSeries } from '../../useSeries/types';
5
5
  export type SegmentData = {
6
6
  value: number;
7
7
  color: string;
8
+ opacity: number | null;
8
9
  series: PreparedPieSeries;
9
10
  hovered: boolean;
10
11
  active: boolean;
@@ -1,4 +1,4 @@
1
- import { pie, curveBasis, curveLinear } from 'd3';
1
+ import { curveBasis, curveLinear, pie } from 'd3';
2
2
  export const pieGenerator = pie()
3
3
  .value((d) => d.value)
4
4
  .sort(null);
@@ -1,9 +1,9 @@
1
1
  import React from 'react';
2
- import get from 'lodash/get';
3
2
  import { pointer, select } from 'd3';
3
+ import get from 'lodash/get';
4
4
  import { block } from '../../../../../../utils/cn';
5
- import { setActiveState, shapeKey } from '../utils';
6
5
  import { getMarkerHaloVisibility, renderMarker, selectMarkerHalo, selectMarkerSymbol, setMarker, } from '../marker';
6
+ import { setActiveState, shapeKey } from '../utils';
7
7
  export { prepareScatterData } from './prepare-data';
8
8
  const b = block('d3-scatter');
9
9
  export function ScatterSeriesShape(props) {
@@ -22,10 +22,14 @@ export function ScatterSeriesShape(props) {
22
22
  .data(preparedData, shapeKey)
23
23
  .join('g')
24
24
  .call(renderMarker)
25
- .attr('fill', (d) => d.point.data.color || d.point.series.color || '');
25
+ .attr('fill', (d) => d.point.data.color || d.point.series.color || '')
26
+ .attr('opacity', (d) => d.point.opacity);
27
+ const getSelectedPoint = (element) => {
28
+ return select(element).datum();
29
+ };
26
30
  svgElement
27
31
  .on('mousemove', (e) => {
28
- const datum = select(e.target).datum();
32
+ const datum = getSelectedPoint(e.target);
29
33
  if (!datum) {
30
34
  return;
31
35
  }
@@ -42,6 +46,12 @@ export function ScatterSeriesShape(props) {
42
46
  })
43
47
  .on('mouseleave', () => {
44
48
  dispatcher.call('hover-shape', {}, undefined);
49
+ })
50
+ .on('click', (e) => {
51
+ const datum = getSelectedPoint(e.target);
52
+ if (datum) {
53
+ dispatcher.call('click-chart', undefined, { point: datum.point.data, series: datum.point.series }, e);
54
+ }
45
55
  });
46
56
  const hoverEnabled = hoverOptions === null || hoverOptions === void 0 ? void 0 : hoverOptions.enabled;
47
57
  const inactiveEnabled = inactiveOptions === null || inactiveOptions === void 0 ? void 0 : inactiveOptions.enabled;
@@ -1,3 +1,4 @@
1
+ import get from 'lodash/get';
1
2
  import { getXValue, getYValue } from '../utils';
2
3
  const getFilteredLinearScatterData = (data) => {
3
4
  return data.filter((d) => typeof d.x === 'number' && typeof d.y === 'number');
@@ -15,6 +16,7 @@ export const prepareScatterData = (args) => {
15
16
  series: s,
16
17
  x: getXValue({ point: d, xAxis, xScale }),
17
18
  y: getYValue({ point: d, yAxis, yScale }),
19
+ opacity: get(d, 'opacity', null),
18
20
  },
19
21
  hovered: false,
20
22
  active: true,
@@ -3,6 +3,7 @@ import { PreparedScatterSeries } from '../../useSeries/types';
3
3
  type PointData = {
4
4
  x: number;
5
5
  y: number;
6
+ opacity: number | null;
6
7
  data: ScatterSeriesData;
7
8
  series: PreparedScatterSeries;
8
9
  };
@@ -1,8 +1,8 @@
1
1
  import React from 'react';
2
2
  import { color, pointer, select } from 'd3';
3
3
  import get from 'lodash/get';
4
- import { setEllipsisForOverflowTexts } from '../../../utils';
5
4
  import { block } from '../../../../../../utils/cn';
5
+ import { setEllipsisForOverflowTexts } from '../../../utils';
6
6
  const b = block('d3-treemap');
7
7
  export const TreemapSeriesShape = (props) => {
8
8
  const { dispatcher, preparedData, seriesOptions, svgContainer } = props;
@@ -44,17 +44,24 @@ export const TreemapSeriesShape = (props) => {
44
44
  .style('font-weight', () => { var _a; return ((_a = series.dataLabels.style) === null || _a === void 0 ? void 0 : _a.fontWeight) || null; })
45
45
  .style('fill', () => { var _a; return ((_a = series.dataLabels.style) === null || _a === void 0 ? void 0 : _a.fontColor) || null; })
46
46
  .call(setEllipsisForOverflowTexts, (d) => d.width);
47
- const eventName = `hover-shape.pie`;
47
+ const getSelectedPart = (node) => {
48
+ const hoveredRect = select(node);
49
+ return hoveredRect.datum();
50
+ };
51
+ const eventName = `hover-shape.treemap`;
48
52
  const hoverOptions = get(seriesOptions, 'treemap.states.hover');
49
53
  const inactiveOptions = get(seriesOptions, 'treemap.states.inactive');
50
54
  svgElement
51
55
  .on('mousemove', (e) => {
52
- const hoveredRect = select(e.target);
53
- const datum = hoveredRect.datum();
56
+ const datum = getSelectedPart(e.target);
54
57
  dispatcher.call('hover-shape', {}, [{ data: datum.data, series }], pointer(e, svgContainer));
55
58
  })
56
59
  .on('mouseleave', () => {
57
60
  dispatcher.call('hover-shape', {}, undefined);
61
+ })
62
+ .on('click', (e) => {
63
+ const datum = getSelectedPart(e.target);
64
+ dispatcher.call('click-chart', undefined, { point: datum.data, series }, e);
58
65
  });
59
66
  dispatcher.on(eventName, (data) => {
60
67
  const hoverEnabled = hoverOptions === null || hoverOptions === void 0 ? void 0 : hoverOptions.enabled;
@@ -1,8 +1,8 @@
1
1
  import type { BaseType } from 'd3';
2
+ import { DashStyle } from '../../../../../constants';
2
3
  import type { BasicInactiveState } from '../../../../../types';
3
4
  import type { ChartScale } from '../useAxisScales';
4
5
  import type { PreparedAxis } from '../useChartOptions/types';
5
- import { DashStyle } from '../../../../../constants';
6
6
  export declare function getXValue(args: {
7
7
  point: {
8
8
  x?: number | string;
@@ -7,7 +7,7 @@ type Args = {
7
7
  tooltip: PreparedTooltip;
8
8
  };
9
9
  export declare const useTooltip: ({ dispatcher, tooltip }: Args) => {
10
- hovered: TooltipDataChunk<any>[] | undefined;
10
+ hovered: TooltipDataChunk[] | undefined;
11
11
  pointerPosition: PointerPosition | undefined;
12
12
  };
13
13
  export {};
@@ -1,7 +1,7 @@
1
1
  import { select } from 'd3';
2
2
  import { getXAxisItems, getXAxisOffset, getXTickPosition } from '../axis';
3
- import { getLabelsSize, setEllipsisForOverflowText } from '../text';
4
3
  import { calculateCos, calculateSin } from '../math';
4
+ import { getLabelsSize, setEllipsisForOverflowText } from '../text';
5
5
  function addDomain(selection, options) {
6
6
  const { size, color } = options;
7
7
  selection
@@ -1,5 +1,5 @@
1
- import { PreparedAxis } from '../hooks';
2
1
  import { AxisDomain, AxisScale, ScaleBand } from 'd3';
2
+ import { PreparedAxis } from '../hooks';
3
3
  export declare function getTicksCount({ axis, range }: {
4
4
  axis: PreparedAxis;
5
5
  range: number;
@@ -1,12 +1,12 @@
1
+ import { dateTime } from '@gravity-ui/date-utils';
1
2
  import { group, select } from 'd3';
2
3
  import get from 'lodash/get';
3
4
  import isNil from 'lodash/isNil';
4
- import { dateTime } from '@gravity-ui/date-utils';
5
5
  import { formatNumber } from '../../../shared';
6
- import { DEFAULT_AXIS_LABEL_FONT_SIZE } from '../constants';
7
6
  import { getNumberUnitRate } from '../../../shared/format-number/format-number';
8
- import { getDefaultDateFormat } from './time';
7
+ import { DEFAULT_AXIS_LABEL_FONT_SIZE } from '../constants';
9
8
  import { getSeriesStackId } from '../hooks/useSeries/utils';
9
+ import { getDefaultDateFormat } from './time';
10
10
  export * from './math';
11
11
  export * from './text';
12
12
  export * from './time';
@@ -1,4 +1,4 @@
1
- import { symbolDiamond2, symbolCircle, symbolSquare, symbolTriangle2 } from 'd3';
1
+ import { symbolCircle, symbolDiamond2, symbolSquare, symbolTriangle2 } from 'd3';
2
2
  import { SymbolType } from '../../../../constants';
3
3
  export const getSymbolType = (index) => {
4
4
  const scatterStyles = Object.values(SymbolType);
@@ -1,8 +1,8 @@
1
1
  import get from 'lodash/get';
2
2
  import isEmpty from 'lodash/isEmpty';
3
3
  import { SeriesType } from '../../../../constants';
4
- import { ChartKitError, CHARTKIT_ERROR_CODE } from '../../../../libs';
5
4
  import { i18n } from '../../../../i18n';
5
+ import { CHARTKIT_ERROR_CODE, ChartKitError } from '../../../../libs';
6
6
  import { DEFAULT_AXIS_TYPE } from '../constants';
7
7
  const AVAILABLE_SERIES_TYPES = Object.values(SeriesType);
8
8
  const validateXYSeries = (args) => {
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import Highcharts, { ChartCallbackFunction, Options, Chart } from 'highcharts';
2
+ import Highcharts, { Chart, ChartCallbackFunction, Options } from 'highcharts';
3
3
  import type { ChartKitProps } from '../../../../types';
4
4
  import type { HighchartsWidgetData, StringParams } from '../../types';
5
5
  import './HighchartsComponent.css';
@@ -1,12 +1,12 @@
1
1
  import React from 'react';
2
2
  import Highcharts from 'highcharts';
3
- import HighchartsReact from './HighchartsReact';
4
3
  import get from 'lodash/get';
5
4
  import { settings } from '../../../../libs';
6
5
  import { settingsEventEmitter } from '../../../../libs/settings/settings';
7
- import { markChartPerformance, getChartPerformanceDuration, getRandomCKId } from '../../../../utils';
6
+ import { getChartPerformanceDuration, getRandomCKId, markChartPerformance } from '../../../../utils';
8
7
  import { getGraph } from '../helpers/graph';
9
8
  import { initHighchartsLangOptions } from '../helpers/highcharts/highcharts';
9
+ import HighchartsReact from './HighchartsReact';
10
10
  import { withSplitPane } from './withSplitPane/withSplitPane';
11
11
  import './HighchartsComponent.css';
12
12
  const HighcharsReactWithSplitPane = withSplitPane(HighchartsReact);
@@ -26,7 +26,13 @@ export const HighchartsReact = React.memo(React.forwardRef(function HighchartsRe
26
26
  if (!chartRef.current) {
27
27
  createChart();
28
28
  }
29
- }, [props.options, props.allowChartUpdate, props.containerProps, props.highcharts, props.constructorType]);
29
+ }, [
30
+ props.options,
31
+ props.allowChartUpdate,
32
+ props.containerProps,
33
+ props.highcharts,
34
+ props.constructorType,
35
+ ]);
30
36
  useIsomorphicLayoutEffect(() => {
31
37
  return () => {
32
38
  if (chartRef.current) {
@@ -1,5 +1,5 @@
1
1
  .styled-split-pane__pane-resizer {
2
- background: var(--yc-color-base-generic);
2
+ background: var(--g-color-base-generic);
3
3
  z-index: 1;
4
4
  box-sizing: border-box;
5
5
  position: relative;