@unovis/ts 1.5.1-ql.2 → 1.5.1-xplg.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 (118) hide show
  1. package/components/area/index.js +1 -1
  2. package/components/area/index.js.map +1 -1
  3. package/components/axis/config.d.ts +1 -1
  4. package/components/axis/config.js.map +1 -1
  5. package/components/axis/index.d.ts +0 -1
  6. package/components/axis/index.js +2 -10
  7. package/components/axis/index.js.map +1 -1
  8. package/components/brush/config.d.ts +1 -1
  9. package/components/brush/config.js.map +1 -1
  10. package/components/donut/config.d.ts +4 -0
  11. package/components/donut/config.js +1 -1
  12. package/components/donut/config.js.map +1 -1
  13. package/components/donut/constants.d.ts +2 -0
  14. package/components/donut/constants.js +8 -0
  15. package/components/donut/constants.js.map +1 -0
  16. package/components/donut/index.js +35 -5
  17. package/components/donut/index.js.map +1 -1
  18. package/components/graph/config.d.ts +28 -4
  19. package/components/graph/config.js +5 -2
  20. package/components/graph/config.js.map +1 -1
  21. package/components/graph/index.d.ts +12 -9
  22. package/components/graph/index.js +48 -25
  23. package/components/graph/index.js.map +1 -1
  24. package/components/graph/modules/layout-helpers.js +1 -1
  25. package/components/graph/modules/layout-helpers.js.map +1 -1
  26. package/components/graph/modules/layout.js +1 -1
  27. package/components/graph/modules/layout.js.map +1 -1
  28. package/components/graph/modules/link/index.d.ts +3 -2
  29. package/components/graph/modules/link/index.js +53 -28
  30. package/components/graph/modules/link/index.js.map +1 -1
  31. package/components/graph/modules/link/style.js +4 -3
  32. package/components/graph/modules/link/style.js.map +1 -1
  33. package/components/graph/modules/node/index.d.ts +2 -0
  34. package/components/graph/modules/node/index.js +7 -4
  35. package/components/graph/modules/node/index.js.map +1 -1
  36. package/components/graph/modules/panel/index.js +2 -2
  37. package/components/graph/modules/panel/index.js.map +1 -1
  38. package/components/graph/types.d.ts +5 -0
  39. package/components/graph/types.js.map +1 -1
  40. package/components/nested-donut/config.d.ts +1 -1
  41. package/components/nested-donut/config.js.map +1 -1
  42. package/components/stacked-bar/index.js +7 -5
  43. package/components/stacked-bar/index.js.map +1 -1
  44. package/components/stacked-bar/types.d.ts +1 -1
  45. package/components/timeline/config.d.ts +65 -14
  46. package/components/timeline/config.js +15 -1
  47. package/components/timeline/config.js.map +1 -1
  48. package/components/timeline/constants.d.ts +3 -0
  49. package/components/timeline/constants.js +6 -0
  50. package/components/timeline/constants.js.map +1 -0
  51. package/components/timeline/index.d.ts +21 -10
  52. package/components/timeline/index.js +375 -93
  53. package/components/timeline/index.js.map +1 -1
  54. package/components/timeline/style.d.ts +7 -0
  55. package/components/timeline/style.js +40 -1
  56. package/components/timeline/style.js.map +1 -1
  57. package/components/timeline/types.d.ts +62 -0
  58. package/components/timeline/types.js +2 -0
  59. package/components/timeline/types.js.map +1 -0
  60. package/components/timeline/utils.d.ts +2 -0
  61. package/components/timeline/utils.js +16 -0
  62. package/components/timeline/utils.js.map +1 -0
  63. package/components/treemap/config.d.ts +44 -0
  64. package/components/treemap/config.js +6 -0
  65. package/components/treemap/config.js.map +1 -0
  66. package/components/treemap/index.d.ts +16 -0
  67. package/components/treemap/index.js +263 -0
  68. package/components/treemap/index.js.map +1 -0
  69. package/components/treemap/style.d.ts +22 -0
  70. package/components/treemap/style.js +62 -0
  71. package/components/treemap/style.js.map +1 -0
  72. package/components/treemap/types.d.ts +11 -0
  73. package/components/treemap/types.js +2 -0
  74. package/components/treemap/types.js.map +1 -0
  75. package/components.d.ts +3 -0
  76. package/components.js +2 -0
  77. package/components.js.map +1 -1
  78. package/containers/single-container/config.d.ts +3 -0
  79. package/containers/single-container/config.js.map +1 -1
  80. package/containers/single-container/index.js +2 -1
  81. package/containers/single-container/index.js.map +1 -1
  82. package/containers/xy-container/config.d.ts +5 -0
  83. package/containers/xy-container/config.js +1 -1
  84. package/containers/xy-container/config.js.map +1 -1
  85. package/containers/xy-container/index.d.ts +1 -0
  86. package/containers/xy-container/index.js +15 -11
  87. package/containers/xy-container/index.js.map +1 -1
  88. package/data-models/graph.d.ts +3 -2
  89. package/data-models/graph.js +15 -6
  90. package/data-models/graph.js.map +1 -1
  91. package/data-models/index.d.ts +4 -0
  92. package/data-models/index.js +5 -0
  93. package/data-models/index.js.map +1 -0
  94. package/index.d.ts +1 -0
  95. package/index.js +10 -3
  96. package/index.js.map +1 -1
  97. package/package.json +4 -5
  98. package/types/data.d.ts +1 -2
  99. package/types/graph.d.ts +4 -0
  100. package/types/position.d.ts +2 -1
  101. package/types/position.js +1 -0
  102. package/types/position.js.map +1 -1
  103. package/types.d.ts +2 -0
  104. package/types.js +2 -0
  105. package/types.js.map +1 -1
  106. package/utils/color.d.ts +14 -0
  107. package/utils/color.js +26 -2
  108. package/utils/color.js.map +1 -1
  109. package/utils/data.d.ts +2 -2
  110. package/utils/data.js +10 -17
  111. package/utils/data.js.map +1 -1
  112. package/utils/index.js +3 -3
  113. package/utils/path.d.ts +8 -0
  114. package/utils/path.js +109 -1
  115. package/utils/path.js.map +1 -1
  116. package/utils/text.d.ts +10 -9
  117. package/utils/text.js +26 -10
  118. package/utils/text.js.map +1 -1
@@ -0,0 +1,263 @@
1
+ import { select } from 'd3-selection';
2
+ import { hierarchy, treemap } from 'd3-hierarchy';
3
+ import { extent, group, max } from 'd3-array';
4
+ import { scaleLinear, scaleThreshold } from 'd3-scale';
5
+ import { hsl } from 'd3-color';
6
+ import { wrapSVGText } from '../../utils/text.js';
7
+ import { ComponentCore } from '../../core/component/index.js';
8
+ import { SeriesDataModel } from '../../data-models/series.js';
9
+ import { getColor, getHexValue, brighter, isDarkBackground } from '../../utils/color.js';
10
+ import { getString, getNumber } from '../../utils/data.js';
11
+ import { TreemapDefaultConfig } from './config.js';
12
+ import * as style from './style.js';
13
+ import { tiles, tileGroup, tile, clickableTile, label } from './style.js';
14
+
15
+ const LIGHTNESS_VARIATION_AMOUNT = 0.08;
16
+ const MIN_TILE_SIZE_FOR_LABEL = 20;
17
+ const defaultNumberFormat = (value) => `${value}`;
18
+ class Treemap extends ComponentCore {
19
+ constructor(config) {
20
+ super();
21
+ this._defaultConfig = TreemapDefaultConfig;
22
+ this.config = this._defaultConfig;
23
+ this.datamodel = new SeriesDataModel();
24
+ if (config)
25
+ this.setConfig(config);
26
+ this.tiles = this.g.append('g').attr('class', tiles);
27
+ }
28
+ isTileLargeEnough(d) {
29
+ const w = d.x1 - d.x0;
30
+ const h = d.y1 - d.y0;
31
+ return (w >= MIN_TILE_SIZE_FOR_LABEL) && (h >= MIN_TILE_SIZE_FOR_LABEL);
32
+ }
33
+ getTileLightness(node, siblings) {
34
+ // Get the value extent of the sibling group
35
+ const [minValue, maxValue] = extent(siblings, d => d.value);
36
+ // If there's no range or no value, return default lightness
37
+ if (minValue === maxValue || !node.value)
38
+ return 0;
39
+ // Calculate relative position in the range (0 to 1)
40
+ // Larger values will be closer to 0 (darker)
41
+ return LIGHTNESS_VARIATION_AMOUNT * ((maxValue - node.value) / (maxValue - minValue));
42
+ }
43
+ _render() {
44
+ var _a;
45
+ const { config, datamodel: { data }, _width, _height } = this;
46
+ const { numberFormat = defaultNumberFormat } = config;
47
+ if (!((_a = config.layers) === null || _a === void 0 ? void 0 : _a.length)) {
48
+ console.warn('Unovis | Treemap: No layers defined');
49
+ return;
50
+ }
51
+ // Map each layer accessor function to get string values from the data array
52
+ const layerAccessors = config.layers.map(layerAccessor => {
53
+ return (i) => getString(data[i], layerAccessor, i);
54
+ });
55
+ // Group the data indices by the layer accessors to create a hierarchical structure
56
+ const nestedData = group(data.keys(), ...layerAccessors);
57
+ // Create the hierarchy from the grouped data,
58
+ // which by itself is not quite right because there is an extra
59
+ // level of nesting that we don't want, just above the leaf nodes.
60
+ const rootNode = hierarchy(nestedData);
61
+ // Compute the aggregation
62
+ if (config.value) {
63
+ rootNode.sum(index => typeof index === 'number' && getNumber(data[index], config.value, index));
64
+ }
65
+ else {
66
+ rootNode.count();
67
+ }
68
+ // Fix the hierarchy by removing the extra level of nesting
69
+ rootNode.each(node => {
70
+ if (!node.children) {
71
+ node.parent.children = null;
72
+ }
73
+ });
74
+ const treemapLayout = treemap()
75
+ .size([_width, _height])
76
+ .round(true)
77
+ .padding(config.tilePadding);
78
+ // Apply padding to the top of each tile,
79
+ // but not for the root node.
80
+ if (this.config.tilePaddingTop !== undefined) {
81
+ treemapLayout.paddingTop(d => d.parent ? config.tilePaddingTop : 0);
82
+ }
83
+ // Compute the treemap layout
84
+ const treemapData = treemapLayout(rootNode);
85
+ // Process the resulting hierarchy into the type we need
86
+ let nodeId = 0;
87
+ treemapData.each(node => {
88
+ const n = node;
89
+ // Generate unique IDs for each node
90
+ node._id = `node-${nodeId++}`;
91
+ const treemapDatum = {
92
+ key: n.data[0],
93
+ };
94
+ // Populate the index and datum for leaf nodes
95
+ const isLeafNode = !n.children;
96
+ if (isLeafNode) {
97
+ treemapDatum.index = n.data[1][0];
98
+ treemapDatum.datum = data[treemapDatum.index];
99
+ }
100
+ node.data = treemapDatum;
101
+ });
102
+ const descendants = treemapData.descendants();
103
+ // Set up the brightness increase scale based on depth
104
+ const maxDepth = max(descendants, d => d.depth);
105
+ const brightnessIncrease = scaleLinear()
106
+ .domain([1, maxDepth])
107
+ .range([0, 1]);
108
+ // Get all leaf node values and calculate their square roots
109
+ // (since area is proportional to value)
110
+ const leafValues = descendants.filter(d => !d.children).map(d => d.value);
111
+ const maxLeafValue = Math.sqrt(max(leafValues)) || 0;
112
+ // Divide the range into three equal intervals based on the square root of values
113
+ // This accounts for the fact that area is proportional to value
114
+ const fontSizeScale = scaleThreshold()
115
+ .domain([
116
+ maxLeafValue / 3,
117
+ (maxLeafValue * 2) / 3, // Second third of the max value
118
+ ])
119
+ .range([
120
+ config.tileLabelSmallFontSize,
121
+ config.tileLabelMediumFontSize,
122
+ config.tileLabelLargeFontSize,
123
+ ]);
124
+ // First pass: Set base colors without considering tileColor config
125
+ treemapData
126
+ .eachBefore((node) => {
127
+ if (!node.children)
128
+ return;
129
+ const children = node.children;
130
+ children.forEach((treemapChild, i) => {
131
+ // Use default color scheme without tileColor config
132
+ let color = getColor(treemapChild, undefined, i, treemapChild.depth !== 1);
133
+ color = color !== null && color !== void 0 ? color : node._fill;
134
+ const hexColor = color ? getHexValue(color, this.g.node()) : null;
135
+ if (hexColor) {
136
+ const hslColor = hsl(hexColor);
137
+ if (config.enableLightnessVariance) {
138
+ if (!treemapChild.children) {
139
+ const lightnessAdjustment = this.getTileLightness(treemapChild, children);
140
+ hslColor.l = Math.min(1, hslColor.l + lightnessAdjustment);
141
+ }
142
+ }
143
+ treemapChild._fill = brighter(hslColor.toString(), brightnessIncrease(treemapChild.depth));
144
+ }
145
+ else {
146
+ treemapChild._fill = null;
147
+ }
148
+ });
149
+ });
150
+ // Second pass: Apply tileColor config as an overlay
151
+ if (config.tileColor) {
152
+ treemapData
153
+ .eachBefore((node) => {
154
+ const color = getColor(node, config.tileColor);
155
+ if (color !== null) {
156
+ node._fill = color;
157
+ }
158
+ });
159
+ }
160
+ // Render tiles
161
+ const visibleNodes = descendants.filter(d => d.depth > 0);
162
+ const tiles = this.tiles
163
+ .selectAll(`g.${tileGroup}`)
164
+ .data(visibleNodes, d => d._id);
165
+ const tilesEnter = tiles
166
+ .enter()
167
+ .append('g')
168
+ .attr('class', tileGroup);
169
+ // Computes the rect border radius for a given tile.
170
+ // The rx and ry values are the minimum of the tile
171
+ // border radius and some fraction the width of the tile,
172
+ // based on the tileBorderRadiusFactor config.
173
+ // This ensures that the tile border radius is not
174
+ // larger than the tile size, which makes small tiles
175
+ // look better.
176
+ const rx = (d) => Math.min(config.tileBorderRadius, (d.x1 - d.x0) * config.tileBorderRadiusFactor);
177
+ // Add clipPath elements
178
+ tilesEnter
179
+ .append('clipPath')
180
+ .attr('id', d => `clip-${d._id}`)
181
+ .append('rect')
182
+ .attr('rx', rx)
183
+ .attr('ry', rx);
184
+ // Tile rectangles
185
+ tilesEnter
186
+ .append('rect')
187
+ .classed(tile, true)
188
+ // Make the leaf tiles clickable if a click handler is provided
189
+ .classed(clickableTile, d => config.showTileClickAffordance && !d.children)
190
+ .attr('rx', rx)
191
+ .attr('ry', rx)
192
+ // Initialize tile positions so that the initial transition is smooth
193
+ .attr('x', d => d.x0)
194
+ .attr('y', d => d.y0)
195
+ .attr('width', d => d.x1 - d.x0)
196
+ .attr('height', d => d.y1 - d.y0)
197
+ .style('fill', d => { var _a; return (_a = d._fill) !== null && _a !== void 0 ? _a : getColor(d, config.tileColor); })
198
+ .style('opacity', 0)
199
+ .style('cursor', config.showTileClickAffordance ? d => !d.children ? 'pointer' : null : null);
200
+ tiles.merge(tilesEnter).select(`rect.${tile}`)
201
+ .style('fill', d => { var _a; return (_a = d._fill) !== null && _a !== void 0 ? _a : getColor(d, config.tileColor); })
202
+ .style('opacity', 1)
203
+ .attr('x', d => d.x0)
204
+ .attr('y', d => d.y0)
205
+ .attr('width', d => d.x1 - d.x0)
206
+ .attr('height', d => d.y1 - d.y0);
207
+ // Update clipPath rects
208
+ tiles.merge(tilesEnter).select('clipPath rect')
209
+ .attr('x', d => d.x0)
210
+ .attr('y', d => d.y0)
211
+ .attr('width', d => d.x1 - d.x0 - config.tilePadding)
212
+ .attr('height', d => d.y1 - d.y0);
213
+ // Tile labels
214
+ tilesEnter
215
+ .append('text')
216
+ .attr('class', label)
217
+ .attr('clip-path', d => `url(#clip-${d._id})`);
218
+ // Update all labels first
219
+ const mergedTiles = tiles.merge(tilesEnter);
220
+ // Hide labels that don't meet criteria
221
+ mergedTiles.select(`text.${label}`)
222
+ .style('display', d => {
223
+ const isAllowedNode = config.labelInternalNodes ? true : !d.children;
224
+ return isAllowedNode && this.isTileLargeEnough(d) ? null : 'none';
225
+ })
226
+ // Make the internal labels semibold
227
+ .style('font-weight', d => d.children ? '500' : 'normal');
228
+ // Update visible labels
229
+ mergedTiles.select(`text.${label}`)
230
+ .filter(d => {
231
+ const isAllowedNode = config.labelInternalNodes ? true : !d.children;
232
+ return isAllowedNode && this.isTileLargeEnough(d);
233
+ })
234
+ .attr('clip-path', d => `url(#clip-${d._id})`)
235
+ .attr('x', d => d.x0 + config.labelOffsetX)
236
+ .attr('y', d => d.y0 + config.labelOffsetY)
237
+ .each(function (d) {
238
+ var _a;
239
+ const text = select(this);
240
+ const label = `${d.data.key}: ${numberFormat(d.value)}`;
241
+ text.text(label);
242
+ // Set text color based on background darkness
243
+ const backgroundColor = (_a = d._fill) !== null && _a !== void 0 ? _a : getColor(d, config.tileColor);
244
+ const textColor = backgroundColor && isDarkBackground(backgroundColor) ? '#ffffff' : '#000000';
245
+ text.style('fill', textColor);
246
+ // Apply font size scaling only to leaf nodes if enabled
247
+ if (!d.children && config.enableTileLabelFontSizeVariation) {
248
+ text.style('font-size', `${fontSizeScale(Math.sqrt(d.value))}px`);
249
+ }
250
+ // Apply text wrapping to leaf nodes
251
+ if (!d.children) {
252
+ const availableWidth = d.x1 - d.x0 - (2 * config.labelOffsetX);
253
+ wrapSVGText(text, availableWidth);
254
+ }
255
+ });
256
+ // Exit
257
+ tiles.exit().remove();
258
+ }
259
+ }
260
+ Treemap.selectors = style;
261
+
262
+ export { Treemap };
263
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../../src/components/treemap/index.ts"],"sourcesContent":["import { Selection, select } from 'd3-selection'\nimport { hierarchy, HierarchyNode, treemap } from 'd3-hierarchy'\nimport { group, max, extent } from 'd3-array'\nimport { scaleLinear, scaleThreshold } from 'd3-scale'\nimport { hsl } from 'd3-color'\nimport { wrapSVGText } from 'utils/text'\nimport { ComponentCore } from 'core/component'\nimport { SeriesDataModel } from 'data-models/series'\nimport { getColor, brighter, getHexValue, isDarkBackground } from 'utils/color'\nimport { getString, getNumber } from 'utils/data'\nimport { TreemapConfigInterface, TreemapDefaultConfig } from './config'\nimport { TreemapDatum, TreemapNode } from './types'\n\nimport * as s from './style' // Minimum pixel size for showing labels\n\nconst LIGHTNESS_VARIATION_AMOUNT = 0.08\n\nconst MIN_TILE_SIZE_FOR_LABEL = 20\n\nconst defaultNumberFormat = (value: number): string => `${value}`\n\nexport class Treemap<Datum> extends ComponentCore<Datum[], TreemapConfigInterface<Datum>> {\n static selectors = s\n protected _defaultConfig = TreemapDefaultConfig as TreemapConfigInterface<Datum>\n public config: TreemapConfigInterface<Datum> = this._defaultConfig\n\n datamodel: SeriesDataModel<Datum> = new SeriesDataModel()\n tiles: Selection<SVGGElement, unknown, SVGGElement, unknown>\n\n private isTileLargeEnough (d: TreemapNode<Datum>): boolean {\n const w = d.x1 - d.x0\n const h = d.y1 - d.y0\n return (w >= MIN_TILE_SIZE_FOR_LABEL) && (h >= MIN_TILE_SIZE_FOR_LABEL)\n }\n\n private getTileLightness (node: TreemapNode<Datum>, siblings: TreemapNode<Datum>[]): number {\n // Get the value extent of the sibling group\n const [minValue, maxValue] = extent(siblings, d => d.value)\n\n // If there's no range or no value, return default lightness\n if (minValue === maxValue || !node.value) return 0\n\n // Calculate relative position in the range (0 to 1)\n // Larger values will be closer to 0 (darker)\n return LIGHTNESS_VARIATION_AMOUNT * ((maxValue - node.value) / (maxValue - minValue))\n }\n\n constructor (config?: TreemapConfigInterface<Datum>) {\n super()\n if (config) this.setConfig(config)\n this.tiles = this.g.append('g').attr('class', s.tiles)\n }\n\n _render (): void {\n const { config, datamodel: { data }, _width, _height } = this\n const { numberFormat = defaultNumberFormat } = config\n\n if (!config.layers?.length) {\n console.warn('Unovis | Treemap: No layers defined')\n return\n }\n\n // Map each layer accessor function to get string values from the data array\n const layerAccessors = config.layers.map(layerAccessor => {\n return (i: number) => getString(data[i], layerAccessor, i)\n })\n\n // Group the data indices by the layer accessors to create a hierarchical structure\n const nestedData = group(data.keys(), ...layerAccessors as [(d: number) => string])\n\n // Create the hierarchy from the grouped data,\n // which by itself is not quite right because there is an extra\n // level of nesting that we don't want, just above the leaf nodes.\n const rootNode = hierarchy(nestedData)\n\n // Compute the aggregation\n if (config.value) {\n rootNode.sum(index => typeof index === 'number' && getNumber(data[index], config.value, index))\n } else {\n rootNode.count()\n }\n\n // Fix the hierarchy by removing the extra level of nesting\n rootNode.each(node => {\n if (!node.children) {\n node.parent.children = null\n }\n })\n\n const treemapLayout = treemap()\n .size([_width, _height])\n .round(true)\n .padding(config.tilePadding)\n\n // Apply padding to the top of each tile,\n // but not for the root node.\n if (this.config.tilePaddingTop !== undefined) {\n treemapLayout.paddingTop(d => d.parent ? config.tilePaddingTop : 0)\n }\n\n // Compute the treemap layout\n const treemapData = treemapLayout(rootNode) as TreemapNode<Datum>\n\n // Process the resulting hierarchy into the type we need\n let nodeId = 0\n treemapData.each(node => {\n const n = node as unknown as HierarchyNode<[string, number[]]>\n // Generate unique IDs for each node\n node._id = `node-${nodeId++}`\n\n const treemapDatum: TreemapDatum<Datum> = {\n key: n.data[0],\n }\n\n // Populate the index and datum for leaf nodes\n const isLeafNode = !n.children\n if (isLeafNode) {\n treemapDatum.index = n.data[1][0]\n treemapDatum.datum = data[treemapDatum.index]\n }\n\n node.data = treemapDatum\n })\n\n const descendants = treemapData.descendants()\n\n // Set up the brightness increase scale based on depth\n const maxDepth = max(descendants, d => d.depth)\n\n const brightnessIncrease = scaleLinear()\n .domain([1, maxDepth])\n .range([0, 1])\n\n // Get all leaf node values and calculate their square roots\n // (since area is proportional to value)\n const leafValues = descendants.filter(d => !d.children).map(d => d.value)\n const maxLeafValue = Math.sqrt(max(leafValues)) || 0\n\n // Divide the range into three equal intervals based on the square root of values\n // This accounts for the fact that area is proportional to value\n const fontSizeScale = scaleThreshold<number, number>()\n .domain([\n maxLeafValue / 3, // First third of the max value\n (maxLeafValue * 2) / 3, // Second third of the max value\n ])\n .range([\n config.tileLabelSmallFontSize,\n config.tileLabelMediumFontSize,\n config.tileLabelLargeFontSize,\n ])\n\n // First pass: Set base colors without considering tileColor config\n treemapData\n .eachBefore((node) => {\n if (!node.children) return\n const children = node.children\n\n children.forEach((treemapChild, i) => {\n // Use default color scheme without tileColor config\n let color = getColor(treemapChild, undefined, i, treemapChild.depth !== 1)\n color = color ?? (node as TreemapNode<Datum>)._fill\n\n const hexColor = color ? getHexValue(color, this.g.node()) : null\n\n if (hexColor) {\n const hslColor = hsl(hexColor)\n\n if (config.enableLightnessVariance) {\n if (!treemapChild.children) {\n const lightnessAdjustment = this.getTileLightness(treemapChild, children)\n hslColor.l = Math.min(1, hslColor.l + lightnessAdjustment)\n }\n }\n\n treemapChild._fill = brighter(hslColor.toString(), brightnessIncrease(treemapChild.depth))\n } else {\n treemapChild._fill = null\n }\n })\n })\n\n // Second pass: Apply tileColor config as an overlay\n if (config.tileColor) {\n treemapData\n .eachBefore((node) => {\n const color = getColor(node, config.tileColor)\n if (color !== null) {\n node._fill = color\n }\n })\n }\n\n // Render tiles\n const visibleNodes = descendants.filter(d => d.depth > 0)\n const tiles = this.tiles\n .selectAll<SVGGElement, TreemapNode<Datum>>(`g.${s.tileGroup}`)\n .data(visibleNodes, d => d._id)\n const tilesEnter = tiles\n .enter()\n .append('g')\n .attr('class', s.tileGroup)\n\n // Computes the rect border radius for a given tile.\n // The rx and ry values are the minimum of the tile\n // border radius and some fraction the width of the tile,\n // based on the tileBorderRadiusFactor config.\n // This ensures that the tile border radius is not\n // larger than the tile size, which makes small tiles\n // look better.\n const rx = (d: TreemapNode<Datum>): number =>\n Math.min(config.tileBorderRadius, (d.x1 - d.x0) * config.tileBorderRadiusFactor)\n\n // Add clipPath elements\n tilesEnter\n .append('clipPath')\n .attr('id', d => `clip-${d._id}`)\n .append('rect')\n .attr('rx', rx)\n .attr('ry', rx)\n\n // Tile rectangles\n tilesEnter\n .append('rect')\n .classed(s.tile, true)\n\n // Make the leaf tiles clickable if a click handler is provided\n .classed(s.clickableTile, d => config.showTileClickAffordance && !d.children)\n\n .attr('rx', rx)\n .attr('ry', rx)\n // Initialize tile positions so that the initial transition is smooth\n .attr('x', d => d.x0)\n .attr('y', d => d.y0)\n .attr('width', d => d.x1 - d.x0)\n .attr('height', d => d.y1 - d.y0)\n .style('fill', d => d._fill ?? getColor(d, config.tileColor))\n .style('opacity', 0)\n .style('cursor', config.showTileClickAffordance ? d => !d.children ? 'pointer' : null : null)\n\n tiles.merge(tilesEnter).select(`rect.${s.tile}`)\n .style('fill', d => d._fill ?? getColor(d, config.tileColor))\n .style('opacity', 1)\n .attr('x', d => d.x0)\n .attr('y', d => d.y0)\n .attr('width', d => d.x1 - d.x0)\n .attr('height', d => d.y1 - d.y0)\n\n // Update clipPath rects\n tiles.merge(tilesEnter).select('clipPath rect')\n .attr('x', d => d.x0)\n .attr('y', d => d.y0)\n .attr('width', d => d.x1 - d.x0 - config.tilePadding)\n .attr('height', d => d.y1 - d.y0)\n\n // Tile labels\n tilesEnter\n .append('text')\n .attr('class', s.label)\n .attr('clip-path', d => `url(#clip-${d._id})`)\n // Update all labels first\n const mergedTiles = tiles.merge(tilesEnter)\n\n // Hide labels that don't meet criteria\n mergedTiles.select(`text.${s.label}`)\n .style('display', d => {\n const isAllowedNode = config.labelInternalNodes ? true : !d.children\n return isAllowedNode && this.isTileLargeEnough(d) ? null : 'none'\n })\n // Make the internal labels semibold\n .style('font-weight', d => d.children ? '500' : 'normal')\n\n // Update visible labels\n mergedTiles.select(`text.${s.label}`)\n .filter(d => {\n const isAllowedNode = config.labelInternalNodes ? true : !d.children\n return isAllowedNode && this.isTileLargeEnough(d)\n })\n .attr('clip-path', d => `url(#clip-${d._id})`)\n .attr('x', d => d.x0 + config.labelOffsetX)\n .attr('y', d => d.y0 + config.labelOffsetY)\n .each(function (d) {\n const text = select(this) as unknown as Selection<SVGTextElement, any, SVGElement, any>\n\n const label = `${d.data.key}: ${numberFormat(d.value)}`\n text.text(label)\n\n // Set text color based on background darkness\n const backgroundColor = d._fill ?? getColor(d, config.tileColor)\n const textColor = backgroundColor && isDarkBackground(backgroundColor) ? '#ffffff' : '#000000'\n text.style('fill', textColor)\n\n // Apply font size scaling only to leaf nodes if enabled\n if (!d.children && config.enableTileLabelFontSizeVariation) {\n text.style('font-size', `${fontSizeScale(Math.sqrt(d.value))}px`)\n }\n\n // Apply text wrapping to leaf nodes\n if (!d.children) {\n const availableWidth = d.x1 - d.x0 - (2 * config.labelOffsetX)\n wrapSVGText(text, availableWidth)\n }\n })\n\n // Exit\n tiles.exit().remove()\n }\n}\n"],"names":["s.tiles","s.tileGroup","s.tile","s.clickableTile","s.label","s"],"mappings":";;;;;;;;;;;;;;AAeA,MAAM,0BAA0B,GAAG,IAAI,CAAA;AAEvC,MAAM,uBAAuB,GAAG,EAAE,CAAA;AAElC,MAAM,mBAAmB,GAAG,CAAC,KAAa,KAAa,CAAA,EAAG,KAAK,CAAA,CAAE,CAAA;AAE3D,MAAO,OAAe,SAAQ,aAAqD,CAAA;AA0BvF,IAAA,WAAA,CAAa,MAAsC,EAAA;AACjD,QAAA,KAAK,EAAE,CAAA;QAzBC,IAAc,CAAA,cAAA,GAAG,oBAAqD,CAAA;AACzE,QAAA,IAAA,CAAA,MAAM,GAAkC,IAAI,CAAC,cAAc,CAAA;AAElE,QAAA,IAAA,CAAA,SAAS,GAA2B,IAAI,eAAe,EAAE,CAAA;AAuBvD,QAAA,IAAI,MAAM;AAAE,YAAA,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAA;QAClC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,OAAO,EAAEA,KAAO,CAAC,CAAA;KACvD;AAtBO,IAAA,iBAAiB,CAAE,CAAqB,EAAA;QAC9C,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,EAAE,CAAA;QACrB,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,EAAE,CAAA;QACrB,OAAO,CAAC,CAAC,IAAI,uBAAuB,MAAM,CAAC,IAAI,uBAAuB,CAAC,CAAA;KACxE;IAEO,gBAAgB,CAAE,IAAwB,EAAE,QAA8B,EAAA;;AAEhF,QAAA,MAAM,CAAC,QAAQ,EAAE,QAAQ,CAAC,GAAG,MAAM,CAAC,QAAQ,EAAE,CA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AAA,EAAA,GAAA,CAAC,CAAC,KAAK,MAAA,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,EAAA,GAAI,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC,SAAS,CAAC,CAAA;AAChE,YAAA,MAAM,SAAS,GAAG,eAAe,IAAI,gBAAgB,CAAC,eAAe,CAAC,GAAG,SAAS,GAAG,SAAS,CAAA;AAC9F,YAAA,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,SAAS,CAAC,CAAA;;YAG7B,IAAI,CAAC,CAAC,CAAC,QAAQ,IAAI,MAAM,CAAC,gCAAgC,EAAE;AAC1D,gBAAA,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,CAAA,EAAG,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAA,EAAA,CAAI,CAAC,CAAA;AAClE,aAAA;;AAGD,YAAA,IAAI,CAAC,CAAC,CAAC,QAAQ,EAAE;AACf,gBAAA,MAAM,cAAc,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,MAAM,CAAC,YAAY,CAAC,CAAA;AAC9D,gBAAA,WAAW,CAAC,IAAI,EAAE,cAAc,CAAC,CAAA;AAClC,aAAA;AACH,SAAC,CAAC,CAAA;;AAGJ,QAAA,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,EAAE,CAAA;KACtB;;AA3RM,OAAS,CAAA,SAAA,GAAGC,KAAC;;;;"}
@@ -0,0 +1,22 @@
1
+ export declare const root: string;
2
+ export declare const variables: {
3
+ treemapTileStrokeColor: "--vis-treemap-tile-stroke-color";
4
+ treemapTileStrokeWidth: "--vis-treemap-tile-stroke-width";
5
+ treemapTileHoverStrokeColor: "--vis-treemap-tile-hover-stroke-color";
6
+ treemapTileFillColor: "--vis-treemap-tile-fill-color";
7
+ treemapTileBackgroundColor: "--vis-treemap-tile-background-color";
8
+ treemapTileCursor: "--vis-treemap-tile-cursor";
9
+ treemapLabelFontFamily: "--vis-treemap-label-font-family";
10
+ treemapLabelTextColor: "--vis-treemap-label-text-color";
11
+ treemapLabelFontSize: "--vis-treemap-label-font-size";
12
+ treemapLabelOpacity: "--vis-treemap-label-opacity";
13
+ darkTreemapTileStrokeColor: "--vis-dark-treemap-tile-stroke-color";
14
+ darkTreemapTileFillColor: "--vis-dark-treemap-tile-fill-color";
15
+ darkTreemapLabelTextColor: "--vis-dark-treemap-label-text-color";
16
+ };
17
+ export declare const tiles: string;
18
+ export declare const tileGroup: string;
19
+ export declare const tile: string;
20
+ export declare const clickableTile: string;
21
+ export declare const tileForeground: string;
22
+ export declare const label: string;
@@ -0,0 +1,62 @@
1
+ import { css } from '@emotion/css';
2
+ import { getCssVarNames, injectGlobalCssVariables } from '../../utils/style.js';
3
+
4
+ const cssVarDefaults = {
5
+ '--vis-treemap-tile-stroke-color': '#fff',
6
+ '--vis-treemap-tile-stroke-width': '2px',
7
+ '--vis-treemap-tile-hover-stroke-color': '#fff',
8
+ '--vis-treemap-tile-fill-color': '#B9BEC3',
9
+ '--vis-treemap-tile-background-color': '#fff',
10
+ '--vis-treemap-tile-cursor': 'default',
11
+ /* Undefined by default to allow proper fallback to var(--vis-font-family) */
12
+ '--vis-treemap-label-font-family': undefined,
13
+ '--vis-treemap-label-text-color': '#5b5f6d',
14
+ '--vis-treemap-label-font-size': '12px',
15
+ /* Label opacity */
16
+ '--vis-treemap-label-opacity': 0.8,
17
+ /* Dark Theme */
18
+ '--vis-dark-treemap-tile-stroke-color': '#2c2c2c',
19
+ '--vis-dark-treemap-tile-fill-color': '#5b5f6d',
20
+ '--vis-dark-treemap-label-text-color': '#fff',
21
+ };
22
+ const root = css `
23
+ label: treemap-component;
24
+ `;
25
+ const variables = getCssVarNames(cssVarDefaults);
26
+ injectGlobalCssVariables(cssVarDefaults, root);
27
+ const tiles = css `
28
+ label: g-tiles;
29
+ `;
30
+ const tileGroup = css `
31
+ label: tile-group;
32
+ `;
33
+ const tile = css `
34
+ label: tile;
35
+ stroke: var(--vis-treemap-tile-hover-stroke-color);
36
+ stroke-opacity: 0;
37
+ transition: stroke-opacity 100ms ease-in-out;
38
+
39
+ &:hover {
40
+ stroke-opacity: 1;
41
+ }
42
+ `;
43
+ // The leaf tiles are clickable
44
+ const clickableTile = css `
45
+ label: clickable-tile;
46
+ cursor: pointer;
47
+ `;
48
+ const tileForeground = css `
49
+ label: tile-foreground;
50
+ `;
51
+ const label = css `
52
+ label: label;
53
+ text-anchor: start;
54
+ dominant-baseline: hanging;
55
+ user-select: none;
56
+ pointer-events: none;
57
+ font-size: var(--vis-treemap-label-font-size);
58
+ opacity: var(--vis-treemap-label-opacity);
59
+ `;
60
+
61
+ export { clickableTile, label, root, tile, tileForeground, tileGroup, tiles, variables };
62
+ //# sourceMappingURL=style.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"style.js","sources":["../../../src/components/treemap/style.ts"],"sourcesContent":["import { css } from '@emotion/css'\n\n// Utils\nimport { getCssVarNames, injectGlobalCssVariables } from 'utils/style'\n\nconst cssVarDefaults = {\n '--vis-treemap-tile-stroke-color': '#fff',\n '--vis-treemap-tile-stroke-width': '2px',\n '--vis-treemap-tile-hover-stroke-color': '#fff',\n '--vis-treemap-tile-fill-color': '#B9BEC3',\n '--vis-treemap-tile-background-color': '#fff',\n '--vis-treemap-tile-cursor': 'default',\n /* Undefined by default to allow proper fallback to var(--vis-font-family) */\n '--vis-treemap-label-font-family': undefined as undefined,\n '--vis-treemap-label-text-color': '#5b5f6d',\n '--vis-treemap-label-font-size': '12px',\n\n /* Label opacity */\n '--vis-treemap-label-opacity': 0.8,\n\n /* Dark Theme */\n '--vis-dark-treemap-tile-stroke-color': '#2c2c2c',\n '--vis-dark-treemap-tile-fill-color': '#5b5f6d',\n '--vis-dark-treemap-label-text-color': '#fff',\n}\n\nexport const root = css`\n label: treemap-component;\n`\n\nexport const variables = getCssVarNames(cssVarDefaults)\ninjectGlobalCssVariables(cssVarDefaults, root)\n\nexport const tiles = css`\n label: g-tiles;\n`\n\nexport const tileGroup = css`\n label: tile-group;\n`\n\nexport const tile = css`\n label: tile;\n stroke: var(--vis-treemap-tile-hover-stroke-color);\n stroke-opacity: 0;\n transition: stroke-opacity 100ms ease-in-out;\n\n &:hover {\n stroke-opacity: 1;\n }\n`\n\n// The leaf tiles are clickable\nexport const clickableTile = css`\n label: clickable-tile;\n cursor: pointer;\n`\n\nexport const tileForeground = css`\n label: tile-foreground;\n`\n\nexport const label = css`\n label: label;\n text-anchor: start;\n dominant-baseline: hanging;\n user-select: none;\n pointer-events: none;\n font-size: var(--vis-treemap-label-font-size);\n opacity: var(--vis-treemap-label-opacity);\n`\n"],"names":[],"mappings":";;;AAKA,MAAM,cAAc,GAAG;AACrB,IAAA,iCAAiC,EAAE,MAAM;AACzC,IAAA,iCAAiC,EAAE,KAAK;AACxC,IAAA,uCAAuC,EAAE,MAAM;AAC/C,IAAA,+BAA+B,EAAE,SAAS;AAC1C,IAAA,qCAAqC,EAAE,MAAM;AAC7C,IAAA,2BAA2B,EAAE,SAAS;;AAEtC,IAAA,iCAAiC,EAAE,SAAsB;AACzD,IAAA,gCAAgC,EAAE,SAAS;AAC3C,IAAA,+BAA+B,EAAE,MAAM;;AAGvC,IAAA,6BAA6B,EAAE,GAAG;;AAGlC,IAAA,sCAAsC,EAAE,SAAS;AACjD,IAAA,oCAAoC,EAAE,SAAS;AAC/C,IAAA,qCAAqC,EAAE,MAAM;CAC9C,CAAA;AAEM,MAAM,IAAI,GAAG,GAAG,CAAA,CAAA;;EAEtB;MAEY,SAAS,GAAG,cAAc,CAAC,cAAc,EAAC;AACvD,wBAAwB,CAAC,cAAc,EAAE,IAAI,CAAC,CAAA;AAEvC,MAAM,KAAK,GAAG,GAAG,CAAA,CAAA;;EAEvB;AAEM,MAAM,SAAS,GAAG,GAAG,CAAA,CAAA;;EAE3B;AAEM,MAAM,IAAI,GAAG,GAAG,CAAA,CAAA;;;;;;;;;EAStB;AAED;AACO,MAAM,aAAa,GAAG,GAAG,CAAA,CAAA;;;EAG/B;AAEM,MAAM,cAAc,GAAG,GAAG,CAAA,CAAA;;EAEhC;AAEM,MAAM,KAAK,GAAG,GAAG,CAAA,CAAA;;;;;;;;;;;;"}
@@ -0,0 +1,11 @@
1
+ import { HierarchyRectangularNode } from 'd3-hierarchy';
2
+ export declare type TreemapDatum<Datum> = {
3
+ key?: string;
4
+ index?: number;
5
+ datum?: Datum;
6
+ };
7
+ export interface TreemapNode<Datum> extends HierarchyRectangularNode<TreemapDatum<Datum>> {
8
+ _id: string;
9
+ _fill?: string;
10
+ _fillOpacity?: number | null;
11
+ }
@@ -0,0 +1,2 @@
1
+
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
package/components.d.ts CHANGED
@@ -27,6 +27,8 @@ export { FreeBrush } from './components/free-brush';
27
27
  export { XYLabels } from './components/xy-labels';
28
28
  export { NestedDonut } from './components/nested-donut';
29
29
  export { Annotations } from "./components/annotations";
30
+ export { Treemap } from './components/treemap';
31
+ export * from './components/donut/constants';
30
32
  export type { LineConfigInterface } from './components/line/config';
31
33
  export type { StackedBarConfigInterface } from './components/stacked-bar/config';
32
34
  export type { GroupedBarConfigInterface } from './components/grouped-bar/config';
@@ -51,3 +53,4 @@ export type { FreeBrushConfigInterface } from './components/free-brush/config';
51
53
  export type { XYLabelsConfigInterface } from './components/xy-labels/config';
52
54
  export type { NestedDonutConfigInterface } from './components/nested-donut/config';
53
55
  export type { AnnotationsConfigInterface } from './components/annotations/config';
56
+ export type { TreemapConfigInterface } from './components/treemap/config';
package/components.js CHANGED
@@ -25,6 +25,8 @@ export { FreeBrush } from './components/free-brush/index.js';
25
25
  export { XYLabels } from './components/xy-labels/index.js';
26
26
  export { NestedDonut } from './components/nested-donut/index.js';
27
27
  export { Annotations } from './components/annotations/index.js';
28
+ export { Treemap } from './components/treemap/index.js';
29
+ export { DONUT_HALF_ANGLE_RANGES, DONUT_HALF_ANGLE_RANGE_BOTTOM, DONUT_HALF_ANGLE_RANGE_LEFT, DONUT_HALF_ANGLE_RANGE_RIGHT, DONUT_HALF_ANGLE_RANGE_TOP } from './components/donut/constants.js';
28
30
 
29
31
  // Core
30
32
  //# sourceMappingURL=components.js.map
package/components.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"components.js","sources":["../src/components.ts"],"sourcesContent":["// Core\nexport { ComponentCore } from 'core/component'\nexport type { ComponentConfigInterface } from 'core/component/config'\nexport { XYComponentCore } from 'core/xy-component'\nexport type { XYComponentConfigInterface } from 'core/xy-component/config'\n\n// Components\nexport { Tooltip } from 'components/tooltip'\nexport { Line } from './components/line'\nexport { StackedBar } from './components/stacked-bar'\nexport { GroupedBar } from './components/grouped-bar'\nexport { Axis } from './components/axis'\nexport { Scatter } from './components/scatter'\nexport { Brush } from './components/brush'\nexport { BulletLegend } from './components/bullet-legend'\nexport { FlowLegend } from './components/flow-legend'\nexport { Crosshair } from './components/crosshair'\nexport { Timeline } from './components/timeline'\nexport { Sankey } from './components/sankey'\nexport { Area } from './components/area'\nexport { TopoJSONMap } from './components/topojson-map'\nexport { LeafletMap } from './components/leaflet-map'\nexport { MapLibreArcticDark, MapLibreArcticLight } from './components/leaflet-map/renderer/map-style'\nexport { LeafletFlowMap } from './components/leaflet-flow-map'\nexport { ChordDiagram } from './components/chord-diagram'\nexport { Graph } from './components/graph'\nexport { VisControls } from './components/vis-controls'\nexport { Donut } from './components/donut'\nexport { FreeBrush } from './components/free-brush'\nexport { XYLabels } from './components/xy-labels'\nexport { NestedDonut } from './components/nested-donut'\nexport { Annotations } from 'components/annotations'\n\n// Config Interfaces\nexport type { LineConfigInterface } from './components/line/config'\nexport type { StackedBarConfigInterface } from './components/stacked-bar/config'\nexport type { GroupedBarConfigInterface } from './components/grouped-bar/config'\nexport type { ScatterConfigInterface } from './components/scatter/config'\nexport type { TooltipConfigInterface } from './components/tooltip/config'\nexport type { BrushConfigInterface } from './components/brush/config'\nexport type { AxisConfigInterface } from './components/axis/config'\nexport type { BulletLegendConfigInterface } from './components/bullet-legend/config'\nexport type { FlowLegendConfigInterface } from './components/flow-legend/config'\nexport type { CrosshairConfigInterface } from './components/crosshair/config'\nexport type { TimelineConfigInterface } from './components/timeline/config'\nexport type { SankeyConfigInterface } from './components/sankey/config'\nexport type { AreaConfigInterface } from './components/area/config'\nexport type { TopoJSONMapConfigInterface } from './components/topojson-map/config'\nexport type { LeafletMapConfigInterface } from './components/leaflet-map/config'\nexport type { LeafletFlowMapConfigInterface } from './components/leaflet-flow-map/config'\nexport type { ChordDiagramConfigInterface } from './components/chord-diagram/config'\nexport type { GraphConfigInterface } from './components/graph/config'\nexport type { VisControlsConfigInterface } from './components/vis-controls/config'\nexport type { DonutConfigInterface } from './components/donut/config'\nexport type { FreeBrushConfigInterface } from './components/free-brush/config'\nexport type { XYLabelsConfigInterface } from './components/xy-labels/config'\nexport type { NestedDonutConfigInterface } from './components/nested-donut/config'\nexport type { AnnotationsConfigInterface } from './components/annotations/config'\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA"}
1
+ {"version":3,"file":"components.js","sources":["../src/components.ts"],"sourcesContent":["// Core\nexport { ComponentCore } from 'core/component'\nexport type { ComponentConfigInterface } from 'core/component/config'\nexport { XYComponentCore } from 'core/xy-component'\nexport type { XYComponentConfigInterface } from 'core/xy-component/config'\n\n// Components\nexport { Tooltip } from 'components/tooltip'\nexport { Line } from './components/line'\nexport { StackedBar } from './components/stacked-bar'\nexport { GroupedBar } from './components/grouped-bar'\nexport { Axis } from './components/axis'\nexport { Scatter } from './components/scatter'\nexport { Brush } from './components/brush'\nexport { BulletLegend } from './components/bullet-legend'\nexport { FlowLegend } from './components/flow-legend'\nexport { Crosshair } from './components/crosshair'\nexport { Timeline } from './components/timeline'\nexport { Sankey } from './components/sankey'\nexport { Area } from './components/area'\nexport { TopoJSONMap } from './components/topojson-map'\nexport { LeafletMap } from './components/leaflet-map'\nexport { MapLibreArcticDark, MapLibreArcticLight } from './components/leaflet-map/renderer/map-style'\nexport { LeafletFlowMap } from './components/leaflet-flow-map'\nexport { ChordDiagram } from './components/chord-diagram'\nexport { Graph } from './components/graph'\nexport { VisControls } from './components/vis-controls'\nexport { Donut } from './components/donut'\nexport { FreeBrush } from './components/free-brush'\nexport { XYLabels } from './components/xy-labels'\nexport { NestedDonut } from './components/nested-donut'\nexport { Annotations } from 'components/annotations'\nexport { Treemap } from './components/treemap'\n\n// Constants\nexport * from './components/donut/constants'\n\n// Config Interfaces\nexport type { LineConfigInterface } from './components/line/config'\nexport type { StackedBarConfigInterface } from './components/stacked-bar/config'\nexport type { GroupedBarConfigInterface } from './components/grouped-bar/config'\nexport type { ScatterConfigInterface } from './components/scatter/config'\nexport type { TooltipConfigInterface } from './components/tooltip/config'\nexport type { BrushConfigInterface } from './components/brush/config'\nexport type { AxisConfigInterface } from './components/axis/config'\nexport type { BulletLegendConfigInterface } from './components/bullet-legend/config'\nexport type { FlowLegendConfigInterface } from './components/flow-legend/config'\nexport type { CrosshairConfigInterface } from './components/crosshair/config'\nexport type { TimelineConfigInterface } from './components/timeline/config'\nexport type { SankeyConfigInterface } from './components/sankey/config'\nexport type { AreaConfigInterface } from './components/area/config'\nexport type { TopoJSONMapConfigInterface } from './components/topojson-map/config'\nexport type { LeafletMapConfigInterface } from './components/leaflet-map/config'\nexport type { LeafletFlowMapConfigInterface } from './components/leaflet-flow-map/config'\nexport type { ChordDiagramConfigInterface } from './components/chord-diagram/config'\nexport type { GraphConfigInterface } from './components/graph/config'\nexport type { VisControlsConfigInterface } from './components/vis-controls/config'\nexport type { DonutConfigInterface } from './components/donut/config'\nexport type { FreeBrushConfigInterface } from './components/free-brush/config'\nexport type { XYLabelsConfigInterface } from './components/xy-labels/config'\nexport type { NestedDonutConfigInterface } from './components/nested-donut/config'\nexport type { AnnotationsConfigInterface } from './components/annotations/config'\nexport type { TreemapConfigInterface } from './components/treemap/config'\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA"}
@@ -2,6 +2,7 @@ import { ContainerConfigInterface } from "../../core/container/config";
2
2
  import { ComponentCore } from "../../core/component";
3
3
  import { Tooltip } from "../../components/tooltip";
4
4
  import { Annotations } from "../../components/annotations";
5
+ import { Spacing } from "../../types/spacing";
5
6
  export interface SingleContainerConfigInterface<Datum> extends ContainerConfigInterface {
6
7
  /** Visualization component. Default: `undefined` */
7
8
  component?: ComponentCore<Datum>;
@@ -9,5 +10,7 @@ export interface SingleContainerConfigInterface<Datum> extends ContainerConfigIn
9
10
  tooltip?: Tooltip;
10
11
  /** Annotations component. Default: `undefined` */
11
12
  annotations?: Annotations | undefined;
13
+ /** Callback function to be called when the chart rendering is complete. Default: `undefined` */
14
+ onRenderComplete?: (svgNode: SVGSVGElement, margin: Spacing, containerWidth: number, containerHeight: number, componentWidth: number, componentHeight: number) => void;
12
15
  }
13
16
  export declare const SingleContainerDefaultConfig: SingleContainerConfigInterface<unknown>;
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sources":["../../../src/containers/single-container/config.ts"],"sourcesContent":["// Core\nimport { ContainerDefaultConfig, ContainerConfigInterface } from 'core/container/config'\nimport { ComponentCore } from 'core/component'\nimport { Tooltip } from 'components/tooltip'\nimport { Annotations } from 'components/annotations'\n\nexport interface SingleContainerConfigInterface<Datum> extends ContainerConfigInterface {\n /** Visualization component. Default: `undefined` */\n component?: ComponentCore<Datum>;\n /** Tooltip component. Default: `undefined` */\n tooltip?: Tooltip;\n /** Annotations component. Default: `undefined` */\n annotations?: Annotations | undefined;\n}\n\nexport const SingleContainerDefaultConfig: SingleContainerConfigInterface<unknown> = {\n ...ContainerDefaultConfig,\n tooltip: undefined,\n annotations: undefined,\n}\n"],"names":[],"mappings":";;AAAA;AAeO,MAAM,4BAA4B,GAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EACpC,sBAAsB,CACzB,EAAA,EAAA,OAAO,EAAE,SAAS,EAClB,WAAW,EAAE,SAAS;;;;"}
1
+ {"version":3,"file":"config.js","sources":["../../../src/containers/single-container/config.ts"],"sourcesContent":["// Core\nimport { ContainerDefaultConfig, ContainerConfigInterface } from 'core/container/config'\nimport { ComponentCore } from 'core/component'\nimport { Tooltip } from 'components/tooltip'\nimport { Annotations } from 'components/annotations'\n\n// Types\nimport { Spacing } from 'types/spacing'\n\nexport interface SingleContainerConfigInterface<Datum> extends ContainerConfigInterface {\n /** Visualization component. Default: `undefined` */\n component?: ComponentCore<Datum>;\n /** Tooltip component. Default: `undefined` */\n tooltip?: Tooltip;\n /** Annotations component. Default: `undefined` */\n annotations?: Annotations | undefined;\n /** Callback function to be called when the chart rendering is complete. Default: `undefined` */\n onRenderComplete?: (\n svgNode: SVGSVGElement,\n margin: Spacing,\n containerWidth: number,\n containerHeight: number,\n componentWidth: number,\n componentHeight: number,\n ) => void;\n}\n\nexport const SingleContainerDefaultConfig: SingleContainerConfigInterface<unknown> = {\n ...ContainerDefaultConfig,\n tooltip: undefined,\n annotations: undefined,\n}\n"],"names":[],"mappings":";;AAAA;AA2BO,MAAM,4BAA4B,GAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EACpC,sBAAsB,CACzB,EAAA,EAAA,OAAO,EAAE,SAAS,EAClB,WAAW,EAAE,SAAS;;;;"}
@@ -83,7 +83,7 @@ class SingleContainer extends ContainerCore {
83
83
  (_a = this.config.annotations) === null || _a === void 0 ? void 0 : _a.setSize(this.width, this.height, this.containerWidth, this.containerHeight);
84
84
  }
85
85
  _render(duration) {
86
- var _a;
86
+ var _a, _b;
87
87
  const { config, component } = this;
88
88
  super._render(duration);
89
89
  component.g.attr('transform', `translate(${config.margin.left},${config.margin.top})`);
@@ -91,6 +91,7 @@ class SingleContainer extends ContainerCore {
91
91
  (_a = config.annotations) === null || _a === void 0 ? void 0 : _a.render(duration);
92
92
  if (config.tooltip)
93
93
  config.tooltip.update();
94
+ (_b = config.onRenderComplete) === null || _b === void 0 ? void 0 : _b.call(config, this.svg.node(), config.margin, this.containerWidth, this.containerHeight, this.width, this.height);
94
95
  }
95
96
  // Re-defining the `render()` function to handle different sizing techniques (`Sizing.Extend` and `Sizing.FitWidth`)
96
97
  // Not calling `super.render()` because we don't want it to interfere with setting the SVG size here.
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/containers/single-container/index.ts"],"sourcesContent":["// Global CSS variables (side effects import)\nimport 'styles/index'\n\n// Core\nimport { ContainerCore } from 'core/container'\nimport { ComponentCore } from 'core/component'\nimport { ComponentConfigInterface } from 'core/component/config'\n\n// Utils\nimport { smartTransition } from 'utils/d3'\n\n// Types\nimport { Sizing, ExtendedSizeComponent } from 'types/component'\n\n// Config\nimport { SingleContainerDefaultConfig, SingleContainerConfigInterface } from './config'\n\nexport class SingleContainer<Data> extends ContainerCore {\n protected _defaultConfig = SingleContainerDefaultConfig as SingleContainerConfigInterface<Data>\n public component: ComponentCore<Data>\n public config: SingleContainerConfigInterface<Data> = this._defaultConfig\n\n constructor (element: HTMLElement, config?: SingleContainerConfigInterface<Data>, data?: Data) {\n super(element)\n\n if (config) {\n this.updateContainer(config, true)\n this.component = config.component\n }\n\n if (data) {\n this.setData(data, true)\n }\n\n // Render if component exists and has data\n if (this.component?.datamodel.data) this.render()\n }\n\n public setData (data: Data, preventRender?: boolean): void {\n const { config } = this\n\n if (this.component) this.component.setData(data)\n if (!preventRender) this.render()\n config.tooltip?.hide()\n }\n\n public updateContainer (containerConfig: SingleContainerConfigInterface<Data>, preventRender?: boolean): void {\n super.updateContainer(containerConfig)\n this._removeAllChildren()\n\n this.component = containerConfig.component\n if (containerConfig.sizing) this.component.sizing = containerConfig.sizing\n this.element.appendChild(this.component.element)\n\n const tooltip = containerConfig.tooltip\n if (tooltip) {\n if (!tooltip.hasContainer()) tooltip.setContainer(this._container)\n tooltip.setComponents([this.component])\n }\n\n const annotations = containerConfig.annotations\n if (annotations) {\n this.element.appendChild(annotations.element)\n }\n\n // Defs\n this.element.appendChild(this._svgDefs.node())\n this.element.appendChild(this._svgDefsExternal.node())\n\n if (!preventRender) this.render()\n }\n\n public updateComponent (componentConfig: ComponentConfigInterface, preventRender?: boolean): void {\n this.component.setConfig(componentConfig)\n if (!preventRender) this.render()\n }\n\n public update (\n containerConfig: SingleContainerConfigInterface<Data>,\n componentConfig?: ComponentConfigInterface,\n data?: Data\n ): void {\n if (containerConfig) this.updateContainer(containerConfig, true)\n if (componentConfig) this.updateComponent(componentConfig, true)\n if (data) this.setData(data, true)\n this.render()\n }\n\n public getFitWidthScale (): number {\n const { config, component } = this\n\n const extendedSizeComponent = component as ExtendedSizeComponent\n if (!extendedSizeComponent.getWidth) return 1\n\n const componentWidth = extendedSizeComponent.getWidth() + config.margin.left + config.margin.right\n return this.width / componentWidth\n }\n\n protected _preRender (): void {\n super._preRender()\n this.component.setSize(this.width, this.height, this.containerWidth, this.containerHeight)\n this.config.annotations?.setSize(this.width, this.height, this.containerWidth, this.containerHeight)\n }\n\n protected _render (duration?: number): void {\n const { config, component } = this\n super._render(duration)\n\n component.g.attr('transform', `translate(${config.margin.left},${config.margin.top})`)\n component.render(duration)\n config.annotations?.render(duration)\n\n if (config.tooltip) config.tooltip.update()\n }\n\n // Re-defining the `render()` function to handle different sizing techniques (`Sizing.Extend` and `Sizing.FitWidth`)\n // Not calling `super.render()` because we don't want it to interfere with setting the SVG size here.\n public render (duration = this.config.duration): void {\n const { config, component } = this\n\n if (config.sizing === Sizing.Extend || config.sizing === Sizing.FitWidth) {\n const fitToWidth = config.sizing === Sizing.FitWidth\n const extendedSizeComponent = component as ExtendedSizeComponent\n\n const componentWidth = extendedSizeComponent.getWidth() + config.margin.left + config.margin.right\n const componentHeight = extendedSizeComponent.getHeight() + config.margin.top + config.margin.bottom\n const scale = fitToWidth ? this.getFitWidthScale() : 1\n\n const currentWidth = this.svg.attr('width')\n const currentHeight = this.svg.attr('height')\n const scaledWidth = componentWidth * scale\n const scaledHeight = componentHeight * scale\n const animated = currentWidth || currentHeight\n\n smartTransition(this.svg, animated ? duration : 0)\n .attr('width', scaledWidth)\n .attr('height', scaledHeight)\n .attr('viewBox', `${0} ${0} ${componentWidth} ${fitToWidth ? scaledHeight : componentHeight}`)\n .attr('preserveAspectRatio', 'xMinYMin')\n } else {\n this.svg\n .attr('width', this.config.width || this.containerWidth)\n .attr('height', this.config.height || this.containerHeight)\n }\n\n // Set up Resize Observer\n if (!this._resizeObserver) this._setUpResizeObserver()\n\n // Schedule the actual rendering in the next frame\n cancelAnimationFrame(this._renderAnimationFrameId)\n this._renderAnimationFrameId = requestAnimationFrame(() => {\n this._preRender()\n this._render(duration)\n })\n }\n\n protected _onResize (): void {\n const { config } = this\n super._onResize()\n config.tooltip?.hide()\n }\n\n public destroy (): void {\n const { component, config } = this\n super.destroy()\n\n component?.destroy()\n config.tooltip?.destroy()\n config.annotations?.destroy()\n }\n}\n"],"names":[],"mappings":";;;;;;AAAA;AAiBM,MAAO,eAAsB,SAAQ,aAAa,CAAA;AAKtD,IAAA,WAAA,CAAa,OAAoB,EAAE,MAA6C,EAAE,IAAW,EAAA;;QAC3F,KAAK,CAAC,OAAO,CAAC,CAAA;QALN,IAAc,CAAA,cAAA,GAAG,4BAAoE,CAAA;AAExF,QAAA,IAAA,CAAA,MAAM,GAAyC,IAAI,CAAC,cAAc,CAAA;AAKvE,QAAA,IAAI,MAAM,EAAE;AACV,YAAA,IAAI,CAAC,eAAe,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;AAClC,YAAA,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,SAAS,CAAA;AAClC,SAAA;AAED,QAAA,IAAI,IAAI,EAAE;AACR,YAAA,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;AACzB,SAAA;;AAGD,QAAA,IAAI,MAAA,IAAI,CAAC,SAAS,MAAE,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GA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,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,OAAO,EAAE,CAAA;AACzB,QAAA,CAAA,EAAA,GAAA,MAAM,CAAC,WAAW,MAAE,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,OAAO,EAAE,CAAA;KAC9B;AACF;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../src/containers/single-container/index.ts"],"sourcesContent":["// Global CSS variables (side effects import)\nimport 'styles/index'\n\n// Core\nimport { ContainerCore } from 'core/container'\nimport { ComponentCore } from 'core/component'\nimport { ComponentConfigInterface } from 'core/component/config'\n\n// Utils\nimport { smartTransition } from 'utils/d3'\n\n// Types\nimport { Sizing, ExtendedSizeComponent } from 'types/component'\n\n// Config\nimport { SingleContainerDefaultConfig, SingleContainerConfigInterface } from './config'\n\nexport class SingleContainer<Data> extends ContainerCore {\n protected _defaultConfig = SingleContainerDefaultConfig as SingleContainerConfigInterface<Data>\n public component: ComponentCore<Data>\n public config: SingleContainerConfigInterface<Data> = this._defaultConfig\n\n constructor (element: HTMLElement, config?: SingleContainerConfigInterface<Data>, data?: Data) {\n super(element)\n\n if (config) {\n this.updateContainer(config, true)\n this.component = config.component\n }\n\n if (data) {\n this.setData(data, true)\n }\n\n // Render if component exists and has data\n if (this.component?.datamodel.data) this.render()\n }\n\n public setData (data: Data, preventRender?: boolean): void {\n const { config } = this\n\n if (this.component) this.component.setData(data)\n if (!preventRender) this.render()\n config.tooltip?.hide()\n }\n\n public updateContainer (containerConfig: SingleContainerConfigInterface<Data>, preventRender?: boolean): void {\n super.updateContainer(containerConfig)\n this._removeAllChildren()\n\n this.component = containerConfig.component\n if (containerConfig.sizing) this.component.sizing = containerConfig.sizing\n this.element.appendChild(this.component.element)\n\n const tooltip = containerConfig.tooltip\n if (tooltip) {\n if (!tooltip.hasContainer()) tooltip.setContainer(this._container)\n tooltip.setComponents([this.component])\n }\n\n const annotations = containerConfig.annotations\n if (annotations) {\n this.element.appendChild(annotations.element)\n }\n\n // Defs\n this.element.appendChild(this._svgDefs.node())\n this.element.appendChild(this._svgDefsExternal.node())\n\n if (!preventRender) this.render()\n }\n\n public updateComponent (componentConfig: ComponentConfigInterface, preventRender?: boolean): void {\n this.component.setConfig(componentConfig)\n if (!preventRender) this.render()\n }\n\n public update (\n containerConfig: SingleContainerConfigInterface<Data>,\n componentConfig?: ComponentConfigInterface,\n data?: Data\n ): void {\n if (containerConfig) this.updateContainer(containerConfig, true)\n if (componentConfig) this.updateComponent(componentConfig, true)\n if (data) this.setData(data, true)\n this.render()\n }\n\n public getFitWidthScale (): number {\n const { config, component } = this\n\n const extendedSizeComponent = component as ExtendedSizeComponent\n if (!extendedSizeComponent.getWidth) return 1\n\n const componentWidth = extendedSizeComponent.getWidth() + config.margin.left + config.margin.right\n return this.width / componentWidth\n }\n\n protected _preRender (): void {\n super._preRender()\n this.component.setSize(this.width, this.height, this.containerWidth, this.containerHeight)\n this.config.annotations?.setSize(this.width, this.height, this.containerWidth, this.containerHeight)\n }\n\n protected _render (duration?: number): void {\n const { config, component } = this\n super._render(duration)\n\n component.g.attr('transform', `translate(${config.margin.left},${config.margin.top})`)\n component.render(duration)\n config.annotations?.render(duration)\n\n if (config.tooltip) config.tooltip.update()\n config.onRenderComplete?.(this.svg.node(), config.margin, this.containerWidth, this.containerHeight, this.width, this.height)\n }\n\n // Re-defining the `render()` function to handle different sizing techniques (`Sizing.Extend` and `Sizing.FitWidth`)\n // Not calling `super.render()` because we don't want it to interfere with setting the SVG size here.\n public render (duration = this.config.duration): void {\n const { config, component } = this\n\n if (config.sizing === Sizing.Extend || config.sizing === Sizing.FitWidth) {\n const fitToWidth = config.sizing === Sizing.FitWidth\n const extendedSizeComponent = component as ExtendedSizeComponent\n\n const componentWidth = extendedSizeComponent.getWidth() + config.margin.left + config.margin.right\n const componentHeight = extendedSizeComponent.getHeight() + config.margin.top + config.margin.bottom\n const scale = fitToWidth ? this.getFitWidthScale() : 1\n\n const currentWidth = this.svg.attr('width')\n const currentHeight = this.svg.attr('height')\n const scaledWidth = componentWidth * scale\n const scaledHeight = componentHeight * scale\n const animated = currentWidth || currentHeight\n\n smartTransition(this.svg, animated ? duration : 0)\n .attr('width', scaledWidth)\n .attr('height', scaledHeight)\n .attr('viewBox', `${0} ${0} ${componentWidth} ${fitToWidth ? scaledHeight : componentHeight}`)\n .attr('preserveAspectRatio', 'xMinYMin')\n } else {\n this.svg\n .attr('width', this.config.width || this.containerWidth)\n .attr('height', this.config.height || this.containerHeight)\n }\n\n // Set up Resize Observer\n if (!this._resizeObserver) this._setUpResizeObserver()\n\n // Schedule the actual rendering in the next frame\n cancelAnimationFrame(this._renderAnimationFrameId)\n this._renderAnimationFrameId = requestAnimationFrame(() => {\n this._preRender()\n this._render(duration)\n })\n }\n\n protected _onResize (): void {\n const { config } = this\n super._onResize()\n config.tooltip?.hide()\n }\n\n public destroy (): void {\n const { component, config } = this\n super.destroy()\n\n component?.destroy()\n config.tooltip?.destroy()\n config.annotations?.destroy()\n }\n}\n"],"names":[],"mappings":";;;;;;AAAA;AAiBM,MAAO,eAAsB,SAAQ,aAAa,CAAA;AAKtD,IAAA,WAAA,CAAa,OAAoB,EAAE,MAA6C,EAAE,IAAW,EAAA;;QAC3F,KAAK,CAAC,OAAO,CAAC,CAAA;QALN,IAAc,CAAA,cAAA,GAAG,4BAAoE,CAAA;AAExF,QAAA,IAAA,CAAA,MAAM,GAAyC,IAAI,CAAC,cAAc,CAAA;AAKvE,QAAA,IAAI,MAAM,EAAE;AACV,YAAA,IAAI,CAAC,eAAe,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;AAClC,YAAA,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,SAAS,CAAA;AAClC,SAAA;AAED,QAAA,IAAI,IAAI,EAAE;AACR,YAAA,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;AACzB,SAAA;;AAGD,QAAA,IAAI,MAAA,IAAI,CA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KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,IAAI,EAAE,CAAA;KACvB;IAEM,OAAO,GAAA;;AACZ,QAAA,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,IAAI,CAAA;QAClC,KAAK,CAAC,OAAO,EAAE,CAAA;AAEf,QAAA,SAAS,aAAT,SAAS,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAT,SAAS,CAAE,OAAO,EAAE,CAAA;AACpB,QAAA,CAAA,EAAA,GAAA,MAAM,CAAC,OAAO,MAAE,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,OAAO,EAAE,CAAA;AACzB,QAAA,CAAA,EAAA,GAAA,MAAM,CAAC,WAAW,MAAE,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,OAAO,EAAE,CAAA;KAC9B;AACF;;;;"}
@@ -6,6 +6,7 @@ import { Axis } from "../../components/axis";
6
6
  import { Crosshair } from "../../components/crosshair";
7
7
  import { ContinuousScale } from "../../types/scale";
8
8
  import { Direction } from "../../types/direction";
9
+ import { Spacing } from "../../types/spacing";
9
10
  export interface XYContainerConfigInterface<Datum> extends ContainerConfigInterface {
10
11
  /** An array of visualization components. Default: `[]` */
11
12
  components?: XYComponentCore<Datum>[];
@@ -80,5 +81,9 @@ export interface XYContainerConfigInterface<Datum> extends ContainerConfigInterf
80
81
  scaleByDomain?: boolean;
81
82
  /** Annotations component. Default: `undefined` */
82
83
  annotations?: Annotations | undefined;
84
+ /** Extend the clip path by the specified number of pixels. Default: `2` */
85
+ clipPathExtend?: number;
86
+ /** Callback function to be called when the chart rendering is complete. Default: `undefined` */
87
+ onRenderComplete?: (svgNode: SVGSVGElement, margin: Spacing, bleed: Spacing, containerWidth: number, containerHeight: number, componentWidth: number, componentHeight: number) => void;
83
88
  }
84
89
  export declare const XYContainerDefaultConfig: XYContainerConfigInterface<unknown>;
@@ -1,7 +1,7 @@
1
1
  import { ContainerDefaultConfig } from '../../core/container/config.js';
2
2
  import { Direction } from '../../types/direction.js';
3
3
 
4
- const XYContainerDefaultConfig = Object.assign(Object.assign({}, ContainerDefaultConfig), { components: [], tooltip: undefined, crosshair: undefined, annotations: undefined, xAxis: undefined, yAxis: undefined, autoMargin: true, xScale: undefined, xDomain: undefined, xDomainMinConstraint: undefined, xDomainMaxConstraint: undefined, xRange: undefined, yScale: undefined, yDomain: undefined, yDomainMinConstraint: undefined, yDomainMaxConstraint: undefined, yRange: undefined, yDirection: Direction.North, preventEmptyDomain: null, scaleByDomain: false });
4
+ const XYContainerDefaultConfig = Object.assign(Object.assign({}, ContainerDefaultConfig), { components: [], tooltip: undefined, crosshair: undefined, annotations: undefined, xAxis: undefined, yAxis: undefined, autoMargin: true, xScale: undefined, xDomain: undefined, xDomainMinConstraint: undefined, xDomainMaxConstraint: undefined, xRange: undefined, yScale: undefined, yDomain: undefined, yDomainMinConstraint: undefined, yDomainMaxConstraint: undefined, yRange: undefined, yDirection: Direction.North, preventEmptyDomain: null, scaleByDomain: false, clipPathExtend: 2 });
5
5
 
6
6
  export { XYContainerDefaultConfig };
7
7
  //# sourceMappingURL=config.js.map