@gravity-ui/charts 1.51.0 → 1.51.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 (55) hide show
  1. package/dist/cjs/components/AxisY/utils.js +16 -4
  2. package/dist/cjs/core/shapes/area/types.d.ts +3 -3
  3. package/dist/cjs/core/shapes/bar-x/types.d.ts +3 -3
  4. package/dist/cjs/core/shapes/bar-y/prepare-data.js +6 -6
  5. package/dist/cjs/core/shapes/bar-y/types.d.ts +3 -3
  6. package/dist/cjs/core/shapes/funnel/types.d.ts +3 -3
  7. package/dist/cjs/core/shapes/heatmap/prepare-data.js +1 -1
  8. package/dist/cjs/core/shapes/heatmap/types.d.ts +3 -3
  9. package/dist/cjs/core/shapes/line/types.d.ts +3 -3
  10. package/dist/cjs/core/shapes/pie/types.d.ts +3 -3
  11. package/dist/cjs/core/shapes/radar/types.d.ts +3 -3
  12. package/dist/cjs/core/shapes/sankey/prepare-data.js +2 -2
  13. package/dist/cjs/core/shapes/sankey/types.d.ts +3 -3
  14. package/dist/cjs/core/shapes/scatter/types.d.ts +2 -2
  15. package/dist/cjs/core/shapes/treemap/prepare-data.js +3 -3
  16. package/dist/cjs/core/shapes/treemap/types.d.ts +3 -3
  17. package/dist/cjs/core/shapes/types.d.ts +4 -0
  18. package/dist/cjs/core/shapes/types.js +1 -0
  19. package/dist/cjs/core/shapes/waterfall/prepare-data.js +1 -1
  20. package/dist/cjs/core/shapes/waterfall/types.d.ts +3 -3
  21. package/dist/cjs/core/shapes/x-range/types.d.ts +3 -3
  22. package/dist/cjs/core/utils/axis/x-axis.js +16 -4
  23. package/dist/cjs/hooks/useShapes/bar-y/index.js +1 -1
  24. package/dist/cjs/hooks/useShapes/heatmap/index.js +1 -1
  25. package/dist/cjs/hooks/useShapes/sankey/index.js +1 -1
  26. package/dist/cjs/hooks/useShapes/treemap/index.js +1 -1
  27. package/dist/cjs/hooks/useShapes/waterfall/index.js +1 -1
  28. package/dist/esm/components/AxisY/utils.js +16 -4
  29. package/dist/esm/core/shapes/area/types.d.ts +3 -3
  30. package/dist/esm/core/shapes/bar-x/types.d.ts +3 -3
  31. package/dist/esm/core/shapes/bar-y/prepare-data.js +6 -6
  32. package/dist/esm/core/shapes/bar-y/types.d.ts +3 -3
  33. package/dist/esm/core/shapes/funnel/types.d.ts +3 -3
  34. package/dist/esm/core/shapes/heatmap/prepare-data.js +1 -1
  35. package/dist/esm/core/shapes/heatmap/types.d.ts +3 -3
  36. package/dist/esm/core/shapes/line/types.d.ts +3 -3
  37. package/dist/esm/core/shapes/pie/types.d.ts +3 -3
  38. package/dist/esm/core/shapes/radar/types.d.ts +3 -3
  39. package/dist/esm/core/shapes/sankey/prepare-data.js +2 -2
  40. package/dist/esm/core/shapes/sankey/types.d.ts +3 -3
  41. package/dist/esm/core/shapes/scatter/types.d.ts +2 -2
  42. package/dist/esm/core/shapes/treemap/prepare-data.js +3 -3
  43. package/dist/esm/core/shapes/treemap/types.d.ts +3 -3
  44. package/dist/esm/core/shapes/types.d.ts +4 -0
  45. package/dist/esm/core/shapes/types.js +1 -0
  46. package/dist/esm/core/shapes/waterfall/prepare-data.js +1 -1
  47. package/dist/esm/core/shapes/waterfall/types.d.ts +3 -3
  48. package/dist/esm/core/shapes/x-range/types.d.ts +3 -3
  49. package/dist/esm/core/utils/axis/x-axis.js +16 -4
  50. package/dist/esm/hooks/useShapes/bar-y/index.js +1 -1
  51. package/dist/esm/hooks/useShapes/heatmap/index.js +1 -1
  52. package/dist/esm/hooks/useShapes/sankey/index.js +1 -1
  53. package/dist/esm/hooks/useShapes/treemap/index.js +1 -1
  54. package/dist/esm/hooks/useShapes/waterfall/index.js +1 -1
  55. package/package.json +1 -1
@@ -31,8 +31,13 @@ export function getTickValues({ scale, axis, labelLineHeight, series, }) {
31
31
  let result = originalTickValues;
32
32
  let availableSpaceForLabel = getMinSpaceBetween(result, (d) => d.y) - axis.labels.padding * 2;
33
33
  let ticksCount = result.length - 1;
34
+ let lastMultiTickResult = result;
35
+ const triedCounts = new Set();
34
36
  while (availableSpaceForLabel < labelLineHeight && result.length > 1) {
35
37
  ticksCount = ticksCount ? ticksCount - 1 : result.length - 1;
38
+ if (triedCounts.has(ticksCount))
39
+ break;
40
+ triedCounts.add(ticksCount);
36
41
  const newScaleTicks = scale.ticks(ticksCount);
37
42
  result = newScaleTicks.map((t) => ({
38
43
  y: scale(t),
@@ -40,16 +45,23 @@ export function getTickValues({ scale, axis, labelLineHeight, series, }) {
40
45
  }));
41
46
  availableSpaceForLabel =
42
47
  getMinSpaceBetween(result, (d) => d.y) - axis.labels.padding * 2;
48
+ if (result.length > 1) {
49
+ lastMultiTickResult = result;
50
+ }
43
51
  }
44
52
  // when this is not possible (for example, such values cannot be selected for the logarithmic axis with a small range)
45
- // just thin out the originally proposed result
46
- if (!result.length) {
47
- result = originalTickValues;
53
+ // just thin out the last result that had multiple ticks
54
+ // For log scales, 1 tick is also a failure: d3 only places ticks at powers of the base,
55
+ // so a sub-decade range legitimately yields 1 tick despite having room for more.
56
+ // For linear scales, 1 tick is a valid result meaning the chart is simply too small.
57
+ const isLogScale = axis.type === 'logarithmic';
58
+ if ((isLogScale ? result.length <= 1 : !result.length) && lastMultiTickResult.length > 1) {
59
+ result = lastMultiTickResult;
48
60
  availableSpaceForLabel =
49
61
  getMinSpaceBetween(result, (d) => d.y) - axis.labels.padding * 2;
50
62
  let delta = 2;
51
63
  while (availableSpaceForLabel < labelLineHeight && result.length > 1) {
52
- result = thinOut(result, delta);
64
+ result = thinOut(lastMultiTickResult, delta);
53
65
  if (result.length > 1) {
54
66
  delta += 1;
55
67
  availableSpaceForLabel =
@@ -1,5 +1,6 @@
1
- import type { AreaSeriesData, HtmlItem, LabelData } from '../../../types';
1
+ import type { AreaSeriesData, LabelData } from '../../../types';
2
2
  import type { AnnotationAnchor, PreparedAnnotation, PreparedAreaSeries } from '../../series/types';
3
+ import type { SeriesShapeData } from '../types';
3
4
  export type PointData = {
4
5
  annotation?: PreparedAnnotation;
5
6
  color?: string;
@@ -31,5 +32,4 @@ export type PreparedAreaData = {
31
32
  hovered: boolean;
32
33
  active: boolean;
33
34
  svgLabels: LabelData[];
34
- htmlLabels: HtmlItem[];
35
- };
35
+ } & SeriesShapeData;
@@ -1,5 +1,6 @@
1
- import type { HtmlItem, LabelData, TooltipDataChunkBarX } from '../../../types';
1
+ import type { LabelData, TooltipDataChunkBarX } from '../../../types';
2
2
  import type { PreparedAnnotation, PreparedBarXSeries } from '../../series/types';
3
+ import type { SeriesShapeData } from '../types';
3
4
  export type PreparedBarXData = Omit<TooltipDataChunkBarX, 'series'> & {
4
5
  annotation?: PreparedAnnotation;
5
6
  x: number;
@@ -9,11 +10,10 @@ export type PreparedBarXData = Omit<TooltipDataChunkBarX, 'series'> & {
9
10
  opacity: number | null;
10
11
  series: PreparedBarXSeries;
11
12
  svgLabels: LabelData[];
12
- htmlLabels: HtmlItem[];
13
13
  isLastStackItem: boolean;
14
14
  /**
15
15
  * the utility field for storing the original height (for recalculations, etc.)
16
16
  * should not be used for displaying
17
17
  */
18
18
  _height: number;
19
- };
19
+ } & SeriesShapeData;
@@ -13,7 +13,7 @@ export async function prepareBarYData(args) {
13
13
  return {
14
14
  shapes: [],
15
15
  labels: [],
16
- htmlElements: [],
16
+ htmlLabels: [],
17
17
  };
18
18
  }
19
19
  const sortingOptions = get(seriesOptions, 'bar-y.dataSorting');
@@ -134,7 +134,7 @@ export async function prepareBarYData(args) {
134
134
  });
135
135
  });
136
136
  let labels = [];
137
- let htmlElements = [];
137
+ let htmlLabels = [];
138
138
  const map = new Map();
139
139
  for (let i = 0; i < result.length; i++) {
140
140
  const prepared = result[i];
@@ -160,7 +160,7 @@ export async function prepareBarYData(args) {
160
160
  x,
161
161
  y: y - height / 2,
162
162
  });
163
- htmlElements.push({
163
+ htmlLabels.push({
164
164
  content,
165
165
  size: { width, height },
166
166
  style: dataLabels.style,
@@ -202,12 +202,12 @@ export async function prepareBarYData(args) {
202
202
  if (labels.length && !allowOverlap) {
203
203
  labels = filterOverlappingLabels(labels);
204
204
  }
205
- else if (htmlElements.length && !allowOverlap) {
206
- htmlElements = filterOverlappingLabels(htmlElements);
205
+ else if (htmlLabels.length && !allowOverlap) {
206
+ htmlLabels = filterOverlappingLabels(htmlLabels);
207
207
  }
208
208
  return {
209
209
  shapes: result,
210
210
  labels,
211
- htmlElements,
211
+ htmlLabels,
212
212
  };
213
213
  }
@@ -1,5 +1,6 @@
1
- import type { HtmlItem, LabelData, TooltipDataChunkBarY } from '../../../types';
1
+ import type { LabelData, TooltipDataChunkBarY } from '../../../types';
2
2
  import type { PreparedBarYSeries } from '../../series/types';
3
+ import type { SeriesShapeData } from '../types';
3
4
  export type PreparedBarYData = Omit<TooltipDataChunkBarY, 'series'> & {
4
5
  x: number;
5
6
  y: number;
@@ -15,5 +16,4 @@ export type PreparedBarYData = Omit<TooltipDataChunkBarY, 'series'> & {
15
16
  export type BarYShapesArgs = {
16
17
  shapes: PreparedBarYData[];
17
18
  labels: LabelData[];
18
- htmlElements: HtmlItem[];
19
- };
19
+ } & SeriesShapeData;
@@ -1,7 +1,8 @@
1
1
  import type { Path } from 'd3-path';
2
- import type { FunnelSeriesData, HtmlItem, LabelData } from '../../../types';
2
+ import type { FunnelSeriesData, LabelData } from '../../../types';
3
3
  import type { DashStyle } from '../../constants';
4
4
  import type { PreparedFunnelSeries } from '../../series/types';
5
+ import type { SeriesShapeData } from '../types';
5
6
  export type FunnelItemData = {
6
7
  x: number;
7
8
  y: number;
@@ -30,5 +31,4 @@ export type PreparedFunnelData = {
30
31
  items: FunnelItemData[];
31
32
  connectors: FunnelConnectorData[];
32
33
  svgLabels: LabelData[];
33
- htmlLabels: HtmlItem[];
34
- };
34
+ } & SeriesShapeData;
@@ -94,7 +94,7 @@ export async function prepareHeatmapData({ series, xAxis, xScale, yAxis, yScale,
94
94
  }
95
95
  const preparedData = {
96
96
  series: series,
97
- htmlElements: htmlDataLabels,
97
+ htmlLabels: htmlDataLabels,
98
98
  items: heatmapItems,
99
99
  labels: svgDataLabels,
100
100
  };
@@ -1,5 +1,6 @@
1
- import type { BaseTextStyle, HeatmapSeriesData, HtmlItem } from '../../../types';
1
+ import type { BaseTextStyle, HeatmapSeriesData } from '../../../types';
2
2
  import type { PreparedHeatmapSeries } from '../../series/types';
3
+ import type { SeriesShapeData } from '../types';
3
4
  export type HeatmapItem = {
4
5
  x: number;
5
6
  y: number;
@@ -20,6 +21,5 @@ export type HeatmapLabel = {
20
21
  export type PreparedHeatmapData = {
21
22
  series: PreparedHeatmapSeries;
22
23
  items: HeatmapItem[];
23
- htmlElements: HtmlItem[];
24
24
  labels: HeatmapLabel[];
25
- };
25
+ } & SeriesShapeData;
@@ -1,6 +1,7 @@
1
- import type { HtmlItem, LabelData, LineSeriesData, LineSeriesLineBaseStyle } from '../../../types';
1
+ import type { LabelData, LineSeriesData, LineSeriesLineBaseStyle } from '../../../types';
2
2
  import type { DashStyle, LineCap, LineJoin } from '../../constants';
3
3
  import type { AnnotationAnchor, PreparedAnnotation, PreparedLineSeries } from '../../series/types';
4
+ import type { SeriesShapeData } from '../types';
4
5
  export type PointData = {
5
6
  annotation?: PreparedAnnotation;
6
7
  color?: string;
@@ -29,9 +30,8 @@ export type PreparedLineData = {
29
30
  hovered: boolean;
30
31
  active: boolean;
31
32
  svgLabels: LabelData[];
32
- htmlLabels: HtmlItem[];
33
33
  color: string;
34
34
  dashStyle: DashStyle;
35
35
  linecap: LineCap;
36
36
  linejoin: LineJoin;
37
- } & Required<LineSeriesLineBaseStyle>;
37
+ } & Required<LineSeriesLineBaseStyle> & SeriesShapeData;
@@ -1,6 +1,7 @@
1
1
  import type { PieArcDatum } from 'd3-shape';
2
- import type { ConnectorCurve, HtmlItem, LabelData } from '../../../types';
2
+ import type { ConnectorCurve, LabelData } from '../../../types';
3
3
  import type { PreparedPieSeries } from '../../series/types';
4
+ import type { SeriesShapeData } from '../types';
4
5
  export type SegmentData = {
5
6
  value: number;
6
7
  color: string;
@@ -37,5 +38,4 @@ export type PreparedPieData = {
37
38
  opacity: number;
38
39
  size: number;
39
40
  };
40
- htmlLabels: HtmlItem[];
41
- };
41
+ } & SeriesShapeData;
@@ -1,5 +1,6 @@
1
- import type { HtmlItem, LabelData, RadarSeriesData } from '../../../types';
1
+ import type { LabelData, RadarSeriesData } from '../../../types';
2
2
  import type { PreparedRadarSeries } from '../../series/types';
3
+ import type { SeriesShapeData } from '../types';
3
4
  export type RadarLabelData = LabelData & {
4
5
  maxWidth: number;
5
6
  };
@@ -54,6 +55,5 @@ export type PreparedRadarData = {
54
55
  grid: RadarGridData[];
55
56
  center: [number, number];
56
57
  radius: number;
57
- htmlLabels: HtmlItem[];
58
58
  cursor: string | null;
59
- };
59
+ } & SeriesShapeData;
@@ -2,7 +2,7 @@ import { getFormattedValue } from '../../utils/format';
2
2
  import { sankey, sankeyLinkHorizontal } from './sankey-layout';
3
3
  export function prepareSankeyData(args) {
4
4
  const { series, width, height } = args;
5
- const htmlElements = [];
5
+ const htmlLabels = [];
6
6
  const sankeyGenerator = sankey()
7
7
  .nodeId((d) => d.name)
8
8
  .nodeSort((a, b) => { var _a, _b; return ((_a = a.index) !== null && _a !== void 0 ? _a : 0) - ((_b = b.index) !== null && _b !== void 0 ? _b : 0); })
@@ -70,5 +70,5 @@ export function prepareSankeyData(args) {
70
70
  });
71
71
  dataLabels.push(...labels);
72
72
  }
73
- return { series, nodes: sankeyNodes, links: sankeyLinks, htmlElements, labels: dataLabels };
73
+ return { series, nodes: sankeyNodes, links: sankeyLinks, htmlLabels, labels: dataLabels };
74
74
  }
@@ -1,5 +1,6 @@
1
- import type { BaseTextStyle, HtmlItem, SankeySeriesData } from '../../../types';
1
+ import type { BaseTextStyle, SankeySeriesData } from '../../../types';
2
2
  import type { PreparedSankeySeries } from '../../series/types';
3
+ import type { SeriesShapeData } from '../types';
3
4
  export type SankeyDataLabel = {
4
5
  text: string;
5
6
  x: number;
@@ -26,8 +27,7 @@ export type SankeyLink = {
26
27
  };
27
28
  export type PreparedSankeyData = {
28
29
  series: PreparedSankeySeries;
29
- htmlElements: HtmlItem[];
30
30
  nodes: SankeyNode[];
31
31
  links: SankeyLink[];
32
32
  labels: SankeyDataLabel[];
33
- };
33
+ } & SeriesShapeData;
@@ -1,5 +1,6 @@
1
1
  import type { HtmlItem, LabelData, ScatterSeriesData } from '../../../types';
2
2
  import type { PreparedScatterSeries } from '../../series/types';
3
+ import type { SeriesShapeData } from '../types';
3
4
  type PointData = {
4
5
  x: number;
5
6
  y: number;
@@ -19,6 +20,5 @@ export type PreparedScatterData = MarkerData;
19
20
  export type PreparedScatterShapeData = {
20
21
  markers: PreparedScatterData[];
21
22
  svgLabels: LabelData[];
22
- htmlLabels: HtmlItem[];
23
- };
23
+ } & SeriesShapeData;
24
24
  export {};
@@ -148,17 +148,17 @@ export async function prepareTreemapData(args) {
148
148
  })(hierarchy);
149
149
  const leaves = root.leaves();
150
150
  let labelData = [];
151
- const htmlElements = [];
151
+ const htmlLabels = [];
152
152
  if ((_a = series.dataLabels) === null || _a === void 0 ? void 0 : _a.enabled) {
153
153
  const { html, style: dataLabelsStyle } = series.dataLabels;
154
154
  const labels = await getLabels({ data: leaves, options: series.dataLabels });
155
155
  if (html) {
156
156
  const htmlItems = labels.map((l) => (Object.assign({ style: Object.assign(Object.assign({}, dataLabelsStyle), { maxWidth: l.size.width, maxHeight: l.size.height, overflow: 'hidden' }) }, l)));
157
- htmlElements.push(...htmlItems);
157
+ htmlLabels.push(...htmlItems);
158
158
  }
159
159
  else {
160
160
  labelData = labels;
161
161
  }
162
162
  }
163
- return { labelData, leaves, series, htmlElements };
163
+ return { labelData, leaves, series, htmlLabels };
164
164
  }
@@ -1,6 +1,7 @@
1
1
  import type { HierarchyRectangularNode } from 'd3-hierarchy';
2
- import type { HtmlItem, TreemapSeriesData } from '../../../types';
2
+ import type { TreemapSeriesData } from '../../../types';
3
3
  import type { PreparedTreemapSeries } from '../../series/types';
4
+ import type { SeriesShapeData } from '../types';
4
5
  export type TreemapLabelData = {
5
6
  text: string;
6
7
  x: number;
@@ -11,5 +12,4 @@ export type PreparedTreemapData = {
11
12
  labelData: TreemapLabelData[];
12
13
  leaves: HierarchyRectangularNode<TreemapSeriesData<any>>[];
13
14
  series: PreparedTreemapSeries;
14
- htmlElements: HtmlItem[];
15
- };
15
+ } & SeriesShapeData;
@@ -0,0 +1,4 @@
1
+ import type { HtmlItem } from '../../types';
2
+ export interface SeriesShapeData {
3
+ htmlLabels: HtmlItem[];
4
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -144,7 +144,7 @@ export const prepareWaterfallData = async (args) => {
144
144
  data: item.data,
145
145
  series: item.series,
146
146
  subTotal: totalValue,
147
- htmlElements: [],
147
+ htmlLabels: [],
148
148
  };
149
149
  preparedData.label = await getLabelData(preparedData, plotHeight);
150
150
  result.push(preparedData);
@@ -1,5 +1,6 @@
1
- import type { HtmlItem, LabelData, WaterfallSeriesData } from '../../../types';
1
+ import type { LabelData, WaterfallSeriesData } from '../../../types';
2
2
  import type { PreparedWaterfallSeries } from '../../series/types';
3
+ import type { SeriesShapeData } from '../types';
3
4
  export type PreparedWaterfallData = {
4
5
  x: number;
5
6
  y: number;
@@ -10,5 +11,4 @@ export type PreparedWaterfallData = {
10
11
  data: WaterfallSeriesData;
11
12
  label?: LabelData;
12
13
  subTotal: number;
13
- htmlElements: HtmlItem[];
14
- };
14
+ } & SeriesShapeData;
@@ -1,5 +1,6 @@
1
- import type { HtmlItem, LabelData, TooltipDataChunkXRange } from '../../../types';
1
+ import type { LabelData, TooltipDataChunkXRange } from '../../../types';
2
2
  import type { PreparedXRangeSeries } from '../../series/types';
3
+ import type { SeriesShapeData } from '../types';
3
4
  export type PreparedXRangeData = Omit<TooltipDataChunkXRange, 'series'> & {
4
5
  x: number;
5
6
  y: number;
@@ -8,5 +9,4 @@ export type PreparedXRangeData = Omit<TooltipDataChunkXRange, 'series'> & {
8
9
  color: string;
9
10
  series: PreparedXRangeSeries;
10
11
  svgLabels: LabelData[];
11
- htmlLabels: HtmlItem[];
12
- };
12
+ } & SeriesShapeData;
@@ -55,8 +55,13 @@ export function getXAxisTickValues({ axis, labelLineHeight, scale, series, }) {
55
55
  let result = originalTickValues;
56
56
  let availableSpaceForLabel = getMinSpaceBetween(result, (d) => d.x) - axis.labels.padding * 2;
57
57
  let ticksCount = result.length - 1;
58
+ let lastMultiTickResult = result;
59
+ const triedCounts = new Set();
58
60
  while (availableSpaceForLabel < labelLineHeight && result.length > 1) {
59
61
  ticksCount = ticksCount ? ticksCount - 1 : result.length - 1;
62
+ if (triedCounts.has(ticksCount))
63
+ break;
64
+ triedCounts.add(ticksCount);
60
65
  const newScaleTicks = getScaleTicks({ scale, ticksCount, dateTimeLabelFormats });
61
66
  result = newScaleTicks.map((t) => ({
62
67
  x: scale(t),
@@ -64,16 +69,23 @@ export function getXAxisTickValues({ axis, labelLineHeight, scale, series, }) {
64
69
  }));
65
70
  availableSpaceForLabel =
66
71
  getMinSpaceBetween(result, (d) => d.x) - axis.labels.padding * 2;
72
+ if (result.length > 1) {
73
+ lastMultiTickResult = result;
74
+ }
67
75
  }
68
76
  // when this is not possible (for example, such values cannot be selected for the logarithmic axis with a small range)
69
- // just thin out the originally proposed result
70
- if (!result.length) {
71
- result = originalTickValues;
77
+ // just thin out the last result that had multiple ticks
78
+ // For log scales, 1 tick is also a failure: d3 only places ticks at powers of the base,
79
+ // so a sub-decade range legitimately yields 1 tick despite having room for more.
80
+ // For linear scales, 1 tick is a valid result meaning the chart is simply too small.
81
+ const isLogScale = axis.type === 'logarithmic';
82
+ if ((isLogScale ? result.length <= 1 : !result.length) && lastMultiTickResult.length > 1) {
83
+ result = lastMultiTickResult;
72
84
  availableSpaceForLabel =
73
85
  getMinSpaceBetween(result, (d) => d.x) - axis.labels.padding * 2;
74
86
  let delta = 2;
75
87
  while (availableSpaceForLabel < labelLineHeight && result.length > 1) {
76
- result = thinOut(result, delta);
88
+ result = thinOut(lastMultiTickResult, delta);
77
89
  if (result.length > 1) {
78
90
  delta += 1;
79
91
  availableSpaceForLabel =
@@ -5,7 +5,7 @@ import { HtmlLayer } from '../HtmlLayer';
5
5
  export { prepareBarYData } from '../../../core/shapes/bar-y/prepare-data';
6
6
  const b = block('bar-y');
7
7
  export function BarYSeriesShapes(args) {
8
- const { dispatcher, preparedData: { htmlElements }, seriesOptions, htmlLayout, clipPathId, } = args;
8
+ const { dispatcher, preparedData: { htmlLabels: htmlElements }, seriesOptions, htmlLayout, clipPathId, } = args;
9
9
  const ref = React.useRef(null);
10
10
  React.useEffect(() => {
11
11
  if (!ref.current) {
@@ -16,5 +16,5 @@ export const HeatmapSeriesShapes = (args) => {
16
16
  }, [dispatcher, preparedData, seriesOptions]);
17
17
  return (React.createElement(React.Fragment, null,
18
18
  React.createElement("g", { ref: ref, className: b() }),
19
- React.createElement(HtmlLayer, { preparedData: preparedData, htmlLayout: htmlLayout })));
19
+ React.createElement(HtmlLayer, { preparedData: { htmlElements: preparedData.htmlLabels }, htmlLayout: htmlLayout })));
20
20
  };
@@ -14,5 +14,5 @@ export const SankeySeriesShape = (props) => {
14
14
  }, [dispatcher, preparedData, seriesOptions]);
15
15
  return (React.createElement(React.Fragment, null,
16
16
  React.createElement("g", { ref: ref, className: b() }),
17
- React.createElement(HtmlLayer, { preparedData: preparedData, htmlLayout: htmlLayout })));
17
+ React.createElement(HtmlLayer, { preparedData: { htmlElements: preparedData.htmlLabels }, htmlLayout: htmlLayout })));
18
18
  };
@@ -14,5 +14,5 @@ export const TreemapSeriesShape = (props) => {
14
14
  }, [dispatcher, preparedData, seriesOptions]);
15
15
  return (React.createElement(React.Fragment, null,
16
16
  React.createElement("g", { ref: ref, className: b() }),
17
- React.createElement(HtmlLayer, { preparedData: preparedData, htmlLayout: htmlLayout })));
17
+ React.createElement(HtmlLayer, { preparedData: { htmlElements: preparedData.htmlLabels }, htmlLayout: htmlLayout })));
18
18
  };
@@ -19,7 +19,7 @@ export const WaterfallSeriesShapes = (args) => {
19
19
  return renderWaterfall({ plot: ref.current }, preparedData, seriesOptions, allowOverlapDataLabels, dispatcher);
20
20
  }, [allowOverlapDataLabels, dispatcher, preparedData, seriesOptions]);
21
21
  const htmlLayerData = React.useMemo(() => {
22
- const items = preparedData.map((d) => d === null || d === void 0 ? void 0 : d.htmlElements).flat();
22
+ const items = preparedData.map((d) => d === null || d === void 0 ? void 0 : d.htmlLabels).flat();
23
23
  if (allowOverlapDataLabels) {
24
24
  return { htmlElements: items };
25
25
  }
@@ -31,8 +31,13 @@ export function getTickValues({ scale, axis, labelLineHeight, series, }) {
31
31
  let result = originalTickValues;
32
32
  let availableSpaceForLabel = getMinSpaceBetween(result, (d) => d.y) - axis.labels.padding * 2;
33
33
  let ticksCount = result.length - 1;
34
+ let lastMultiTickResult = result;
35
+ const triedCounts = new Set();
34
36
  while (availableSpaceForLabel < labelLineHeight && result.length > 1) {
35
37
  ticksCount = ticksCount ? ticksCount - 1 : result.length - 1;
38
+ if (triedCounts.has(ticksCount))
39
+ break;
40
+ triedCounts.add(ticksCount);
36
41
  const newScaleTicks = scale.ticks(ticksCount);
37
42
  result = newScaleTicks.map((t) => ({
38
43
  y: scale(t),
@@ -40,16 +45,23 @@ export function getTickValues({ scale, axis, labelLineHeight, series, }) {
40
45
  }));
41
46
  availableSpaceForLabel =
42
47
  getMinSpaceBetween(result, (d) => d.y) - axis.labels.padding * 2;
48
+ if (result.length > 1) {
49
+ lastMultiTickResult = result;
50
+ }
43
51
  }
44
52
  // when this is not possible (for example, such values cannot be selected for the logarithmic axis with a small range)
45
- // just thin out the originally proposed result
46
- if (!result.length) {
47
- result = originalTickValues;
53
+ // just thin out the last result that had multiple ticks
54
+ // For log scales, 1 tick is also a failure: d3 only places ticks at powers of the base,
55
+ // so a sub-decade range legitimately yields 1 tick despite having room for more.
56
+ // For linear scales, 1 tick is a valid result meaning the chart is simply too small.
57
+ const isLogScale = axis.type === 'logarithmic';
58
+ if ((isLogScale ? result.length <= 1 : !result.length) && lastMultiTickResult.length > 1) {
59
+ result = lastMultiTickResult;
48
60
  availableSpaceForLabel =
49
61
  getMinSpaceBetween(result, (d) => d.y) - axis.labels.padding * 2;
50
62
  let delta = 2;
51
63
  while (availableSpaceForLabel < labelLineHeight && result.length > 1) {
52
- result = thinOut(result, delta);
64
+ result = thinOut(lastMultiTickResult, delta);
53
65
  if (result.length > 1) {
54
66
  delta += 1;
55
67
  availableSpaceForLabel =
@@ -1,5 +1,6 @@
1
- import type { AreaSeriesData, HtmlItem, LabelData } from '../../../types';
1
+ import type { AreaSeriesData, LabelData } from '../../../types';
2
2
  import type { AnnotationAnchor, PreparedAnnotation, PreparedAreaSeries } from '../../series/types';
3
+ import type { SeriesShapeData } from '../types';
3
4
  export type PointData = {
4
5
  annotation?: PreparedAnnotation;
5
6
  color?: string;
@@ -31,5 +32,4 @@ export type PreparedAreaData = {
31
32
  hovered: boolean;
32
33
  active: boolean;
33
34
  svgLabels: LabelData[];
34
- htmlLabels: HtmlItem[];
35
- };
35
+ } & SeriesShapeData;
@@ -1,5 +1,6 @@
1
- import type { HtmlItem, LabelData, TooltipDataChunkBarX } from '../../../types';
1
+ import type { LabelData, TooltipDataChunkBarX } from '../../../types';
2
2
  import type { PreparedAnnotation, PreparedBarXSeries } from '../../series/types';
3
+ import type { SeriesShapeData } from '../types';
3
4
  export type PreparedBarXData = Omit<TooltipDataChunkBarX, 'series'> & {
4
5
  annotation?: PreparedAnnotation;
5
6
  x: number;
@@ -9,11 +10,10 @@ export type PreparedBarXData = Omit<TooltipDataChunkBarX, 'series'> & {
9
10
  opacity: number | null;
10
11
  series: PreparedBarXSeries;
11
12
  svgLabels: LabelData[];
12
- htmlLabels: HtmlItem[];
13
13
  isLastStackItem: boolean;
14
14
  /**
15
15
  * the utility field for storing the original height (for recalculations, etc.)
16
16
  * should not be used for displaying
17
17
  */
18
18
  _height: number;
19
- };
19
+ } & SeriesShapeData;
@@ -13,7 +13,7 @@ export async function prepareBarYData(args) {
13
13
  return {
14
14
  shapes: [],
15
15
  labels: [],
16
- htmlElements: [],
16
+ htmlLabels: [],
17
17
  };
18
18
  }
19
19
  const sortingOptions = get(seriesOptions, 'bar-y.dataSorting');
@@ -134,7 +134,7 @@ export async function prepareBarYData(args) {
134
134
  });
135
135
  });
136
136
  let labels = [];
137
- let htmlElements = [];
137
+ let htmlLabels = [];
138
138
  const map = new Map();
139
139
  for (let i = 0; i < result.length; i++) {
140
140
  const prepared = result[i];
@@ -160,7 +160,7 @@ export async function prepareBarYData(args) {
160
160
  x,
161
161
  y: y - height / 2,
162
162
  });
163
- htmlElements.push({
163
+ htmlLabels.push({
164
164
  content,
165
165
  size: { width, height },
166
166
  style: dataLabels.style,
@@ -202,12 +202,12 @@ export async function prepareBarYData(args) {
202
202
  if (labels.length && !allowOverlap) {
203
203
  labels = filterOverlappingLabels(labels);
204
204
  }
205
- else if (htmlElements.length && !allowOverlap) {
206
- htmlElements = filterOverlappingLabels(htmlElements);
205
+ else if (htmlLabels.length && !allowOverlap) {
206
+ htmlLabels = filterOverlappingLabels(htmlLabels);
207
207
  }
208
208
  return {
209
209
  shapes: result,
210
210
  labels,
211
- htmlElements,
211
+ htmlLabels,
212
212
  };
213
213
  }
@@ -1,5 +1,6 @@
1
- import type { HtmlItem, LabelData, TooltipDataChunkBarY } from '../../../types';
1
+ import type { LabelData, TooltipDataChunkBarY } from '../../../types';
2
2
  import type { PreparedBarYSeries } from '../../series/types';
3
+ import type { SeriesShapeData } from '../types';
3
4
  export type PreparedBarYData = Omit<TooltipDataChunkBarY, 'series'> & {
4
5
  x: number;
5
6
  y: number;
@@ -15,5 +16,4 @@ export type PreparedBarYData = Omit<TooltipDataChunkBarY, 'series'> & {
15
16
  export type BarYShapesArgs = {
16
17
  shapes: PreparedBarYData[];
17
18
  labels: LabelData[];
18
- htmlElements: HtmlItem[];
19
- };
19
+ } & SeriesShapeData;
@@ -1,7 +1,8 @@
1
1
  import type { Path } from 'd3-path';
2
- import type { FunnelSeriesData, HtmlItem, LabelData } from '../../../types';
2
+ import type { FunnelSeriesData, LabelData } from '../../../types';
3
3
  import type { DashStyle } from '../../constants';
4
4
  import type { PreparedFunnelSeries } from '../../series/types';
5
+ import type { SeriesShapeData } from '../types';
5
6
  export type FunnelItemData = {
6
7
  x: number;
7
8
  y: number;
@@ -30,5 +31,4 @@ export type PreparedFunnelData = {
30
31
  items: FunnelItemData[];
31
32
  connectors: FunnelConnectorData[];
32
33
  svgLabels: LabelData[];
33
- htmlLabels: HtmlItem[];
34
- };
34
+ } & SeriesShapeData;
@@ -94,7 +94,7 @@ export async function prepareHeatmapData({ series, xAxis, xScale, yAxis, yScale,
94
94
  }
95
95
  const preparedData = {
96
96
  series: series,
97
- htmlElements: htmlDataLabels,
97
+ htmlLabels: htmlDataLabels,
98
98
  items: heatmapItems,
99
99
  labels: svgDataLabels,
100
100
  };
@@ -1,5 +1,6 @@
1
- import type { BaseTextStyle, HeatmapSeriesData, HtmlItem } from '../../../types';
1
+ import type { BaseTextStyle, HeatmapSeriesData } from '../../../types';
2
2
  import type { PreparedHeatmapSeries } from '../../series/types';
3
+ import type { SeriesShapeData } from '../types';
3
4
  export type HeatmapItem = {
4
5
  x: number;
5
6
  y: number;
@@ -20,6 +21,5 @@ export type HeatmapLabel = {
20
21
  export type PreparedHeatmapData = {
21
22
  series: PreparedHeatmapSeries;
22
23
  items: HeatmapItem[];
23
- htmlElements: HtmlItem[];
24
24
  labels: HeatmapLabel[];
25
- };
25
+ } & SeriesShapeData;
@@ -1,6 +1,7 @@
1
- import type { HtmlItem, LabelData, LineSeriesData, LineSeriesLineBaseStyle } from '../../../types';
1
+ import type { LabelData, LineSeriesData, LineSeriesLineBaseStyle } from '../../../types';
2
2
  import type { DashStyle, LineCap, LineJoin } from '../../constants';
3
3
  import type { AnnotationAnchor, PreparedAnnotation, PreparedLineSeries } from '../../series/types';
4
+ import type { SeriesShapeData } from '../types';
4
5
  export type PointData = {
5
6
  annotation?: PreparedAnnotation;
6
7
  color?: string;
@@ -29,9 +30,8 @@ export type PreparedLineData = {
29
30
  hovered: boolean;
30
31
  active: boolean;
31
32
  svgLabels: LabelData[];
32
- htmlLabels: HtmlItem[];
33
33
  color: string;
34
34
  dashStyle: DashStyle;
35
35
  linecap: LineCap;
36
36
  linejoin: LineJoin;
37
- } & Required<LineSeriesLineBaseStyle>;
37
+ } & Required<LineSeriesLineBaseStyle> & SeriesShapeData;
@@ -1,6 +1,7 @@
1
1
  import type { PieArcDatum } from 'd3-shape';
2
- import type { ConnectorCurve, HtmlItem, LabelData } from '../../../types';
2
+ import type { ConnectorCurve, LabelData } from '../../../types';
3
3
  import type { PreparedPieSeries } from '../../series/types';
4
+ import type { SeriesShapeData } from '../types';
4
5
  export type SegmentData = {
5
6
  value: number;
6
7
  color: string;
@@ -37,5 +38,4 @@ export type PreparedPieData = {
37
38
  opacity: number;
38
39
  size: number;
39
40
  };
40
- htmlLabels: HtmlItem[];
41
- };
41
+ } & SeriesShapeData;
@@ -1,5 +1,6 @@
1
- import type { HtmlItem, LabelData, RadarSeriesData } from '../../../types';
1
+ import type { LabelData, RadarSeriesData } from '../../../types';
2
2
  import type { PreparedRadarSeries } from '../../series/types';
3
+ import type { SeriesShapeData } from '../types';
3
4
  export type RadarLabelData = LabelData & {
4
5
  maxWidth: number;
5
6
  };
@@ -54,6 +55,5 @@ export type PreparedRadarData = {
54
55
  grid: RadarGridData[];
55
56
  center: [number, number];
56
57
  radius: number;
57
- htmlLabels: HtmlItem[];
58
58
  cursor: string | null;
59
- };
59
+ } & SeriesShapeData;
@@ -2,7 +2,7 @@ import { getFormattedValue } from '../../utils/format';
2
2
  import { sankey, sankeyLinkHorizontal } from './sankey-layout';
3
3
  export function prepareSankeyData(args) {
4
4
  const { series, width, height } = args;
5
- const htmlElements = [];
5
+ const htmlLabels = [];
6
6
  const sankeyGenerator = sankey()
7
7
  .nodeId((d) => d.name)
8
8
  .nodeSort((a, b) => { var _a, _b; return ((_a = a.index) !== null && _a !== void 0 ? _a : 0) - ((_b = b.index) !== null && _b !== void 0 ? _b : 0); })
@@ -70,5 +70,5 @@ export function prepareSankeyData(args) {
70
70
  });
71
71
  dataLabels.push(...labels);
72
72
  }
73
- return { series, nodes: sankeyNodes, links: sankeyLinks, htmlElements, labels: dataLabels };
73
+ return { series, nodes: sankeyNodes, links: sankeyLinks, htmlLabels, labels: dataLabels };
74
74
  }
@@ -1,5 +1,6 @@
1
- import type { BaseTextStyle, HtmlItem, SankeySeriesData } from '../../../types';
1
+ import type { BaseTextStyle, SankeySeriesData } from '../../../types';
2
2
  import type { PreparedSankeySeries } from '../../series/types';
3
+ import type { SeriesShapeData } from '../types';
3
4
  export type SankeyDataLabel = {
4
5
  text: string;
5
6
  x: number;
@@ -26,8 +27,7 @@ export type SankeyLink = {
26
27
  };
27
28
  export type PreparedSankeyData = {
28
29
  series: PreparedSankeySeries;
29
- htmlElements: HtmlItem[];
30
30
  nodes: SankeyNode[];
31
31
  links: SankeyLink[];
32
32
  labels: SankeyDataLabel[];
33
- };
33
+ } & SeriesShapeData;
@@ -1,5 +1,6 @@
1
1
  import type { HtmlItem, LabelData, ScatterSeriesData } from '../../../types';
2
2
  import type { PreparedScatterSeries } from '../../series/types';
3
+ import type { SeriesShapeData } from '../types';
3
4
  type PointData = {
4
5
  x: number;
5
6
  y: number;
@@ -19,6 +20,5 @@ export type PreparedScatterData = MarkerData;
19
20
  export type PreparedScatterShapeData = {
20
21
  markers: PreparedScatterData[];
21
22
  svgLabels: LabelData[];
22
- htmlLabels: HtmlItem[];
23
- };
23
+ } & SeriesShapeData;
24
24
  export {};
@@ -148,17 +148,17 @@ export async function prepareTreemapData(args) {
148
148
  })(hierarchy);
149
149
  const leaves = root.leaves();
150
150
  let labelData = [];
151
- const htmlElements = [];
151
+ const htmlLabels = [];
152
152
  if ((_a = series.dataLabels) === null || _a === void 0 ? void 0 : _a.enabled) {
153
153
  const { html, style: dataLabelsStyle } = series.dataLabels;
154
154
  const labels = await getLabels({ data: leaves, options: series.dataLabels });
155
155
  if (html) {
156
156
  const htmlItems = labels.map((l) => (Object.assign({ style: Object.assign(Object.assign({}, dataLabelsStyle), { maxWidth: l.size.width, maxHeight: l.size.height, overflow: 'hidden' }) }, l)));
157
- htmlElements.push(...htmlItems);
157
+ htmlLabels.push(...htmlItems);
158
158
  }
159
159
  else {
160
160
  labelData = labels;
161
161
  }
162
162
  }
163
- return { labelData, leaves, series, htmlElements };
163
+ return { labelData, leaves, series, htmlLabels };
164
164
  }
@@ -1,6 +1,7 @@
1
1
  import type { HierarchyRectangularNode } from 'd3-hierarchy';
2
- import type { HtmlItem, TreemapSeriesData } from '../../../types';
2
+ import type { TreemapSeriesData } from '../../../types';
3
3
  import type { PreparedTreemapSeries } from '../../series/types';
4
+ import type { SeriesShapeData } from '../types';
4
5
  export type TreemapLabelData = {
5
6
  text: string;
6
7
  x: number;
@@ -11,5 +12,4 @@ export type PreparedTreemapData = {
11
12
  labelData: TreemapLabelData[];
12
13
  leaves: HierarchyRectangularNode<TreemapSeriesData<any>>[];
13
14
  series: PreparedTreemapSeries;
14
- htmlElements: HtmlItem[];
15
- };
15
+ } & SeriesShapeData;
@@ -0,0 +1,4 @@
1
+ import type { HtmlItem } from '../../types';
2
+ export interface SeriesShapeData {
3
+ htmlLabels: HtmlItem[];
4
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -144,7 +144,7 @@ export const prepareWaterfallData = async (args) => {
144
144
  data: item.data,
145
145
  series: item.series,
146
146
  subTotal: totalValue,
147
- htmlElements: [],
147
+ htmlLabels: [],
148
148
  };
149
149
  preparedData.label = await getLabelData(preparedData, plotHeight);
150
150
  result.push(preparedData);
@@ -1,5 +1,6 @@
1
- import type { HtmlItem, LabelData, WaterfallSeriesData } from '../../../types';
1
+ import type { LabelData, WaterfallSeriesData } from '../../../types';
2
2
  import type { PreparedWaterfallSeries } from '../../series/types';
3
+ import type { SeriesShapeData } from '../types';
3
4
  export type PreparedWaterfallData = {
4
5
  x: number;
5
6
  y: number;
@@ -10,5 +11,4 @@ export type PreparedWaterfallData = {
10
11
  data: WaterfallSeriesData;
11
12
  label?: LabelData;
12
13
  subTotal: number;
13
- htmlElements: HtmlItem[];
14
- };
14
+ } & SeriesShapeData;
@@ -1,5 +1,6 @@
1
- import type { HtmlItem, LabelData, TooltipDataChunkXRange } from '../../../types';
1
+ import type { LabelData, TooltipDataChunkXRange } from '../../../types';
2
2
  import type { PreparedXRangeSeries } from '../../series/types';
3
+ import type { SeriesShapeData } from '../types';
3
4
  export type PreparedXRangeData = Omit<TooltipDataChunkXRange, 'series'> & {
4
5
  x: number;
5
6
  y: number;
@@ -8,5 +9,4 @@ export type PreparedXRangeData = Omit<TooltipDataChunkXRange, 'series'> & {
8
9
  color: string;
9
10
  series: PreparedXRangeSeries;
10
11
  svgLabels: LabelData[];
11
- htmlLabels: HtmlItem[];
12
- };
12
+ } & SeriesShapeData;
@@ -55,8 +55,13 @@ export function getXAxisTickValues({ axis, labelLineHeight, scale, series, }) {
55
55
  let result = originalTickValues;
56
56
  let availableSpaceForLabel = getMinSpaceBetween(result, (d) => d.x) - axis.labels.padding * 2;
57
57
  let ticksCount = result.length - 1;
58
+ let lastMultiTickResult = result;
59
+ const triedCounts = new Set();
58
60
  while (availableSpaceForLabel < labelLineHeight && result.length > 1) {
59
61
  ticksCount = ticksCount ? ticksCount - 1 : result.length - 1;
62
+ if (triedCounts.has(ticksCount))
63
+ break;
64
+ triedCounts.add(ticksCount);
60
65
  const newScaleTicks = getScaleTicks({ scale, ticksCount, dateTimeLabelFormats });
61
66
  result = newScaleTicks.map((t) => ({
62
67
  x: scale(t),
@@ -64,16 +69,23 @@ export function getXAxisTickValues({ axis, labelLineHeight, scale, series, }) {
64
69
  }));
65
70
  availableSpaceForLabel =
66
71
  getMinSpaceBetween(result, (d) => d.x) - axis.labels.padding * 2;
72
+ if (result.length > 1) {
73
+ lastMultiTickResult = result;
74
+ }
67
75
  }
68
76
  // when this is not possible (for example, such values cannot be selected for the logarithmic axis with a small range)
69
- // just thin out the originally proposed result
70
- if (!result.length) {
71
- result = originalTickValues;
77
+ // just thin out the last result that had multiple ticks
78
+ // For log scales, 1 tick is also a failure: d3 only places ticks at powers of the base,
79
+ // so a sub-decade range legitimately yields 1 tick despite having room for more.
80
+ // For linear scales, 1 tick is a valid result meaning the chart is simply too small.
81
+ const isLogScale = axis.type === 'logarithmic';
82
+ if ((isLogScale ? result.length <= 1 : !result.length) && lastMultiTickResult.length > 1) {
83
+ result = lastMultiTickResult;
72
84
  availableSpaceForLabel =
73
85
  getMinSpaceBetween(result, (d) => d.x) - axis.labels.padding * 2;
74
86
  let delta = 2;
75
87
  while (availableSpaceForLabel < labelLineHeight && result.length > 1) {
76
- result = thinOut(result, delta);
88
+ result = thinOut(lastMultiTickResult, delta);
77
89
  if (result.length > 1) {
78
90
  delta += 1;
79
91
  availableSpaceForLabel =
@@ -5,7 +5,7 @@ import { HtmlLayer } from '../HtmlLayer';
5
5
  export { prepareBarYData } from '../../../core/shapes/bar-y/prepare-data';
6
6
  const b = block('bar-y');
7
7
  export function BarYSeriesShapes(args) {
8
- const { dispatcher, preparedData: { htmlElements }, seriesOptions, htmlLayout, clipPathId, } = args;
8
+ const { dispatcher, preparedData: { htmlLabels: htmlElements }, seriesOptions, htmlLayout, clipPathId, } = args;
9
9
  const ref = React.useRef(null);
10
10
  React.useEffect(() => {
11
11
  if (!ref.current) {
@@ -16,5 +16,5 @@ export const HeatmapSeriesShapes = (args) => {
16
16
  }, [dispatcher, preparedData, seriesOptions]);
17
17
  return (React.createElement(React.Fragment, null,
18
18
  React.createElement("g", { ref: ref, className: b() }),
19
- React.createElement(HtmlLayer, { preparedData: preparedData, htmlLayout: htmlLayout })));
19
+ React.createElement(HtmlLayer, { preparedData: { htmlElements: preparedData.htmlLabels }, htmlLayout: htmlLayout })));
20
20
  };
@@ -14,5 +14,5 @@ export const SankeySeriesShape = (props) => {
14
14
  }, [dispatcher, preparedData, seriesOptions]);
15
15
  return (React.createElement(React.Fragment, null,
16
16
  React.createElement("g", { ref: ref, className: b() }),
17
- React.createElement(HtmlLayer, { preparedData: preparedData, htmlLayout: htmlLayout })));
17
+ React.createElement(HtmlLayer, { preparedData: { htmlElements: preparedData.htmlLabels }, htmlLayout: htmlLayout })));
18
18
  };
@@ -14,5 +14,5 @@ export const TreemapSeriesShape = (props) => {
14
14
  }, [dispatcher, preparedData, seriesOptions]);
15
15
  return (React.createElement(React.Fragment, null,
16
16
  React.createElement("g", { ref: ref, className: b() }),
17
- React.createElement(HtmlLayer, { preparedData: preparedData, htmlLayout: htmlLayout })));
17
+ React.createElement(HtmlLayer, { preparedData: { htmlElements: preparedData.htmlLabels }, htmlLayout: htmlLayout })));
18
18
  };
@@ -19,7 +19,7 @@ export const WaterfallSeriesShapes = (args) => {
19
19
  return renderWaterfall({ plot: ref.current }, preparedData, seriesOptions, allowOverlapDataLabels, dispatcher);
20
20
  }, [allowOverlapDataLabels, dispatcher, preparedData, seriesOptions]);
21
21
  const htmlLayerData = React.useMemo(() => {
22
- const items = preparedData.map((d) => d === null || d === void 0 ? void 0 : d.htmlElements).flat();
22
+ const items = preparedData.map((d) => d === null || d === void 0 ? void 0 : d.htmlLabels).flat();
23
23
  if (allowOverlapDataLabels) {
24
24
  return { htmlElements: items };
25
25
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravity-ui/charts",
3
- "version": "1.51.0",
3
+ "version": "1.51.1",
4
4
  "description": "A flexible JavaScript library for data visualization and chart rendering using React",
5
5
  "license": "MIT",
6
6
  "main": "dist/cjs/index.js",