@d3plus/core 4.5.0 → 4.6.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 (241) hide show
  1. package/README.md +3698 -1074
  2. package/es/index.js +3 -3
  3. package/es/index.js.map +1 -1
  4. package/es/internal.js +6 -1
  5. package/es/internal.js.map +1 -1
  6. package/es/src/charts/BarChart/index.js +8 -1
  7. package/es/src/charts/BarChart/index.js.map +1 -1
  8. package/es/src/charts/BoxWhisker/index.js +5 -0
  9. package/es/src/charts/BoxWhisker/index.js.map +1 -1
  10. package/es/src/charts/Chord/emit.js +55 -3
  11. package/es/src/charts/Chord/emit.js.map +1 -1
  12. package/es/src/charts/Chord/index.js +15 -0
  13. package/es/src/charts/Chord/index.js.map +1 -1
  14. package/es/src/charts/Geomap/applyLayout.js +17 -10
  15. package/es/src/charts/Geomap/applyLayout.js.map +1 -1
  16. package/es/src/charts/Geomap/index.js +5 -1
  17. package/es/src/charts/Geomap/index.js.map +1 -1
  18. package/es/src/charts/Histogram/binData.js +225 -0
  19. package/es/src/charts/Histogram/binData.js.map +1 -0
  20. package/es/src/charts/Histogram/index.js +271 -0
  21. package/es/src/charts/Histogram/index.js.map +1 -0
  22. package/es/src/charts/Network/applyLayout.js +52 -4
  23. package/es/src/charts/Network/applyLayout.js.map +1 -1
  24. package/es/src/charts/Network/emit.js +4 -4
  25. package/es/src/charts/Network/emit.js.map +1 -1
  26. package/es/src/charts/Network/index.js +6 -1
  27. package/es/src/charts/Network/index.js.map +1 -1
  28. package/es/src/charts/Pack/emit.js +37 -2
  29. package/es/src/charts/Pack/emit.js.map +1 -1
  30. package/es/src/charts/Pack/index.js +13 -0
  31. package/es/src/charts/Pack/index.js.map +1 -1
  32. package/es/src/charts/Pie/applyLayout.js +20 -2
  33. package/es/src/charts/Pie/applyLayout.js.map +1 -1
  34. package/es/src/charts/Pie/emit.js +274 -33
  35. package/es/src/charts/Pie/emit.js.map +1 -1
  36. package/es/src/charts/Pie/index.js +46 -1
  37. package/es/src/charts/Pie/index.js.map +1 -1
  38. package/es/src/charts/Plot/discreteSpan.js +42 -0
  39. package/es/src/charts/Plot/discreteSpan.js.map +1 -0
  40. package/es/src/charts/Plot/draw.js +3 -1
  41. package/es/src/charts/Plot/draw.js.map +1 -1
  42. package/es/src/charts/Plot/index.js +129 -14
  43. package/es/src/charts/Plot/index.js.map +1 -1
  44. package/es/src/charts/Plot/pipeline.js +47 -20
  45. package/es/src/charts/Plot/pipeline.js.map +1 -1
  46. package/es/src/charts/Plot/pipelineDomains.js +84 -8
  47. package/es/src/charts/Plot/pipelineDomains.js.map +1 -1
  48. package/es/src/charts/Plot/shapeDefaults.js +3 -3
  49. package/es/src/charts/Plot/shapeDefaults.js.map +1 -1
  50. package/es/src/charts/Plot/sharedHover.js +431 -0
  51. package/es/src/charts/Plot/sharedHover.js.map +1 -0
  52. package/es/src/charts/Plot/sharedHoverScene.js +230 -0
  53. package/es/src/charts/Plot/sharedHoverScene.js.map +1 -0
  54. package/es/src/charts/Plot/sharedTooltip.js +163 -0
  55. package/es/src/charts/Plot/sharedTooltip.js.map +1 -0
  56. package/es/src/charts/Plot/stackShareLabels.js +137 -0
  57. package/es/src/charts/Plot/stackShareLabels.js.map +1 -0
  58. package/es/src/charts/Plot/stackShareTooltip.js +31 -0
  59. package/es/src/charts/Plot/stackShareTooltip.js.map +1 -0
  60. package/es/src/charts/Plot/trendLines.js +367 -0
  61. package/es/src/charts/Plot/trendLines.js.map +1 -0
  62. package/es/src/charts/Plot/trendScene.js +220 -0
  63. package/es/src/charts/Plot/trendScene.js.map +1 -0
  64. package/es/src/charts/Plot/trendTooltip.js +160 -0
  65. package/es/src/charts/Plot/trendTooltip.js.map +1 -0
  66. package/es/src/charts/Priestley/emit.js +32 -3
  67. package/es/src/charts/Priestley/emit.js.map +1 -1
  68. package/es/src/charts/Radar/index.js +15 -2
  69. package/es/src/charts/Radar/index.js.map +1 -1
  70. package/es/src/charts/RadialMatrix/index.js +17 -1
  71. package/es/src/charts/RadialMatrix/index.js.map +1 -1
  72. package/es/src/charts/Rings/applyLayout.js +72 -116
  73. package/es/src/charts/Rings/applyLayout.js.map +1 -1
  74. package/es/src/charts/Rings/emit.js +2 -3
  75. package/es/src/charts/Rings/emit.js.map +1 -1
  76. package/es/src/charts/Rings/index.js +13 -2
  77. package/es/src/charts/Rings/index.js.map +1 -1
  78. package/es/src/charts/Rings/ringsSizing.js +189 -0
  79. package/es/src/charts/Rings/ringsSizing.js.map +1 -0
  80. package/es/src/charts/StackedArea/index.js +8 -1
  81. package/es/src/charts/StackedArea/index.js.map +1 -1
  82. package/es/src/charts/Tree/emit.js +2 -2
  83. package/es/src/charts/Tree/emit.js.map +1 -1
  84. package/es/src/charts/Tree/index.js +5 -3
  85. package/es/src/charts/Tree/index.js.map +1 -1
  86. package/es/src/charts/Treemap/emit.js +56 -3
  87. package/es/src/charts/Treemap/emit.js.map +1 -1
  88. package/es/src/charts/definition/ChartDefinition.js.map +1 -1
  89. package/es/src/charts/definition/makeChart.js +8 -1
  90. package/es/src/charts/definition/makeChart.js.map +1 -1
  91. package/es/src/charts/drawSteps/backControl.js +17 -2
  92. package/es/src/charts/drawSteps/backControl.js.map +1 -1
  93. package/es/src/charts/drawSteps/bottomRightControls.js +193 -0
  94. package/es/src/charts/drawSteps/bottomRightControls.js.map +1 -0
  95. package/es/src/charts/drawSteps/bottomRightControlsMarkup.js +161 -0
  96. package/es/src/charts/drawSteps/bottomRightControlsMarkup.js.map +1 -0
  97. package/es/src/charts/drawSteps/minimap.js +34 -9
  98. package/es/src/charts/drawSteps/minimap.js.map +1 -1
  99. package/es/src/charts/drawSteps/zoomControls.js +3 -0
  100. package/es/src/charts/drawSteps/zoomControls.js.map +1 -1
  101. package/es/src/charts/events/click.shape.js +24 -1
  102. package/es/src/charts/events/click.shape.js.map +1 -1
  103. package/es/src/charts/events/mouseenter.js +3 -0
  104. package/es/src/charts/events/mouseenter.js.map +1 -1
  105. package/es/src/charts/events/mouseleave.js +3 -0
  106. package/es/src/charts/events/mouseleave.js.map +1 -1
  107. package/es/src/charts/events/mousemove.shape.js +2 -0
  108. package/es/src/charts/events/mousemove.shape.js.map +1 -1
  109. package/es/src/charts/features/axes.js +4 -1
  110. package/es/src/charts/features/axes.js.map +1 -1
  111. package/es/src/charts/features/emitHelpers.js +24 -0
  112. package/es/src/charts/features/emitHelpers.js.map +1 -1
  113. package/es/src/charts/features/features.js +6 -2
  114. package/es/src/charts/features/features.js.map +1 -1
  115. package/es/src/charts/features/featuresLegend.js +13 -5
  116. package/es/src/charts/features/featuresLegend.js.map +1 -1
  117. package/es/src/charts/features/plotPaint.js +51 -24
  118. package/es/src/charts/features/plotPaint.js.map +1 -1
  119. package/es/src/charts/features/shapeEmit.js +20 -2
  120. package/es/src/charts/features/shapeEmit.js.map +1 -1
  121. package/es/src/charts/index.js +1 -0
  122. package/es/src/charts/index.js.map +1 -1
  123. package/es/src/charts/pipeline/drillMorph.js +159 -0
  124. package/es/src/charts/pipeline/drillMorph.js.map +1 -0
  125. package/es/src/charts/pipeline/runChartDraw.js +35 -1
  126. package/es/src/charts/pipeline/runChartDraw.js.map +1 -1
  127. package/es/src/charts/pipeline/runVizPipeline.js +16 -1
  128. package/es/src/charts/pipeline/runVizPipeline.js.map +1 -1
  129. package/es/src/charts/pipeline/vizDrawPure.js +20 -0
  130. package/es/src/charts/pipeline/vizDrawPure.js.map +1 -1
  131. package/es/src/charts/viz/Viz.js +64 -8
  132. package/es/src/charts/viz/Viz.js.map +1 -1
  133. package/es/src/charts/viz/VizBase.js +29 -1
  134. package/es/src/charts/viz/VizBase.js.map +1 -1
  135. package/es/src/charts/viz/VizBaseConfig.js +9 -1
  136. package/es/src/charts/viz/VizBaseConfig.js.map +1 -1
  137. package/es/src/charts/viz/ordinalColor.js +2 -2
  138. package/es/src/charts/viz/ordinalColor.js.map +1 -1
  139. package/es/src/charts/viz/vizDefaults.js +27 -8
  140. package/es/src/charts/viz/vizDefaults.js.map +1 -1
  141. package/es/src/charts/viz/vizRender.js +54 -4
  142. package/es/src/charts/viz/vizRender.js.map +1 -1
  143. package/es/src/charts/viz/vizTypes.js.map +1 -1
  144. package/es/src/charts/viz/vizVisibility.js +145 -0
  145. package/es/src/charts/viz/vizVisibility.js.map +1 -0
  146. package/es/src/components/Axis/Axis.js +8 -8
  147. package/es/src/components/Axis/Axis.js.map +1 -1
  148. package/es/src/components/ColorScale/ColorScale.js +11 -11
  149. package/es/src/components/ColorScale/ColorScale.js.map +1 -1
  150. package/es/src/components/ColorScale/colorScaleScale.js +22 -10
  151. package/es/src/components/ColorScale/colorScaleScale.js.map +1 -1
  152. package/es/src/components/Legend/Legend.js +8 -5
  153. package/es/src/components/Legend/Legend.js.map +1 -1
  154. package/es/src/components/Legend/legendConfig.js +1 -1
  155. package/es/src/components/Legend/legendConfig.js.map +1 -1
  156. package/es/src/components/Legend/legendRender.js +29 -22
  157. package/es/src/components/Legend/legendRender.js.map +1 -1
  158. package/es/src/components/SizeLegend/SizeLegend.js +411 -0
  159. package/es/src/components/SizeLegend/SizeLegend.js.map +1 -0
  160. package/es/src/components/SizeLegend/sizeLegendLayout.js +285 -0
  161. package/es/src/components/SizeLegend/sizeLegendLayout.js.map +1 -0
  162. package/es/src/components/Timeline/timelineConfig.js +8 -4
  163. package/es/src/components/Timeline/timelineConfig.js.map +1 -1
  164. package/es/src/components/Timeline/timelineRender.js +1 -2
  165. package/es/src/components/Timeline/timelineRender.js.map +1 -1
  166. package/es/src/components/Tooltip.js +27 -7
  167. package/es/src/components/Tooltip.js.map +1 -1
  168. package/es/src/components/index.js +1 -0
  169. package/es/src/components/index.js.map +1 -1
  170. package/es/src/shapes/Box.js +4 -2
  171. package/es/src/shapes/Box.js.map +1 -1
  172. package/es/src/shapes/Shape.js +1 -1
  173. package/es/src/shapes/Shape.js.map +1 -1
  174. package/es/src/shapes/Whisker.js +3 -2
  175. package/es/src/shapes/Whisker.js.map +1 -1
  176. package/es/src/shapes/validateShapeConfig.js +141 -0
  177. package/es/src/shapes/validateShapeConfig.js.map +1 -0
  178. package/es/src/utils/BaseClass.js +134 -4
  179. package/es/src/utils/BaseClass.js.map +1 -1
  180. package/es/src/utils/D3plusConfig.js.map +1 -1
  181. package/es/src/utils/configDefault.js +17 -0
  182. package/es/src/utils/configDefault.js.map +1 -0
  183. package/es/src/utils/configPrep.js +2 -1
  184. package/es/src/utils/configPrep.js.map +1 -1
  185. package/es/src/utils/configWarnings.js +37 -0
  186. package/es/src/utils/configWarnings.js.map +1 -0
  187. package/es/src/utils/index.js +1 -0
  188. package/es/src/utils/index.js.map +1 -1
  189. package/package.json +11 -10
  190. package/types/index.d.ts +4 -4
  191. package/types/internal.d.ts +8 -1
  192. package/types/src/charts/BarChart/index.d.ts +2 -1
  193. package/types/src/charts/Geomap/applyLayout.d.ts +9 -1
  194. package/types/src/charts/Histogram/binData.d.ts +37 -0
  195. package/types/src/charts/Histogram/index.d.ts +14 -0
  196. package/types/src/charts/Network/applyLayout.d.ts +8 -0
  197. package/types/src/charts/Plot/discreteSpan.d.ts +9 -0
  198. package/types/src/charts/Plot/index.d.ts +39 -0
  199. package/types/src/charts/Plot/pipeline.d.ts +14 -0
  200. package/types/src/charts/Plot/sharedHover.d.ts +79 -0
  201. package/types/src/charts/Plot/sharedHoverScene.d.ts +11 -0
  202. package/types/src/charts/Plot/sharedTooltip.d.ts +26 -0
  203. package/types/src/charts/Plot/stackShareLabels.d.ts +21 -0
  204. package/types/src/charts/Plot/stackShareTooltip.d.ts +9 -0
  205. package/types/src/charts/Plot/trendLines.d.ts +70 -0
  206. package/types/src/charts/Plot/trendScene.d.ts +18 -0
  207. package/types/src/charts/Plot/trendTooltip.d.ts +19 -0
  208. package/types/src/charts/Rings/applyLayout.d.ts +9 -0
  209. package/types/src/charts/Rings/ringsSizing.d.ts +49 -0
  210. package/types/src/charts/StackedArea/index.d.ts +2 -1
  211. package/types/src/charts/definition/ChartDefinition.d.ts +30 -0
  212. package/types/src/charts/definition/makeChart.d.ts +2 -1
  213. package/types/src/charts/drawSteps/bottomRightControls.d.ts +26 -0
  214. package/types/src/charts/drawSteps/bottomRightControlsMarkup.d.ts +108 -0
  215. package/types/src/charts/features/emitHelpers.d.ts +8 -0
  216. package/types/src/charts/features/plotPaint.d.ts +25 -0
  217. package/types/src/charts/index.d.ts +1 -0
  218. package/types/src/charts/pipeline/drillMorph.d.ts +29 -0
  219. package/types/src/charts/pipeline/runVizPipeline.d.ts +8 -0
  220. package/types/src/charts/viz/Viz.d.ts +18 -1
  221. package/types/src/charts/viz/VizBase.d.ts +13 -0
  222. package/types/src/charts/viz/VizBaseConfig.d.ts +5 -1
  223. package/types/src/charts/viz/vizTypes.d.ts +147 -3
  224. package/types/src/charts/viz/vizVisibility.d.ts +34 -0
  225. package/types/src/components/Legend/legendRender.d.ts +8 -2
  226. package/types/src/components/SizeLegend/SizeLegend.d.ts +107 -0
  227. package/types/src/components/SizeLegend/sizeLegendLayout.d.ts +101 -0
  228. package/types/src/components/Tooltip.d.ts +18 -3
  229. package/types/src/components/index.d.ts +1 -0
  230. package/types/src/shapes/validateShapeConfig.d.ts +10 -0
  231. package/types/src/utils/BaseClass.d.ts +15 -1
  232. package/types/src/utils/D3plusConfig.d.ts +98 -0
  233. package/types/src/utils/configDefault.d.ts +11 -0
  234. package/types/src/utils/configWarnings.d.ts +28 -0
  235. package/types/src/utils/index.d.ts +2 -1
  236. package/umd/d3plus-core.full.js +7104 -2602
  237. package/umd/d3plus-core.full.js.map +1 -1
  238. package/umd/d3plus-core.full.min.js +2860 -1583
  239. package/umd/d3plus-core.js +3682 -441
  240. package/umd/d3plus-core.js.map +1 -1
  241. package/umd/d3plus-core.min.js +1656 -719
@@ -1,3 +1,11 @@
1
+ function _array_like_to_array(arr, len) {
2
+ if (len == null || len > arr.length) len = arr.length;
3
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
4
+ return arr2;
5
+ }
6
+ function _array_without_holes(arr) {
7
+ if (Array.isArray(arr)) return _array_like_to_array(arr);
8
+ }
1
9
  function _class_call_check(instance, Constructor) {
2
10
  if (!(instance instanceof Constructor)) {
3
11
  throw new TypeError("Cannot call a class as a function");
@@ -30,9 +38,88 @@ function _define_property(obj, key, value) {
30
38
  }
31
39
  return obj;
32
40
  }
41
+ function _instanceof(left, right) {
42
+ "@swc/helpers - instanceof";
43
+ if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
44
+ return !!right[Symbol.hasInstance](left);
45
+ } else {
46
+ return left instanceof right;
47
+ }
48
+ }
49
+ function _iterable_to_array(iter) {
50
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
51
+ }
52
+ function _non_iterable_spread() {
53
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
54
+ }
55
+ function _object_spread(target) {
56
+ for(var i = 1; i < arguments.length; i++){
57
+ var source = arguments[i] != null ? arguments[i] : {};
58
+ var ownKeys = Object.keys(source);
59
+ if (typeof Object.getOwnPropertySymbols === "function") {
60
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
61
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
62
+ }));
63
+ }
64
+ ownKeys.forEach(function(key) {
65
+ _define_property(target, key, source[key]);
66
+ });
67
+ }
68
+ return target;
69
+ }
70
+ function _object_without_properties(source, excluded) {
71
+ if (source == null) return {};
72
+ var target = {}, sourceKeys, key, i;
73
+ if (typeof Reflect !== "undefined" && Reflect.ownKeys) {
74
+ sourceKeys = Reflect.ownKeys(Object(source));
75
+ for(i = 0; i < sourceKeys.length; i++){
76
+ key = sourceKeys[i];
77
+ if (excluded.indexOf(key) >= 0) continue;
78
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
79
+ target[key] = source[key];
80
+ }
81
+ return target;
82
+ }
83
+ target = _object_without_properties_loose(source, excluded);
84
+ if (Object.getOwnPropertySymbols) {
85
+ sourceKeys = Object.getOwnPropertySymbols(source);
86
+ for(i = 0; i < sourceKeys.length; i++){
87
+ key = sourceKeys[i];
88
+ if (excluded.indexOf(key) >= 0) continue;
89
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
90
+ target[key] = source[key];
91
+ }
92
+ }
93
+ return target;
94
+ }
95
+ function _object_without_properties_loose(source, excluded) {
96
+ if (source == null) return {};
97
+ var target = {}, sourceKeys = Object.getOwnPropertyNames(source), key, i;
98
+ for(i = 0; i < sourceKeys.length; i++){
99
+ key = sourceKeys[i];
100
+ if (excluded.indexOf(key) >= 0) continue;
101
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
102
+ target[key] = source[key];
103
+ }
104
+ return target;
105
+ }
106
+ function _to_consumable_array(arr) {
107
+ return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
108
+ }
109
+ function _unsupported_iterable_to_array(o, minLen) {
110
+ if (!o) return;
111
+ if (typeof o === "string") return _array_like_to_array(o, minLen);
112
+ var n = Object.prototype.toString.call(o).slice(8, -1);
113
+ if (n === "Object" && o.constructor) n = o.constructor.name;
114
+ if (n === "Map" || n === "Set") return Array.from(n);
115
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
116
+ }
117
+ import { colorDefaults } from "@d3plus/color";
33
118
  import { assign, isObject } from "@d3plus/dom";
119
+ import { scaleOrdinal } from "d3-scale";
34
120
  import { findLocale, translateLocale as dictionaries } from "@d3plus/locales";
35
121
  import RESET from "./RESET.js";
122
+ import { isSharedConfig, warnUnknownConfig } from "./configWarnings.js";
36
123
  /**
37
124
  Recursive function that resets nested Object configs.
38
125
 
@@ -80,6 +167,36 @@ import RESET from "./RESET.js";
80
167
  ].includes(e);
81
168
  });
82
169
  }
170
+ /**
171
+ Merges color overrides into an instance and every BaseClass it owns (own
172
+ properties and `ctx` entries), so a Viz's legend, tooltip, axes, and
173
+ shapes pick them up too.
174
+ @private
175
+ */ function cascadeColorDefaults(obj, overrides, seen) {
176
+ if (seen.has(obj)) return;
177
+ seen.add(obj);
178
+ obj.schema.colorDefaults = _object_spread({}, obj.schema.colorDefaults, overrides);
179
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
180
+ try {
181
+ for(var _iterator = _to_consumable_array(Object.values(obj)).concat(_to_consumable_array(Object.values(obj.ctx)))[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
182
+ var child = _step.value;
183
+ if (_instanceof(child, BaseClass)) cascadeColorDefaults(child, overrides, seen);
184
+ }
185
+ } catch (err) {
186
+ _didIteratorError = true;
187
+ _iteratorError = err;
188
+ } finally{
189
+ try {
190
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
191
+ _iterator.return();
192
+ }
193
+ } finally{
194
+ if (_didIteratorError) {
195
+ throw _iteratorError;
196
+ }
197
+ }
198
+ }
199
+ }
83
200
  var BaseClass = /*#__PURE__*/ function() {
84
201
  "use strict";
85
202
  function BaseClass() {
@@ -99,6 +216,7 @@ var BaseClass = /*#__PURE__*/ function() {
99
216
  _define_property(this, "_configDefault", void 0);
100
217
  this.schema = {};
101
218
  this.ctx = {};
219
+ this.schema.colorDefaults = _object_spread({}, colorDefaults);
102
220
  this.schema.locale = "en-US";
103
221
  this.schema.on = {};
104
222
  this.schema.parent = {};
@@ -135,10 +253,8 @@ var BaseClass = /*#__PURE__*/ function() {
135
253
  nestedReset(v, this._configDefault[k]);
136
254
  this[k](v);
137
255
  }
138
- } else {
139
- // console.warn(
140
- // `${this.constructor.name}.config() received unknown property "${k}".`,
141
- // );
256
+ } else if (!isSharedConfig(_)) {
257
+ warnUnknownConfig("".concat(this.constructor.name, ".config()"), k);
142
258
  }
143
259
  }
144
260
  }
@@ -158,6 +274,20 @@ var BaseClass = /*#__PURE__*/ function() {
158
274
  return arguments.length ? (this.schema.locale = findLocale(_), this) : this.schema.locale;
159
275
  }
160
276
  },
277
+ {
278
+ key: "colorDefaults",
279
+ value: function colorDefaults(_) {
280
+ if (!arguments.length) return this.schema.colorDefaults;
281
+ var _ref = _ !== null && _ !== void 0 ? _ : {}, scale = _ref.scale, rest = _object_without_properties(_ref, [
282
+ "scale"
283
+ ]);
284
+ var next = _object_spread({}, rest);
285
+ if (Array.isArray(scale)) next.scale = scaleOrdinal().range(scale);
286
+ else if (scale) next.scale = scale;
287
+ cascadeColorDefaults(this, next, new WeakSet());
288
+ return this;
289
+ }
290
+ },
161
291
  {
162
292
  key: "on",
163
293
  value: function on(_, f) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/utils/BaseClass.ts"],"sourcesContent":["import {assign, isObject} from \"@d3plus/dom\";\nimport {\n findLocale,\n translateLocale as dictionaries,\n type TranslationStrings,\n} from \"@d3plus/locales\";\n\nimport type {D3plusConfig} from \"./D3plusConfig.js\";\nimport RESET from \"./RESET.js\";\n\n/**\n Recursive function that resets nested Object configs.\n\n @private\n*/\nfunction nestedReset(\n obj: Record<string, unknown>,\n defaults: Record<string, unknown> | undefined,\n): void {\n if (isObject(obj)) {\n for (const nestedKey in obj) {\n if (\n {}.hasOwnProperty.call(obj, nestedKey) &&\n !nestedKey.startsWith(\"_\")\n ) {\n const defaultValue =\n defaults && isObject(defaults) ? defaults[nestedKey] : undefined;\n if (obj[nestedKey] === RESET) {\n if (defaultValue) obj[nestedKey] = defaultValue;\n else delete obj[nestedKey];\n } else if (isObject(obj[nestedKey])) {\n nestedReset(\n obj[nestedKey] as Record<string, unknown>,\n defaultValue as Record<string, unknown> | undefined,\n );\n }\n }\n }\n }\n}\n\n/**\n finds all prototype methods of a class and it's parent classes\n @param obj\n @private\n*/\nfunction getAllMethods(obj: object): string[] {\n let props: string[] = [];\n do {\n props = props.concat(Object.getOwnPropertyNames(obj));\n obj = Object.getPrototypeOf(obj);\n } while (obj && obj !== Object.prototype);\n return props.filter(\n e =>\n e.indexOf(\"_\") !== 0 &&\n // Side-effect/lifecycle methods excluded from config reflection: invoking\n // them as no-arg getters would run real work. `measure` runs the full\n // axis-layout pass; `destroy` tears down the scene renderer (which defeats\n // keyed reconcile and forces a full remount on the next draw).\n ![\"config\", \"constructor\", \"destroy\", \"measure\", \"parent\", \"render\", \"renderMode\", \"renderScene\", \"toScene\"].includes(e),\n );\n}\n\n/**\n Provides shared configuration, event handling, and locale management inherited by all d3plus classes.\n*/\nexport default class BaseClass {\n /**\n Post-coercion fluent storage (`.sum(...)`, `.x(...)`, …). `any` is\n deliberate and load-bearing: `installFluent` coerces accessor/const\n fields into functions, so call sites invoke `schema.fill(d, i)` and\n index `schema.groupBy[i]`. It is NOT `D3plusConfig` (that describes\n the pre-coercion user input). Typing it as a coerced `ResolvedSchema`\n interface is the only way to drop the `any`; until then it stays.\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n schema: Record<string, any>;\n /** Chart-internal scratch (d3 layout instances, computed derived state). */\n ctx: Record<string, unknown>;\n\n _uuid: string;\n _configDefault?: D3plusConfig;\n\n /**\n Invoked when creating a new class instance, and sets any default parameters.\n @private\n*/\n constructor() {\n this.schema = {};\n this.ctx = {};\n this.schema.locale = \"en-US\";\n this.schema.on = {};\n this.schema.parent = {};\n this.schema.translate = (\n d: string,\n locale: string = this.schema.locale,\n ): string => {\n const dictionary: TranslationStrings | undefined = dictionaries[locale];\n const key = d as keyof TranslationStrings;\n return dictionary && dictionary[key] ? dictionary[key] : d;\n };\n this._uuid = crypto.randomUUID();\n }\n\n /**\n Methods that correspond to the key/value pairs and returns this class.\n*/\n config(): D3plusConfig;\n config(_: D3plusConfig): this;\n config(_?: D3plusConfig): D3plusConfig | this {\n if (!this._configDefault) {\n const config: D3plusConfig = {};\n getAllMethods(Object.getPrototypeOf(this)).forEach(k => {\n const v = (this as unknown as Record<string, () => unknown>)[k]();\n if (v !== this) config[k] = isObject(v) ? assign({}, v as Record<string, unknown>) : v;\n });\n this._configDefault = config;\n }\n\n if (arguments.length) {\n for (const k in _) {\n if ({}.hasOwnProperty.call(_, k)) {\n if (k in this) {\n const v = _![k];\n if (v === RESET) {\n if (k === \"on\")\n this.schema.on = this._configDefault![k];\n else\n (this as unknown as Record<string, (v: unknown) => unknown>)[k](\n this._configDefault![k],\n );\n } else {\n nestedReset(\n v as Record<string, unknown>,\n this._configDefault![k] as Record<string, unknown>,\n );\n (this as unknown as Record<string, (v: unknown) => unknown>)[k](\n v,\n );\n }\n } else {\n // console.warn(\n // `${this.constructor.name}.config() received unknown property \"${k}\".`,\n // );\n }\n }\n }\n return this;\n } else {\n const config: D3plusConfig = {};\n getAllMethods(Object.getPrototypeOf(this)).forEach(k => {\n config[k] = (this as unknown as Record<string, () => unknown>)[k]();\n });\n return config;\n }\n }\n\n /**\n The locale used for all text and number formatting. Supports the locales defined in [d3plus-format](https://github.com/d3plus/d3plus-format/blob/master/src/locale.js). The locale can be a complex Object, a locale code (like \"en-US\"), or a 2-digit language code (like \"en\"). If a 2-digit code is provided, the \"findLocale\" function is used to identify the most approximate locale.\n\n@example\n {\n separator: \"\",\n suffixes: [\"y\", \"z\", \"a\", \"f\", \"p\", \"n\", \"\\u00b5\", \"m\", \"\", \"k\", \"M\", \"B\", \"t\", \"q\", \"Q\", \"Z\", \"Y\"],\n grouping: [3],\n delimiters: {\n thousands: \",\",\n decimal: \".\"\n },\n currency: [\"$\", \"\"]\n }\n*/\n locale(): string;\n locale(_: string | object): this;\n locale(_?: string | object): string | this {\n return arguments.length\n ? ((this.schema.locale = findLocale(_ as string)), this)\n : this.schema.locale;\n }\n\n /**\n Event listener for the specified event *typenames*. Mirrors the core [d3-selection](https://github.com/d3/d3-selection#selection_on) behavior.\n\n@example <caption>By default, listeners apply globally to all objects, however, passing a namespace with the class name gives control over specific elements:</caption>\nnew Plot\n .on(\"click.Shape\", function(d) {\n console.log(\"data for shape clicked:\", d);\n })\n .on(\"click.Legend\", function(d) {\n console.log(\"data for legend clicked:\", d);\n })\n*/\n on(): Record<string, (...args: unknown[]) => unknown>;\n on(_: string): ((...args: unknown[]) => unknown) | undefined;\n on(_: string, f: (...args: unknown[]) => unknown): this;\n on(_: Record<string, (...args: unknown[]) => unknown>): this;\n on(\n _?: string | Record<string, (...args: unknown[]) => unknown>,\n f?: (...args: unknown[]) => unknown,\n ):\n | Record<string, (...args: unknown[]) => unknown>\n | ((...args: unknown[]) => unknown)\n | undefined\n | this {\n return arguments.length === 2\n ? ((this.schema.on[_ as string] = f!), this)\n : arguments.length\n ? typeof _ === \"string\"\n ? this.schema.on[_]\n : ((this.schema.on = Object.assign({}, this.schema.on, _)), this)\n : this.schema.on;\n }\n\n /**\n Parent config used by the wrapper.\n*/\n parent(): unknown;\n parent(_: unknown): this;\n parent(_?: unknown): unknown {\n return arguments.length\n ? ((this.schema.parent = _!), this)\n : this.schema.parent;\n }\n\n /**\n Defines how informational text strings should be displayed. By default, this function will try to find the string in question (which is the first argument provided to this function) inside of an internally managed translation Object. If you'd like to override to use custom text, simply pass this method your own custom formatting function.\n\n@example <caption>For example, if we wanted to only change the string \"Back\" and allow all other string to return in English:</caption>\n.translate(function(d) {\n return d === \"Back\" ? \"Get outta here\" : d;\n})\n*/\n translate(): (d: string, locale?: string) => string;\n translate(_: (d: string, locale?: string) => string): this;\n translate(\n _?: (d: string, locale?: string) => string,\n ): ((d: string, locale?: string) => string) | this {\n return arguments.length\n ? ((this.schema.translate = _!), this)\n : this.schema.translate;\n }\n\n /**\n Configuration object with key/value pairs applied as method calls on each shape.\n*/\n shapeConfig(): D3plusConfig;\n shapeConfig(_: D3plusConfig): this;\n shapeConfig(_?: D3plusConfig): D3plusConfig | this {\n return arguments.length\n ? ((this.schema.shapeConfig = assign(\n this.schema.shapeConfig ?? {},\n _!,\n ) as D3plusConfig),\n this)\n : (this.schema.shapeConfig as D3plusConfig);\n }\n}\n"],"names":["assign","isObject","findLocale","translateLocale","dictionaries","RESET","nestedReset","obj","defaults","nestedKey","hasOwnProperty","call","startsWith","defaultValue","undefined","getAllMethods","props","concat","Object","getOwnPropertyNames","getPrototypeOf","prototype","filter","e","indexOf","includes","BaseClass","schema","ctx","_uuid","_configDefault","locale","on","parent","translate","d","dictionary","key","crypto","randomUUID","config","_","forEach","k","v","arguments","length","f","shapeConfig"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAQA,MAAM,EAAEC,QAAQ,QAAO,cAAc;AAC7C,SACEC,UAAU,EACVC,mBAAmBC,YAAY,QAE1B,kBAAkB;AAGzB,OAAOC,WAAW,aAAa;AAE/B;;;;AAIA,GACA,SAASC,YACPC,GAA4B,EAC5BC,QAA6C;IAE7C,IAAIP,SAASM,MAAM;QACjB,IAAK,IAAME,aAAaF,IAAK;YAC3B,IACE,CAAA,CAAC,CAAA,EAAEG,cAAc,CAACC,IAAI,CAACJ,KAAKE,cAC5B,CAACA,UAAUG,UAAU,CAAC,MACtB;gBACA,IAAMC,eACJL,YAAYP,SAASO,YAAYA,QAAQ,CAACC,UAAU,GAAGK;gBACzD,IAAIP,GAAG,CAACE,UAAU,KAAKJ,OAAO;oBAC5B,IAAIQ,cAAcN,GAAG,CAACE,UAAU,GAAGI;yBAC9B,OAAON,GAAG,CAACE,UAAU;gBAC5B,OAAO,IAAIR,SAASM,GAAG,CAACE,UAAU,GAAG;oBACnCH,YACEC,GAAG,CAACE,UAAU,EACdI;gBAEJ;YACF;QACF;IACF;AACF;AAEA;;;;AAIA,GACA,SAASE,cAAcR,GAAW;IAChC,IAAIS,QAAkB,EAAE;IACxB,GAAG;QACDA,QAAQA,MAAMC,MAAM,CAACC,OAAOC,mBAAmB,CAACZ;QAChDA,MAAMW,OAAOE,cAAc,CAACb;IAC9B,QAASA,OAAOA,QAAQW,OAAOG,SAAS,EAAE;IAC1C,OAAOL,MAAMM,MAAM,CACjBC,SAAAA;eACEA,EAAEC,OAAO,CAAC,SAAS,KACnB,0EAA0E;QAC1E,sEAAsE;QACtE,2EAA2E;QAC3E,+DAA+D;QAC/D,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M,CAACK,EAAE,CAACS,EAAE,GAChB,CAAA,AAAC,IAAI,CAACd,MAAM,CAACK,EAAE,GAAGd,OAAOlB,MAAM,CAAC,CAAC,GAAG,IAAI,CAAC2B,MAAM,CAACK,EAAE,EAAES,IAAK,IAAI,AAAD,IAC/D,IAAI,CAACd,MAAM,CAACK,EAAE;YACtB;;;YAOAC,KAAAA;mBAAAA,SAAAA,OAAOQ,CAAW;gBAChB,OAAOI,UAAUC,MAAM,GAClB,CAAA,AAAC,IAAI,CAACnB,MAAM,CAACM,MAAM,GAAGQ,GAAK,IAAI,AAAD,IAC/B,IAAI,CAACd,MAAM,CAACM,MAAM;YACxB;;;YAYAC,KAAAA;mBAAAA,SAAAA,UACEO,CAA0C;gBAE1C,OAAOI,UAAUC,MAAM,GAClB,CAAA,AAAC,IAAI,CAACnB,MAAM,CAACO,SAAS,GAAGO,GAAK,IAAI,AAAD,IAClC,IAAI,CAACd,MAAM,CAACO,SAAS;YAC3B;;;YAOAc,KAAAA;mBAAAA,SAAAA,YAAYP,CAAgB;oBAGpB;gBAFN,OAAOI,UAAUC,MAAM,GAClB,CAAA,AAAC,IAAI,CAACnB,MAAM,CAACqB,WAAW,GAAGhD,QAC1B,2BAAA,IAAI,CAAC2B,MAAM,CAACqB,WAAW,cAAvB,sCAAA,2BAA2B,CAAC,GAC5BP,IAEF,IAAI,AAAD,IACF,IAAI,CAACd,MAAM,CAACqB,WAAW;YAC9B;;;WA7LmBtB;;AAHrB;;AAEA,GACA,SAAqBA,uBA8LpB"}
1
+ {"version":3,"sources":["../../../src/utils/BaseClass.ts"],"sourcesContent":["import {colorDefaults, type ColorDefaults} from \"@d3plus/color\";\nimport {assign, isObject} from \"@d3plus/dom\";\nimport {scaleOrdinal} from \"d3-scale\";\nimport {\n findLocale,\n translateLocale as dictionaries,\n type TranslationStrings,\n} from \"@d3plus/locales\";\n\nimport type {ColorDefaultsConfig, D3plusConfig} from \"./D3plusConfig.js\";\nimport RESET from \"./RESET.js\";\nimport {isSharedConfig, warnUnknownConfig} from \"./configWarnings.js\";\n\n/**\n Recursive function that resets nested Object configs.\n\n @private\n*/\nfunction nestedReset(\n obj: Record<string, unknown>,\n defaults: Record<string, unknown> | undefined,\n): void {\n if (isObject(obj)) {\n for (const nestedKey in obj) {\n if (\n {}.hasOwnProperty.call(obj, nestedKey) &&\n !nestedKey.startsWith(\"_\")\n ) {\n const defaultValue =\n defaults && isObject(defaults) ? defaults[nestedKey] : undefined;\n if (obj[nestedKey] === RESET) {\n if (defaultValue) obj[nestedKey] = defaultValue;\n else delete obj[nestedKey];\n } else if (isObject(obj[nestedKey])) {\n nestedReset(\n obj[nestedKey] as Record<string, unknown>,\n defaultValue as Record<string, unknown> | undefined,\n );\n }\n }\n }\n }\n}\n\n/**\n finds all prototype methods of a class and it's parent classes\n @param obj\n @private\n*/\nfunction getAllMethods(obj: object): string[] {\n let props: string[] = [];\n do {\n props = props.concat(Object.getOwnPropertyNames(obj));\n obj = Object.getPrototypeOf(obj);\n } while (obj && obj !== Object.prototype);\n return props.filter(\n e =>\n e.indexOf(\"_\") !== 0 &&\n // Side-effect/lifecycle methods excluded from config reflection: invoking\n // them as no-arg getters would run real work. `measure` runs the full\n // axis-layout pass; `destroy` tears down the scene renderer (which defeats\n // keyed reconcile and forces a full remount on the next draw).\n ![\"config\", \"constructor\", \"destroy\", \"measure\", \"parent\", \"render\", \"renderMode\", \"renderScene\", \"toScene\"].includes(e),\n );\n}\n\n/**\n Merges color overrides into an instance and every BaseClass it owns (own\n properties and `ctx` entries), so a Viz's legend, tooltip, axes, and\n shapes pick them up too.\n @private\n*/\nfunction cascadeColorDefaults(\n obj: BaseClass,\n overrides: Partial<ColorDefaults>,\n seen: WeakSet<BaseClass>,\n): void {\n if (seen.has(obj)) return;\n seen.add(obj);\n obj.schema.colorDefaults = {...obj.schema.colorDefaults, ...overrides};\n for (const child of [...Object.values(obj), ...Object.values(obj.ctx)]) {\n if (child instanceof BaseClass) cascadeColorDefaults(child, overrides, seen);\n }\n}\n\n/**\n Provides shared configuration, event handling, and locale management inherited by all d3plus classes.\n*/\nexport default class BaseClass {\n /**\n Post-coercion fluent storage (`.sum(...)`, `.x(...)`, …). `any` is\n deliberate and load-bearing: `installFluent` coerces accessor/const\n fields into functions, so call sites invoke `schema.fill(d, i)` and\n index `schema.groupBy[i]`. It is NOT `D3plusConfig` (that describes\n the pre-coercion user input). Typing it as a coerced `ResolvedSchema`\n interface is the only way to drop the `any`; until then it stays.\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n schema: Record<string, any>;\n /** Chart-internal scratch (d3 layout instances, computed derived state). */\n ctx: Record<string, unknown>;\n\n _uuid: string;\n _configDefault?: D3plusConfig;\n\n /**\n Invoked when creating a new class instance, and sets any default parameters.\n @private\n*/\n constructor() {\n this.schema = {};\n this.ctx = {};\n this.schema.colorDefaults = {...colorDefaults};\n this.schema.locale = \"en-US\";\n this.schema.on = {};\n this.schema.parent = {};\n this.schema.translate = (\n d: string,\n locale: string = this.schema.locale,\n ): string => {\n const dictionary: TranslationStrings | undefined = dictionaries[locale];\n const key = d as keyof TranslationStrings;\n return dictionary && dictionary[key] ? dictionary[key] : d;\n };\n this._uuid = crypto.randomUUID();\n }\n\n /**\n Methods that correspond to the key/value pairs and returns this class.\n*/\n config(): D3plusConfig;\n config(_: D3plusConfig): this;\n config(_?: D3plusConfig): D3plusConfig | this {\n if (!this._configDefault) {\n const config: D3plusConfig = {};\n getAllMethods(Object.getPrototypeOf(this)).forEach(k => {\n const v = (this as unknown as Record<string, () => unknown>)[k]();\n if (v !== this) config[k] = isObject(v) ? assign({}, v as Record<string, unknown>) : v;\n });\n this._configDefault = config;\n }\n\n if (arguments.length) {\n for (const k in _) {\n if ({}.hasOwnProperty.call(_, k)) {\n if (k in this) {\n const v = _![k];\n if (v === RESET) {\n if (k === \"on\")\n this.schema.on = this._configDefault![k];\n else\n (this as unknown as Record<string, (v: unknown) => unknown>)[k](\n this._configDefault![k],\n );\n } else {\n nestedReset(\n v as Record<string, unknown>,\n this._configDefault![k] as Record<string, unknown>,\n );\n (this as unknown as Record<string, (v: unknown) => unknown>)[k](\n v,\n );\n }\n } else if (!isSharedConfig(_)) {\n warnUnknownConfig(`${this.constructor.name}.config()`, k);\n }\n }\n }\n return this;\n } else {\n const config: D3plusConfig = {};\n getAllMethods(Object.getPrototypeOf(this)).forEach(k => {\n config[k] = (this as unknown as Record<string, () => unknown>)[k]();\n });\n return config;\n }\n }\n\n /**\n The locale used for all text and number formatting. Supports the locales defined in [d3plus-format](https://github.com/d3plus/d3plus-format/blob/master/src/locale.js). The locale can be a complex Object, a locale code (like \"en-US\"), or a 2-digit language code (like \"en\"). If a 2-digit code is provided, the \"findLocale\" function is used to identify the most approximate locale.\n\n@example\n {\n separator: \"\",\n suffixes: [\"y\", \"z\", \"a\", \"f\", \"p\", \"n\", \"\\u00b5\", \"m\", \"\", \"k\", \"M\", \"B\", \"t\", \"q\", \"Q\", \"Z\", \"Y\"],\n grouping: [3],\n delimiters: {\n thousands: \",\",\n decimal: \".\"\n },\n currency: [\"$\", \"\"]\n }\n*/\n locale(): string;\n locale(_: string | object): this;\n locale(_?: string | object): string | this {\n return arguments.length\n ? ((this.schema.locale = findLocale(_ as string)), this)\n : this.schema.locale;\n }\n\n /**\n Overrides the default colors used when assigning fills from data and choosing legible text colors: `dark` and `light` (the text colors picked for contrast against a background), `missing` (null/undefined values), `on`/`off` (`true`/`false` values), `sequential` (the anchor hue for magnitude ramps), and `scale` (the categorical palette, given as a d3 ordinal scale or an array of colors). Keys are merged into the current defaults, and a Viz passes its overrides down to the shapes and components it draws.\n\n@example\nnew Treemap()\n .colorDefaults({\n dark: \"#222\",\n light: \"#fff\",\n scale: [\"#1b9e77\", \"#d95f02\", \"#7570b3\"]\n })\n*/\n colorDefaults(): ColorDefaults;\n colorDefaults(_: ColorDefaultsConfig): this;\n colorDefaults(_?: ColorDefaultsConfig): ColorDefaults | this {\n if (!arguments.length) return this.schema.colorDefaults;\n const {scale, ...rest} = _ ?? {};\n const next: Partial<ColorDefaults> = {...rest};\n if (Array.isArray(scale)) next.scale = scaleOrdinal<string>().range(scale);\n else if (scale) next.scale = scale;\n cascadeColorDefaults(this, next, new WeakSet());\n return this;\n }\n\n /**\n Event listener for the specified event *typenames*. Mirrors the core [d3-selection](https://github.com/d3/d3-selection#selection_on) behavior.\n\n@example <caption>By default, listeners apply globally to all objects, however, passing a namespace with the class name gives control over specific elements:</caption>\nnew Plot\n .on(\"click.Shape\", function(d) {\n console.log(\"data for shape clicked:\", d);\n })\n .on(\"click.Legend\", function(d) {\n console.log(\"data for legend clicked:\", d);\n })\n*/\n on(): Record<string, (...args: unknown[]) => unknown>;\n on(_: string): ((...args: unknown[]) => unknown) | undefined;\n on(_: string, f: (...args: unknown[]) => unknown): this;\n on(_: Record<string, (...args: unknown[]) => unknown>): this;\n on(\n _?: string | Record<string, (...args: unknown[]) => unknown>,\n f?: (...args: unknown[]) => unknown,\n ):\n | Record<string, (...args: unknown[]) => unknown>\n | ((...args: unknown[]) => unknown)\n | undefined\n | this {\n return arguments.length === 2\n ? ((this.schema.on[_ as string] = f!), this)\n : arguments.length\n ? typeof _ === \"string\"\n ? this.schema.on[_]\n : ((this.schema.on = Object.assign({}, this.schema.on, _)), this)\n : this.schema.on;\n }\n\n /**\n Parent config used by the wrapper.\n*/\n parent(): unknown;\n parent(_: unknown): this;\n parent(_?: unknown): unknown {\n return arguments.length\n ? ((this.schema.parent = _!), this)\n : this.schema.parent;\n }\n\n /**\n Defines how informational text strings should be displayed. By default, this function will try to find the string in question (which is the first argument provided to this function) inside of an internally managed translation Object. If you'd like to override to use custom text, simply pass this method your own custom formatting function.\n\n@example <caption>For example, if we wanted to only change the string \"Back\" and allow all other string to return in English:</caption>\n.translate(function(d) {\n return d === \"Back\" ? \"Get outta here\" : d;\n})\n*/\n translate(): (d: string, locale?: string) => string;\n translate(_: (d: string, locale?: string) => string): this;\n translate(\n _?: (d: string, locale?: string) => string,\n ): ((d: string, locale?: string) => string) | this {\n return arguments.length\n ? ((this.schema.translate = _!), this)\n : this.schema.translate;\n }\n\n /**\n Configuration object with key/value pairs applied as method calls on each shape.\n*/\n shapeConfig(): D3plusConfig;\n shapeConfig(_: D3plusConfig): this;\n shapeConfig(_?: D3plusConfig): D3plusConfig | this {\n return arguments.length\n ? ((this.schema.shapeConfig = assign(\n this.schema.shapeConfig ?? {},\n _!,\n ) as D3plusConfig),\n this)\n : (this.schema.shapeConfig as D3plusConfig);\n }\n}\n"],"names":["colorDefaults","assign","isObject","scaleOrdinal","findLocale","translateLocale","dictionaries","RESET","isSharedConfig","warnUnknownConfig","nestedReset","obj","defaults","nestedKey","hasOwnProperty","call","startsWith","defaultValue","undefined","getAllMethods","props","concat","Object","getOwnPropertyNames","getPrototypeOf","prototype","filter","e","indexOf","includes","cascadeColorDefaults","overrides","seen","has","add","schema","values","ctx","child","BaseClass","_uuid","_configDefault","locale","on","parent","translate","d","dictionary","key","crypto","randomUUID","config","_","forEach","k","v","arguments","length","name","scale","rest","next","Array","isArray","range","WeakSet","f","shapeConfig"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAQA,aAAa,QAA2B,gBAAgB;AAChE,SAAQC,MAAM,EAAEC,QAAQ,QAAO,cAAc;AAC7C,SAAQC,YAAY,QAAO,WAAW;AACtC,SACEC,UAAU,EACVC,mBAAmBC,YAAY,QAE1B,kBAAkB;AAGzB,OAAOC,WAAW,aAAa;AAC/B,SAAQC,cAAc,EAAEC,iBAAiB,QAAO,sBAAsB;AAEtE;;;;AAIA,GACA,SAASC,YACPC,GAA4B,EAC5BC,QAA6C;IAE7C,IAAIV,SAASS,MAAM;QACjB,IAAK,IAAME,aAAaF,IAAK;YAC3B,IACE,CAAA,CAAC,CAAA,EAAEG,cAAc,CAACC,IAAI,CAACJ,KAAK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B;gBAFN,OAAOI,UAAUC,MAAM,GAClB,CAAA,AAAC,IAAI,CAACtB,MAAM,CAACgC,WAAW,GAAGlE,QAC1B,2BAAA,IAAI,CAACkC,MAAM,CAACgC,WAAW,cAAvB,sCAAA,2BAA2B,CAAC,GAC5Bf,IAEF,IAAI,AAAD,IACF,IAAI,CAACjB,MAAM,CAACgC,WAAW;YAC9B;;;WAnNmB5B;;AAHrB;;AAEA,GACA,SAAqBA,uBAoNpB"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/utils/D3plusConfig.ts"],"sourcesContent":["import type {DataPoint} from \"@d3plus/data\";\n\nimport type VizBase from \"../charts/viz/VizBase.js\";\nimport type {AccessorFn} from \"./AccessorFn.js\";\n\ntype Position = \"top\" | \"right\" | \"bottom\" | \"left\";\n\ntype DataPointAccessor<T> = string | ((d: DataPoint) => T);\n\n/** A config value that is either a constant or a `(datum, index)` accessor. */\ntype Accessor<T> = T | ((d: DataPoint, i?: number) => T);\n\ntype AxisScale =\n | \"auto\"\n | \"band\"\n | \"diverging\"\n | \"divergingLog\"\n | \"divergingPow\"\n | \"divergingSqrt\"\n | \"divergingSymlog\"\n | \"identity\"\n | \"implicit\"\n | \"jenks\"\n | \"linear\"\n | \"log\"\n | \"ordinal\"\n | \"point\"\n | \"pow\"\n | \"quantile\"\n | \"quantize\"\n | \"radial\"\n | \"sequential\"\n | \"sequentialLog\"\n | \"sequentialPow\"\n | \"sequentialQuantile\"\n | \"sequentialSqrt\"\n | \"sequentialSymlog\"\n | \"sqrt\"\n | \"symlog\"\n | \"threshold\"\n | \"time\"\n | \"utc\";\n\nexport interface AxisConfig {\n barConfig?: Record<string, string | number>;\n /** Grid values of the axis. */\n grid?: unknown[];\n gridConfig?: Record<string, string | number>;\n /** Grid size of the axis. */\n gridSize?: number;\n label?: string;\n /** Visible tick labels of the axis. */\n labels?: unknown[];\n labelOffset?: false | number;\n /**\n Exact size of the space that contains the axis tick labels and title.\n Labels that need more room overflow outward instead of moving the axis\n line; zooming pins a rescaled axis this way so it doesn't shift.\n */\n fixedSize?: number;\n /** Maximum size allowed for the space that contains the axis tick labels and title. */\n maxSize?: number;\n /** Minimum size alloted for the space that contains the axis tick labels and title. */\n minSize?: number;\n /**\n Scale range (in pixels) of the axis. The given array must have 2 values,\n but one may be `undefined` to allow the default behavior for that value.\n */\n range?: (number | undefined)[];\n /** Scale of the axis. */\n scale?: AxisScale;\n /** Tick formatter. */\n tickFormat?: (d: number | string) => string | number;\n /** Tick values of the axis. */\n ticks?: unknown[];\n /**\n Whether the domain's min and max are always shown as ticks, even when\n they aren't among the scale's own \"nice\" tick values (the nearest nice\n tick is dropped when it would crowd them). Defaults to `true`; zooming\n turns it off so a rescaled axis shows only nice values.\n */\n domainTicks?: boolean;\n tickSize?: number;\n /**\n Defines a custom locale object to be used in time scales. Must include\n `dateTime`, `date`, `time`, `periods`, `days`, `shortDays`, `months`, and\n `shortMonths` (see\n [d3-time-format](https://github.com/d3/d3-time-format/blob/master/README.md#timeFormatLocale)).\n */\n timeLocale?: Record<string, unknown>;\n /** Title of the axis. */\n title?: string;\n}\n\nexport interface TooltipConfig {\n /** The inner HTML content of the arrow element, empty by default. */\n arrow?: ((d: DataPoint) => string) | string;\n /** The background color accessor for each tooltip. */\n background?: ((d: DataPoint) => string) | string;\n /** The border accessor for each tooltip. */\n border?: ((d: DataPoint) => string) | string;\n /** The border-radius accessor for each tooltip. */\n borderRadius?: ((d: DataPoint) => string) | string;\n /** The footer content accessor for each tooltip. */\n footer?: ((d: DataPoint) => string) | string;\n /** The max-width accessor for each tooltip. */\n maxWidth?: ((d: DataPoint) => string | number) | string | number;\n /** The min-width accessor for each tooltip. */\n minWidth?: ((d: DataPoint) => string | number) | string | number;\n /** The pixel offset between the tooltip and its anchor point. */\n offset?: ((d: DataPoint) => number) | number;\n /** The inner padding of each tooltip. */\n padding?: ((d: DataPoint) => string | number) | string | number;\n title?: ((d: DataPoint) => string) | string;\n body?: ((d: DataPoint) => string) | string;\n thead?:\n | ((d: DataPoint) => [string, string][])\n | Array<\n Array<\n | ((d: DataPoint, i?: number, x?: {share: number}) => string)\n | string\n >\n >;\n tbody?:\n | ((d: DataPoint) => [string, string][])\n | Array<\n Array<\n | ((d: DataPoint, i?: number, x?: {share: number}) => string)\n | string\n >\n >;\n}\n\nexport interface TextBoxConfig {\n /** The text content for each box. */\n text?: Accessor<string>;\n /** The font color as an accessor function or static string. Inferred from the DOM selection by default. */\n fontColor?: Accessor<string>;\n /** The font size in pixels. Inferred from the DOM selection by default. */\n fontSize?: Accessor<number>;\n /**\n The font-family to use: a font name, a comma-separated list of fallbacks,\n an array of fallbacks, or an accessor returning a string or array. The\n first available font on the client is used.\n */\n fontFamily?: Accessor<string | string[]>;\n /** The font weight. Inferred from the DOM selection by default. */\n fontWeight?: Accessor<string | number>;\n /** The minimum font size in pixels, used when dynamically resizing fonts. */\n fontMin?: number;\n /** The maximum font size in pixels, used when dynamically resizing fonts. */\n fontMax?: number;\n /** Toggles font resizing — a static boolean, or an accessor returning a boolean. */\n fontResize?: Accessor<boolean>;\n /** The font opacity as an accessor function or static number between 0 and 1. */\n fontOpacity?: Accessor<number>;\n /** The font stroke color for the rendered text. */\n fontStroke?: Accessor<string>;\n /** The font stroke width for the rendered text. */\n fontStrokeWidth?: Accessor<number>;\n /** The line height, which is 1.2 times the font size by default. */\n lineHeight?: Accessor<number>;\n /** Restricts the maximum number of lines to wrap onto; null (unlimited) by default. */\n maxLines?: Accessor<number | null>;\n /** Whether text is allowed to overflow its bounding box. */\n overflow?: Accessor<boolean>;\n /**\n Handles truncated lines, returning the new line value. Passed the line's\n text and number; by default appends an ellipsis to every line except a\n first word that cannot fit (which returns \"\").\n */\n ellipsis?: (text: string, line: number) => string;\n /** The padding as a CSS shorthand string or number. Defaults to 0. */\n padding?: Accessor<string | number>;\n /** The anchor point around which to rotate the text box. */\n rotateAnchor?: Accessor<[number, number]>;\n /** The word split function: given a string, returns it split into an array of words. */\n split?: (text: string) => string[];\n /** The width for each text box. */\n width?: Accessor<number>;\n /** The height for each text box. */\n height?: Accessor<number>;\n /** The x position (left edge) for each text box. */\n x?: Accessor<number>;\n /** The y position (top edge) for each text box. */\n y?: Accessor<number>;\n}\n\nexport interface TimelineConfig {\n /** Brush event filter. */\n brushFilter?: () => boolean;\n /**\n The minimum number of ticks that can be highlighted when using \"ticks\"\n `buttonBehavior`. Helpful for x/y plots where selecting fewer than 2 time\n periods is undesirable.\n */\n brushMin?: number;\n /** Toggles the horizontal alignment of the button timeline. */\n buttonAlign?: \"start\" | \"middle\" | \"end\";\n /** Toggles the style of the timeline. */\n buttonBehavior?: \"auto\" | \"buttons\" | \"ticks\";\n /** Button height. */\n buttonHeight?: number;\n /** Button padding. */\n buttonPadding?: number;\n /** Handle style. */\n handleConfig?: Record<string, unknown>;\n /** Handle size. */\n handleSize?: number;\n /**\n Determines the visibility of the play button to the left of the timeline,\n which cycles through the available periods at a rate set by `playButtonInterval`.\n */\n playButton?: boolean;\n /**\n The interval, in milliseconds, between periods when cycling via the play\n button. Used only when the chart's `duration` is 0 (no transition);\n otherwise playback steps once per `duration` so each step animates in full.\n */\n playButtonInterval?: number;\n /** The current selection. Defaults to the most recent period in the timeline. */\n selection?: (Date | number)[] | Date | number | false;\n /** Toggles the snapping value. */\n snapping?: boolean;\n}\n\nexport interface LegendConfig {\n /** The active method for all shapes. */\n active?: ((d: DataPoint, i?: number) => boolean) | false;\n /** The hover method for all shapes. */\n hover?: ((d: DataPoint, i?: number) => boolean) | false;\n /** The shape type used for each legend entry. */\n shape?: Accessor<string>;\n}\n\nexport interface ColorScaleConfig {\n /**\n For a linear scale, the `[min, max]` values used by the color scale; values\n outside this range map to the nearest color.\n */\n domain?: number[];\n /**\n Formats the label for each bucket in a bucket-type scale (\"jenks\",\n \"quantile\", …). Passed the bucket's start value, its index, the full\n bucket array, and every data value used to build the buckets.\n */\n bucketFormat?: (\n start: number,\n i: number,\n buckets: number[],\n values: number[],\n ) => string;\n /** Given a bucket's minimum and maximum values, returns the full label. */\n bucketJoiner?: (min: string, max: string) => string;\n}\n\nexport interface D3plusConfig {\n /** Data array or URL string to load data from. */\n data?: DataPoint[] | string;\n /** Locale code used for text and number formatting. */\n locale?: string;\n\n /** The active callback function for highlighting shapes. */\n active?: ((d: DataPoint, i: number) => boolean) | false | null;\n /** Custom aggregation functions keyed by data property. */\n aggs?: {[k: string]: (d: DataPoint[]) => unknown};\n /** Hides the SVG from assistive technology when true (`aria-hidden`). */\n ariaHidden?: boolean;\n /**\n Text (rendered as HTML — any valid HTML string works, including anchor\n links) shown in the chart's bottom-right corner, most often a map tile\n credit. `false` (the default) shows nothing. A credit wider than half\n the chart area collapses to a small \"ⓘ\" badge that expands on hover,\n focus, or click.\n */\n attribution?: string | boolean;\n /**\n Overrides the \"ⓘ\" badge a long attribution collapses to, which\n otherwise renders as an inline SVG. A string is used as the badge's\n raw HTML content; a mount function, `(el: HTMLElement) => void | (() =>\n void)`, is called once with the badge's reserved element so a live\n component (a React tree via `createRoot(el).render(...)`, or anything\n else imperative) can be mounted into it — return a cleanup function if\n there's teardown to do.\n */\n attributionIcon?: string | ((el: HTMLElement) => void | (() => void));\n /** CSS key/value pairs used to style the attribution text. */\n attributionStyle?: Record<string, unknown>;\n /** Additional CSS class name(s) applied to the back button, alongside the fixed `back-control` class. */\n backControlClassName?: string;\n /** Padding between bars in pixels. */\n barPadding?: number;\n /** The baseline for the x/y plot. */\n baseline?: number;\n /** Whether to cache the processed data between renders. */\n cache?: boolean;\n /** Treat a discrete color field as ordered: color it with a single-hue light→dark ramp instead of nominal categorical hues. */\n colorOrdinal?: boolean;\n /** Color scale key or custom color function. */\n colorScale?: string | ((d: number) => string);\n /** Configuration for the color scale component. */\n colorScaleConfig?: {\n axisConfig?: AxisConfig;\n centered?: boolean;\n colors?: string[];\n colorMin?: string;\n colorMid?: string;\n colorMax?: string;\n scale?: AxisScale;\n };\n /** Whether the color scale uses the visualization's internal padding when positioning, or an accessor receiving the viz. */\n colorScalePadding?: boolean | ((viz: VizBase) => boolean);\n /** Position of the color scale, `false` to hide it, or an accessor returning either. */\n colorScalePosition?: false | Position | (() => false | Position);\n /** Column key for matrix-style layouts. */\n column?: string;\n /**\n The confidence interval as `[lower, upper]` bounds — each given as an\n accessor function or a static data key (e.g. `[\"lci\", \"hci\"]`), or `false`\n to disable.\n */\n confidence?:\n | [\n string | ((d: DataPoint, i: number) => number),\n string | ((d: DataPoint, i: number) => number),\n ]\n | false;\n /** Maximum number of data points to render before downsampling. */\n dataCutoff?: number;\n /** Active depth level for nested groupings. */\n depth?: number;\n /** Sets orientation of main category axis. */\n discrete?: \"x\" | \"y\";\n /** Default duration of transitions, in milliseconds. */\n duration?: number;\n /** Predicate filtering which data points are included, or false to disable. */\n filter?: ((d: DataPoint, i: number) => boolean) | false;\n /** Allows removing specific geographies from topojson file to improve zoom. */\n fitFilter?:\n | number\n | string\n | ((d: Record<string, unknown>) => boolean);\n /** Grouping key(s) or accessor function(s). */\n groupBy?:\n | string\n | string[]\n | ((d: DataPoint) => string | number)\n | ((d: DataPoint) => string | number)[];\n /** Padding between groups of bars in pixels. */\n groupPadding?: number;\n /** Overall height of the visualization in pixels. */\n height?: number;\n /** Color for legend shapes whose grouping is hidden (via legend click), or a `(datum, index)` accessor. */\n hiddenColor?: string | ((d: DataPoint, i: number) => string);\n /** Opacity for legend labels whose grouping is hidden (via legend click), or a `(datum, index)` accessor. */\n hiddenOpacity?: number | ((d: DataPoint, i: number) => number);\n /** The hover callback function for highlighting shapes on mouseover. */\n hover?: ((d: DataPoint, i: number) => boolean) | false | null;\n /** Persistently emphasizes matching marks (keep color) and grays the rest. */\n highlight?: ((d: DataPoint, i: number) => boolean) | false | null;\n /** Label accessor for shapes. */\n label?: string | string[] | false | AccessorFn;\n /**\n Controls legend visibility. Pass `false` to hide it, `true` to always\n show it, or a `(config, data) => boolean` accessor to decide dynamically\n — the chart defaults use an accessor to auto-hide the legend when it\n would be redundant.\n */\n legend?: boolean | ((config: D3plusConfig, arr: DataPoint[]) => boolean);\n /** Configuration for the legend component. */\n legendConfig?: {\n label?: DataPointAccessor<string>;\n shapeConfig?: Record<string, string | number>;\n };\n /** Inverts legend click behavior (click hides / shift-click solos, or the reverse), or an accessor receiving the viz. */\n legendFilterInvert?: boolean | ((viz: VizBase) => boolean);\n /** Whether the legend uses the visualization's internal padding when positioning, or an accessor receiving the viz. */\n legendPadding?: boolean | ((viz: VizBase) => boolean);\n /** Position of the legend, or an accessor returning it. */\n legendPosition?: Position | (() => Position);\n /** Custom sort comparator for legend items. */\n legendSort?: (a: DataPoint, b: DataPoint) => number;\n /** Tooltip configuration for legend items. */\n legendTooltip?: TooltipConfig;\n /** Whether to show labels on line charts. */\n lineLabels?: boolean;\n /** Whether to show the loading message. */\n loadingMessage?: boolean;\n /** Custom HTML content for the loading indicator, or a function receiving the viz instance. */\n loadingHTML?: string | ((viz: VizBase) => string);\n /** Metric key for the visualization. */\n metric?: string;\n /** Shows a small overview + draggable-viewport minimap underneath the zoom controls once the chart is zoomed in. On by default whenever `zoom` is enabled. */\n minimap?: boolean;\n /** Additional CSS class name(s) applied to the minimap, alongside its fixed `d3plus-minimap`/etc. classes. */\n minimapClassName?: string;\n /** Custom HTML content shown when no data is supplied, or a function receiving the viz instance. */\n noDataHTML?: string | ((viz: VizBase) => string);\n /**\n Ocean color for geomaps (any CSS value including 'transparent'), or a\n `{light, dark}` pair chosen by the chart's backdrop. Defaults to the\n default basemap's own water colors.\n */\n ocean?: string | {light: string; dark: string};\n /** Event listeners keyed by event name. */\n on?: Record<string, (event: Event) => void>;\n /** Coordinate accessor for point-based geomaps. */\n point?: (d: DataPoint) => number[];\n /** Point size accessor for geomaps. */\n pointSize?: string | ((d: DataPoint) => number);\n /** Minimum point size for geomaps. */\n pointSizeMin?: number;\n /** Maximum point size for geomaps. */\n pointSizeMax?: number;\n /** Map projection name or function. */\n projection?: string | ((x: number, y: number) => [number, number]);\n /** Outer padding between the visualization edge and map shapes. */\n projectionPadding?: number | string;\n /** Rotation offset for the map projection center. */\n projectionRotate?: [number, number];\n /** Row key for matrix-style layouts. */\n row?: string;\n /** Scrollable container selector for tooltip positioning. */\n scrollContainer?: string | Window;\n /** Shows a top-left search button that expands into an input; typing highlights shapes whose label matches. On by default for every chart. */\n search?: boolean;\n /** Resolves the string the search box matches its typed term against, for a given datum. Defaults to the mark's resolved on-screen label. */\n searchAccessor?: (d: DataPoint, i: number) => string;\n /** Additional CSS class name(s) applied to the search toggle button and input, alongside the fixed `search-control` classes. */\n searchControlClassName?: string;\n /** Configuration for shape rendering. */\n shapeConfig?: {\n duration?: number;\n [key: string]: unknown;\n };\n /**\n A [sort comparator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort)\n that receives each shape class (e.g. \"Circle\", \"Line\") as its arguments.\n Shapes are drawn in groups by type, so this defines the layering order for\n all shapes of a given type.\n */\n shapeSort?: (a: string, b: string) => number;\n /** Size accessor key. */\n size?: string;\n /** Whether to stack series. */\n stacked?: boolean;\n /**\n Vertical offset applied to stacked series. One of `\"diverging\"`\n (default — positive and negative values split around zero), `\"none\"`,\n `\"expand\"` (normalize each stack to 100%), `\"silhouette\"` (streamgraph),\n or `\"wiggle\"` (minimize slope changes); or a custom offset function.\n */\n stackOffset?: string | ((series: number[][][], order: number[]) => void);\n /**\n Order of stacked series, from the bottom of the stack upward. Accepts a\n named order (`\"descending\"` [default] / `\"ascending\"` by summed value,\n `\"key\"` / `\"keyReverse\"` alphabetically, `\"none\"` / `\"data\"` for input\n order, or d3's `\"insideOut\"` / `\"appearance\"` / `\"reverse\"`), an Array of\n series keys for an explicit order, a value accessor, or a `{value, order}`\n config to rank series by an aggregate of any data field.\n */\n stackOrder?:\n | string\n | string[]\n | {value: string | ((d: DataPoint) => unknown); order?: \"ascending\" | \"descending\"}\n | ((d: DataPoint) => unknown);\n /** Subtitle text, or an accessor returning it. */\n subtitle?: string | ((data: DataPoint[]) => string);\n /** Whether the subtitle uses the visualization's internal padding when positioning, or an accessor receiving the viz. */\n subtitlePadding?: boolean | ((viz: VizBase) => boolean);\n /** Value accessor for treemaps and aggregation. */\n sum?: DataPointAccessor<number>;\n /** Accessible description applied to the root SVG (`<desc>`). */\n svgDesc?: string;\n /** Accessible title applied to the root SVG (`<title>`). */\n svgTitle?: string;\n /** Enables the top-left table-view toggle button, which swaps the chart for a static, scrollable `<table>` of its data. On by default for every chart. */\n tableView?: boolean;\n /** Additional CSS class name(s) applied to the `<table>` element rendered while in table view, alongside the fixed `d3plus-table-view-table` class. */\n tableViewClassName?: string;\n /** Additional CSS class name(s) applied to the table-view toggle button, alongside the fixed `table-view-control`/`table-view-toggle` classes. */\n tableViewControlClassName?: string;\n /** CSS key/value pairs styling the table-view toggle button. `false` removes all default styling. */\n tableViewControlStyle?: Record<string, unknown> | false;\n /** CSS key/value pairs styling the table-view toggle button while active (showing the data table). `false` removes all default styling. */\n tableViewControlStyleActive?: Record<string, unknown> | false;\n /** CSS key/value pairs styling the table-view toggle button on hover. `false` removes all default styling. */\n tableViewControlStyleHover?: Record<string, unknown> | false;\n /** Whether the data table shows a \"download CSV\" button, exporting its full (sorted, unpaginated) rows. On by default. */\n tableViewDownload?: boolean;\n /** Rows per page while in table view. `false` (or any non-positive number) disables pagination and shows every row on one page. */\n tableViewPageSize?: number | false;\n /** Whether the data table's column headers are clickable to sort (toggling asc/desc). On by default. */\n tableViewSort?: boolean;\n /** Threshold value for grouping small slices. */\n threshold?: number;\n /** Label for the threshold group, or a `(datum, index)` accessor. */\n thresholdName?: string | ((d: DataPoint, i: number) => string);\n /**\n URL template for XYZ map tiles, with `{z}`, `{x}`, `{y}` (and optional\n `{s}` subdomain) placeholders — or a `{light, dark}` pair, chosen by the\n chart's backdrop. Defaults to Esri's Light Gray and Dark Gray Canvas.\n */\n tileUrl?: string | {light: string; dark: string};\n /** Whether to show map tiles. */\n tiles?: boolean;\n /** Time key for temporal data. */\n time?: string;\n /** Predicate filtering which time slices are shown, or false to disable. */\n timeFilter?: ((d: DataPoint, i: number) => boolean) | false;\n /** Whether to show the timeline component. */\n timeline?: boolean;\n /** Whether the timeline uses the visualization's internal padding when positioning, or an accessor receiving the viz. */\n timelinePadding?: boolean | ((viz: VizBase) => boolean);\n /** Chart title or title accessor function. */\n title?: string | ((data: DataPoint[]) => string);\n /** CSS style configuration for the title. */\n titleConfig?: Record<string, string | number>;\n /** Whether the title uses the visualization's internal padding when positioning, or an accessor receiving the viz. */\n titlePadding?: boolean | ((viz: VizBase) => boolean);\n /** Whether to show tooltips, or a `(datum, index)` accessor deciding per mark. */\n tooltip?: boolean | ((d: DataPoint, i: number) => boolean);\n /** Configuration for the tooltip component. */\n tooltipConfig?: TooltipConfig;\n /** Path or object for the topojson data. */\n topojson?: string | object;\n /** CSS color to fill the map shapes. */\n topojsonFill?: string;\n /** Accessor function for topojson feature IDs. */\n topojsonId?: (obj: Record<string, unknown>) => string;\n /** Whether the total uses the visualization's internal padding when positioning, or an accessor receiving the viz. */\n totalPadding?: boolean | ((viz: VizBase) => boolean);\n /** Value accessor for the visualization. */\n value?: DataPointAccessor<number>;\n /** Overall width of the visualization in pixels. */\n width?: number;\n /** Key, index, or accessor function for x-axis values. */\n x?: string | number | ((d: DataPoint, i: number) => unknown);\n /** Configuration for the x-axis. */\n xConfig?: AxisConfig;\n /** The x domain as an array. If either value is undefined, it is calculated from the data. */\n xDomain?: (number | Date)[];\n /** The x2 domain as an array. If either value is undefined, it is calculated from the data. */\n x2Domain?: (number | Date)[];\n /** Custom sort function for x-axis values. */\n xSort?: (a: DataPoint, b: DataPoint) => number;\n /** Defines a custom sorting comparator function for discrete x2 axes. */\n x2Sort?: (a: DataPoint, b: DataPoint) => number;\n /** Key, index, or accessor function for y-axis values. */\n y?: string | number | ((d: DataPoint, i: number) => unknown);\n /** Configuration for the y-axis. */\n yConfig?: AxisConfig;\n /** The y domain as an array. If either value is undefined, it is calculated from the data. */\n yDomain?: (number | Date)[];\n /** The y2 domain as an array. If either value is undefined, it is calculated from the data. */\n y2Domain?: (number | Date)[];\n /** Custom sort function for y-axis values. */\n ySort?: (a: DataPoint, b: DataPoint) => number;\n /** Defines a custom sorting comparator function for discrete y2 axes. */\n y2Sort?: (a: DataPoint, b: DataPoint) => number;\n /** Enables pan/zoom with zoom-control buttons. On by default for every chart. */\n zoom?: boolean;\n /** Additional CSS class name(s) applied to each zoom control button, alongside the fixed `zoom-control`/`zoom-in`/etc. classes. */\n zoomControlClassName?: string;\n /**\n Overrides one or more of the four built-in zoom-control icons (`zoomIn`,\n `zoomOut`, `zoomReset`, `zoomBrush`), which otherwise render as inline\n SVGs. Each value is either raw HTML — used as that button's content — or\n a mount function, `(el: HTMLElement) => void | (() => void)`, called\n once with the button's reserved icon slot so a live component (a React\n tree via `createRoot(el).render(...)`, or anything else imperative) can\n be mounted into it — return a cleanup function if there's teardown to do.\n */\n zoomControlIcons?: Partial<\n Record<\n \"zoomIn\" | \"zoomOut\" | \"zoomReset\" | \"zoomBrush\",\n string | ((el: HTMLElement) => void | (() => void))\n >\n >;\n /** Multiplier applied to programmatic zoom steps. */\n zoomFactor?: number;\n /** Maximum zoom scale factor. Defaults to the scale at which the smallest shape fills the chart area. */\n zoomMax?: number;\n /** Whether panning (drag) is enabled while zoomed. */\n zoomPan?: boolean;\n /**\n Whether the mouse wheel (and one-finger touch) zooms. `\"modifier\"` (the\n default) leaves page scrolling alone: only\n Ctrl/⌘ + wheel or a trackpad/two-finger pinch zooms, and one finger pans\n only once zoomed in. `true` zooms on any wheel; `false` never does.\n */\n zoomScroll?: boolean | \"modifier\";\n\n /** Allows additional custom properties. */\n [key: string]: unknown;\n}\n"],"names":[],"mappings":"AAgQA,WAmVC"}
1
+ {"version":3,"sources":["../../../src/utils/D3plusConfig.ts"],"sourcesContent":["import type {ColorDefaults} from \"@d3plus/color\";\nimport type {DataPoint} from \"@d3plus/data\";\n\nimport type VizBase from \"../charts/viz/VizBase.js\";\nimport type {AccessorFn} from \"./AccessorFn.js\";\nimport type {\n SizeLegendLineConfig,\n SizeLegendShapeConfig,\n SizeLegendTextConfig,\n} from \"../components/SizeLegend/SizeLegend.js\";\nimport type {SizeLegendScale, SizeLegendSize} from \"../components/SizeLegend/sizeLegendLayout.js\";\n\ntype Position = \"top\" | \"right\" | \"bottom\" | \"left\";\n\ntype DataPointAccessor<T> = string | ((d: DataPoint) => T);\n\n/** A config value that is either a constant or a `(datum, index)` accessor. */\ntype Accessor<T> = T | ((d: DataPoint, i?: number) => T);\n\ntype AxisScale =\n | \"auto\"\n | \"band\"\n | \"diverging\"\n | \"divergingLog\"\n | \"divergingPow\"\n | \"divergingSqrt\"\n | \"divergingSymlog\"\n | \"identity\"\n | \"implicit\"\n | \"jenks\"\n | \"linear\"\n | \"log\"\n | \"ordinal\"\n | \"point\"\n | \"pow\"\n | \"quantile\"\n | \"quantize\"\n | \"radial\"\n | \"sequential\"\n | \"sequentialLog\"\n | \"sequentialPow\"\n | \"sequentialQuantile\"\n | \"sequentialSqrt\"\n | \"sequentialSymlog\"\n | \"sqrt\"\n | \"symlog\"\n | \"threshold\"\n | \"time\"\n | \"utc\";\n\nexport interface AxisConfig {\n barConfig?: Record<string, string | number>;\n /** Grid values of the axis. */\n grid?: unknown[];\n gridConfig?: Record<string, string | number>;\n /** Grid size of the axis. */\n gridSize?: number;\n label?: string;\n /** Visible tick labels of the axis. */\n labels?: unknown[];\n labelOffset?: false | number;\n /**\n Exact size of the space that contains the axis tick labels and title.\n Labels that need more room overflow outward instead of moving the axis\n line; zooming pins a rescaled axis this way so it doesn't shift.\n */\n fixedSize?: number;\n /** Maximum size allowed for the space that contains the axis tick labels and title. */\n maxSize?: number;\n /** Minimum size alloted for the space that contains the axis tick labels and title. */\n minSize?: number;\n /**\n Scale range (in pixels) of the axis. The given array must have 2 values,\n but one may be `undefined` to allow the default behavior for that value.\n */\n range?: (number | undefined)[];\n /** Scale of the axis. */\n scale?: AxisScale;\n /** Tick formatter. */\n tickFormat?: (d: number | string) => string | number;\n /** Tick values of the axis. */\n ticks?: unknown[];\n /**\n Whether the domain's min and max are always shown as ticks, even when\n they aren't among the scale's own \"nice\" tick values (the nearest nice\n tick is dropped when it would crowd them). Defaults to `true`; zooming\n turns it off so a rescaled axis shows only nice values.\n */\n domainTicks?: boolean;\n tickSize?: number;\n /**\n Defines a custom locale object to be used in time scales. Must include\n `dateTime`, `date`, `time`, `periods`, `days`, `shortDays`, `months`, and\n `shortMonths` (see\n [d3-time-format](https://github.com/d3/d3-time-format/blob/master/README.md#timeFormatLocale)).\n */\n timeLocale?: Record<string, unknown>;\n /** Title of the axis. */\n title?: string;\n}\n\nexport interface TooltipConfig {\n /** The inner HTML content of the arrow element, empty by default. */\n arrow?: ((d: DataPoint) => string) | string;\n /** The background color accessor for each tooltip. */\n background?: ((d: DataPoint) => string) | string;\n /** The border accessor for each tooltip. */\n border?: ((d: DataPoint) => string) | string;\n /** The border-radius accessor for each tooltip. */\n borderRadius?: ((d: DataPoint) => string) | string;\n /** The footer content accessor for each tooltip. */\n footer?: ((d: DataPoint) => string) | string;\n /** The max-width accessor for each tooltip. */\n maxWidth?: ((d: DataPoint) => string | number) | string | number;\n /** The min-width accessor for each tooltip. */\n minWidth?: ((d: DataPoint) => string | number) | string | number;\n /** The pixel offset between the tooltip and its anchor point. */\n offset?: ((d: DataPoint) => number) | number;\n /** The inner padding of each tooltip. */\n padding?: ((d: DataPoint) => string | number) | string | number;\n title?: ((d: DataPoint) => string) | string;\n body?: ((d: DataPoint) => string) | string;\n thead?:\n | ((d: DataPoint) => [string, string][])\n | Array<\n Array<\n | ((d: DataPoint, i?: number, x?: {share: number}) => string)\n | string\n >\n >;\n tbody?:\n | ((d: DataPoint) => [string, string][])\n | Array<\n Array<\n | ((d: DataPoint, i?: number, x?: {share: number}) => string)\n | string\n >\n >;\n}\n\nexport interface TextBoxConfig {\n /** The text content for each box. */\n text?: Accessor<string>;\n /** The font color as an accessor function or static string. Inferred from the DOM selection by default. */\n fontColor?: Accessor<string>;\n /** The font size in pixels. Inferred from the DOM selection by default. */\n fontSize?: Accessor<number>;\n /**\n The font-family to use: a font name, a comma-separated list of fallbacks,\n an array of fallbacks, or an accessor returning a string or array. The\n first available font on the client is used.\n */\n fontFamily?: Accessor<string | string[]>;\n /** The font weight. Inferred from the DOM selection by default. */\n fontWeight?: Accessor<string | number>;\n /** The minimum font size in pixels, used when dynamically resizing fonts. */\n fontMin?: number;\n /** The maximum font size in pixels, used when dynamically resizing fonts. */\n fontMax?: number;\n /** Toggles font resizing — a static boolean, or an accessor returning a boolean. */\n fontResize?: Accessor<boolean>;\n /** The font opacity as an accessor function or static number between 0 and 1. */\n fontOpacity?: Accessor<number>;\n /** The font stroke color for the rendered text. */\n fontStroke?: Accessor<string>;\n /** The font stroke width for the rendered text. */\n fontStrokeWidth?: Accessor<number>;\n /** The line height, which is 1.2 times the font size by default. */\n lineHeight?: Accessor<number>;\n /** Restricts the maximum number of lines to wrap onto; null (unlimited) by default. */\n maxLines?: Accessor<number | null>;\n /** Whether text is allowed to overflow its bounding box. */\n overflow?: Accessor<boolean>;\n /**\n Handles truncated lines, returning the new line value. Passed the line's\n text and number; by default appends an ellipsis to every line except a\n first word that cannot fit (which returns \"\").\n */\n ellipsis?: (text: string, line: number) => string;\n /** The padding as a CSS shorthand string or number. Defaults to 0. */\n padding?: Accessor<string | number>;\n /** The anchor point around which to rotate the text box. */\n rotateAnchor?: Accessor<[number, number]>;\n /** The word split function: given a string, returns it split into an array of words. */\n split?: (text: string) => string[];\n /** The width for each text box. */\n width?: Accessor<number>;\n /** The height for each text box. */\n height?: Accessor<number>;\n /** The x position (left edge) for each text box. */\n x?: Accessor<number>;\n /** The y position (top edge) for each text box. */\n y?: Accessor<number>;\n}\n\nexport interface TimelineConfig {\n /** Brush event filter. */\n brushFilter?: () => boolean;\n /**\n The minimum number of ticks that can be highlighted when using \"ticks\"\n `buttonBehavior`. Helpful for x/y plots where selecting fewer than 2 time\n periods is undesirable.\n */\n brushMin?: number;\n /** Toggles the horizontal alignment of the button timeline. */\n buttonAlign?: \"start\" | \"middle\" | \"end\";\n /** Toggles the style of the timeline. */\n buttonBehavior?: \"auto\" | \"buttons\" | \"ticks\";\n /** Button height. */\n buttonHeight?: number;\n /** Button padding. */\n buttonPadding?: number;\n /** Handle style. */\n handleConfig?: Record<string, unknown>;\n /** Handle size. */\n handleSize?: number;\n /**\n Determines the visibility of the play button to the left of the timeline,\n which cycles through the available periods at a rate set by `playButtonInterval`.\n */\n playButton?: boolean;\n /**\n The interval, in milliseconds, between periods when cycling via the play\n button. Used only when the chart's `duration` is 0 (no transition);\n otherwise playback steps once per `duration` so each step animates in full.\n */\n playButtonInterval?: number;\n /** The current selection. Defaults to the most recent period in the timeline. */\n selection?: (Date | number)[] | Date | number | false;\n /** Toggles the snapping value. */\n snapping?: boolean;\n}\n\nexport interface LegendConfig {\n /** The active method for all shapes. */\n active?: ((d: DataPoint, i?: number) => boolean) | false;\n /** The hover method for all shapes. */\n hover?: ((d: DataPoint, i?: number) => boolean) | false;\n /** The shape type used for each legend entry. */\n shape?: Accessor<string>;\n}\n\nexport interface SizeLegendConfig {\n /**\n The values to draw circles for: an array of values, how many to pick\n from the size domain (default 3: its min, max, and a round middle), or\n a function receiving the `[min, max]` domain and returning values.\n */\n values?: number[] | number | ((domain: [number, number]) => number[]);\n /** Formats each value's label. Defaults to the locale's abbreviated number format. */\n tickFormat?: (value: number) => string;\n /** Title above the circles. Defaults to the `size` key when `size` is set to a string. */\n title?: string;\n /** Circle paint: `fill`, `fillOpacity`, `stroke`, `strokeWidth`, `strokeOpacity`. */\n shapeConfig?: SizeLegendShapeConfig;\n /** Leader-line paint: `stroke`, `strokeWidth`, `strokeOpacity`, `strokeDasharray`. */\n lineConfig?: SizeLegendLineConfig;\n /** Value-label font: `fontColor`, `fontFamily`, `fontSize`. */\n labelConfig?: SizeLegendTextConfig;\n /** Title font: `fontColor`, `fontFamily`, `fontSize`, `fontWeight`. */\n titleConfig?: SizeLegendTextConfig;\n padding?: number;\n /** Length of the leader lines past the largest circle, in pixels. */\n lineLength?: number;\n /** Gap between each leader line and its label, in pixels. */\n labelPadding?: number;\n}\n\nexport interface TrendLineConfig {\n /** `\"series\"` (default) fits one line per series, colored to match it; `\"all\"` fits one line to every point. Stacked charts always fit the stack totals. */\n group?: \"series\" | \"all\";\n /** The polynomial degree when `trendLine` is `\"polynomial\"`. Defaults to 2. */\n order?: number;\n /** Draws a confidence band around a linear fit. Defaults to `false`. */\n confidence?: boolean;\n /** The confidence band's level, between 0 and 1. Defaults to 0.95. */\n confidenceLevel?: number;\n /** Area shape config for the confidence band. Its fill defaults to the line color. */\n confidenceConfig?: Record<string, unknown>;\n /** Shows the fitted equation, R², and observations when hovering a line. Defaults to `true`. */\n tooltip?: boolean;\n /** Line color. Defaults to the series color (dark gray when `group` is `\"all\"`). */\n stroke?: string;\n /** Line width in pixels. Defaults to 2. */\n strokeWidth?: number;\n /** Line dash pattern. Defaults to `\"6 4\"`. */\n strokeDasharray?: string;\n /** Other Line shape config. */\n [key: string]: unknown;\n}\n\nexport interface ColorScaleConfig {\n /**\n For a linear scale, the `[min, max]` values used by the color scale; values\n outside this range map to the nearest color.\n */\n domain?: number[];\n /**\n Formats the label for each bucket in a bucket-type scale (\"jenks\",\n \"quantile\", …). Passed the bucket's start value, its index, the full\n bucket array, and every data value used to build the buckets.\n */\n bucketFormat?: (\n start: number,\n i: number,\n buckets: number[],\n values: number[],\n ) => string;\n /** Given a bucket's minimum and maximum values, returns the full label. */\n bucketJoiner?: (min: string, max: string) => string;\n}\n\n/** `colorDefaults` input: any subset of the color defaults, with `scale` also accepting an array of colors. */\nexport type ColorDefaultsConfig = Partial<Omit<ColorDefaults, \"scale\">> & {\n scale?: ColorDefaults[\"scale\"] | string[];\n};\n\nexport interface D3plusConfig {\n /** Data array or URL string to load data from. */\n data?: DataPoint[] | string;\n /** Locale code used for text and number formatting. */\n locale?: string;\n\n /** The active callback function for highlighting shapes. */\n active?: ((d: DataPoint, i: number) => boolean) | false | null;\n /** Custom aggregation functions keyed by data property. */\n aggs?: {[k: string]: (d: DataPoint[]) => unknown};\n /** Hides the SVG from assistive technology when true (`aria-hidden`). */\n ariaHidden?: boolean;\n /**\n Text (rendered as HTML — any valid HTML string works, including anchor\n links) shown in the chart's bottom-right corner, most often a map tile\n credit. `false` (the default) shows nothing. A credit wider than half\n the chart area collapses to a small \"ⓘ\" badge that expands on hover,\n focus, or click.\n */\n attribution?: string | boolean;\n /**\n Overrides the \"ⓘ\" badge a long attribution collapses to, which\n otherwise renders as an inline SVG. A string is used as the badge's\n raw HTML content; a mount function, `(el: HTMLElement) => void | (() =>\n void)`, is called once with the badge's reserved element so a live\n component (a React tree via `createRoot(el).render(...)`, or anything\n else imperative) can be mounted into it — return a cleanup function if\n there's teardown to do.\n */\n attributionIcon?: string | ((el: HTMLElement) => void | (() => void));\n /** CSS key/value pairs used to style the attribution text. */\n attributionStyle?: Record<string, unknown>;\n /** Additional CSS class name(s) applied to the back button, alongside the fixed `back-control` class. */\n backControlClassName?: string;\n /** Padding between bars in pixels. */\n barPadding?: number;\n /** The baseline for the x/y plot. */\n baseline?: number;\n /** Whether to cache the processed data between renders. */\n cache?: boolean;\n /** Overrides for the default colors used for data fills and legible text (see `colorDefaults` in @d3plus/color). */\n colorDefaults?: ColorDefaultsConfig;\n /** Treat a discrete color field as ordered: color it with a single-hue light→dark ramp instead of nominal categorical hues. */\n colorOrdinal?: boolean;\n /** Color scale key or custom color function. */\n colorScale?: string | ((d: number) => string);\n /** Configuration for the color scale component. */\n colorScaleConfig?: {\n axisConfig?: AxisConfig;\n centered?: boolean;\n colors?: string[];\n colorMin?: string;\n colorMid?: string;\n colorMax?: string;\n scale?: AxisScale;\n };\n /** Whether the color scale uses the visualization's internal padding when positioning, or an accessor receiving the viz. */\n colorScalePadding?: boolean | ((viz: VizBase) => boolean);\n /** Position of the color scale, `false` to hide it, or an accessor returning either. */\n colorScalePosition?: false | Position | (() => false | Position);\n /** Column key for matrix-style layouts. */\n column?: string;\n /**\n The confidence interval as `[lower, upper]` bounds — each given as an\n accessor function or a static data key (e.g. `[\"lci\", \"hci\"]`), or `false`\n to disable.\n */\n confidence?:\n | [\n string | ((d: DataPoint, i: number) => number),\n string | ((d: DataPoint, i: number) => number),\n ]\n | false;\n /**\n Paint for the shared tooltip's crosshair guide line (`stroke`,\n `strokeWidth`, `strokeDasharray`, `strokeOpacity`, …).\n */\n crosshairConfig?: Record<string, unknown>;\n /** Maximum number of data points to render before downsampling. */\n dataCutoff?: number;\n /** Active depth level for nested groupings. */\n depth?: number;\n /** Sets orientation of main category axis. */\n discrete?: \"x\" | \"y\";\n /** Default duration of transitions, in milliseconds. */\n duration?: number;\n /** Predicate filtering which data points are included, or false to disable. */\n filter?: ((d: DataPoint, i: number) => boolean) | false;\n /** Allows removing specific geographies from topojson file to improve zoom. */\n fitFilter?:\n | number\n | string\n | ((d: Record<string, unknown>) => boolean);\n /** Grouping key(s) or accessor function(s). */\n groupBy?:\n | string\n | string[]\n | ((d: DataPoint) => string | number)\n | ((d: DataPoint) => string | number)[];\n /** Padding between groups of bars in pixels. */\n groupPadding?: number;\n /** Overall height of the visualization in pixels. */\n height?: number;\n /** Color for legend shapes whose grouping is hidden (via legend click), or a `(datum, index)` accessor. */\n hiddenColor?: string | ((d: DataPoint, i: number) => string);\n /** Opacity for legend labels whose grouping is hidden (via legend click), or a `(datum, index)` accessor. */\n hiddenOpacity?: number | ((d: DataPoint, i: number) => number);\n /** The hover callback function for highlighting shapes on mouseover. */\n hover?: ((d: DataPoint, i: number) => boolean) | false | null;\n /** Persistently emphasizes matching marks (keep color) and grays the rest. */\n highlight?: ((d: DataPoint, i: number) => boolean) | false | null;\n /** Label accessor for shapes. */\n label?: string | string[] | false | AccessorFn;\n /**\n Controls legend visibility. Pass `false` to hide it, `true` to always\n show it, or a `(config, data) => boolean` accessor to decide dynamically\n — the chart defaults use an accessor to auto-hide the legend when it\n would be redundant.\n */\n legend?: boolean | ((config: D3plusConfig, arr: DataPoint[]) => boolean);\n /** Configuration for the legend component. */\n legendConfig?: {\n label?: DataPointAccessor<string>;\n shapeConfig?: Record<string, string | number>;\n };\n /** Inverts legend click behavior (click hides / shift-click solos, or the reverse), or an accessor receiving the viz. */\n legendFilterInvert?: boolean | ((viz: VizBase) => boolean);\n /** Whether the legend uses the visualization's internal padding when positioning, or an accessor receiving the viz. */\n legendPadding?: boolean | ((viz: VizBase) => boolean);\n /** Position of the legend, or an accessor returning it. */\n legendPosition?: Position | (() => Position);\n /** Custom sort comparator for legend items. */\n legendSort?: (a: DataPoint, b: DataPoint) => number;\n /** Tooltip configuration for legend items. */\n legendTooltip?: TooltipConfig;\n /** Whether to show labels on line charts. */\n lineLabels?: boolean;\n /** Whether to show the loading message. */\n loadingMessage?: boolean;\n /** Custom HTML content for the loading indicator, or a function receiving the viz instance. */\n loadingHTML?: string | ((viz: VizBase) => string);\n /** Metric key for the visualization. */\n metric?: string;\n /** Shows a small overview + draggable-viewport minimap underneath the zoom controls once the chart is zoomed in. On by default whenever `zoom` is enabled. */\n minimap?: boolean;\n /** Additional CSS class name(s) applied to the minimap, alongside its fixed `d3plus-minimap`/etc. classes. */\n minimapClassName?: string;\n /** Custom HTML content shown when no data is supplied, or a function receiving the viz instance. */\n noDataHTML?: string | ((viz: VizBase) => string);\n /**\n Ocean color for geomaps (any CSS value including 'transparent'), or a\n `{light, dark}` pair chosen by the chart's backdrop. Defaults to the\n default basemap's own water colors.\n */\n ocean?: string | {light: string; dark: string};\n /** Event listeners keyed by event name. */\n on?: Record<string, (event: Event) => void>;\n /** Coordinate accessor for point-based geomaps. */\n point?: (d: DataPoint) => number[];\n /** Point size accessor for geomaps. */\n pointSize?: string | ((d: DataPoint) => number);\n /** Minimum point size for geomaps. */\n pointSizeMin?: number;\n /** Maximum point size for geomaps. */\n pointSizeMax?: number;\n /** Map projection name or function. */\n projection?: string | ((x: number, y: number) => [number, number]);\n /** Outer padding between the visualization edge and map shapes. */\n projectionPadding?: number | string;\n /** Rotation offset for the map projection center. */\n projectionRotate?: [number, number];\n /** Row key for matrix-style layouts. */\n row?: string;\n /** Scrollable container selector for tooltip positioning. */\n scrollContainer?: string | Window;\n /** Shows a top-left search button that expands into an input; typing highlights shapes whose label matches. On by default for every chart. */\n search?: boolean;\n /** Resolves the string the search box matches its typed term against, for a given datum. Defaults to the mark's resolved on-screen label. */\n searchAccessor?: (d: DataPoint, i: number) => string;\n /** Additional CSS class name(s) applied to the search toggle button and input, alongside the fixed `search-control` classes. */\n searchControlClassName?: string;\n /** Configuration for shape rendering. */\n shapeConfig?: {\n duration?: number;\n [key: string]: unknown;\n };\n /**\n A [sort comparator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort)\n that receives each shape class (e.g. \"Circle\", \"Line\") as its arguments.\n Shapes are drawn in groups by type, so this defines the layering order for\n all shapes of a given type.\n */\n shapeSort?: (a: string, b: string) => number;\n /** Size accessor key. */\n size?: string;\n /**\n Controls size-legend visibility — the nested-circle key drawn in the\n bottom-right corner of charts that size their marks. Shown by default\n whenever marks are sized by more than one value, unless it would take\n up more than a third of the chart's width or height; pass `true` to\n always show it, `false` to hide it, or a `(config, scale, size) =>\n boolean` accessor.\n */\n sizeLegend?:\n | boolean\n | ((config: D3plusConfig, scale: SizeLegendScale, size: SizeLegendSize) => boolean);\n /** Configuration for the size-legend component. */\n sizeLegendConfig?: SizeLegendConfig;\n /**\n Which margin the size legend claims in the bottom-right corner:\n `\"right\"` (default) keeps the chart's full height, `\"bottom\"` its full\n width.\n */\n sizeLegendPosition?: \"right\" | \"bottom\";\n /** Whether to stack series. */\n stacked?: boolean;\n /**\n Vertical offset applied to stacked series. One of `\"diverging\"`\n (default — positive and negative values split around zero), `\"none\"`,\n `\"expand\"` (normalize each stack to 100%), `\"silhouette\"` (streamgraph),\n or `\"wiggle\"` (minimize slope changes); or a custom offset function.\n */\n stackOffset?: string | ((series: number[][][], order: number[]) => void);\n /**\n Order of stacked series, from the bottom of the stack upward. Accepts a\n named order (`\"descending\"` [default] / `\"ascending\"` by summed value,\n `\"key\"` / `\"keyReverse\"` alphabetically, `\"none\"` / `\"data\"` for input\n order, or d3's `\"insideOut\"` / `\"appearance\"` / `\"reverse\"`), an Array of\n series keys for an explicit order, a value accessor, or a `{value, order}`\n config to rank series by an aggregate of any data field.\n */\n stackOrder?:\n | string\n | string[]\n | {value: string | ((d: DataPoint) => unknown); order?: \"ascending\" | \"descending\"}\n | ((d: DataPoint) => unknown);\n /** Subtitle text, or an accessor returning it. */\n subtitle?: string | ((data: DataPoint[]) => string);\n /** Whether the subtitle uses the visualization's internal padding when positioning, or an accessor receiving the viz. */\n subtitlePadding?: boolean | ((viz: VizBase) => boolean);\n /** Value accessor for treemaps and aggregation. */\n sum?: DataPointAccessor<number>;\n /** Accessible description applied to the root SVG (`<desc>`). */\n svgDesc?: string;\n /** Accessible title applied to the root SVG (`<title>`). */\n svgTitle?: string;\n /** Enables the top-left table-view toggle button, which swaps the chart for a static, scrollable `<table>` of its data. On by default for every chart. */\n tableView?: boolean;\n /** Additional CSS class name(s) applied to the `<table>` element rendered while in table view, alongside the fixed `d3plus-table-view-table` class. */\n tableViewClassName?: string;\n /** Additional CSS class name(s) applied to the table-view toggle button, alongside the fixed `table-view-control`/`table-view-toggle` classes. */\n tableViewControlClassName?: string;\n /** CSS key/value pairs styling the table-view toggle button. `false` removes all default styling. */\n tableViewControlStyle?: Record<string, unknown> | false;\n /** CSS key/value pairs styling the table-view toggle button while active (showing the data table). `false` removes all default styling. */\n tableViewControlStyleActive?: Record<string, unknown> | false;\n /** CSS key/value pairs styling the table-view toggle button on hover. `false` removes all default styling. */\n tableViewControlStyleHover?: Record<string, unknown> | false;\n /** Whether the data table shows a \"download CSV\" button, exporting its full (sorted, unpaginated) rows. On by default. */\n tableViewDownload?: boolean;\n /** Rows per page while in table view. `false` (or any non-positive number) disables pagination and shows every row on one page. */\n tableViewPageSize?: number | false;\n /** Whether the data table's column headers are clickable to sort (toggling asc/desc). On by default. */\n tableViewSort?: boolean;\n /** Threshold value for grouping small slices. */\n threshold?: number;\n /** Label for the threshold group, or a `(datum, index)` accessor. */\n thresholdName?: string | ((d: DataPoint, i: number) => string);\n /**\n URL template for XYZ map tiles, with `{z}`, `{x}`, `{y}` (and optional\n `{s}` subdomain) placeholders — or a `{light, dark}` pair, chosen by the\n chart's backdrop. Defaults to Esri's Light Gray and Dark Gray Canvas.\n */\n tileUrl?: string | {light: string; dark: string};\n /** Whether to show map tiles. */\n tiles?: boolean;\n /** Time key for temporal data. */\n time?: string;\n /** Predicate filtering which time slices are shown, or false to disable. */\n timeFilter?: ((d: DataPoint, i: number) => boolean) | false;\n /** Whether to show the timeline component. */\n timeline?: boolean;\n /** Whether the timeline uses the visualization's internal padding when positioning, or an accessor receiving the viz. */\n timelinePadding?: boolean | ((viz: VizBase) => boolean);\n /** Chart title or title accessor function. */\n title?: string | ((data: DataPoint[]) => string);\n /** CSS style configuration for the title. */\n titleConfig?: Record<string, string | number>;\n /** Whether the title uses the visualization's internal padding when positioning, or an accessor receiving the viz. */\n titlePadding?: boolean | ((viz: VizBase) => boolean);\n /** Whether to show tooltips, or a `(datum, index)` accessor deciding per mark. */\n tooltip?: boolean | ((d: DataPoint, i: number) => boolean);\n /** Configuration for the tooltip component. */\n tooltipConfig?: TooltipConfig;\n /**\n Whether hovering a Plot's plot area shows one tooltip listing every\n series' value at the nearest discrete-axis position, with a crosshair\n through it. Applies when a discrete axis is set and at least two series\n share that position.\n */\n tooltipShared?: boolean;\n /**\n Draws an automatic trend line fit to the plotted data: `true` (or\n `\"linear\"`) for a least-squares line, or `\"exponential\"`,\n `\"logarithmic\"`, `\"power\"`, or `\"polynomial\"`. `false` removes it.\n */\n trendLine?: boolean | \"linear\" | \"exponential\" | \"logarithmic\" | \"power\" | \"polynomial\";\n /**\n Options for the trend lines: `group` (`\"series\"` or `\"all\"`), the\n polynomial `order`, a `confidence` band with `confidenceLevel` and\n `confidenceConfig`, `tooltip`, and Line styles (`stroke`,\n `strokeWidth`, `strokeDasharray`, …).\n */\n trendLineConfig?: TrendLineConfig;\n /** Path or object for the topojson data. */\n topojson?: string | object;\n /** CSS color to fill the map shapes. */\n topojsonFill?: string;\n /** Accessor function for topojson feature IDs. */\n topojsonId?: (obj: Record<string, unknown>) => string;\n /** Whether the total uses the visualization's internal padding when positioning, or an accessor receiving the viz. */\n totalPadding?: boolean | ((viz: VizBase) => boolean);\n /** Value accessor for the visualization. */\n value?: DataPointAccessor<number>;\n /** Overall width of the visualization in pixels. */\n width?: number;\n /** Key, index, or accessor function for x-axis values. */\n x?: string | number | ((d: DataPoint, i: number) => unknown);\n /** Configuration for the x-axis. */\n xConfig?: AxisConfig;\n /** The x domain as an array. If either value is undefined, it is calculated from the data. */\n xDomain?: (number | Date)[];\n /** The x2 domain as an array. If either value is undefined, it is calculated from the data. */\n x2Domain?: (number | Date)[];\n /** Custom sort function for x-axis values. */\n xSort?: (a: DataPoint, b: DataPoint) => number;\n /** Defines a custom sorting comparator function for discrete x2 axes. */\n x2Sort?: (a: DataPoint, b: DataPoint) => number;\n /** Key, index, or accessor function for y-axis values. */\n y?: string | number | ((d: DataPoint, i: number) => unknown);\n /** Configuration for the y-axis. */\n yConfig?: AxisConfig;\n /** The y domain as an array. If either value is undefined, it is calculated from the data. */\n yDomain?: (number | Date)[];\n /** The y2 domain as an array. If either value is undefined, it is calculated from the data. */\n y2Domain?: (number | Date)[];\n /** Custom sort function for y-axis values. */\n ySort?: (a: DataPoint, b: DataPoint) => number;\n /** Defines a custom sorting comparator function for discrete y2 axes. */\n y2Sort?: (a: DataPoint, b: DataPoint) => number;\n /** Enables pan/zoom with zoom-control buttons. On by default for every chart. */\n zoom?: boolean;\n /** Additional CSS class name(s) applied to each zoom control button, alongside the fixed `zoom-control`/`zoom-in`/etc. classes. */\n zoomControlClassName?: string;\n /**\n Overrides one or more of the four built-in zoom-control icons (`zoomIn`,\n `zoomOut`, `zoomReset`, `zoomBrush`), which otherwise render as inline\n SVGs. Each value is either raw HTML — used as that button's content — or\n a mount function, `(el: HTMLElement) => void | (() => void)`, called\n once with the button's reserved icon slot so a live component (a React\n tree via `createRoot(el).render(...)`, or anything else imperative) can\n be mounted into it — return a cleanup function if there's teardown to do.\n */\n zoomControlIcons?: Partial<\n Record<\n \"zoomIn\" | \"zoomOut\" | \"zoomReset\" | \"zoomBrush\",\n string | ((el: HTMLElement) => void | (() => void))\n >\n >;\n /** Multiplier applied to programmatic zoom steps. */\n zoomFactor?: number;\n /** Maximum zoom scale factor. Defaults to the scale at which the smallest shape fills the chart area. */\n zoomMax?: number;\n /** Whether panning (drag) is enabled while zoomed. */\n zoomPan?: boolean;\n /**\n Whether the mouse wheel (and one-finger touch) zooms. `\"modifier\"` (the\n default) leaves page scrolling alone: only\n Ctrl/⌘ + wheel or a trackpad/two-finger pinch zooms, and one finger pans\n only once zoomed in. `true` zooms on any wheel; `false` never does.\n */\n zoomScroll?: boolean | \"modifier\";\n\n /** Allows additional custom properties. */\n [key: string]: unknown;\n}\n"],"names":[],"mappings":"AA6TA,WAiYC"}
@@ -0,0 +1,17 @@
1
+ var defaults = new WeakSet();
2
+ /**
3
+ Marks a config function seeded by the library itself, so code that layers
4
+ config can tell it apart from one the user set.
5
+ @private
6
+ */ export function markDefault(value) {
7
+ defaults.add(value);
8
+ return value;
9
+ }
10
+ /**
11
+ Whether a config value is one registered with `markDefault`.
12
+ @private
13
+ */ export function isDefault(value) {
14
+ return typeof value === "function" && defaults.has(value);
15
+ }
16
+
17
+ //# sourceMappingURL=configDefault.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/utils/configDefault.ts"],"sourcesContent":["const defaults = new WeakSet<object>();\n\n/**\n Marks a config function seeded by the library itself, so code that layers\n config can tell it apart from one the user set.\n @private\n*/\nexport function markDefault<T extends object>(value: T): T {\n defaults.add(value);\n return value;\n}\n\n/**\n Whether a config value is one registered with `markDefault`.\n @private\n*/\nexport function isDefault(value: unknown): boolean {\n return typeof value === \"function\" && defaults.has(value);\n}\n"],"names":["defaults","WeakSet","markDefault","value","add","isDefault","has"],"mappings":"AAAA,IAAMA,WAAW,IAAIC;AAErB;;;;AAIA,GACA,OAAO,SAASC,YAA8BC,KAAQ;IACpDH,SAASI,GAAG,CAACD;IACb,OAAOA;AACT;AAEA;;;AAGA,GACA,OAAO,SAASE,UAAUF,KAAc;IACtC,OAAO,OAAOA,UAAU,cAAcH,SAASM,GAAG,CAACH;AACrD"}
@@ -10,6 +10,7 @@ function _type_of(obj) {
10
10
  "@swc/helpers - typeof";
11
11
  return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
12
12
  }
13
+ import { markSharedConfig } from "./configWarnings.js";
13
14
  /**
14
15
  Preps a config object for d3plus data, and optionally bubbles up a specific nested type. When using this function, you must bind a d3plus class' `this` context.
15
16
  @param config The configuration object to parse.
@@ -78,7 +79,7 @@ function _type_of(obj) {
78
79
  keyEval(newConfig, config[nest]);
79
80
  if (config[nest].on) parseEvents(newConfig, config[nest].on);
80
81
  }
81
- return newConfig;
82
+ return markSharedConfig(newConfig);
82
83
  }
83
84
 
84
85
  //# sourceMappingURL=configPrep.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/utils/configPrep.ts"],"sourcesContent":["import type {DataPoint} from \"@d3plus/data\";\nimport { D3plusConfig } from \"./D3plusConfig.js\";\n\ninterface D3PlusWrapped {\n __d3plus__?: boolean;\n __d3plusParent__?: D3PlusWrapped;\n data?: DataPoint;\n feature?: DataPoint;\n i?: number;\n [key: string]: unknown;\n}\n\ntype DataAccessor = (\n d: DataPoint,\n i: number,\n s?: D3PlusWrapped,\n e?: Event,\n) => DataPoint[keyof DataPoint];\ntype ConfigValue =\n | DataAccessor\n | string\n | number\n | boolean\n | ConfigObject\n | ConfigValue[];\ninterface ConfigObject extends D3plusConfig {\n [key: string]: unknown;\n}\n\nexport interface VizContext {\n schema: {\n shapeConfig: ConfigObject;\n duration?: number;\n on?: Record<string, DataAccessor>;\n [key: string]: unknown;\n };\n [key: string]: unknown;\n}\n\n/**\n Preps a config object for d3plus data, and optionally bubbles up a specific nested type. When using this function, you must bind a d3plus class' `this` context.\n @param config The configuration object to parse.\n @param type The event classifier to user for \"on\" events. For example, the default event type of \"shape\" will apply all events in the \"on\" config object with that key, like \"click.shape\" and \"mouseleave.shape\", in addition to any gloval events like \"click\" and \"mouseleave\".\n @param nest An optional nested key to bubble up to the parent config level.\n*/\nexport default function configPrep(\n this: VizContext,\n config: ConfigObject = this.schema.shapeConfig,\n type: string = \"shape\",\n nest: string | false = false,\n): ConfigObject {\n const newConfig: ConfigObject = {\n duration: this.schema.duration,\n on: {},\n };\n\n const wrapFunction =\n (func: DataAccessor) =>\n (\n d: DataPoint | D3PlusWrapped,\n i: number,\n s?: D3PlusWrapped,\n e?: Event,\n ): DataPoint[keyof DataPoint] => {\n if (!func) return func as unknown as DataPoint[keyof DataPoint];\n let parent: D3PlusWrapped | undefined;\n while ((d as D3PlusWrapped).__d3plus__) {\n if (parent) (d as D3PlusWrapped).__d3plusParent__ = parent;\n parent = d as D3PlusWrapped;\n i = (d as D3PlusWrapped).i!;\n d = ((d as D3PlusWrapped).data || (d as D3PlusWrapped).feature)!;\n }\n return func.bind(this)(d as DataPoint, i, s || parent, e);\n };\n\n const parseEvents = (\n newObj: ConfigObject,\n on: Record<string, DataAccessor>,\n ): void => {\n for (const event in on) {\n if (\n ({}.hasOwnProperty.call(on, event) && !event.includes(\".\")) ||\n event.includes(`.${type}`)\n ) {\n (newObj.on as unknown as Record<string, DataAccessor>)[event] = wrapFunction(on[event]);\n }\n }\n };\n\n const arrayEval = (arr: ConfigValue[]): ConfigValue[] =>\n arr.map((d: ConfigValue) => {\n if (d instanceof Array) return arrayEval(d);\n else if (typeof d === \"object\")\n return keyEval({} as ConfigObject, d as ConfigObject);\n else if (typeof d === \"function\") return wrapFunction(d as DataAccessor);\n else return d;\n });\n\n const keyEval = (newObj: ConfigObject, obj: ConfigObject): ConfigObject => {\n for (const key in obj) {\n if ({}.hasOwnProperty.call(obj, key)) {\n if (key === \"on\")\n parseEvents(newObj, obj[key] as unknown as Record<string, DataAccessor>);\n else if (key === \"sort\")\n // `sort` is a two-argument layering comparator, not a per-datum\n // accessor — pass it through untouched so `wrapFunction` doesn't\n // rewrite it into a single-datum call (which would feed the index\n // as its second argument).\n newObj[key] = obj[key];\n else if (typeof obj[key] === \"function\") {\n newObj[key] = wrapFunction(obj[key] as DataAccessor);\n } else if (obj[key] instanceof Array) {\n newObj[key] = arrayEval(obj[key] as ConfigValue[]);\n } else if (typeof obj[key] === \"object\") {\n if (!newObj[key]) newObj[key] = {} as ConfigObject;\n (newObj[key] as ConfigObject).on = {};\n keyEval(newObj[key] as ConfigObject, obj[key] as ConfigObject);\n } else newObj[key] = obj[key];\n }\n }\n\n return newObj;\n };\n\n keyEval(newConfig, config);\n if (this.schema.on) parseEvents(newConfig, this.schema.on as unknown as Record<string, DataAccessor>);\n if (nest && config[nest]) {\n keyEval(newConfig, config[nest] as ConfigObject);\n if ((config[nest] as ConfigObject).on)\n parseEvents(newConfig, (config[nest] as ConfigObject).on as unknown as Record<string, DataAccessor>);\n }\n\n return newConfig;\n}\n"],"names":["configPrep","config","schema","shapeConfig","type","nest","newConfig","duration","on","wrapFunction","func","d","i","s","e","parent","__d3plus__","__d3plusParent__","data","feature","bind","parseEvents","newObj","event","hasOwnProperty","call","includes","arrayEval","arr","map","Array","keyEval","obj","key"],"mappings":";;;;;;;;;;;;AAuCA;;;;;AAKA,GACA,eAAe,SAASA;;QAEtBC,SAAAA,iEAAuB,IAAI,CAACC,MAAM,CAACC,WAAW,EAC9CC,OAAAA,iEAAe,SACfC,OAAAA,iEAAuB;IAEvB,IAAMC,YAA0B;QAC9BC,UAAU,IAAI,CAACL,MAAM,CAACK,QAAQ;QAC9BC,IAAI,CAAC;IACP;IAEA,IAAMC,eACJ,sBAACC;eACD,SACEC,GACAC,GACAC,GACAC;YAEA,IAAI,CAACJ,MAAM,OAAOA;YAClB,IAAIK;YACJ,MAAO,AAACJ,EAAoBK,UA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CX,MAAM,CAACW,IAAI,GAAGxB,aAAauB,GAAG,CAACC,IAAI;gBACrC,OAAO,IAAID,AAAQ,YAARA,GAAG,CAACC,IAAI,EAAYH,QAAO;oBACpCR,MAAM,CAACW,IAAI,GAAGN,UAAUK,GAAG,CAACC,IAAI;gBAClC,OAAO,IAAI,SAAOD,GAAG,CAACC,IAAI,MAAK,UAAU;oBACvC,IAAI,CAACX,MAAM,CAACW,IAAI,EAAEX,MAAM,CAACW,IAAI,GAAG,CAAC;oBAChCX,MAAM,CAACW,IAAI,CAAkBzB,EAAE,GAAG,CAAC;oBACpCuB,QAAQT,MAAM,CAACW,IAAI,EAAkBD,GAAG,CAACC,IAAI;gBAC/C,OAAOX,MAAM,CAACW,IAAI,GAAGD,GAAG,CAACC,IAAI;YAC/B;QACF;QAEA,OAAOX;IACT;IAEAS,QAAQzB,WAAWL;IACnB,IAAI,IAAI,CAACC,MAAM,CAACM,EAAE,EAAEa,YAAYf,WAAW,IAAI,CAACJ,MAAM,CAACM,EAAE;IACzD,IAAIH,QAAQJ,MAAM,CAACI,KAAK,EAAE;QACxB0B,QAAQzB,WAAWL,MAAM,CAACI,KAAK;QAC/B,IAAI,AAACJ,MAAM,CAACI,KAAK,CAAkBG,EAAE,EACnCa,YAAYf,WAAW,AAACL,MAAM,CAACI,KAAK,CAAkBG,EAAE;IAC5D;IAEA,OAAOF;AACT"}
1
+ {"version":3,"sources":["../../../src/utils/configPrep.ts"],"sourcesContent":["import type {DataPoint} from \"@d3plus/data\";\nimport { D3plusConfig } from \"./D3plusConfig.js\";\nimport {markSharedConfig} from \"./configWarnings.js\";\n\ninterface D3PlusWrapped {\n __d3plus__?: boolean;\n __d3plusParent__?: D3PlusWrapped;\n data?: DataPoint;\n feature?: DataPoint;\n i?: number;\n [key: string]: unknown;\n}\n\ntype DataAccessor = (\n d: DataPoint,\n i: number,\n s?: D3PlusWrapped,\n e?: Event,\n) => DataPoint[keyof DataPoint];\ntype ConfigValue =\n | DataAccessor\n | string\n | number\n | boolean\n | ConfigObject\n | ConfigValue[];\ninterface ConfigObject extends D3plusConfig {\n [key: string]: unknown;\n}\n\nexport interface VizContext {\n schema: {\n shapeConfig: ConfigObject;\n duration?: number;\n on?: Record<string, DataAccessor>;\n [key: string]: unknown;\n };\n [key: string]: unknown;\n}\n\n/**\n Preps a config object for d3plus data, and optionally bubbles up a specific nested type. When using this function, you must bind a d3plus class' `this` context.\n @param config The configuration object to parse.\n @param type The event classifier to user for \"on\" events. For example, the default event type of \"shape\" will apply all events in the \"on\" config object with that key, like \"click.shape\" and \"mouseleave.shape\", in addition to any gloval events like \"click\" and \"mouseleave\".\n @param nest An optional nested key to bubble up to the parent config level.\n*/\nexport default function configPrep(\n this: VizContext,\n config: ConfigObject = this.schema.shapeConfig,\n type: string = \"shape\",\n nest: string | false = false,\n): ConfigObject {\n const newConfig: ConfigObject = {\n duration: this.schema.duration,\n on: {},\n };\n\n const wrapFunction =\n (func: DataAccessor) =>\n (\n d: DataPoint | D3PlusWrapped,\n i: number,\n s?: D3PlusWrapped,\n e?: Event,\n ): DataPoint[keyof DataPoint] => {\n if (!func) return func as unknown as DataPoint[keyof DataPoint];\n let parent: D3PlusWrapped | undefined;\n while ((d as D3PlusWrapped).__d3plus__) {\n if (parent) (d as D3PlusWrapped).__d3plusParent__ = parent;\n parent = d as D3PlusWrapped;\n i = (d as D3PlusWrapped).i!;\n d = ((d as D3PlusWrapped).data || (d as D3PlusWrapped).feature)!;\n }\n return func.bind(this)(d as DataPoint, i, s || parent, e);\n };\n\n const parseEvents = (\n newObj: ConfigObject,\n on: Record<string, DataAccessor>,\n ): void => {\n for (const event in on) {\n if (\n ({}.hasOwnProperty.call(on, event) && !event.includes(\".\")) ||\n event.includes(`.${type}`)\n ) {\n (newObj.on as unknown as Record<string, DataAccessor>)[event] = wrapFunction(on[event]);\n }\n }\n };\n\n const arrayEval = (arr: ConfigValue[]): ConfigValue[] =>\n arr.map((d: ConfigValue) => {\n if (d instanceof Array) return arrayEval(d);\n else if (typeof d === \"object\")\n return keyEval({} as ConfigObject, d as ConfigObject);\n else if (typeof d === \"function\") return wrapFunction(d as DataAccessor);\n else return d;\n });\n\n const keyEval = (newObj: ConfigObject, obj: ConfigObject): ConfigObject => {\n for (const key in obj) {\n if ({}.hasOwnProperty.call(obj, key)) {\n if (key === \"on\")\n parseEvents(newObj, obj[key] as unknown as Record<string, DataAccessor>);\n else if (key === \"sort\")\n // `sort` is a two-argument layering comparator, not a per-datum\n // accessor — pass it through untouched so `wrapFunction` doesn't\n // rewrite it into a single-datum call (which would feed the index\n // as its second argument).\n newObj[key] = obj[key];\n else if (typeof obj[key] === \"function\") {\n newObj[key] = wrapFunction(obj[key] as DataAccessor);\n } else if (obj[key] instanceof Array) {\n newObj[key] = arrayEval(obj[key] as ConfigValue[]);\n } else if (typeof obj[key] === \"object\") {\n if (!newObj[key]) newObj[key] = {} as ConfigObject;\n (newObj[key] as ConfigObject).on = {};\n keyEval(newObj[key] as ConfigObject, obj[key] as ConfigObject);\n } else newObj[key] = obj[key];\n }\n }\n\n return newObj;\n };\n\n keyEval(newConfig, config);\n if (this.schema.on) parseEvents(newConfig, this.schema.on as unknown as Record<string, DataAccessor>);\n if (nest && config[nest]) {\n keyEval(newConfig, config[nest] as ConfigObject);\n if ((config[nest] as ConfigObject).on)\n parseEvents(newConfig, (config[nest] as ConfigObject).on as unknown as Record<string, DataAccessor>);\n }\n\n return markSharedConfig(newConfig);\n}\n"],"names":["markSharedConfig","configPrep","config","schema","shapeConfig","type","nest","newConfig","duration","on","wrapFunction","func","d","i","s","e","parent","__d3plus__","__d3plusParent__","data","feature","bind","parseEvents","newObj","event","hasOwnProperty","call","includes","arrayEval","arr","map","Array","keyEval","obj","key"],"mappings":";;;;;;;;;;;;AAEA,SAAQA,gBAAgB,QAAO,sBAAsB;AAsCrD;;;;;AAKA,GACA,eAAe,SAASC;;QAEtBC,SAAAA,iEAAuB,IAAI,CAACC,MAAM,CAACC,WAAW,EAC9CC,OAAAA,iE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BACpC,IAAIA,QAAQ,MACVZ,YAAYC,QAAQU,GAAG,CAACC,IAAI;qBACzB,IAAIA,QAAQ,QACf,gEAAgE;gBAChE,iEAAiE;gBACjE,kEAAkE;gBAClE,2BAA2B;gBAC3BX,MAAM,CAACW,IAAI,GAAGD,GAAG,CAACC,IAAI;qBACnB,IAAI,OAAOD,GAAG,CAACC,IAAI,KAAK,YAAY;oBACvCX,MAAM,CAACW,IAAI,GAAGxB,aAAauB,GAAG,CAACC,IAAI;gBACrC,OAAO,IAAID,AAAQ,YAARA,GAAG,CAACC,IAAI,EAAYH,QAAO;oBACpCR,MAAM,CAACW,IAAI,GAAGN,UAAUK,GAAG,CAACC,IAAI;gBAClC,OAAO,IAAI,SAAOD,GAAG,CAACC,IAAI,MAAK,UAAU;oBACvC,IAAI,CAACX,MAAM,CAACW,IAAI,EAAEX,MAAM,CAACW,IAAI,GAAG,CAAC;oBAChCX,MAAM,CAACW,IAAI,CAAkBzB,EAAE,GAAG,CAAC;oBACpCuB,QAAQT,MAAM,CAACW,IAAI,EAAkBD,GAAG,CAACC,IAAI;gBAC/C,OAAOX,MAAM,CAACW,IAAI,GAAGD,GAAG,CAACC,IAAI;YAC/B;QACF;QAEA,OAAOX;IACT;IAEAS,QAAQzB,WAAWL;IACnB,IAAI,IAAI,CAACC,MAAM,CAACM,EAAE,EAAEa,YAAYf,WAAW,IAAI,CAACJ,MAAM,CAACM,EAAE;IACzD,IAAIH,QAAQJ,MAAM,CAACI,KAAK,EAAE;QACxB0B,QAAQzB,WAAWL,MAAM,CAACI,KAAK;QAC/B,IAAI,AAACJ,MAAM,CAACI,KAAK,CAAkBG,EAAE,EACnCa,YAAYf,WAAW,AAACL,MAAM,CAACI,KAAK,CAAkBG,EAAE;IAC5D;IAEA,OAAOT,iBAAiBO;AAC1B"}
@@ -0,0 +1,37 @@
1
+ function _type_of(obj) {
2
+ "@swc/helpers - typeof";
3
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
4
+ }
5
+ var shared = new WeakSet();
6
+ var warned = new Set();
7
+ var enabled = true;
8
+ export function configWarnings(_) {
9
+ if (!arguments.length) return enabled;
10
+ enabled = !!_;
11
+ }
12
+ /**
13
+ Marks a config object as shared across several classes, so keys meant for
14
+ other targets (like a `shapeConfig` carrying both `r` and `width`) are
15
+ applied where supported without `BaseClass.config()` warning about the rest.
16
+ @private
17
+ */ export function markSharedConfig(config) {
18
+ shared.add(config);
19
+ return config;
20
+ }
21
+ /** @private */ export function isSharedConfig(config) {
22
+ return (typeof config === "undefined" ? "undefined" : _type_of(config)) === "object" && config !== null && shared.has(config);
23
+ }
24
+ /**
25
+ Warns that `owner` was given a config key it does not support. Each message
26
+ is logged once, so re-renders (and framework wrappers re-applying the same
27
+ config) don't flood the console.
28
+ @private
29
+ */ export function warnUnknownConfig(owner, key) {
30
+ if (!enabled) return;
31
+ var message = "".concat(owner, ' received unknown property "').concat(key, '".');
32
+ if (warned.has(message)) return;
33
+ warned.add(message);
34
+ console.warn(message);
35
+ }
36
+
37
+ //# sourceMappingURL=configWarnings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/utils/configWarnings.ts"],"sourcesContent":["const shared = new WeakSet<object>();\nconst warned = new Set<string>();\nlet enabled = true;\n\n/**\n Toggles the console warnings d3plus logs when a class receives a config\n property it does not support (like a misspelled key passed to `.config()`\n or `shapeConfig`). Warnings are on by default and the setting applies to\n every chart on the page. With no argument, returns the current setting.\n\n@example\nimport {configWarnings} from \"@d3plus/core\";\nconfigWarnings(false);\n*/\nexport function configWarnings(): boolean;\nexport function configWarnings(_: boolean): void;\nexport function configWarnings(_?: boolean): boolean | void {\n if (!arguments.length) return enabled;\n enabled = !!_;\n}\n\n/**\n Marks a config object as shared across several classes, so keys meant for\n other targets (like a `shapeConfig` carrying both `r` and `width`) are\n applied where supported without `BaseClass.config()` warning about the rest.\n @private\n*/\nexport function markSharedConfig<T extends object>(config: T): T {\n shared.add(config);\n return config;\n}\n\n/** @private */\nexport function isSharedConfig(config: unknown): boolean {\n return typeof config === \"object\" && config !== null && shared.has(config);\n}\n\n/**\n Warns that `owner` was given a config key it does not support. Each message\n is logged once, so re-renders (and framework wrappers re-applying the same\n config) don't flood the console.\n @private\n*/\nexport function warnUnknownConfig(owner: string, key: string): void {\n if (!enabled) return;\n const message = `${owner} received unknown property \"${key}\".`;\n if (warned.has(message)) return;\n warned.add(message);\n console.warn(message);\n}\n"],"names":["shared","WeakSet","warned","Set","enabled","configWarnings","_","arguments","length","markSharedConfig","config","add","isSharedConfig","has","warnUnknownConfig","owner","key","message","console","warn"],"mappings":";;;;AAAA,IAAMA,SAAS,IAAIC;AACnB,IAAMC,SAAS,IAAIC;AACnB,IAAIC,UAAU;AAcd,OAAO,SAASC,eAAeC,CAAW;IACxC,IAAI,CAACC,UAAUC,MAAM,EAAE,OAAOJ;IAC9BA,UAAU,CAAC,CAACE;AACd;AAEA;;;;;AAKA,GACA,OAAO,SAASG,iBAAmCC,MAAS;IAC1DV,OAAOW,GAAG,CAACD;IACX,OAAOA;AACT;AAEA,aAAa,GACb,OAAO,SAASE,eAAeF,MAAe;IAC5C,OAAO,CAAA,OAAOA,uCAAP,SAAOA,OAAK,MAAM,YAAYA,WAAW,QAAQV,OAAOa,GAAG,CAACH;AACrE;AAEA;;;;;AAKA,GACA,OAAO,SAASI,kBAAkBC,KAAa,EAAEC,GAAW;IAC1D,IAAI,CAACZ,SAAS;IACd,IAAMa,UAAU,AAAC,GAAsCD,OAApCD,OAAM,gCAAkC,OAAJC,KAAI;IAC3D,IAAId,OAAOW,GAAG,CAACI,UAAU;IACzBf,OAAOS,GAAG,CAACM;IACXC,QAAQC,IAAI,CAACF;AACf"}
@@ -1,6 +1,7 @@
1
1
  export { default as accessor } from "./accessor.js";
2
2
  export { default as BaseClass } from "./BaseClass.js";
3
3
  export { default as configPrep } from "./configPrep.js";
4
+ export { configWarnings } from "./configWarnings.js";
4
5
  export { default as constant } from "./constant.js";
5
6
  export { default as getProp } from "./getProp.js";
6
7
  export { paintComponentScene } from "./paintComponentScene.js";
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/utils/index.ts"],"sourcesContent":["export type {AccessorFn} from \"./AccessorFn.js\";\nexport {default as accessor} from \"./accessor.js\";\nexport {default as BaseClass} from \"./BaseClass.js\";\nexport type {\n D3plusConfig,\n AxisConfig,\n ColorScaleConfig,\n LegendConfig,\n TextBoxConfig,\n TimelineConfig,\n TooltipConfig,\n} from \"./D3plusConfig.js\";\nexport type {D3Scale} from \"./D3Scale.js\";\nexport {default as configPrep} from \"./configPrep.js\";\nexport {default as constant} from \"./constant.js\";\nexport {default as getProp} from \"./getProp.js\";\nexport {paintComponentScene} from \"./paintComponentScene.js\";\nexport {default as RESET} from \"./RESET.js\";\n"],"names":["default","accessor","BaseClass","configPrep","constant","getProp","paintComponentScene","RESET"],"mappings":"AACA,SAAQA,WAAWC,QAAQ,QAAO,gBAAgB;AAClD,SAAQD,WAAWE,SAAS,QAAO,iBAAiB;AAWpD,SAAQF,WAAWG,UAAU,QAAO,kBAAkB;AACtD,SAAQH,WAAWI,QAAQ,QAAO,gBAAgB;AAClD,SAAQJ,WAAWK,OAAO,QAAO,eAAe;AAChD,SAAQC,mBAAmB,QAAO,2BAA2B;AAC7D,SAAQN,WAAWO,KAAK,QAAO,aAAa"}
1
+ {"version":3,"sources":["../../../src/utils/index.ts"],"sourcesContent":["export type {AccessorFn} from \"./AccessorFn.js\";\nexport {default as accessor} from \"./accessor.js\";\nexport {default as BaseClass} from \"./BaseClass.js\";\nexport type {\n D3plusConfig,\n AxisConfig,\n ColorDefaultsConfig,\n ColorScaleConfig,\n LegendConfig,\n SizeLegendConfig,\n TextBoxConfig,\n TimelineConfig,\n TooltipConfig,\n TrendLineConfig,\n} from \"./D3plusConfig.js\";\nexport type {D3Scale} from \"./D3Scale.js\";\nexport {default as configPrep} from \"./configPrep.js\";\nexport {configWarnings} from \"./configWarnings.js\";\nexport {default as constant} from \"./constant.js\";\nexport {default as getProp} from \"./getProp.js\";\nexport {paintComponentScene} from \"./paintComponentScene.js\";\nexport {default as RESET} from \"./RESET.js\";\n"],"names":["default","accessor","BaseClass","configPrep","configWarnings","constant","getProp","paintComponentScene","RESET"],"mappings":"AACA,SAAQA,WAAWC,QAAQ,QAAO,gBAAgB;AAClD,SAAQD,WAAWE,SAAS,QAAO,iBAAiB;AAcpD,SAAQF,WAAWG,UAAU,QAAO,kBAAkB;AACtD,SAAQC,cAAc,QAAO,sBAAsB;AACnD,SAAQJ,WAAWK,QAAQ,QAAO,gBAAgB;AAClD,SAAQL,WAAWM,OAAO,QAAO,eAAe;AAChD,SAAQC,mBAAmB,QAAO,2BAA2B;AAC7D,SAAQP,WAAWQ,KAAK,QAAO,aAAa"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@d3plus/core",
3
- "version": "4.5.0",
3
+ "version": "4.6.0",
4
4
  "description": "Data visualization made easy. A javascript library that extends the popular D3.js to enable fast and beautiful visualizations.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -63,16 +63,17 @@
63
63
  "open-color": "^1.9.1",
64
64
  "textures": "^1.2.3",
65
65
  "topojson-client": "^3.1.0",
66
- "@d3plus/data": "4.5.0",
67
- "@d3plus/dom": "4.5.0",
68
- "@d3plus/format": "4.5.0",
69
- "@d3plus/locales": "4.5.0",
70
- "@d3plus/math": "4.5.0",
71
- "@d3plus/text": "4.5.0",
72
- "@d3plus/render": "4.5.0",
73
- "@d3plus/color": "4.5.0"
66
+ "@d3plus/dom": "4.6.0",
67
+ "@d3plus/locales": "4.6.0",
68
+ "@d3plus/data": "4.6.0",
69
+ "@d3plus/format": "4.6.0",
70
+ "@d3plus/render": "4.6.0",
71
+ "@d3plus/math": "4.6.0",
72
+ "@d3plus/text": "4.6.0",
73
+ "@d3plus/color": "4.6.0"
74
74
  },
75
75
  "devDependencies": {
76
+ "@bcoe/v8-coverage": "^1.0.2",
76
77
  "playwright": "1.59.1"
77
78
  },
78
79
  "scripts": {
@@ -81,6 +82,6 @@
81
82
  "build:umd": "node ../../scripts/build-umd.js",
82
83
  "dev": "node ../../scripts/dev.js",
83
84
  "test": "eslint index.ts internal.ts umd-entry.ts src && eslint --global=it test && mocha 'test/**/*-test.js'",
84
- "test:coverage": "c8 -r text -r lcov --src src mocha 'test/**/*-test.js'"
85
+ "test:coverage": "c8 -r text -r lcov --src src --exclude-after-remap --include 'src/**' --include '*.ts' mocha 'test/**/*-test.js'"
85
86
  }
86
87
  }
package/types/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- export { AreaPlot, BarChart, BoxWhisker, BumpChart, Chord, Donut, Geomap, LinePlot, Matrix, Network, Pack, Pie, Plot, Priestley, Radar, RadialMatrix, Rings, Sankey, StackedArea, Tree, Treemap, Viz, } from "./src/charts/index.js";
2
- export { Axis, AxisBottom, AxisLeft, AxisRight, AxisTop, ColorScale, Legend, Message, TextBox, Timeline, Tooltip, } from "./src/components/index.js";
1
+ export { AreaPlot, BarChart, BoxWhisker, BumpChart, Chord, Donut, Geomap, Histogram, LinePlot, Matrix, Network, Pack, Pie, Plot, Priestley, Radar, RadialMatrix, Rings, Sankey, StackedArea, Tree, Treemap, Viz, } from "./src/charts/index.js";
2
+ export { Axis, AxisBottom, AxisLeft, AxisRight, AxisTop, ColorScale, Legend, Message, SizeLegend, TextBox, Timeline, Tooltip, } from "./src/components/index.js";
3
3
  export { Area, Bar, Box, Circle, Image, Line, Path, Rect, Shape, Whisker, } from "./src/shapes/index.js";
4
- export { accessor, BaseClass, configPrep, constant, RESET, } from "./src/utils/index.js";
5
- export type { D3plusConfig, AxisConfig, ColorScaleConfig, LegendConfig, TextBoxConfig, TimelineConfig, TooltipConfig, } from "./src/utils/index.js";
4
+ export { accessor, BaseClass, configPrep, configWarnings, constant, RESET, } from "./src/utils/index.js";
5
+ export type { D3plusConfig, AxisConfig, ColorDefaultsConfig, ColorScaleConfig, LegendConfig, SizeLegendConfig, TextBoxConfig, TimelineConfig, TooltipConfig, TrendLineConfig, } from "./src/utils/index.js";
6
6
  export type { AnyShapeConfig, AreaConfig, BarConfig, BaseShapeConfig, BoxConfig, CircleConfig, ConstOrAccessor, ImageConfig, LineConfig, PathConfig, RectConfig, StringOrAccessor, WhiskerConfig, } from "./src/shapes/shapeConfig.js";
7
7
  export type { D3Selection, Margin, Padding, } from "./src/charts/viz/vizTypes.js";