@gravity-ui/charts 1.40.0 → 1.41.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.
Files changed (220) hide show
  1. package/README.md +4 -24
  2. package/dist/cjs/components/AxisX/AxisX.js +2 -1
  3. package/dist/cjs/components/AxisY/AxisY.js +2 -1
  4. package/dist/cjs/components/ChartInner/useChartInnerHandlers.d.ts +1 -1
  5. package/dist/cjs/components/ChartInner/useChartInnerHandlers.js +1 -1
  6. package/dist/cjs/components/ChartInner/useChartInnerProps.d.ts +1 -1
  7. package/dist/cjs/components/ChartInner/useChartInnerState.d.ts +1 -1
  8. package/dist/cjs/components/ChartInner/useDefaultState.d.ts +1 -1
  9. package/dist/cjs/components/Legend/index.js +3 -1
  10. package/dist/cjs/components/RangeSlider/utils.js +1 -1
  11. package/dist/cjs/components/Tooltip/DefaultTooltipContent/Row.js +4 -4
  12. package/dist/cjs/components/Tooltip/DefaultTooltipContent/RowWithAggregation.js +3 -2
  13. package/dist/cjs/components/Tooltip/DefaultTooltipContent/index.js +128 -118
  14. package/dist/cjs/components/Tooltip/index.d.ts +1 -1
  15. package/dist/cjs/components/Tooltip/styles.css +33 -7
  16. package/dist/cjs/components/index.d.ts +4 -1
  17. package/dist/cjs/components/index.js +9 -4
  18. package/dist/cjs/components/utils/index.js +1 -1
  19. package/dist/cjs/hooks/useAxis/x-axis.js +5 -2
  20. package/dist/cjs/hooks/useAxisScales/types.d.ts +1 -1
  21. package/dist/cjs/hooks/useAxisScales/x-scale.js +2 -1
  22. package/dist/cjs/hooks/useAxisScales/y-scale.js +2 -1
  23. package/dist/cjs/hooks/useBrush/index.js +2 -1
  24. package/dist/cjs/hooks/useBrush/types.d.ts +1 -1
  25. package/dist/cjs/hooks/useBrush/utils.d.ts +1 -1
  26. package/dist/cjs/hooks/useBrush/utils.js +2 -1
  27. package/dist/cjs/hooks/useCrosshair/index.d.ts +1 -1
  28. package/dist/cjs/hooks/useCrosshair/index.js +2 -1
  29. package/dist/cjs/hooks/useCrosshair/useCrosshairHover.d.ts +1 -1
  30. package/dist/cjs/hooks/useRangeSlider/index.js +1 -1
  31. package/dist/cjs/hooks/useSeries/index.js +2 -1
  32. package/dist/cjs/hooks/useSeries/prepare-area.d.ts +1 -1
  33. package/dist/cjs/hooks/useSeries/prepare-bar-x.d.ts +1 -1
  34. package/dist/cjs/hooks/useSeries/prepare-bar-y.d.ts +1 -1
  35. package/dist/cjs/hooks/useSeries/prepare-funnel.js +1 -1
  36. package/dist/cjs/hooks/useSeries/prepare-heatmap.d.ts +1 -1
  37. package/dist/cjs/hooks/useSeries/prepare-line.d.ts +1 -1
  38. package/dist/cjs/hooks/useSeries/prepare-pie.js +1 -1
  39. package/dist/cjs/hooks/useSeries/prepare-radar.js +1 -1
  40. package/dist/cjs/hooks/useSeries/prepare-sankey.d.ts +1 -1
  41. package/dist/cjs/hooks/useSeries/prepare-scatter.d.ts +1 -1
  42. package/dist/cjs/hooks/useSeries/prepare-treemap.d.ts +1 -1
  43. package/dist/cjs/hooks/useSeries/prepare-waterfall.d.ts +1 -1
  44. package/dist/cjs/hooks/useSeries/prepareSeries.d.ts +1 -1
  45. package/dist/cjs/hooks/useShapes/area/index.d.ts +1 -1
  46. package/dist/cjs/hooks/useShapes/area/index.js +3 -1
  47. package/dist/cjs/hooks/useShapes/area/prepare-data.d.ts +0 -1
  48. package/dist/cjs/hooks/useShapes/area/prepare-data.js +61 -31
  49. package/dist/cjs/hooks/useShapes/bar-x/index.d.ts +1 -1
  50. package/dist/cjs/hooks/useShapes/bar-x/index.js +2 -1
  51. package/dist/cjs/hooks/useShapes/bar-x/prepare-data.js +4 -3
  52. package/dist/cjs/hooks/useShapes/bar-x/types.d.ts +5 -0
  53. package/dist/cjs/hooks/useShapes/bar-y/index.d.ts +1 -1
  54. package/dist/cjs/hooks/useShapes/bar-y/index.js +2 -1
  55. package/dist/cjs/hooks/useShapes/bar-y/prepare-data.js +1 -1
  56. package/dist/cjs/hooks/useShapes/funnel/index.d.ts +1 -1
  57. package/dist/cjs/hooks/useShapes/funnel/index.js +2 -1
  58. package/dist/cjs/hooks/useShapes/funnel/prepare-data.js +1 -1
  59. package/dist/cjs/hooks/useShapes/funnel/types.d.ts +1 -1
  60. package/dist/cjs/hooks/useShapes/heatmap/index.d.ts +1 -1
  61. package/dist/cjs/hooks/useShapes/heatmap/index.js +2 -1
  62. package/dist/cjs/hooks/useShapes/index.d.ts +1 -1
  63. package/dist/cjs/hooks/useShapes/index.js +1 -2
  64. package/dist/cjs/hooks/useShapes/line/index.d.ts +1 -1
  65. package/dist/cjs/hooks/useShapes/line/index.js +3 -1
  66. package/dist/cjs/hooks/useShapes/marker.d.ts +1 -1
  67. package/dist/cjs/hooks/useShapes/marker.js +1 -1
  68. package/dist/cjs/hooks/useShapes/pie/index.d.ts +2 -1
  69. package/dist/cjs/hooks/useShapes/pie/index.js +3 -1
  70. package/dist/cjs/hooks/useShapes/pie/prepare-data.js +2 -1
  71. package/dist/cjs/hooks/useShapes/pie/types.d.ts +1 -1
  72. package/dist/cjs/hooks/useShapes/pie/utils.d.ts +1 -1
  73. package/dist/cjs/hooks/useShapes/pie/utils.js +1 -1
  74. package/dist/cjs/hooks/useShapes/radar/index.d.ts +1 -1
  75. package/dist/cjs/hooks/useShapes/radar/index.js +3 -1
  76. package/dist/cjs/hooks/useShapes/radar/prepare-data.js +3 -1
  77. package/dist/cjs/hooks/useShapes/sankey/index.d.ts +1 -1
  78. package/dist/cjs/hooks/useShapes/sankey/index.js +1 -1
  79. package/dist/cjs/hooks/useShapes/scatter/index.d.ts +1 -1
  80. package/dist/cjs/hooks/useShapes/scatter/index.js +1 -1
  81. package/dist/cjs/hooks/useShapes/treemap/index.d.ts +1 -1
  82. package/dist/cjs/hooks/useShapes/treemap/index.js +2 -1
  83. package/dist/cjs/hooks/useShapes/treemap/prepare-data.js +2 -1
  84. package/dist/cjs/hooks/useShapes/treemap/types.d.ts +1 -1
  85. package/dist/cjs/hooks/useShapes/utils.d.ts +1 -1
  86. package/dist/cjs/hooks/useShapes/utils.js +2 -1
  87. package/dist/cjs/hooks/useShapes/waterfall/index.d.ts +1 -1
  88. package/dist/cjs/hooks/useShapes/waterfall/index.js +3 -1
  89. package/dist/cjs/hooks/useTooltip/index.d.ts +1 -1
  90. package/dist/cjs/hooks/useZoom/index.js +1 -1
  91. package/dist/cjs/hooks/useZoom/utils.d.ts +1 -1
  92. package/dist/cjs/hooks/utils/bar-y.js +1 -1
  93. package/dist/cjs/hooks/utils/get-band-size.d.ts +1 -1
  94. package/dist/cjs/types/chart/pie.d.ts +1 -1
  95. package/dist/cjs/types/chart/tooltip.d.ts +24 -1
  96. package/dist/cjs/utils/chart/axis/common.d.ts +2 -1
  97. package/dist/cjs/utils/chart/axis/common.js +1 -1
  98. package/dist/cjs/utils/chart/axis-generators/bottom.d.ts +2 -1
  99. package/dist/cjs/utils/chart/axis-generators/bottom.js +2 -1
  100. package/dist/cjs/utils/chart/color.js +2 -1
  101. package/dist/cjs/utils/chart/common.js +2 -1
  102. package/dist/cjs/utils/chart/format.d.ts +1 -1
  103. package/dist/cjs/utils/chart/get-closest-data.js +2 -1
  104. package/dist/cjs/utils/chart/legend.d.ts +1 -1
  105. package/dist/cjs/utils/chart/series/sorting.js +1 -1
  106. package/dist/cjs/utils/chart/symbol.js +1 -1
  107. package/dist/cjs/utils/chart/text.d.ts +1 -1
  108. package/dist/cjs/utils/chart/ticks/datetime.js +2 -1
  109. package/dist/cjs/utils/chart/ticks/index.d.ts +1 -1
  110. package/dist/cjs/utils/dispatcher.js +1 -1
  111. package/dist/esm/components/AxisX/AxisX.js +2 -1
  112. package/dist/esm/components/AxisY/AxisY.js +2 -1
  113. package/dist/esm/components/ChartInner/useChartInnerHandlers.d.ts +1 -1
  114. package/dist/esm/components/ChartInner/useChartInnerHandlers.js +1 -1
  115. package/dist/esm/components/ChartInner/useChartInnerProps.d.ts +1 -1
  116. package/dist/esm/components/ChartInner/useChartInnerState.d.ts +1 -1
  117. package/dist/esm/components/ChartInner/useDefaultState.d.ts +1 -1
  118. package/dist/esm/components/Legend/index.js +3 -1
  119. package/dist/esm/components/RangeSlider/utils.js +1 -1
  120. package/dist/esm/components/Tooltip/DefaultTooltipContent/Row.js +4 -4
  121. package/dist/esm/components/Tooltip/DefaultTooltipContent/RowWithAggregation.js +3 -2
  122. package/dist/esm/components/Tooltip/DefaultTooltipContent/index.js +128 -118
  123. package/dist/esm/components/Tooltip/index.d.ts +1 -1
  124. package/dist/esm/components/Tooltip/styles.css +33 -7
  125. package/dist/esm/components/index.d.ts +4 -1
  126. package/dist/esm/components/index.js +9 -4
  127. package/dist/esm/components/utils/index.js +1 -1
  128. package/dist/esm/hooks/useAxis/x-axis.js +5 -2
  129. package/dist/esm/hooks/useAxisScales/types.d.ts +1 -1
  130. package/dist/esm/hooks/useAxisScales/x-scale.js +2 -1
  131. package/dist/esm/hooks/useAxisScales/y-scale.js +2 -1
  132. package/dist/esm/hooks/useBrush/index.js +2 -1
  133. package/dist/esm/hooks/useBrush/types.d.ts +1 -1
  134. package/dist/esm/hooks/useBrush/utils.d.ts +1 -1
  135. package/dist/esm/hooks/useBrush/utils.js +2 -1
  136. package/dist/esm/hooks/useCrosshair/index.d.ts +1 -1
  137. package/dist/esm/hooks/useCrosshair/index.js +2 -1
  138. package/dist/esm/hooks/useCrosshair/useCrosshairHover.d.ts +1 -1
  139. package/dist/esm/hooks/useRangeSlider/index.js +1 -1
  140. package/dist/esm/hooks/useSeries/index.js +2 -1
  141. package/dist/esm/hooks/useSeries/prepare-area.d.ts +1 -1
  142. package/dist/esm/hooks/useSeries/prepare-bar-x.d.ts +1 -1
  143. package/dist/esm/hooks/useSeries/prepare-bar-y.d.ts +1 -1
  144. package/dist/esm/hooks/useSeries/prepare-funnel.js +1 -1
  145. package/dist/esm/hooks/useSeries/prepare-heatmap.d.ts +1 -1
  146. package/dist/esm/hooks/useSeries/prepare-line.d.ts +1 -1
  147. package/dist/esm/hooks/useSeries/prepare-pie.js +1 -1
  148. package/dist/esm/hooks/useSeries/prepare-radar.js +1 -1
  149. package/dist/esm/hooks/useSeries/prepare-sankey.d.ts +1 -1
  150. package/dist/esm/hooks/useSeries/prepare-scatter.d.ts +1 -1
  151. package/dist/esm/hooks/useSeries/prepare-treemap.d.ts +1 -1
  152. package/dist/esm/hooks/useSeries/prepare-waterfall.d.ts +1 -1
  153. package/dist/esm/hooks/useSeries/prepareSeries.d.ts +1 -1
  154. package/dist/esm/hooks/useShapes/area/index.d.ts +1 -1
  155. package/dist/esm/hooks/useShapes/area/index.js +3 -1
  156. package/dist/esm/hooks/useShapes/area/prepare-data.d.ts +0 -1
  157. package/dist/esm/hooks/useShapes/area/prepare-data.js +61 -31
  158. package/dist/esm/hooks/useShapes/bar-x/index.d.ts +1 -1
  159. package/dist/esm/hooks/useShapes/bar-x/index.js +2 -1
  160. package/dist/esm/hooks/useShapes/bar-x/prepare-data.js +4 -3
  161. package/dist/esm/hooks/useShapes/bar-x/types.d.ts +5 -0
  162. package/dist/esm/hooks/useShapes/bar-y/index.d.ts +1 -1
  163. package/dist/esm/hooks/useShapes/bar-y/index.js +2 -1
  164. package/dist/esm/hooks/useShapes/bar-y/prepare-data.js +1 -1
  165. package/dist/esm/hooks/useShapes/funnel/index.d.ts +1 -1
  166. package/dist/esm/hooks/useShapes/funnel/index.js +2 -1
  167. package/dist/esm/hooks/useShapes/funnel/prepare-data.js +1 -1
  168. package/dist/esm/hooks/useShapes/funnel/types.d.ts +1 -1
  169. package/dist/esm/hooks/useShapes/heatmap/index.d.ts +1 -1
  170. package/dist/esm/hooks/useShapes/heatmap/index.js +2 -1
  171. package/dist/esm/hooks/useShapes/index.d.ts +1 -1
  172. package/dist/esm/hooks/useShapes/index.js +1 -2
  173. package/dist/esm/hooks/useShapes/line/index.d.ts +1 -1
  174. package/dist/esm/hooks/useShapes/line/index.js +3 -1
  175. package/dist/esm/hooks/useShapes/marker.d.ts +1 -1
  176. package/dist/esm/hooks/useShapes/marker.js +1 -1
  177. package/dist/esm/hooks/useShapes/pie/index.d.ts +2 -1
  178. package/dist/esm/hooks/useShapes/pie/index.js +3 -1
  179. package/dist/esm/hooks/useShapes/pie/prepare-data.js +2 -1
  180. package/dist/esm/hooks/useShapes/pie/types.d.ts +1 -1
  181. package/dist/esm/hooks/useShapes/pie/utils.d.ts +1 -1
  182. package/dist/esm/hooks/useShapes/pie/utils.js +1 -1
  183. package/dist/esm/hooks/useShapes/radar/index.d.ts +1 -1
  184. package/dist/esm/hooks/useShapes/radar/index.js +3 -1
  185. package/dist/esm/hooks/useShapes/radar/prepare-data.js +3 -1
  186. package/dist/esm/hooks/useShapes/sankey/index.d.ts +1 -1
  187. package/dist/esm/hooks/useShapes/sankey/index.js +1 -1
  188. package/dist/esm/hooks/useShapes/scatter/index.d.ts +1 -1
  189. package/dist/esm/hooks/useShapes/scatter/index.js +1 -1
  190. package/dist/esm/hooks/useShapes/treemap/index.d.ts +1 -1
  191. package/dist/esm/hooks/useShapes/treemap/index.js +2 -1
  192. package/dist/esm/hooks/useShapes/treemap/prepare-data.js +2 -1
  193. package/dist/esm/hooks/useShapes/treemap/types.d.ts +1 -1
  194. package/dist/esm/hooks/useShapes/utils.d.ts +1 -1
  195. package/dist/esm/hooks/useShapes/utils.js +2 -1
  196. package/dist/esm/hooks/useShapes/waterfall/index.d.ts +1 -1
  197. package/dist/esm/hooks/useShapes/waterfall/index.js +3 -1
  198. package/dist/esm/hooks/useTooltip/index.d.ts +1 -1
  199. package/dist/esm/hooks/useZoom/index.js +1 -1
  200. package/dist/esm/hooks/useZoom/utils.d.ts +1 -1
  201. package/dist/esm/hooks/utils/bar-y.js +1 -1
  202. package/dist/esm/hooks/utils/get-band-size.d.ts +1 -1
  203. package/dist/esm/types/chart/pie.d.ts +1 -1
  204. package/dist/esm/types/chart/tooltip.d.ts +24 -1
  205. package/dist/esm/utils/chart/axis/common.d.ts +2 -1
  206. package/dist/esm/utils/chart/axis/common.js +1 -1
  207. package/dist/esm/utils/chart/axis-generators/bottom.d.ts +2 -1
  208. package/dist/esm/utils/chart/axis-generators/bottom.js +2 -1
  209. package/dist/esm/utils/chart/color.js +2 -1
  210. package/dist/esm/utils/chart/common.js +2 -1
  211. package/dist/esm/utils/chart/format.d.ts +1 -1
  212. package/dist/esm/utils/chart/get-closest-data.js +2 -1
  213. package/dist/esm/utils/chart/legend.d.ts +1 -1
  214. package/dist/esm/utils/chart/series/sorting.js +1 -1
  215. package/dist/esm/utils/chart/symbol.js +1 -1
  216. package/dist/esm/utils/chart/text.d.ts +1 -1
  217. package/dist/esm/utils/chart/ticks/datetime.js +2 -1
  218. package/dist/esm/utils/chart/ticks/index.d.ts +1 -1
  219. package/dist/esm/utils/dispatcher.js +1 -1
  220. package/package.json +15 -2
@@ -3,8 +3,12 @@
3
3
  background-color: var(--g-color-infographics-tooltip-bg);
4
4
  box-shadow: 0 2px 12px var(--g-color-sfx-shadow);
5
5
  }
6
+ tr.gcharts-tooltip__content-row {
7
+ display: table-row;
8
+ padding: 0;
9
+ }
10
+
6
11
  .gcharts-tooltip__popup-content {
7
- max-width: 450px;
8
12
  text-wrap: nowrap;
9
13
  border-radius: 4px;
10
14
  }
@@ -20,7 +24,13 @@
20
24
  .gcharts-tooltip__content-rows_pinned {
21
25
  overflow: auto;
22
26
  }
27
+ .gcharts-tooltip__content-rows-table {
28
+ width: 100%;
29
+ padding: 0;
30
+ border-collapse: collapse;
31
+ }
23
32
  .gcharts-tooltip__series-name {
33
+ max-width: 450px;
24
34
  padding: 2px 14px 6px;
25
35
  font-size: 13px;
26
36
  font-weight: 600;
@@ -45,8 +55,23 @@
45
55
  font-weight: 600;
46
56
  background-color: var(--g-color-base-info-medium);
47
57
  }
48
- .gcharts-tooltip__content-row-label {
58
+ .gcharts-tooltip__content-row_totals {
59
+ color: var(--g-color-text-complementary);
60
+ }
61
+ .gcharts-tooltip__content-row-totals-label {
49
62
  overflow: hidden;
63
+ max-width: 400px;
64
+ white-space: nowrap;
65
+ text-overflow: ellipsis;
66
+ }
67
+ .gcharts-tooltip__content-row-totals-value {
68
+ flex-shrink: 0;
69
+ margin-inline-start: auto;
70
+ }
71
+ .gcharts-tooltip__content-row-label-cell {
72
+ overflow: hidden;
73
+ max-width: 400px;
74
+ padding: 2px 4px;
50
75
  white-space: nowrap;
51
76
  text-overflow: ellipsis;
52
77
  }
@@ -58,12 +83,13 @@
58
83
  border-radius: 2px;
59
84
  background-color: #dddddd;
60
85
  }
61
- .gcharts-tooltip__content-row-value {
62
- flex-shrink: 0;
63
- margin-inline-start: auto;
86
+ .gcharts-tooltip__content-row-color-cell {
87
+ width: 16px;
88
+ padding: 2px 4px 2px 14px;
64
89
  }
65
- .gcharts-tooltip__content-row-totals {
66
- color: var(--g-color-text-complementary);
90
+ .gcharts-tooltip__content-row-value-cell {
91
+ padding: 2px 14px 2px 4px;
92
+ text-align: end;
67
93
  }
68
94
  .gcharts-tooltip__content-row-totals-divider {
69
95
  margin-block: 5px 5px;
@@ -1,8 +1,11 @@
1
1
  import React from 'react';
2
2
  import type { ChartData } from '../types';
3
3
  export * from './Tooltip/ChartTooltipContent';
4
+ export interface ChartReflowOptions {
5
+ immediate?: boolean;
6
+ }
4
7
  export interface ChartRef {
5
- reflow: () => void;
8
+ reflow: (options?: ChartReflowOptions) => void;
6
9
  }
7
10
  export interface ChartDimentions {
8
11
  height: number;
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { select } from 'd3';
2
+ import { select } from 'd3-selection';
3
3
  import debounce from 'lodash/debounce';
4
4
  import { i18nFactory } from '../i18n';
5
5
  import { getUniqId } from '../utils';
@@ -30,10 +30,15 @@ export const Chart = React.forwardRef(function Chart(props, forwardedRef) {
30
30
  return debounced.current;
31
31
  }, [handleResize]);
32
32
  React.useImperativeHandle(forwardedRef, () => ({
33
- reflow() {
34
- debuncedHandleResize();
33
+ reflow(options) {
34
+ if (options === null || options === void 0 ? void 0 : options.immediate) {
35
+ handleResize();
36
+ }
37
+ else {
38
+ debuncedHandleResize();
39
+ }
35
40
  },
36
- }), [debuncedHandleResize]);
41
+ }), [debuncedHandleResize, handleResize]);
37
42
  React.useEffect(() => {
38
43
  // dimensions initialize
39
44
  handleResize();
@@ -1,6 +1,6 @@
1
1
  import { duration } from '@gravity-ui/date-utils';
2
- import { line as lineGenerator } from 'd3';
3
2
  import { select } from 'd3-selection';
3
+ import { line as lineGenerator } from 'd3-shape';
4
4
  import { getLineDashArray, isTimeScale } from '../../utils';
5
5
  export function getInitialRangeSliderState(args) {
6
6
  const { defaultRange, xScale } = args;
@@ -1,6 +1,6 @@
1
1
  import get from 'lodash/get';
2
2
  import { DASH_STYLE, DEFAULT_AXIS_LABEL_FONT_SIZE, SERIES_TYPE, axisCrosshairDefaults, axisLabelsDefaults, axisTickMarksDefaults, xAxisTitleDefaults, } from '../../constants';
3
- import { TIME_UNITS, calculateCos, calculateNumericProperty, formatAxisTickLabel, getDefaultDateFormat, getHorizontalHtmlTextHeight, getHorizontalSvgTextHeight, getLabelsSize, getMinSpaceBetween, getTextSizeFn, isAxisRelatedSeries, wrapText, } from '../../utils';
3
+ import { TIME_UNITS, calculateCos, calculateNumericProperty, calculateSin, formatAxisTickLabel, getDefaultDateFormat, getHorizontalHtmlTextHeight, getHorizontalSvgTextHeight, getLabelsSize, getMinSpaceBetween, getTextSizeFn, isAxisRelatedSeries, wrapText, } from '../../utils';
4
4
  import { getXAxisTickValues } from '../../utils/chart/axis/x-axis';
5
5
  import { createXScale } from '../useAxisScales';
6
6
  import { getPreparedRangeSlider } from './range-slider';
@@ -49,7 +49,10 @@ async function setLabelSettings({ axis, seriesData, width, axisLabels, }) {
49
49
  html: axis.labels.html,
50
50
  })).maxHeight
51
51
  : axis.labels.lineHeight;
52
- const maxHeight = rotation ? calculateCos(rotation) * axis.labels.maxWidth : labelsHeight;
52
+ const maxHeight = rotation
53
+ ? Math.abs(calculateSin(rotation)) * axis.labels.maxWidth +
54
+ Math.abs(calculateCos(rotation)) * axis.labels.lineHeight
55
+ : labelsHeight;
53
56
  axis.labels.height = Math.min(maxHeight, labelsHeight);
54
57
  axis.labels.rotation = rotation;
55
58
  }
@@ -1,4 +1,4 @@
1
- import type { ScaleBand, ScaleLinear, ScaleTime } from 'd3';
1
+ import type { ScaleBand, ScaleLinear, ScaleTime } from 'd3-scale';
2
2
  type ChartScaleBand = ScaleBand<string>;
3
3
  export type ChartScaleLinear = ScaleLinear<number, number>;
4
4
  export type ChartScaleTime = ScaleTime<number, number>;
@@ -1,4 +1,5 @@
1
- import { extent, scaleBand, scaleLinear, scaleLog, scaleUtc } from 'd3';
1
+ import { extent } from 'd3-array';
2
+ import { scaleBand, scaleLinear, scaleLog, scaleUtc } from 'd3-scale';
2
3
  import get from 'lodash/get';
3
4
  import { DEFAULT_AXIS_TYPE, SERIES_TYPE } from '../../constants';
4
5
  import { getDefaultMaxXAxisValue, getDefaultMinXAxisValue, getDomainDataXBySeries, getEffectiveXRange, } from '../../utils';
@@ -1,4 +1,5 @@
1
- import { extent, scaleBand, scaleLinear, scaleLog, scaleUtc, tickStep, ticks } from 'd3';
1
+ import { extent, tickStep, ticks } from 'd3-array';
2
+ import { scaleBand, scaleLinear, scaleLog, scaleUtc } from 'd3-scale';
2
3
  import get from 'lodash/get';
3
4
  import { getTickValues } from '../../components/AxisY/utils';
4
5
  import { SERIES_TYPE } from '../../constants';
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
- import { brush, brushX, brushY, pointer, select } from 'd3';
2
+ import { brush, brushX, brushY } from 'd3-brush';
3
+ import { pointer, select } from 'd3-selection';
3
4
  import { block } from '../../utils';
4
5
  import { getDefaultSelection, getNormalizedSelection, setBrushBorder, setBrushHandles, } from './utils';
5
6
  import './styles.css';
@@ -1,4 +1,4 @@
1
- import type { BrushBehavior } from 'd3';
1
+ import type { BrushBehavior } from 'd3-brush';
2
2
  import type { ZoomType } from '../../constants';
3
3
  import type { ChartBrush, DeepRequired } from '../../types';
4
4
  export type BrushSelection = [number, number] | [[number, number], [number, number]];
@@ -1,4 +1,4 @@
1
- import type { BrushBehavior } from 'd3';
1
+ import type { BrushBehavior } from 'd3-brush';
2
2
  import type { ChartBrush, DeepRequired } from '../../types';
3
3
  import type { BrushSelection } from './types';
4
4
  export declare function isOneDimensionalSelection(selection?: BrushSelection | null): selection is [number, number];
@@ -1,4 +1,5 @@
1
- import { path, select } from 'd3';
1
+ import { path } from 'd3-path';
2
+ import { select } from 'd3-selection';
2
3
  import round from 'lodash/round';
3
4
  export function isOneDimensionalSelection(selection) {
4
5
  if (!Array.isArray(selection)) {
@@ -1,4 +1,4 @@
1
- import type { Dispatch } from 'd3';
1
+ import type { Dispatch } from 'd3-dispatch';
2
2
  import type { ChartScale, PreparedSplit, PreparedXAxis, PreparedYAxis } from '../../hooks';
3
3
  type Props = {
4
4
  xAxis: PreparedXAxis | null;
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
- import { line, select } from 'd3';
2
+ import { select } from 'd3-selection';
3
+ import { line } from 'd3-shape';
3
4
  import { getAxisPlotsPosition, getLineDashArray } from '../../utils';
4
5
  import { getXValue, getYValue } from '../useShapes/utils';
5
6
  import { useCrosshairHover } from './useCrosshairHover';
@@ -1,4 +1,4 @@
1
- import type { Dispatch } from 'd3';
1
+ import type { Dispatch } from 'd3-dispatch';
2
2
  import type { PointPosition, TooltipDataChunk } from '../../types';
3
3
  type Args = {
4
4
  dispatcher: Dispatch<object>;
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { pointer } from 'd3';
2
+ import { pointer } from 'd3-selection';
3
3
  import { isEqual } from 'lodash';
4
4
  import { SERIES_TYPE } from '../../constants';
5
5
  import { isBandScale } from '../../utils';
@@ -1,4 +1,5 @@
1
- import { group, scaleOrdinal } from 'd3';
1
+ import { group } from 'd3-array';
2
+ import { scaleOrdinal } from 'd3-scale';
2
3
  import { getSeriesNames } from '../../utils';
3
4
  import { prepareSeries } from './prepareSeries';
4
5
  export const getVisibleSeries = ({ preparedSeries, activeLegendItems, }) => {
@@ -1,4 +1,4 @@
1
- import type { ScaleOrdinal } from 'd3';
1
+ import type { ScaleOrdinal } from 'd3-scale';
2
2
  import type { AreaSeries, ChartSeriesOptions } from '../../types';
3
3
  import type { PreparedAreaSeries, PreparedLegend } from './types';
4
4
  export declare const DEFAULT_LINE_WIDTH = 1;
@@ -1,4 +1,4 @@
1
- import type { ScaleOrdinal } from 'd3';
1
+ import type { ScaleOrdinal } from 'd3-scale';
2
2
  import type { BarXSeries, ChartSeriesOptions } from '../../types';
3
3
  import type { PreparedLegend, PreparedSeries } from './types';
4
4
  type PrepareBarXSeriesArgs = {
@@ -1,4 +1,4 @@
1
- import type { ScaleOrdinal } from 'd3';
1
+ import type { ScaleOrdinal } from 'd3-scale';
2
2
  import type { BarYSeries, BarYSeriesData, ChartSeriesOptions } from '../../types';
3
3
  import type { PreparedLegend } from './types';
4
4
  type PrepareBarYSeriesArgs = {
@@ -1,4 +1,4 @@
1
- import { scaleOrdinal } from 'd3';
1
+ import { scaleOrdinal } from 'd3-scale';
2
2
  import get from 'lodash/get';
3
3
  import { DEFAULT_DATALABELS_STYLE } from '../../constants';
4
4
  import { getUniqId } from '../../utils';
@@ -1,4 +1,4 @@
1
- import type { ScaleOrdinal } from 'd3';
1
+ import type { ScaleOrdinal } from 'd3-scale';
2
2
  import type { ChartSeriesOptions, HeatmapSeries } from '../../types';
3
3
  import type { PreparedLegend, PreparedSeries } from './types';
4
4
  type PrepareHeatmapSeriesArgs = {
@@ -1,4 +1,4 @@
1
- import type { ScaleOrdinal } from 'd3';
1
+ import type { ScaleOrdinal } from 'd3-scale';
2
2
  import type { ChartSeriesOptions, LineSeries } from '../../types';
3
3
  import type { PreparedLegend, PreparedLineSeries } from './types';
4
4
  export declare const DEFAULT_LEGEND_SYMBOL_SIZE = 16;
@@ -1,4 +1,4 @@
1
- import { scaleOrdinal } from 'd3';
1
+ import { scaleOrdinal } from 'd3-scale';
2
2
  import get from 'lodash/get';
3
3
  import { DEFAULT_DATALABELS_STYLE } from '../../constants';
4
4
  import { getUniqId } from '../../utils';
@@ -1,4 +1,4 @@
1
- import { scaleOrdinal } from 'd3';
1
+ import { scaleOrdinal } from 'd3-scale';
2
2
  import get from 'lodash/get';
3
3
  import merge from 'lodash/merge';
4
4
  import { DEFAULT_DATALABELS_STYLE } from '../../constants';
@@ -1,4 +1,4 @@
1
- import type { ScaleOrdinal } from 'd3';
1
+ import type { ScaleOrdinal } from 'd3-scale';
2
2
  import type { ChartSeriesOptions, SankeySeries } from '../../types';
3
3
  import type { PreparedLegend, PreparedSankeySeries } from './types';
4
4
  type PrepareSankeySeriesArgs = {
@@ -1,4 +1,4 @@
1
- import type { ScaleOrdinal } from 'd3';
1
+ import type { ScaleOrdinal } from 'd3-scale';
2
2
  import type { ChartSeriesOptions, ScatterSeries } from '../../types';
3
3
  import type { PreparedLegend, PreparedScatterSeries } from './types';
4
4
  interface PrepareScatterSeriesArgs {
@@ -1,4 +1,4 @@
1
- import type { ScaleOrdinal } from 'd3';
1
+ import type { ScaleOrdinal } from 'd3-scale';
2
2
  import type { ChartSeriesOptions, TreemapSeries } from '../../types';
3
3
  import type { PreparedLegend, PreparedTreemapSeries } from './types';
4
4
  type PrepareTreemapSeriesArgs = {
@@ -1,4 +1,4 @@
1
- import type { ScaleOrdinal } from 'd3';
1
+ import type { ScaleOrdinal } from 'd3-scale';
2
2
  import type { WaterfallSeries } from '../../types';
3
3
  import type { PreparedLegend, PreparedSeries } from './types';
4
4
  type PrepareWaterfallSeriesArgs = {
@@ -1,4 +1,4 @@
1
- import type { ScaleOrdinal } from 'd3';
1
+ import type { ScaleOrdinal } from 'd3-scale';
2
2
  import type { ChartSeries, ChartSeriesOptions } from '../../types';
3
3
  import type { PreparedLegend, PreparedSeries } from './types';
4
4
  export declare function prepareSeries(args: {
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import type { Dispatch } from 'd3';
2
+ import type { Dispatch } from 'd3-dispatch';
3
3
  import type { PreparedSeriesOptions } from '../../useSeries/types';
4
4
  import type { PreparedAreaData } from './types';
5
5
  type Args = {
@@ -1,5 +1,7 @@
1
1
  import React from 'react';
2
- import { area as areaGenerator, color, line as lineGenerator, select } from 'd3';
2
+ import { color } from 'd3-color';
3
+ import { select } from 'd3-selection';
4
+ import { area as areaGenerator, line as lineGenerator } from 'd3-shape';
3
5
  import get from 'lodash/get';
4
6
  import { block, filterOverlappingLabels } from '../../../utils';
5
7
  import { HtmlLayer } from '../HtmlLayer';
@@ -9,7 +9,6 @@ export declare const prepareAreaData: (args: {
9
9
  xScale: ChartScale;
10
10
  yAxis: PreparedYAxis[];
11
11
  yScale: (ChartScale | undefined)[];
12
- boundsHeight: number;
13
12
  split: PreparedSplit;
14
13
  isOutsideBounds: (x: number, y: number) => boolean;
15
14
  isRangeSlider?: boolean;
@@ -1,4 +1,6 @@
1
- import { group } from 'd3';
1
+ import { group } from 'd3-array';
2
+ import isNil from 'lodash/isNil';
3
+ import round from 'lodash/round';
2
4
  import { getDataCategoryValue, getLabelsSize, getTextSizeFn } from '../../../utils';
3
5
  import { getFormattedValue } from '../../../utils/chart/format';
4
6
  import { getXValue, getYValue } from '../utils';
@@ -75,7 +77,7 @@ async function prepareDataLabels({ series, points, xMax, yAxisTop, isOutsideBoun
75
77
  }
76
78
  export const prepareAreaData = async (args) => {
77
79
  var _a, _b, _c;
78
- const { series, xAxis, xScale, yAxis, yScale, boundsHeight: plotHeight, split, isOutsideBounds, isRangeSlider, } = args;
80
+ const { series, xAxis, xScale, yAxis, yScale, split, isOutsideBounds, isRangeSlider } = args;
79
81
  const [_xMin, xRangeMax] = xScale.range();
80
82
  const xMax = xRangeMax;
81
83
  const result = [];
@@ -92,6 +94,38 @@ export const prepareAreaData = async (args) => {
92
94
  for (let i = 0; i < list.length; i++) {
93
95
  const [_stackId, seriesStack] = list[i];
94
96
  const xValues = getXValues(seriesStack, xAxis, xScale);
97
+ const isPercentStacking = seriesStack.some((s) => s.stacking === 'percent');
98
+ const stackValues = Object.fromEntries(xValues.map(([key]) => [key, 0]));
99
+ const ratio = Object.fromEntries(xValues.map(([key]) => [key, 1]));
100
+ if (isPercentStacking) {
101
+ seriesStack.forEach((s) => {
102
+ const yAxisIndex = s.yAxis;
103
+ const seriesYScale = yScale[yAxisIndex];
104
+ if (!seriesYScale) {
105
+ return;
106
+ }
107
+ s.data.forEach((d, index) => {
108
+ var _a, _b, _c;
109
+ const yDataValue = (_a = d.y) !== null && _a !== void 0 ? _a : null;
110
+ if (yDataValue &&
111
+ !(isNil((_b = s.data[index - 1]) === null || _b === void 0 ? void 0 : _b.y) && isNil((_c = s.data[index + 1]) === null || _c === void 0 ? void 0 : _c.y))) {
112
+ const x = String(xAxis.type === 'category'
113
+ ? getDataCategoryValue({
114
+ axisDirection: 'x',
115
+ categories: xAxis.categories || [],
116
+ data: d,
117
+ })
118
+ : d.x);
119
+ stackValues[x] += Number(yDataValue);
120
+ }
121
+ });
122
+ });
123
+ xValues.forEach(([x]) => {
124
+ if (stackValues[x]) {
125
+ ratio[x] = 100 / stackValues[x];
126
+ }
127
+ });
128
+ }
95
129
  const positiveStackValues = new Map();
96
130
  const negativeStackValues = new Map();
97
131
  xValues.forEach(([key]) => {
@@ -132,12 +166,22 @@ export const prepareAreaData = async (args) => {
132
166
  x,
133
167
  y: 0,
134
168
  };
135
- const yDataValue = (_b = d.y) !== null && _b !== void 0 ? _b : null;
169
+ let yDataValue = (_b = d.y) !== null && _b !== void 0 ? _b : null;
136
170
  if (s.nullMode === 'connect' && yDataValue === null) {
137
171
  return pointsAcc;
138
172
  }
139
- const yValue = getYValue({ point: d, yAxis: seriesYAxis, yScale: seriesYScale });
173
+ if (yDataValue && isPercentStacking) {
174
+ yDataValue = Number(yDataValue) * ratio[x];
175
+ }
176
+ let yValue = getYValue({
177
+ point: {
178
+ y: yDataValue,
179
+ },
180
+ yAxis: seriesYAxis,
181
+ yScale: seriesYScale,
182
+ });
140
183
  if (typeof yDataValue === 'number' && yValue !== null) {
184
+ yValue = round(yValue, 2);
141
185
  const prevPoint = seriesData.get((_c = xValues[index - 1]) === null || _c === void 0 ? void 0 : _c[0]);
142
186
  const nextPoint = seriesData.get((_d = xValues[index + 1]) === null || _d === void 0 ? void 0 : _d[0]);
143
187
  const currentPointStackHeight = Math.abs(yMin - yValue);
@@ -145,21 +189,30 @@ export const prepareAreaData = async (args) => {
145
189
  const positiveStackHeights = positiveStackValues.get(x);
146
190
  let prevSectionStackHeight = (_e = positiveStackHeights === null || positiveStackHeights === void 0 ? void 0 : positiveStackHeights.prev) !== null && _e !== void 0 ? _e : 0;
147
191
  let nextSectionStackHeight = (_f = positiveStackHeights === null || positiveStackHeights === void 0 ? void 0 : positiveStackHeights.next) !== null && _f !== void 0 ? _f : 0;
148
- pointsAcc.push({
192
+ const point = {
149
193
  y0: yAxisTop + yMin - prevSectionStackHeight,
150
194
  x: xValue,
151
195
  y: yAxisTop + yValue - prevSectionStackHeight,
152
196
  data: d,
153
197
  series: s,
154
- });
198
+ };
199
+ pointsAcc.push(point);
155
200
  if (prevSectionStackHeight !== nextSectionStackHeight) {
156
- pointsAcc.push({
201
+ const point2 = {
157
202
  y0: yAxisTop + yMin - nextSectionStackHeight,
158
203
  x: xValue,
159
204
  y: yAxisTop + yValue - nextSectionStackHeight,
160
205
  data: d,
161
206
  series: s,
162
- });
207
+ };
208
+ pointsAcc.push(point2);
209
+ if (isPercentStacking) {
210
+ const newYValue = yAxisTop +
211
+ yValue -
212
+ Math.max(prevSectionStackHeight, nextSectionStackHeight);
213
+ point.y = newYValue;
214
+ point2.y = newYValue;
215
+ }
163
216
  }
164
217
  if ((prevPoint === null || prevPoint === void 0 ? void 0 : prevPoint.y) !== null) {
165
218
  prevSectionStackHeight =
@@ -253,29 +306,6 @@ export const prepareAreaData = async (args) => {
253
306
  htmlElements: [],
254
307
  });
255
308
  }
256
- if (seriesStack.some((s) => s.stacking === 'percent')) {
257
- xValues.forEach(([x], index) => {
258
- var _a;
259
- const stackHeight = ((_a = positiveStackValues.get(x)) === null || _a === void 0 ? void 0 : _a.prev) || 0;
260
- let acc = 0;
261
- const ratio = plotHeight / stackHeight;
262
- seriesStackData.forEach((item) => {
263
- const point = item.points[index];
264
- if (point.y !== null && point.y !== undefined) {
265
- const height = (point.y0 - point.y) * ratio;
266
- const nextAcc = acc + height;
267
- point.y0 = plotHeight - acc;
268
- point.y = plotHeight - nextAcc;
269
- acc = nextAcc;
270
- }
271
- });
272
- });
273
- seriesStackData.forEach((item) => {
274
- item.markers.forEach((marker) => {
275
- marker.clipped = isOutsideBounds(marker.point.x, marker.point.y);
276
- });
277
- });
278
- }
279
309
  for (let itemIndex = 0; itemIndex < seriesStackData.length; itemIndex++) {
280
310
  const item = seriesStackData[itemIndex];
281
311
  const currentYAxis = yAxis[item.series.yAxis];
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import type { Dispatch } from 'd3';
2
+ import type { Dispatch } from 'd3-dispatch';
3
3
  import type { PreparedSeriesOptions } from '../../useSeries/types';
4
4
  import type { PreparedBarXData } from './types';
5
5
  export { prepareBarXData } from './prepare-data';
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
- import { color, select } from 'd3';
2
+ import { color } from 'd3-color';
3
+ import { select } from 'd3-selection';
3
4
  import get from 'lodash/get';
4
5
  import { block, filterOverlappingLabels } from '../../../utils';
5
6
  import { HtmlLayer } from '../HtmlLayer';
@@ -1,4 +1,4 @@
1
- import { ascending, descending, max, reverse, sort } from 'd3';
1
+ import { ascending, descending, max, reverse, sort } from 'd3-array';
2
2
  import get from 'lodash/get';
3
3
  import { getDataCategoryValue, getLabelsSize } from '../../../utils';
4
4
  import { getFormattedValue } from '../../../utils/chart/format';
@@ -162,6 +162,7 @@ export const prepareBarXData = async (args) => {
162
162
  : yAxisTop + base + negativeStackHeight,
163
163
  width: rectWidth,
164
164
  height: shapeHeight,
165
+ _height: height,
165
166
  opacity: get(yValue.data, 'opacity', null),
166
167
  data: yValue.data,
167
168
  series: yValue.series,
@@ -178,9 +179,9 @@ export const prepareBarXData = async (args) => {
178
179
  }
179
180
  if (series.some((s) => s.stacking === 'percent')) {
180
181
  let acc = 0;
181
- const ratio = plotHeight / (positiveStackHeight - (stackItems.length - 1) * stackGap);
182
+ const ratio = plotHeight / positiveStackHeight;
182
183
  stackItems.forEach((item) => {
183
- item.height = item.height * ratio;
184
+ item.height = item._height * ratio;
184
185
  item.y = plotHeight - item.height - acc;
185
186
  acc += item.height + 1;
186
187
  });
@@ -10,4 +10,9 @@ export type PreparedBarXData = Omit<TooltipDataChunkBarX, 'series'> & {
10
10
  label?: LabelData;
11
11
  htmlElements: HtmlItem[];
12
12
  isLastStackItem: boolean;
13
+ /**
14
+ * the utility field for storing the original height (for recalculations, etc.)
15
+ * should not be used for displaying
16
+ */
17
+ _height: number;
13
18
  };
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import type { Dispatch } from 'd3';
2
+ import type { Dispatch } from 'd3-dispatch';
3
3
  import type { PreparedSeriesOptions } from '../../useSeries/types';
4
4
  import type { BarYShapesArgs } from './types';
5
5
  export { prepareBarYData } from './prepare-data';
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
- import { color, select } from 'd3';
2
+ import { color } from 'd3-color';
3
+ import { select } from 'd3-selection';
3
4
  import get from 'lodash/get';
4
5
  import { block } from '../../../utils';
5
6
  import { HtmlLayer } from '../HtmlLayer';
@@ -1,4 +1,4 @@
1
- import { ascending, descending, sort } from 'd3';
1
+ import { ascending, descending, sort } from 'd3-array';
2
2
  import get from 'lodash/get';
3
3
  import { filterOverlappingLabels, getHtmlLabelConstraintedPosition, getLabelsSize, getSvgLabelConstraintedPosition, getTextSizeFn, } from '../../../utils';
4
4
  import { getFormattedValue } from '../../../utils/chart/format';
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import type { Dispatch } from 'd3';
2
+ import type { Dispatch } from 'd3-dispatch';
3
3
  import type { PreparedSeriesOptions } from '../../useSeries/types';
4
4
  import type { PreparedFunnelData } from './types';
5
5
  export { prepareFunnelData } from './prepare-data';
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
- import { color, select } from 'd3';
2
+ import { color } from 'd3-color';
3
+ import { select } from 'd3-selection';
3
4
  import { block, getLineDashArray } from '../../../utils';
4
5
  export { prepareFunnelData } from './prepare-data';
5
6
  export * from './types';
@@ -1,4 +1,4 @@
1
- import { path } from 'd3';
1
+ import { path } from 'd3-path';
2
2
  import { calculateNumericProperty, getFormattedValue, getTextSizeFn } from '../../../utils';
3
3
  function getLineConnectorPaths(args) {
4
4
  const { points } = args;
@@ -1,4 +1,4 @@
1
- import type { Path } from 'd3';
1
+ import type { Path } from 'd3-path';
2
2
  import type { DashStyle } from 'src/constants';
3
3
  import type { FunnelSeriesData, LabelData } from '../../../types';
4
4
  import type { PreparedFunnelSeries } from '../../useSeries/types';
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import type { Dispatch } from 'd3';
2
+ import type { Dispatch } from 'd3-dispatch';
3
3
  import type { PreparedSeriesOptions } from '../../useSeries/types';
4
4
  import type { PreparedHeatmapData } from './types';
5
5
  export { prepareHeatmapData } from './prepare-data';
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
- import { color, select } from 'd3';
2
+ import { color } from 'd3-color';
3
+ import { select } from 'd3-selection';
3
4
  import { block } from '../../../utils';
4
5
  import { HtmlLayer } from '../HtmlLayer';
5
6
  export { prepareHeatmapData } from './prepare-data';