@semcore/d3-chart 17.0.0-prerelease.9 → 17.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/CHANGELOG.md +14 -1
  2. package/lib/cjs/Bubble.js +20 -15
  3. package/lib/cjs/Bubble.js.map +1 -1
  4. package/lib/cjs/a11y/PlotA11yView.js +5 -5
  5. package/lib/cjs/a11y/PlotA11yView.js.map +1 -1
  6. package/lib/cjs/component/Chart/AbstractChart.js +5 -17
  7. package/lib/cjs/component/Chart/AbstractChart.js.map +1 -1
  8. package/lib/cjs/component/Chart/CigaretteChart.js +197 -57
  9. package/lib/cjs/component/Chart/CigaretteChart.js.map +1 -1
  10. package/lib/cjs/component/Chart/CigaretteChart.type.js.map +1 -1
  11. package/lib/cjs/style/bubble.shadow.css +4 -0
  12. package/lib/cjs/utils.js +3 -2
  13. package/lib/cjs/utils.js.map +1 -1
  14. package/lib/es6/Bubble.js +20 -15
  15. package/lib/es6/Bubble.js.map +1 -1
  16. package/lib/es6/a11y/PlotA11yView.js +4 -3
  17. package/lib/es6/a11y/PlotA11yView.js.map +1 -1
  18. package/lib/es6/component/Chart/AbstractChart.js +5 -17
  19. package/lib/es6/component/Chart/AbstractChart.js.map +1 -1
  20. package/lib/es6/component/Chart/CigaretteChart.js +199 -59
  21. package/lib/es6/component/Chart/CigaretteChart.js.map +1 -1
  22. package/lib/es6/component/Chart/CigaretteChart.type.js.map +1 -1
  23. package/lib/es6/style/bubble.shadow.css +4 -0
  24. package/lib/es6/utils.js +3 -2
  25. package/lib/es6/utils.js.map +1 -1
  26. package/lib/esm/AnimatedClipPath.mjs +1 -1
  27. package/lib/esm/Area.mjs +2 -3
  28. package/lib/esm/Axis.mjs +4 -7
  29. package/lib/esm/Bar.mjs +1 -2
  30. package/lib/esm/Bubble.mjs +24 -21
  31. package/lib/esm/CompactHorizontalBar.mjs +4 -4
  32. package/lib/esm/Donut.mjs +5 -4
  33. package/lib/esm/Dots.mjs +1 -2
  34. package/lib/esm/HorizontalBar.mjs +1 -2
  35. package/lib/esm/Hover.mjs +2 -3
  36. package/lib/esm/Line.mjs +2 -3
  37. package/lib/esm/Pattern.mjs +6 -7
  38. package/lib/esm/Plot.mjs +3 -5
  39. package/lib/esm/Radar.mjs +7 -10
  40. package/lib/esm/RadialTree.mjs +17 -63
  41. package/lib/esm/Reference.mjs +0 -1
  42. package/lib/esm/ResponsiveContainer.mjs +3 -5
  43. package/lib/esm/ScatterPlot.mjs +2 -2
  44. package/lib/esm/StackBar.mjs +2 -2
  45. package/lib/esm/StackedArea.mjs +2 -2
  46. package/lib/esm/Tooltip.mjs +5 -8
  47. package/lib/esm/Venn.mjs +3 -3
  48. package/lib/esm/a11y/DataAccessibilityTable.mjs +2 -4
  49. package/lib/esm/a11y/PlotA11yModule.mjs +2 -2
  50. package/lib/esm/a11y/PlotA11yView.mjs +11 -19
  51. package/lib/esm/a11y/focus.mjs +2 -2
  52. package/lib/esm/a11y/hints.mjs +3 -3
  53. package/lib/esm/a11y/insights.mjs +15 -20
  54. package/lib/esm/a11y/intl.mjs +1 -1
  55. package/lib/esm/a11y/locale.mjs +1 -2
  56. package/lib/esm/a11y/serialize.mjs +17 -17
  57. package/lib/esm/component/Chart/AbstractChart.mjs +20 -34
  58. package/lib/esm/component/Chart/AreaChart.mjs +5 -4
  59. package/lib/esm/component/Chart/BarChart.mjs +4 -3
  60. package/lib/esm/component/Chart/BubbleChart.mjs +8 -8
  61. package/lib/esm/component/Chart/CigaretteChart.mjs +204 -64
  62. package/lib/esm/component/Chart/CompactHorizontalBarChart.mjs +2 -1
  63. package/lib/esm/component/Chart/DonutChart.mjs +3 -2
  64. package/lib/esm/component/Chart/HistogramChart.mjs +5 -4
  65. package/lib/esm/component/Chart/LineChart.mjs +5 -4
  66. package/lib/esm/component/Chart/RadarChart.mjs +4 -5
  67. package/lib/esm/component/Chart/ScatterPlotChart.mjs +3 -2
  68. package/lib/esm/component/Chart/VennChart.mjs +3 -3
  69. package/lib/esm/component/ChartLegend/BaseLegend.mjs +9 -14
  70. package/lib/esm/component/ChartLegend/LegendFlex/LegendFlex.mjs +1 -2
  71. package/lib/esm/component/ChartLegend/LegendItem/LegendItem.mjs +1 -2
  72. package/lib/esm/component/ChartLegend/LegendTable/LegendTable.mjs +2 -4
  73. package/lib/esm/component/ChartLegend/index.mjs +2 -0
  74. package/lib/esm/component/Cigarette/Cigarette.mjs +1 -2
  75. package/lib/esm/component/StackGroupBar/StackGroupBar.mjs +2 -3
  76. package/lib/esm/createElement.mjs +1 -1
  77. package/lib/esm/index.mjs +1 -0
  78. package/lib/esm/style/bubble.shadow.css +4 -0
  79. package/lib/esm/utils.mjs +3 -3
  80. package/lib/types/a11y/PlotA11yView.d.ts +1 -1
  81. package/lib/types/component/Chart/AbstractChart.d.ts +4 -7
  82. package/lib/types/component/Chart/CigaretteChart.type.d.ts +7 -4
  83. package/package.json +17 -17
@@ -1,30 +1,71 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
- import { createComponent, sstyled, assignProps } from "@semcore/core";
2
+ import { sstyled, assignProps, createComponent } from "@semcore/core";
3
3
  import { Box, Flex } from "@semcore/base-components";
4
4
  import i18nEnhance from "@semcore/core/lib/utils/enhances/i18nEnhance";
5
5
  import resolveColorEnhance from "@semcore/core/lib/utils/enhances/resolveColorEnhance";
6
+ import trottle from "@semcore/core/lib/utils/rafTrottle";
6
7
  import uniqueIDEnhancement from "@semcore/core/lib/utils/uniqueID";
7
8
  import Divider from "@semcore/divider";
8
9
  import { Text } from "@semcore/typography";
9
- import { scaleBand, scaleLinear } from "d3-scale";
10
+ import { scaleLinear, scaleThreshold } from "d3-scale";
10
11
  import React from "react";
11
- import Plot from "../../Plot.mjs";
12
- import { HoverRect } from "../../Hover.mjs";
13
- import { interpolateValue, scaleToBand } from "../../utils.mjs";
12
+ import "../../index.mjs";
14
13
  import { AbstractChart, NOT_A_VALUE } from "./AbstractChart.mjs";
15
14
  import AnimatedClipPath from "../../AnimatedClipPath.mjs";
16
15
  import { localizedMessages } from "../../translations/__intergalactic-dynamic-locales.mjs";
16
+ import { eventToPoint, interpolateValue } from "../../utils.mjs";
17
17
  import Cigarette from "../Cigarette/Cigarette.mjs";
18
- const wMin = 2;
18
+ import { HoverRect } from "../../Hover.mjs";
19
+ import Plot from "../../Plot.mjs";
20
+ const DEFAULT_MINIMAL_BAR_WIDTH = 2;
21
+ const DEFAULT_GAP = 2;
19
22
  class CigaretteChartComponent extends AbstractChart {
20
- constructor(...args) {
21
- super(...args);
23
+ constructor(props) {
24
+ super(props);
25
+ _defineProperty(this, "plotRef", /* @__PURE__ */ React.createRef());
22
26
  _defineProperty(this, "plotPadding", 0);
23
27
  _defineProperty(this, "offset", 0);
28
+ _defineProperty(this, "onPlotMouseMove", trottle((event) => {
29
+ if (!this.plotRef.current) return;
30
+ const [pX, pY] = eventToPoint(event, this.plotRef.current);
31
+ this.setState((prevState) => ({
32
+ pX,
33
+ pY
34
+ }));
35
+ }));
36
+ _defineProperty(this, "onPlotMouseLeave", trottle(() => {
37
+ this.setState((prevState) => ({
38
+ pX: null,
39
+ pY: null
40
+ }));
41
+ }));
42
+ this.state = {
43
+ ...this.state,
44
+ pX: null,
45
+ pY: null
46
+ };
47
+ }
48
+ get activeDataDefinitions() {
49
+ const {
50
+ dataDefinitions
51
+ } = this.state;
52
+ return dataDefinitions.filter(({
53
+ checked
54
+ }) => checked);
55
+ }
56
+ get activePositiveDataDefinitions() {
57
+ const {
58
+ data
59
+ } = this.asProps;
60
+ return this.activeDataDefinitions.filter(({
61
+ id
62
+ }) => {
63
+ const itemValue = data[id];
64
+ return typeof itemValue === "number" && itemValue > 0;
65
+ });
24
66
  }
25
67
  resolveColor(id, index) {
26
- var _a;
27
- return ((_a = this.props.colorMap) == null ? void 0 : _a[id]) ?? `blue-${5 - index}00`;
68
+ return this.props.colorMap?.[id] ?? `blue-${5 - index}00`;
28
69
  }
29
70
  getDefaultDataDefinitions() {
30
71
  const dataDefinitions = super.getDefaultDataDefinitions();
@@ -39,17 +80,86 @@ class CigaretteChartComponent extends AbstractChart {
39
80
  w: "fit-content"
40
81
  };
41
82
  }
83
+ totalValue() {
84
+ const {
85
+ data
86
+ } = this.asProps;
87
+ return this.activeDataDefinitions.reduce((acc, {
88
+ id
89
+ }) => {
90
+ const itemValue = data[id];
91
+ if (typeof itemValue === "number") {
92
+ acc += itemValue;
93
+ }
94
+ return acc;
95
+ }, 0);
96
+ }
97
+ computeCigaretteItems() {
98
+ const {
99
+ plotWidth,
100
+ plotHeight,
101
+ data,
102
+ invertAxis,
103
+ minimalBarWidth
104
+ } = this.asProps;
105
+ const dataDefinitions = invertAxis ? this.activeDataDefinitions : [...this.activeDataDefinitions].reverse();
106
+ const count = this.activePositiveDataDefinitions.length;
107
+ const totalGapWidth = DEFAULT_GAP * Math.max(0, count - 1);
108
+ const availableSpace = Math.max(0, (invertAxis ? plotWidth : plotHeight) - totalGapWidth);
109
+ const totalValue = this.totalValue();
110
+ const dataDefinitionsItemSize = dataDefinitions.map(({
111
+ id
112
+ }) => {
113
+ if (totalValue === 0) {
114
+ return 0;
115
+ }
116
+ const itemValue = data[id];
117
+ if (typeof itemValue !== "number") return 0;
118
+ return itemValue / totalValue * availableSpace;
119
+ });
120
+ const result = dataDefinitions.map((dd, index) => ({
121
+ ...dd,
122
+ value: data[dd.id],
123
+ dataWidth: dataDefinitionsItemSize[index],
124
+ visualWidth: dataDefinitionsItemSize[index],
125
+ isMinVisible: false
126
+ }));
127
+ const smallItems = result.filter((r) => {
128
+ const {
129
+ value,
130
+ dataWidth
131
+ } = r;
132
+ if (typeof value !== "number") return false;
133
+ return value > 0 && dataWidth < minimalBarWidth;
134
+ });
135
+ if (smallItems.length === 0) return result;
136
+ let extraNeeded = 0;
137
+ for (const smallItem of smallItems) {
138
+ extraNeeded += minimalBarWidth - smallItem.dataWidth;
139
+ smallItem.visualWidth = minimalBarWidth;
140
+ smallItem.isMinVisible = true;
141
+ }
142
+ const donors = result.filter((r) => !r.isMinVisible && r.dataWidth > minimalBarWidth);
143
+ const donorCapacity = donors.reduce((s, d) => s + (d.dataWidth - minimalBarWidth), 0);
144
+ for (const donor of donors) {
145
+ const available = donor.dataWidth - minimalBarWidth;
146
+ const share = available / donorCapacity;
147
+ const taken = share * extraNeeded;
148
+ donor.visualWidth = donor.dataWidth - taken;
149
+ }
150
+ return result;
151
+ }
42
152
  get xScale() {
43
153
  const {
44
- invertAxis
154
+ plotWidth
45
155
  } = this.asProps;
46
- return invertAxis ? this.valueScale : this.categoryScale;
156
+ return scaleLinear([0, plotWidth]);
47
157
  }
48
158
  get yScale() {
49
159
  const {
50
- invertAxis
160
+ plotHeight
51
161
  } = this.asProps;
52
- return invertAxis ? this.categoryScale : this.valueScale;
162
+ return scaleLinear([plotHeight, 0]);
53
163
  }
54
164
  renderChart() {
55
165
  const {
@@ -67,18 +177,25 @@ class CigaretteChartComponent extends AbstractChart {
67
177
  highlightedLine
68
178
  } = this.state;
69
179
  this.offset = 0;
70
- return /* @__PURE__ */ React.createElement(React.Fragment, null, (invertAxis ? dataDefinitions : [...dataDefinitions].reverse()).map((item, index) => {
71
- const value = data[item.id];
72
- if (!item.checked || value === interpolateValue || value === null) {
180
+ const items = this.computeCigaretteItems();
181
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, items.map((item, index) => {
182
+ const {
183
+ visualWidth,
184
+ id
185
+ } = item;
186
+ const value = data[id];
187
+ if (value === interpolateValue || value === null) {
73
188
  return null;
74
189
  }
75
- const absWidth = Math.abs(this.valueScale(value) - Math.max(this.valueScale(this.valueScale.domain()[0]), this.valueScale(0)));
76
- const height = scaleToBand(this.categoryScale).bandwidth() - 4;
77
- const width = value === 0 ? 0 : Math.max(absWidth, wMin * 2) - wMin;
78
- const y = 2;
79
- const x = index === 0 ? 0 : this.offset;
190
+ const height = invertAxis ? plotHeight - DEFAULT_GAP * 2 : plotWidth - DEFAULT_GAP * 2;
191
+ const width = visualWidth;
192
+ const y = DEFAULT_GAP;
193
+ const x = this.offset;
80
194
  const r = height < 28 ? 2 : 4;
81
- this.offset = this.offset + width + wMin;
195
+ this.offset += visualWidth;
196
+ if (index < items.length - 1) {
197
+ this.offset += DEFAULT_GAP;
198
+ }
82
199
  return /* @__PURE__ */ React.createElement(Cigarette, {
83
200
  key: item.id,
84
201
  dataKey: item.id,
@@ -119,7 +236,9 @@ class CigaretteChartComponent extends AbstractChart {
119
236
  showTooltip
120
237
  } = this.asProps;
121
238
  const {
122
- dataDefinitions
239
+ dataDefinitions,
240
+ pX,
241
+ pY
123
242
  } = this.state;
124
243
  const STooltipChildrenWrapper = Box;
125
244
  if (!showTooltip) {
@@ -129,16 +248,20 @@ class CigaretteChartComponent extends AbstractChart {
129
248
  x: invertAxis ? "" : void 0,
130
249
  y: invertAxis ? void 0 : "",
131
250
  wMin: 100,
132
- hideHoverLine: true
251
+ hideHoverLine: true,
252
+ xIndex: pX !== null ? this.visualScale(pX) : void 0,
253
+ yIndex: pY !== null ? this.visualScale(pY) : void 0
133
254
  }, (tooltipProps) => {
134
255
  var _ref4;
135
256
  const dataKey = invertAxis ? tooltipProps.xIndex : tooltipProps.yIndex;
136
- const showPercentColumn = showPercentValueInTooltip && this.totalValue(data) !== 0;
257
+ const showPercentColumn = showPercentValueInTooltip && this.totalValue() !== 0;
137
258
  if (tooltipViewType === "single") {
138
259
  var _ref3;
139
260
  const item = dataDefinitions.find((dataDefItem) => dataDefItem.id === dataKey);
140
261
  if (!item) {
141
- return null;
262
+ return {
263
+ children: null
264
+ };
142
265
  }
143
266
  return {
144
267
  children: (_ref3 = sstyled(styles), /* @__PURE__ */ React.createElement(STooltipChildrenWrapper, _ref3.cn("STooltipChildrenWrapper", {
@@ -189,6 +312,22 @@ class CigaretteChartComponent extends AbstractChart {
189
312
  };
190
313
  });
191
314
  }
315
+ percentValue(data, key) {
316
+ const {
317
+ percentFormatter
318
+ } = this.asProps;
319
+ const total = this.totalValue();
320
+ const value = data[key];
321
+ if (typeof value === "number" && total !== 0) {
322
+ const rawPercent = 100 * value / total;
323
+ const formattedPercent = percentFormatter ? percentFormatter(rawPercent) : Math.round(rawPercent);
324
+ return `${formattedPercent}%`;
325
+ }
326
+ if (value === null) {
327
+ return `0%`;
328
+ }
329
+ return NOT_A_VALUE;
330
+ }
192
331
  renderTooltipTotalLine(dataItem) {
193
332
  const {
194
333
  showTotalInTooltip,
@@ -197,7 +336,7 @@ class CigaretteChartComponent extends AbstractChart {
197
336
  if (!showTotalInTooltip) {
198
337
  return null;
199
338
  }
200
- const total = this.totalValue(dataItem);
339
+ const total = this.totalValue();
201
340
  return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Box, {
202
341
  mt: 2,
203
342
  mr: 2
@@ -238,13 +377,16 @@ class CigaretteChartComponent extends AbstractChart {
238
377
  }), /* @__PURE__ */ React.createElement(Flex, _ref5.cn("Flex", {
239
378
  "direction": "column"
240
379
  }), header, /* @__PURE__ */ React.createElement(Plot, _ref5.cn("Plot", {
380
+ "ref": this.plotRef,
241
381
  "data": data,
242
382
  "scale": [this.xScale, this.yScale],
243
383
  "width": plotWidth,
244
384
  "height": plotHeight,
245
385
  "dataHints": this.dataHints,
246
386
  "patterns": patterns,
247
- "a11yAltTextConfig": a11yAltTextConfig
387
+ "a11yAltTextConfig": a11yAltTextConfig,
388
+ "onMouseMove": this.onPlotMouseMove,
389
+ "onMouseLeave": this.onPlotMouseLeave
248
390
  }), this.renderTooltip(), this.renderChart())), this.renderLegend());
249
391
  }
250
392
  return _ref6 = sstyled(styles), /* @__PURE__ */ React.createElement(SChart, _ref6.cn("SChart", {
@@ -253,13 +395,16 @@ class CigaretteChartComponent extends AbstractChart {
253
395
  "__excludeProps": ["onClick", "data"]
254
396
  }, _ref2)
255
397
  }), /* @__PURE__ */ React.createElement(Plot, _ref6.cn("Plot", {
398
+ "ref": this.plotRef,
256
399
  "data": data,
257
400
  "scale": [this.xScale, this.yScale],
258
401
  "width": plotWidth,
259
402
  "height": plotHeight,
260
403
  "dataHints": this.dataHints,
261
404
  "patterns": patterns,
262
- "a11yAltTextConfig": a11yAltTextConfig
405
+ "a11yAltTextConfig": a11yAltTextConfig,
406
+ "onMouseMove": this.onPlotMouseMove,
407
+ "onMouseLeave": this.onPlotMouseLeave
263
408
  }), this.renderTooltip(), this.renderChart()), /* @__PURE__ */ React.createElement(Flex, _ref6.cn("Flex", {
264
409
  "direction": "column",
265
410
  "gap": 2
@@ -270,42 +415,36 @@ class CigaretteChartComponent extends AbstractChart {
270
415
  chartType: "Cigarette"
271
416
  });
272
417
  }
273
- get selectedData() {
418
+ get visualScale() {
419
+ const cigaretteItems = this.computeCigaretteItems();
274
420
  const {
275
- data
276
- } = this.asProps;
277
- const {
278
- dataDefinitions
279
- } = this.state;
280
- const result = /* @__PURE__ */ new Map();
281
- dataDefinitions.forEach((dataDefItem) => {
282
- const value = data[dataDefItem.id];
283
- if (dataDefItem.checked && value !== interpolateValue) {
284
- result.set(dataDefItem.id, value);
421
+ range,
422
+ domain
423
+ } = cigaretteItems.reduce((acc, {
424
+ id,
425
+ visualWidth
426
+ }, index) => {
427
+ const {
428
+ range: range2,
429
+ domain: domain2
430
+ } = acc;
431
+ if (visualWidth) {
432
+ range2.push(id);
433
+ if (domain2.length === 0) {
434
+ domain2.push(visualWidth + DEFAULT_GAP);
435
+ return acc;
436
+ }
437
+ if (index !== cigaretteItems.length - 1) {
438
+ const lastAddedDomain = domain2[domain2.length - 1];
439
+ domain2.push(lastAddedDomain + visualWidth + DEFAULT_GAP);
440
+ }
285
441
  }
442
+ return acc;
443
+ }, {
444
+ range: [],
445
+ domain: []
286
446
  });
287
- return result;
288
- }
289
- get categoryScale() {
290
- const {
291
- plotWidth,
292
- plotHeight,
293
- invertAxis
294
- } = this.asProps;
295
- const range = invertAxis ? [plotHeight, 0] : [0, plotWidth];
296
- return scaleBand([0], range);
297
- }
298
- get valueScale() {
299
- const {
300
- plotWidth,
301
- plotHeight,
302
- invertAxis
303
- } = this.asProps;
304
- let max = 0;
305
- this.selectedData.forEach((value) => {
306
- max = max + value;
307
- });
308
- return scaleLinear().range(invertAxis ? [0, plotWidth] : [plotHeight, 0]).domain([0, max]);
447
+ return scaleThreshold(domain, range);
309
448
  }
310
449
  }
311
450
  _defineProperty(CigaretteChartComponent, "displayName", "Cigarette.Bar");
@@ -322,7 +461,8 @@ _defineProperty(CigaretteChartComponent, "defaultProps", (props) => {
322
461
  duration: 500,
323
462
  plotWidth: !invertAxis && !props.plotWidth ? 44 : props.plotWidth,
324
463
  plotHeight: invertAxis && !props.plotHeight ? 28 : props.plotHeight,
325
- showPercentValueInTooltip: false
464
+ showPercentValueInTooltip: false,
465
+ minimalBarWidth: DEFAULT_MINIMAL_BAR_WIDTH
326
466
  };
327
467
  });
328
468
  _defineProperty(CigaretteChartComponent, "enhance", [resolveColorEnhance(), uniqueIDEnhancement(), i18nEnhance(localizedMessages)]);
@@ -3,9 +3,10 @@ import { createComponent } from "@semcore/core";
3
3
  import i18nEnhance from "@semcore/core/lib/utils/enhances/i18nEnhance";
4
4
  import { scaleBand, scaleLinear } from "d3-scale";
5
5
  import React from "react";
6
- import CompactHorizontalBar from "../../CompactHorizontalBar.mjs";
6
+ import "../../index.mjs";
7
7
  import { AbstractChart } from "./AbstractChart.mjs";
8
8
  import { localizedMessages } from "../../translations/__intergalactic-dynamic-locales.mjs";
9
+ import CompactHorizontalBar from "../../CompactHorizontalBar.mjs";
9
10
  class CompactHorizontalBarChartComponent extends AbstractChart {
10
11
  get xScale() {
11
12
  return this.asProps.xScale ?? this.valueScale;
@@ -5,9 +5,10 @@ import i18nEnhance from "@semcore/core/lib/utils/enhances/i18nEnhance";
5
5
  import { Text } from "@semcore/typography";
6
6
  import { scaleLinear } from "d3-scale";
7
7
  import React from "react";
8
- import Donut from "../../Donut.mjs";
8
+ import "../../index.mjs";
9
9
  import { AbstractChart } from "./AbstractChart.mjs";
10
10
  import { localizedMessages } from "../../translations/__intergalactic-dynamic-locales.mjs";
11
+ import Donut from "../../Donut.mjs";
11
12
  class DonutChartComponent extends AbstractChart {
12
13
  get xScale() {
13
14
  const {
@@ -70,7 +71,7 @@ class DonutChartComponent extends AbstractChart {
70
71
  }) => {
71
72
  const title = dataDefinitions.find((item) => item.id === dataKey);
72
73
  return {
73
- children: /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Donut.Tooltip.Title, null, (title == null ? void 0 : title.label) || dataKey), /* @__PURE__ */ React.createElement(Flex, {
74
+ children: /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Donut.Tooltip.Title, null, title?.label || dataKey), /* @__PURE__ */ React.createElement(Flex, {
74
75
  justifyContent: "space-between"
75
76
  }, /* @__PURE__ */ React.createElement(Text, {
76
77
  bold: true
@@ -4,12 +4,13 @@ import { createComponent } from "@semcore/core";
4
4
  import i18nEnhance from "@semcore/core/lib/utils/enhances/i18nEnhance";
5
5
  import { scaleTime, scaleBand, scaleLinear } from "d3-scale";
6
6
  import React from "react";
7
- import Bar from "../../Bar.mjs";
8
- import StackBar from "../../StackBar.mjs";
9
- import { HoverRect } from "../../Hover.mjs";
10
- import { minMax } from "../../utils.mjs";
7
+ import "../../index.mjs";
11
8
  import { AbstractChart } from "./AbstractChart.mjs";
12
9
  import { localizedMessages } from "../../translations/__intergalactic-dynamic-locales.mjs";
10
+ import { minMax } from "../../utils.mjs";
11
+ import StackBar from "../../StackBar.mjs";
12
+ import Bar from "../../Bar.mjs";
13
+ import { HoverRect } from "../../Hover.mjs";
13
14
  class HistogramChartComponent extends AbstractChart {
14
15
  get xScale() {
15
16
  const {
@@ -3,11 +3,12 @@ import { createComponent } from "@semcore/core";
3
3
  import i18nEnhance from "@semcore/core/lib/utils/enhances/i18nEnhance";
4
4
  import { scaleTime, scaleLinear } from "d3-scale";
5
5
  import React from "react";
6
- import Line from "../../Line.mjs";
7
- import { HoverLine } from "../../Hover.mjs";
8
- import { minMax } from "../../utils.mjs";
6
+ import "../../index.mjs";
9
7
  import { AbstractChart } from "./AbstractChart.mjs";
10
8
  import { localizedMessages } from "../../translations/__intergalactic-dynamic-locales.mjs";
9
+ import { minMax } from "../../utils.mjs";
10
+ import Line from "../../Line.mjs";
11
+ import { HoverLine } from "../../Hover.mjs";
11
12
  class LineChartComponent extends AbstractChart {
12
13
  get xScale() {
13
14
  const {
@@ -66,7 +67,7 @@ class LineChartComponent extends AbstractChart {
66
67
  onClick: onClickLine
67
68
  }, showDots && /* @__PURE__ */ React.createElement(Line.Dots, {
68
69
  display: true
69
- }), (area == null ? void 0 : area[item.id]) && /* @__PURE__ */ React.createElement(Line.Area, {
70
+ }), area?.[item.id] && /* @__PURE__ */ React.createElement(Line.Area, {
70
71
  area: area[item.id],
71
72
  y0: "y0",
72
73
  y1: "y1",
@@ -4,8 +4,9 @@ import i18nEnhance from "@semcore/core/lib/utils/enhances/i18nEnhance";
4
4
  import { scaleLinear } from "d3-scale";
5
5
  import React from "react";
6
6
  import { AbstractChart } from "./AbstractChart.mjs";
7
- import Radar from "../../Radar.mjs";
7
+ import "../../index.mjs";
8
8
  import { localizedMessages } from "../../translations/__intergalactic-dynamic-locales.mjs";
9
+ import Radar from "../../Radar.mjs";
9
10
  class RadarChartComponent extends AbstractChart {
10
11
  renderChart() {
11
12
  const {
@@ -48,11 +49,9 @@ class RadarChartComponent extends AbstractChart {
48
49
  }, ({
49
50
  index
50
51
  }) => {
51
- var _a;
52
52
  return {
53
- children: /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Radar.Tooltip.Title, null, (_a = data[groupKey]) == null ? void 0 : _a[index]), dataDefinitions.map((item) => {
54
- var _a2;
55
- const value = (_a2 = data[item.id]) == null ? void 0 : _a2[index];
53
+ children: /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Radar.Tooltip.Title, null, data[groupKey]?.[index]), dataDefinitions.map((item) => {
54
+ const value = data[item.id]?.[index];
56
55
  return item.checked && /* @__PURE__ */ React.createElement(Radar.Tooltip.Dot, {
57
56
  color: item.color,
58
57
  key: item.id
@@ -4,10 +4,11 @@ import i18nEnhance from "@semcore/core/lib/utils/enhances/i18nEnhance";
4
4
  import { Text } from "@semcore/typography";
5
5
  import { scaleTime, scaleLinear } from "d3-scale";
6
6
  import React from "react";
7
- import ScatterPlot from "../../ScatterPlot.mjs";
8
- import { getScatterPlotRadius, minMax } from "../../utils.mjs";
7
+ import "../../index.mjs";
9
8
  import { AbstractChart } from "./AbstractChart.mjs";
10
9
  import { localizedMessages } from "../../translations/__intergalactic-dynamic-locales.mjs";
10
+ import { getScatterPlotRadius, minMax } from "../../utils.mjs";
11
+ import ScatterPlot from "../../ScatterPlot.mjs";
11
12
  class ScatterPlotChartComponent extends AbstractChart {
12
13
  get dataKeys() {
13
14
  const {
@@ -4,9 +4,10 @@ import i18nEnhance from "@semcore/core/lib/utils/enhances/i18nEnhance";
4
4
  import { Text } from "@semcore/typography";
5
5
  import { scaleLinear } from "d3-scale";
6
6
  import React from "react";
7
- import Venn from "../../Venn.mjs";
7
+ import "../../index.mjs";
8
8
  import { AbstractChart } from "./AbstractChart.mjs";
9
9
  import { localizedMessages } from "../../translations/__intergalactic-dynamic-locales.mjs";
10
+ import Venn from "../../Venn.mjs";
10
11
  class VennChartComponent extends AbstractChart {
11
12
  get xScale() {
12
13
  const {
@@ -81,8 +82,7 @@ class VennChartComponent extends AbstractChart {
81
82
  return null;
82
83
  }
83
84
  const name = intersectionKeys.map((id) => {
84
- var _a;
85
- return ((_a = dataDefinitions.find((legendItem) => legendItem.id === id)) == null ? void 0 : _a.label) || "";
85
+ return dataDefinitions.find((legendItem) => legendItem.id === id)?.label || "";
86
86
  }).join(" & ");
87
87
  return /* @__PURE__ */ React.createElement(Venn.Intersection, {
88
88
  key: intersectionKey,
@@ -5,36 +5,31 @@ class BaseLegend extends Component {
5
5
  constructor(...args) {
6
6
  super(...args);
7
7
  _defineProperty(this, "onChangeLegendItem", (shape) => (id, checked) => {
8
- var _a, _b, _c, _d, _e, _f;
9
8
  if (shape !== "Checkbox") return;
10
- (_b = (_a = this.props).onChangeVisibleItem) == null ? void 0 : _b.call(_a, id, checked);
9
+ this.props.onChangeVisibleItem?.(id, checked);
11
10
  if (checked) {
12
- (_d = (_c = this.props).onMouseEnterItem) == null ? void 0 : _d.call(_c, id);
11
+ this.props.onMouseEnterItem?.(id);
13
12
  } else {
14
- (_f = (_e = this.props).onMouseLeaveItem) == null ? void 0 : _f.call(_e, id);
13
+ this.props.onMouseLeaveItem?.(id);
15
14
  }
16
15
  });
17
16
  _defineProperty(this, "onFocusLegendItem", (checked) => (id) => {
18
- var _a, _b, _c, _d;
19
17
  if (!checked) {
20
- return (_b = (_a = this.props).onMouseLeaveItem) == null ? void 0 : _b.call(_a, id);
18
+ return this.props.onMouseLeaveItem?.(id);
21
19
  }
22
- (_d = (_c = this.props).onMouseEnterItem) == null ? void 0 : _d.call(_c, id);
20
+ this.props.onMouseEnterItem?.(id);
23
21
  });
24
22
  _defineProperty(this, "onBlurLegendItem", (id) => {
25
- var _a, _b;
26
- (_b = (_a = this.props).onMouseLeaveItem) == null ? void 0 : _b.call(_a, id);
23
+ this.props.onMouseLeaveItem?.(id);
27
24
  });
28
25
  _defineProperty(this, "bindOnMouseEnterItem", (id) => {
29
26
  return (e) => {
30
- var _a, _b;
31
- (_b = (_a = this.props).onMouseEnterItem) == null ? void 0 : _b.call(_a, id, e);
27
+ this.props.onMouseEnterItem?.(id, e);
32
28
  };
33
29
  });
34
30
  _defineProperty(this, "bindOnMouseLeaveItem", (id) => {
35
31
  return (e) => {
36
- var _a, _b;
37
- (_b = (_a = this.props).onMouseLeaveItem) == null ? void 0 : _b.call(_a, id, e);
32
+ this.props.onMouseLeaveItem?.(id, e);
38
33
  };
39
34
  });
40
35
  }
@@ -53,7 +48,7 @@ class BaseLegend extends Component {
53
48
  } = this.asProps;
54
49
  const dataHintsHandler = dataHints ? makeDataHintsHandlers(dataHints) : void 0;
55
50
  items.forEach((legendItem) => {
56
- dataHintsHandler == null ? void 0 : dataHintsHandler.labelKey("value", legendItem.id, legendItem.label);
51
+ dataHintsHandler?.labelKey("value", legendItem.id, legendItem.label);
57
52
  });
58
53
  }
59
54
  getItem(index) {
@@ -1,5 +1,5 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
- import { createComponent, sstyled, assignProps } from "@semcore/core";
2
+ import { sstyled, assignProps, createComponent } from "@semcore/core";
3
3
  import { Flex } from "@semcore/base-components";
4
4
  import Checkbox from "@semcore/checkbox";
5
5
  import i18nEnhance from "@semcore/core/lib/utils/enhances/i18nEnhance";
@@ -8,7 +8,6 @@ import React from "react";
8
8
  import { localizedMessages } from "../../../translations/__intergalactic-dynamic-locales.mjs";
9
9
  import { BaseLegend } from "../BaseLegend.mjs";
10
10
  import { LegendItemComponent } from "../LegendItem/LegendItem.mjs";
11
- /*!__reshadow-styles__:"./legend-flex.shadow.css"*/
12
11
  const style = (
13
12
  /*__reshadow_css_start__*/
14
13
  (sstyled.insert(
@@ -1,5 +1,5 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
- import { createComponent, Component, sstyled, assignProps } from "@semcore/core";
2
+ import { sstyled, Component, assignProps, createComponent } from "@semcore/core";
3
3
  import { Flex, Box } from "@semcore/base-components";
4
4
  import Checkbox from "@semcore/checkbox";
5
5
  import resolveColorEnhance from "@semcore/core/lib/utils/enhances/resolveColorEnhance";
@@ -9,7 +9,6 @@ import React from "react";
9
9
  import { StaticShapes } from "./LegendItem.type.mjs";
10
10
  import { PatternSymbol } from "../../../Pattern.mjs";
11
11
  import { getChartDefaultColorName } from "../../../utils.mjs";
12
- /*!__reshadow-styles__:"./legend-item.shadow.css"*/
13
12
  const style = (
14
13
  /*__reshadow_css_start__*/
15
14
  (sstyled.insert(
@@ -1,10 +1,9 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
- import { createComponent, sstyled, assignProps } from "@semcore/core";
2
+ import { sstyled, assignProps, createComponent } from "@semcore/core";
3
3
  import { Box } from "@semcore/base-components";
4
4
  import React from "react";
5
5
  import { BaseLegend } from "../BaseLegend.mjs";
6
6
  import { LegendItemComponent } from "../LegendItem/LegendItem.mjs";
7
- /*!__reshadow-styles__:"./legend-table.shadow.css"*/
8
7
  const style = (
9
8
  /*__reshadow_css_start__*/
10
9
  (sstyled.insert(
@@ -23,7 +22,6 @@ const style = (
23
22
  );
24
23
  class LegendTableRoot extends BaseLegend {
25
24
  render() {
26
- var _a;
27
25
  var _ref = this.asProps, _ref3;
28
26
  const SLegendTable = Box;
29
27
  const {
@@ -32,7 +30,7 @@ class LegendTableRoot extends BaseLegend {
32
30
  size = "m",
33
31
  items
34
32
  } = this.asProps;
35
- const columnsCount = (_a = items[0]) == null ? void 0 : _a.columns.length;
33
+ const columnsCount = items[0]?.columns.length;
36
34
  return _ref3 = sstyled(styles), /* @__PURE__ */ React.createElement(SLegendTable, _ref3.cn("SLegendTable", {
37
35
  ...assignProps({
38
36
  "columns-count": columnsCount + 1,
@@ -1,5 +1,7 @@
1
1
  import { LegendFlex } from "./LegendFlex/LegendFlex.mjs";
2
+ import { LegendTable } from "./LegendTable/LegendTable.mjs";
2
3
  export {
3
4
  LegendFlex as ChartLegend,
5
+ LegendTable as ChartLegendTable,
4
6
  LegendFlex as default
5
7
  };