@unovis/ts 1.3.0-beta.3 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (260) hide show
  1. package/components/area/config.d.ts +6 -10
  2. package/components/area/config.js +3 -12
  3. package/components/area/config.js.map +1 -1
  4. package/components/area/index.d.ts +5 -6
  5. package/components/area/index.js +10 -9
  6. package/components/area/index.js.map +1 -1
  7. package/components/axis/config.d.ts +3 -27
  8. package/components/axis/config.js +3 -30
  9. package/components/axis/config.js.map +1 -1
  10. package/components/axis/index.d.ts +4 -3
  11. package/components/axis/index.js +8 -5
  12. package/components/axis/index.js.map +1 -1
  13. package/components/brush/config.d.ts +2 -12
  14. package/components/brush/config.js +11 -20
  15. package/components/brush/config.js.map +1 -1
  16. package/components/brush/index.d.ts +4 -3
  17. package/components/brush/index.js +4 -3
  18. package/components/brush/index.js.map +1 -1
  19. package/components/bullet-legend/config.d.ts +1 -10
  20. package/components/bullet-legend/config.js +11 -14
  21. package/components/bullet-legend/config.js.map +1 -1
  22. package/components/bullet-legend/index.d.ts +4 -3
  23. package/components/bullet-legend/index.js +5 -2
  24. package/components/bullet-legend/index.js.map +1 -1
  25. package/components/chord-diagram/config.d.ts +7 -23
  26. package/components/chord-diagram/config.js +4 -23
  27. package/components/chord-diagram/config.js.map +1 -1
  28. package/components/chord-diagram/index.d.ts +4 -3
  29. package/components/chord-diagram/index.js +8 -7
  30. package/components/chord-diagram/index.js.map +1 -1
  31. package/components/chord-diagram/modules/label.d.ts +3 -3
  32. package/components/chord-diagram/modules/label.js +1 -1
  33. package/components/chord-diagram/modules/label.js.map +1 -1
  34. package/components/chord-diagram/modules/link.d.ts +2 -2
  35. package/components/chord-diagram/modules/link.js.map +1 -1
  36. package/components/chord-diagram/modules/node.d.ts +2 -2
  37. package/components/chord-diagram/modules/node.js.map +1 -1
  38. package/components/chord-diagram/types.d.ts +3 -2
  39. package/components/chord-diagram/types.js.map +1 -1
  40. package/components/crosshair/config.d.ts +4 -14
  41. package/components/crosshair/config.js +3 -16
  42. package/components/crosshair/config.js.map +1 -1
  43. package/components/crosshair/index.d.ts +4 -3
  44. package/components/crosshair/index.js +4 -3
  45. package/components/crosshair/index.js.map +1 -1
  46. package/components/donut/config.d.ts +3 -20
  47. package/components/donut/config.js +3 -24
  48. package/components/donut/config.js.map +1 -1
  49. package/components/donut/index.d.ts +4 -3
  50. package/components/donut/index.js +5 -4
  51. package/components/donut/index.js.map +1 -1
  52. package/components/donut/modules/arc.d.ts +3 -3
  53. package/components/donut/modules/arc.js.map +1 -1
  54. package/components/flow-legend/config.d.ts +1 -11
  55. package/components/flow-legend/config.js +11 -16
  56. package/components/flow-legend/config.js.map +1 -1
  57. package/components/flow-legend/index.d.ts +4 -3
  58. package/components/flow-legend/index.js +5 -2
  59. package/components/flow-legend/index.js.map +1 -1
  60. package/components/free-brush/config.d.ts +2 -12
  61. package/components/free-brush/config.js +11 -20
  62. package/components/free-brush/config.js.map +1 -1
  63. package/components/free-brush/index.d.ts +4 -3
  64. package/components/free-brush/index.js +13 -12
  65. package/components/free-brush/index.js.map +1 -1
  66. package/components/graph/config.d.ts +3 -75
  67. package/components/graph/config.js +13 -79
  68. package/components/graph/config.js.map +1 -1
  69. package/components/graph/index.d.ts +8 -7
  70. package/components/graph/index.js +7 -5
  71. package/components/graph/index.js.map +1 -1
  72. package/components/graph/modules/layout.d.ts +7 -7
  73. package/components/graph/modules/layout.js +7 -2
  74. package/components/graph/modules/layout.js.map +1 -1
  75. package/components/graph/modules/link/helper.d.ts +5 -5
  76. package/components/graph/modules/link/helper.js.map +1 -1
  77. package/components/graph/modules/link/index.d.ts +6 -6
  78. package/components/graph/modules/link/index.js.map +1 -1
  79. package/components/graph/modules/node/helper.d.ts +1 -1
  80. package/components/graph/modules/node/helper.js.map +1 -1
  81. package/components/graph/modules/node/index.d.ts +9 -6
  82. package/components/graph/modules/node/index.js +7 -9
  83. package/components/graph/modules/node/index.js.map +1 -1
  84. package/components/graph/modules/panel/helper.d.ts +4 -4
  85. package/components/graph/modules/panel/helper.js.map +1 -1
  86. package/components/graph/modules/panel/index.d.ts +3 -3
  87. package/components/graph/modules/panel/index.js.map +1 -1
  88. package/components/graph/modules/shape.js +2 -2
  89. package/components/graph/modules/shape.js.map +1 -1
  90. package/components/grouped-bar/config.d.ts +5 -13
  91. package/components/grouped-bar/config.js +3 -16
  92. package/components/grouped-bar/config.js.map +1 -1
  93. package/components/grouped-bar/index.d.ts +5 -9
  94. package/components/grouped-bar/index.js +5 -15
  95. package/components/grouped-bar/index.js.map +1 -1
  96. package/components/leaflet-flow-map/config.d.ts +2 -16
  97. package/components/leaflet-flow-map/config.js +3 -21
  98. package/components/leaflet-flow-map/config.js.map +1 -1
  99. package/components/leaflet-flow-map/index.d.ts +4 -3
  100. package/components/leaflet-flow-map/index.js +3 -2
  101. package/components/leaflet-flow-map/index.js.map +1 -1
  102. package/components/leaflet-map/config.d.ts +4 -59
  103. package/components/leaflet-map/config.js +24 -68
  104. package/components/leaflet-map/config.js.map +1 -1
  105. package/components/leaflet-map/index.d.ts +5 -4
  106. package/components/leaflet-map/index.js +4 -3
  107. package/components/leaflet-map/index.js.map +1 -1
  108. package/components/leaflet-map/modules/clusterBackground.d.ts +4 -2
  109. package/components/leaflet-map/modules/clusterBackground.js.map +1 -1
  110. package/components/leaflet-map/modules/map.d.ts +4 -4
  111. package/components/leaflet-map/modules/map.js +6 -6
  112. package/components/leaflet-map/modules/map.js.map +1 -1
  113. package/components/leaflet-map/modules/node.d.ts +3 -0
  114. package/components/leaflet-map/modules/node.js +8 -12
  115. package/components/leaflet-map/modules/node.js.map +1 -1
  116. package/components/leaflet-map/modules/utils.d.ts +4 -4
  117. package/components/leaflet-map/modules/utils.js +6 -2
  118. package/components/leaflet-map/modules/utils.js.map +1 -1
  119. package/components/leaflet-map/renderer/mapboxgl-layer.d.ts +2 -2
  120. package/components/leaflet-map/renderer/mapboxgl-layer.js.map +1 -1
  121. package/components/leaflet-map/renderer/mapboxgl-utils.d.ts +5 -1
  122. package/components/leaflet-map/renderer/mapboxgl-utils.js +3 -3
  123. package/components/leaflet-map/renderer/mapboxgl-utils.js.map +1 -1
  124. package/components/leaflet-map/style.js.map +1 -1
  125. package/components/leaflet-map/types.d.ts +5 -1
  126. package/components/leaflet-map/types.js.map +1 -1
  127. package/components/line/config.d.ts +6 -11
  128. package/components/line/config.js +3 -13
  129. package/components/line/config.js.map +1 -1
  130. package/components/line/index.d.ts +6 -5
  131. package/components/line/index.js +7 -6
  132. package/components/line/index.js.map +1 -1
  133. package/components/nested-donut/config.d.ts +2 -21
  134. package/components/nested-donut/config.js +3 -24
  135. package/components/nested-donut/config.js.map +1 -1
  136. package/components/nested-donut/index.d.ts +4 -3
  137. package/components/nested-donut/index.js +18 -8
  138. package/components/nested-donut/index.js.map +1 -1
  139. package/components/nested-donut/modules/arc.d.ts +3 -3
  140. package/components/nested-donut/modules/arc.js.map +1 -1
  141. package/components/nested-donut/modules/label.d.ts +2 -2
  142. package/components/nested-donut/modules/label.js.map +1 -1
  143. package/components/nested-donut/style.js.map +1 -1
  144. package/components/sankey/config.d.ts +3 -48
  145. package/components/sankey/config.js +11 -58
  146. package/components/sankey/config.js.map +1 -1
  147. package/components/sankey/index.d.ts +4 -3
  148. package/components/sankey/index.js +3 -2
  149. package/components/sankey/index.js.map +1 -1
  150. package/components/sankey/modules/label.d.ts +7 -7
  151. package/components/sankey/modules/label.js.map +1 -1
  152. package/components/sankey/modules/link.d.ts +12 -2
  153. package/components/sankey/modules/link.js +4 -8
  154. package/components/sankey/modules/link.js.map +1 -1
  155. package/components/sankey/modules/node.d.ts +7 -7
  156. package/components/sankey/modules/node.js +1 -1
  157. package/components/sankey/modules/node.js.map +1 -1
  158. package/components/scatter/config.d.ts +5 -17
  159. package/components/scatter/config.js +3 -19
  160. package/components/scatter/config.js.map +1 -1
  161. package/components/scatter/index.d.ts +4 -3
  162. package/components/scatter/index.js +8 -8
  163. package/components/scatter/index.js.map +1 -1
  164. package/components/scatter/modules/point.d.ts +2 -2
  165. package/components/scatter/modules/point.js.map +1 -1
  166. package/components/scatter/modules/utils.d.ts +2 -2
  167. package/components/scatter/modules/utils.js.map +1 -1
  168. package/components/stacked-bar/config.d.ts +5 -13
  169. package/components/stacked-bar/config.js +3 -16
  170. package/components/stacked-bar/config.js.map +1 -1
  171. package/components/stacked-bar/index.d.ts +4 -3
  172. package/components/stacked-bar/index.js +4 -3
  173. package/components/stacked-bar/index.js.map +1 -1
  174. package/components/timeline/config.d.ts +5 -16
  175. package/components/timeline/config.js +3 -21
  176. package/components/timeline/config.js.map +1 -1
  177. package/components/timeline/index.d.ts +4 -3
  178. package/components/timeline/index.js +4 -3
  179. package/components/timeline/index.js.map +1 -1
  180. package/components/tooltip/config.d.ts +1 -15
  181. package/components/tooltip/config.js +12 -16
  182. package/components/tooltip/config.js.map +1 -1
  183. package/components/tooltip/index.d.ts +6 -4
  184. package/components/tooltip/index.js +15 -6
  185. package/components/tooltip/index.js.map +1 -1
  186. package/components/tooltip/style.d.ts +6 -0
  187. package/components/tooltip/style.js +13 -14
  188. package/components/tooltip/style.js.map +1 -1
  189. package/components/topojson-map/config.d.ts +4 -36
  190. package/components/topojson-map/config.js +3 -38
  191. package/components/topojson-map/config.js.map +1 -1
  192. package/components/topojson-map/index.d.ts +4 -3
  193. package/components/topojson-map/index.js +4 -5
  194. package/components/topojson-map/index.js.map +1 -1
  195. package/components/vis-controls/config.d.ts +1 -5
  196. package/components/vis-controls/config.js +6 -9
  197. package/components/vis-controls/config.js.map +1 -1
  198. package/components/vis-controls/index.d.ts +3 -2
  199. package/components/vis-controls/index.js +5 -2
  200. package/components/vis-controls/index.js.map +1 -1
  201. package/components/xy-labels/config.d.ts +4 -16
  202. package/components/xy-labels/config.js +3 -20
  203. package/components/xy-labels/config.js.map +1 -1
  204. package/components/xy-labels/index.d.ts +4 -3
  205. package/components/xy-labels/index.js +3 -2
  206. package/components/xy-labels/index.js.map +1 -1
  207. package/components/xy-labels/modules/label.d.ts +3 -3
  208. package/components/xy-labels/modules/label.js +1 -1
  209. package/components/xy-labels/modules/label.js.map +1 -1
  210. package/containers/single-container/config.d.ts +2 -4
  211. package/containers/single-container/config.js +3 -8
  212. package/containers/single-container/config.js.map +1 -1
  213. package/containers/single-container/index.d.ts +4 -3
  214. package/containers/single-container/index.js +2 -2
  215. package/containers/single-container/index.js.map +1 -1
  216. package/containers/xy-container/config.d.ts +2 -22
  217. package/containers/xy-container/config.js +3 -26
  218. package/containers/xy-container/config.js.map +1 -1
  219. package/containers/xy-container/index.d.ts +5 -2
  220. package/containers/xy-container/index.js +7 -6
  221. package/containers/xy-container/index.js.map +1 -1
  222. package/core/component/config.d.ts +1 -6
  223. package/core/component/config.js +6 -12
  224. package/core/component/config.js.map +1 -1
  225. package/core/component/index.d.ts +7 -5
  226. package/core/component/index.js +14 -9
  227. package/core/component/index.js.map +1 -1
  228. package/core/container/config.d.ts +1 -21
  229. package/core/container/config.js +21 -25
  230. package/core/container/config.js.map +1 -1
  231. package/core/container/index.d.ts +5 -4
  232. package/core/container/index.js +4 -3
  233. package/core/container/index.js.map +1 -1
  234. package/core/xy-component/config.d.ts +2 -10
  235. package/core/xy-component/config.js +3 -16
  236. package/core/xy-component/config.js.map +1 -1
  237. package/core/xy-component/index.d.ts +5 -4
  238. package/core/xy-component/index.js +2 -0
  239. package/core/xy-component/index.js.map +1 -1
  240. package/data-models/map-graph.d.ts +1 -1
  241. package/data-models/map-graph.js +4 -7
  242. package/data-models/map-graph.js.map +1 -1
  243. package/package.json +3 -1
  244. package/styles/colors.d.ts +2 -2
  245. package/styles/index.d.ts +1 -1
  246. package/styles/patterns.js +2 -1
  247. package/styles/patterns.js.map +1 -1
  248. package/types/accessor.d.ts +5 -5
  249. package/types/component.js +2 -0
  250. package/types/component.js.map +1 -1
  251. package/utils/d3.d.ts +10 -1
  252. package/utils/d3.js.map +1 -1
  253. package/utils/data.d.ts +7 -7
  254. package/utils/data.js +2 -1
  255. package/utils/data.js.map +1 -1
  256. package/utils/text.js +2 -2
  257. package/utils/text.js.map +1 -1
  258. package/core/config/index.d.ts +0 -3
  259. package/core/config/index.js +0 -16
  260. package/core/config/index.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sources":["../../../src/components/brush/config.ts"],"sourcesContent":["import { D3BrushEvent } from 'd3-brush'\nimport { XYComponentConfigInterface, XYComponentConfig } from 'core/xy-component/config'\n\n// Types\nimport { Arrangement } from 'types/position'\n\n// We extend partial XY config interface because x and y properties are optional for Brush\nexport interface BrushConfigInterface<Datum> extends Partial<XYComponentConfigInterface<Datum>> {\n /** Callback function to be called on any Brush event.\n * Default: `(selection: [number, number], event: D3BrushEvent<Datum>, userDriven: boolean): void => {}`\n */\n onBrush?: ((selection: [number, number] | undefined, event: D3BrushEvent<Datum>, userDriven: boolean) => void);\n /** Callback function to be called on the Brush start event.\n * Default: `(selection: [number, number], event: D3BrushEvent<Datum>, userDriven: boolean): void => {}`\n */\n onBrushStart?: ((selection: [number, number] | undefined, event: D3BrushEvent<Datum>, userDriven: boolean) => void);\n /** Callback function to be called on the Brush move event.\n * Default: `(selection: [number, number], event: D3BrushEvent<Datum>, userDriven: boolean): void => {}`\n */\n onBrushMove?: ((selection: [number, number] | undefined, event: D3BrushEvent<Datum>, userDriven: boolean) => void);\n /** Callback function to be called on the Brush end event.\n * Default: `(selection: [number, number], event: D3BrushEvent<Datum>, userDriven: boolean): void => {}`\n */\n onBrushEnd?: ((selection: [number, number] | undefined, event: D3BrushEvent<Datum>, userDriven: boolean) => void);\n /** Width of the Brush handle. Default: `1` */\n handleWidth?: number;\n /** Brush selection in the data space coordinates, can be used to control the selection. Default: `undefined` */\n selection?: [number, number] | null;\n /** Allow dragging the selected area as a whole in order to change the selected range. Default: `false` */\n draggable?: boolean;\n /** Position of the handle: `Arrangement.Inside` or `Arrangement.Outside`. Default: `Arrangement.Inside` */\n handlePosition?: Arrangement | string;\n /** Constraint Brush selection to a minimal length in data units. Default: `undefined` */\n selectionMinLength?: number;\n}\n\nexport class BrushConfig<Datum> extends XYComponentConfig<Datum> implements BrushConfigInterface<Datum> {\n /* eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-function */\n onBrush = (s: [number, number] | undefined, e: D3BrushEvent<Datum>, userDriven: boolean): void => {}\n /* eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-function */\n onBrushStart = (s: [number, number] | undefined, e: D3BrushEvent<Datum>, userDriven: boolean): void => {}\n /* eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-function */\n onBrushMove = (s: [number, number] | undefined, e: D3BrushEvent<Datum>, userDriven: boolean): void => {}\n /* eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-function */\n onBrushEnd = (s: [number, number] | undefined, e: D3BrushEvent<Datum>, userDriven: boolean): void => {}\n handleWidth = 9\n selection = null\n draggable = false\n handlePosition: Arrangement | string = Arrangement.Inside\n selectionMinLength = undefined\n}\n"],"names":[],"mappings":";;;AAoCM,MAAO,WAAmB,SAAQ,iBAAwB,CAAA;AAAhE,IAAA,WAAA,GAAA;;;QAEE,IAAO,CAAA,OAAA,GAAG,CAAC,CAA+B,EAAE,CAAsB,EAAE,UAAmB,KAAY,GAAC,CAAA;;QAEpG,IAAY,CAAA,YAAA,GAAG,CAAC,CAA+B,EAAE,CAAsB,EAAE,UAAmB,KAAY,GAAC,CAAA;;QAEzG,IAAW,CAAA,WAAA,GAAG,CAAC,CAA+B,EAAE,CAAsB,EAAE,UAAmB,KAAY,GAAC,CAAA;;QAExG,IAAU,CAAA,UAAA,GAAG,CAAC,CAA+B,EAAE,CAAsB,EAAE,UAAmB,KAAY,GAAC,CAAA;QACvG,IAAW,CAAA,WAAA,GAAG,CAAC,CAAA;QACf,IAAS,CAAA,SAAA,GAAG,IAAI,CAAA;QAChB,IAAS,CAAA,SAAA,GAAG,KAAK,CAAA;AACjB,QAAA,IAAA,CAAA,cAAc,GAAyB,WAAW,CAAC,MAAM,CAAA;QACzD,IAAkB,CAAA,kBAAA,GAAG,SAAS,CAAA;KAC/B;AAAA;;;;"}
1
+ {"version":3,"file":"config.js","sources":["../../../src/components/brush/config.ts"],"sourcesContent":["import { D3BrushEvent } from 'd3-brush'\nimport { XYComponentConfigInterface, XYComponentDefaultConfig } from 'core/xy-component/config'\n\n// Types\nimport { Arrangement } from 'types/position'\n\n// We extend partial XY config interface because x and y properties are optional for Brush\nexport interface BrushConfigInterface<Datum> extends Partial<XYComponentConfigInterface<Datum>> {\n /** Callback function to be called on any Brush event.\n * Default: `(selection: [number, number], event: D3BrushEvent<Datum>, userDriven: boolean): void => {}`\n */\n onBrush?: ((selection: [number, number] | undefined, event: D3BrushEvent<Datum>, userDriven: boolean) => void);\n /** Callback function to be called on the Brush start event.\n * Default: `(selection: [number, number], event: D3BrushEvent<Datum>, userDriven: boolean): void => {}`\n */\n onBrushStart?: ((selection: [number, number] | undefined, event: D3BrushEvent<Datum>, userDriven: boolean) => void);\n /** Callback function to be called on the Brush move event.\n * Default: `(selection: [number, number], event: D3BrushEvent<Datum>, userDriven: boolean): void => {}`\n */\n onBrushMove?: ((selection: [number, number] | undefined, event: D3BrushEvent<Datum>, userDriven: boolean) => void);\n /** Callback function to be called on the Brush end event.\n * Default: `(selection: [number, number], event: D3BrushEvent<Datum>, userDriven: boolean): void => {}`\n */\n onBrushEnd?: ((selection: [number, number] | undefined, event: D3BrushEvent<Datum>, userDriven: boolean) => void);\n /** Width of the Brush handle. Default: `1` */\n handleWidth?: number;\n /** Brush selection in the data space coordinates, can be used to control the selection. Default: `undefined` */\n selection?: [number, number] | null;\n /** Allow dragging the selected area as a whole in order to change the selected range. Default: `false` */\n draggable?: boolean;\n /** Position of the handle: `Arrangement.Inside` or `Arrangement.Outside`. Default: `Arrangement.Inside` */\n handlePosition?: Arrangement | string;\n /** Constraint Brush selection to a minimal length in data units. Default: `undefined` */\n selectionMinLength?: number;\n}\n\nexport const BrushDefaultConfig: BrushConfigInterface<unknown> = {\n ...XYComponentDefaultConfig,\n /* eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-function */\n onBrush: <Datum>(s: [number, number] | undefined, e: D3BrushEvent<Datum>, userDriven: boolean): void => {},\n /* eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-function */\n onBrushStart: <Datum>(s: [number, number] | undefined, e: D3BrushEvent<Datum>, userDriven: boolean): void => {},\n /* eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-function */\n onBrushMove: <Datum>(s: [number, number] | undefined, e: D3BrushEvent<Datum>, userDriven: boolean): void => {},\n /* eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-function */\n onBrushEnd: <Datum>(s: [number, number] | undefined, e: D3BrushEvent<Datum>, userDriven: boolean): void => {},\n handleWidth: 9,\n selection: null,\n draggable: false,\n handlePosition: Arrangement.Inside,\n selectionMinLength: undefined,\n}\n"],"names":[],"mappings":";;;AAoCO,MAAM,kBAAkB,GAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EAC1B,wBAAwB,CAAA,EAAA;;IAE3B,OAAO,EAAE,CAAQ,CAA+B,EAAE,CAAsB,EAAE,UAAmB,KAAU,GAAG;;IAE1G,YAAY,EAAE,CAAQ,CAA+B,EAAE,CAAsB,EAAE,UAAmB,KAAU,GAAG;;IAE/G,WAAW,EAAE,CAAQ,CAA+B,EAAE,CAAsB,EAAE,UAAmB,KAAU,GAAG;;AAE9G,IAAA,UAAU,EAAE,CAAQ,CAA+B,EAAE,CAAsB,EAAE,UAAmB,QAAa,EAC7G,WAAW,EAAE,CAAC,EACd,SAAS,EAAE,IAAI,EACf,SAAS,EAAE,KAAK,EAChB,cAAc,EAAE,WAAW,CAAC,MAAM,EAClC,kBAAkB,EAAE,SAAS;;;;"}
@@ -1,13 +1,14 @@
1
1
  import { BrushBehavior, D3BrushEvent } from 'd3-brush';
2
2
  import { Selection } from 'd3-selection';
3
3
  import { XYComponentCore } from "../../core/xy-component";
4
- import { BrushConfig, BrushConfigInterface } from './config';
4
+ import { BrushConfigInterface } from './config';
5
5
  import { BrushHandleType } from './types';
6
6
  import * as s from './style';
7
- export declare class Brush<Datum> extends XYComponentCore<Datum, BrushConfig<Datum>, BrushConfigInterface<Datum>> {
7
+ export declare class Brush<Datum> extends XYComponentCore<Datum, BrushConfigInterface<Datum>> {
8
8
  static selectors: typeof s;
9
+ protected _defaultConfig: BrushConfigInterface<Datum>;
9
10
  clippable: boolean;
10
- config: BrushConfig<Datum>;
11
+ config: BrushConfigInterface<Datum>;
11
12
  brush: Selection<SVGGElement, unknown, SVGGElement, unknown>;
12
13
  unselectedRange: Selection<SVGRectElement, BrushHandleType, SVGGElement, unknown>;
13
14
  handleLines: Selection<SVGLineElement, BrushHandleType, SVGGElement, unknown>;
@@ -3,7 +3,7 @@ import { XYComponentCore } from '../../core/xy-component/index.js';
3
3
  import { isNumber, clamp } from '../../utils/data.js';
4
4
  import { smartTransition } from '../../utils/d3.js';
5
5
  import { Arrangement } from '../../types/position.js';
6
- import { BrushConfig } from './config.js';
6
+ import { BrushDefaultConfig } from './config.js';
7
7
  import { BrushDirection } from './types.js';
8
8
  import * as style from './style.js';
9
9
  import { brush, unselected, handleLine } from './style.js';
@@ -11,8 +11,9 @@ import { brush, unselected, handleLine } from './style.js';
11
11
  class Brush extends XYComponentCore {
12
12
  constructor(config) {
13
13
  super();
14
+ this._defaultConfig = BrushDefaultConfig;
14
15
  this.clippable = false; // Don't apply clipping path to this component. See XYContainer
15
- this.config = new BrushConfig();
16
+ this.config = this._defaultConfig;
16
17
  this.brushBehaviour = brushX();
17
18
  this.events = {
18
19
  [Brush.selectors.brush]: {},
@@ -20,7 +21,7 @@ class Brush extends XYComponentCore {
20
21
  this._selection = null;
21
22
  this._firstRender = true;
22
23
  if (config)
23
- this.config.init(config);
24
+ this.setConfig(config);
24
25
  this.brush = this.g
25
26
  .append('g')
26
27
  .attr('class', brush);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/components/brush/index.ts"],"sourcesContent":["import { BrushBehavior, brushX, D3BrushEvent } from 'd3-brush'\nimport { Selection } from 'd3-selection'\n\n// Core\nimport { XYComponentCore } from 'core/xy-component'\n\n// Utils\nimport { isNumber, clamp } from 'utils/data'\nimport { smartTransition } from 'utils/d3'\n\n// Types\nimport { Arrangement } from 'types/position'\n\n// Config\nimport { BrushConfig, BrushConfigInterface } from './config'\n\n// Local Types\nimport { BrushDirection, BrushHandleType } from './types'\n\n// Styles\nimport * as s from './style'\n\nexport class Brush<Datum> extends XYComponentCore<Datum, BrushConfig<Datum>, BrushConfigInterface<Datum>> {\n static selectors = s\n clippable = false // Don't apply clipping path to this component. See XYContainer\n config: BrushConfig<Datum> = new BrushConfig()\n brush: Selection<SVGGElement, unknown, SVGGElement, unknown>\n unselectedRange: Selection<SVGRectElement, BrushHandleType, SVGGElement, unknown>\n handleLines: Selection<SVGLineElement, BrushHandleType, SVGGElement, unknown>\n brushBehaviour: BrushBehavior<unknown> = brushX()\n events = {\n [Brush.selectors.brush]: {},\n }\n\n private _selection: [number, number] | null = null\n private _firstRender = true\n\n constructor (config?: BrushConfigInterface<Datum>) {\n super()\n if (config) this.config.init(config)\n\n this.brush = this.g\n .append('g')\n .attr('class', s.brush)\n\n const directions: BrushHandleType[] = [{ type: BrushDirection.West }, { type: BrushDirection.East }]\n this.unselectedRange = this.g\n .selectAll(`.${s.unselected}`)\n .data(directions)\n .enter().append('rect')\n .attr('class', s.unselected)\n\n this.handleLines = this.g\n .selectAll(`.${s.handleLine}`)\n .data(directions)\n .enter().append('line')\n .attr('class', s.handleLine)\n }\n\n _render (customDuration?: number): void {\n const { brushBehaviour, config } = this\n const duration = isNumber(customDuration) ? customDuration : config.duration\n const xScale = this.xScale\n\n brushBehaviour\n .extent([[0, 0], [this._width, this._height]])\n .on('start', this._onBrushStart.bind(this))\n .on('brush', this._onBrushMove.bind(this))\n .on('end', this._onBrushEnd.bind(this))\n\n this.brush\n .call(brushBehaviour)\n .classed('non-draggable', !config.draggable)\n\n const yRange = [this._height, 0]\n const h = yRange[0] - yRange[1]\n\n this.g.selectAll('.handle')\n .attr('y', yRange[1])\n .attr('height', h)\n\n this.unselectedRange\n .attr('y', yRange[1])\n .attr('height', h)\n\n this.handleLines\n .attr('y1', yRange[1] + 10)\n .attr('y2', yRange[1] + h - 10)\n\n // We save the X scale range and set it to the available horizontal space to calculate the selection range in pixels correctly\n const xRange = [0, this._width]\n const xScaleRange = xScale.range()\n xScale.range(xRange)\n const selectionMin = clamp(xScale((config.selection || this._selection)?.[0]) ?? 0, xRange[0], xRange[1])\n const selectionMax = clamp(xScale((config.selection || this._selection)?.[1]) ?? 0, xRange[0], xRange[1])\n xScale.range(xScaleRange) // Restore the X scale range\n\n const selectionLength = selectionMax - selectionMin\n const brushRange = (selectionLength ? [selectionMin, selectionMax] : xRange) as [number, number]\n this._positionHandles(brushRange)\n\n smartTransition(this.brush, duration)\n .call(brushBehaviour.move, brushRange) // Sets up the brush and calls brush events\n .on('end interrupt', () => { this._firstRender = false })\n // We track the first render to not trigger user events on component initialization\n if (!duration) this._firstRender = false\n }\n\n _updateSelection (s: [number, number]): void {\n const xRange = [0, this._width]\n this.unselectedRange\n .attr('x', d => d.type === BrushDirection.West ? xRange[0] : s[1])\n .attr('width', d => {\n const length = d.type === BrushDirection.West ? s[0] - xRange[0] : xRange[1] - s[1]\n const lengthClamped = clamp(length, 0, xRange[1] - xRange[0])\n return lengthClamped\n })\n\n this._positionHandles(s)\n\n // D3 sets brush handle height to be too long, so we need to update it\n const yRange = [this._height, 0]\n const h = yRange[0] - yRange[1]\n this.g.selectAll('.handle')\n .attr('y', yRange[1])\n .attr('height', h)\n }\n\n private _positionHandles (s: [number, number]): void {\n const { config } = this\n\n this.brush.selectAll<SVGRectElement, BrushHandleType>('.handle')\n .attr('width', config.handleWidth)\n .attr('x', d => {\n if (!s) return 0\n const west = d.type === BrushDirection.West\n const inside = config.handlePosition === Arrangement.Inside\n\n if (west) return s[0] + (inside ? 0 : -config.handleWidth)\n else return s[1] + (inside ? -config.handleWidth : 0)\n })\n\n this.handleLines\n .attr('transform', d => {\n if (!s) return null\n const west = d.type === BrushDirection.West\n const inside = config.handlePosition === Arrangement.Inside\n return `translate(${west\n ? s[0] - (-1) ** Number(inside) * config.handleWidth / 2\n : s[1] + (-1) ** Number(inside) * config.handleWidth / 2},0)`\n })\n }\n\n _onBrush (event: D3BrushEvent<Datum>): void {\n const { config } = this\n const xScale = this.xScale\n const xRange = [0, this._width]\n const s = (event?.selection || xRange) as [number, number]\n const userDriven = !!event?.sourceEvent\n // Handle edge cases:\n // (event?.selection === null) happens when user clicks to reset the selection\n // (s?.[0] === s?.[1]) happens when user drags the selection out of range\n if (userDriven && (\n (event?.selection === null) || // happens when user clicks to reset the selection\n (s?.[0] === s?.[1]) || // happens when user drags the selection out of range\n (s?.[0] < xRange[0]) || //\n (s?.[0] > xRange[1]) || // happens when you drag the brush and the domain updates\n (s?.[1] < xRange[0]) || // to a smaller one and brush goes out of range\n (s?.[1] > xRange[1]) //\n )) {\n this.brush.call(this.brushBehaviour.move, xRange) // Will trigger the 'brush end' callback with `range`\n return\n }\n\n // When you reset selection by clicking on a non-selected brush area, D3 triggers the brush event twice.\n // The first call will have equal selection coordinates (e.g. [441, 441]), the second call will have the full range (e.g. [0, 700]).\n // To avoid unnecessary render from the first call we skip it\n if (s[0] !== s[1] && isNumber(s[0]) && isNumber(s[1])) {\n // We save the X scale range and set it to the available horizontal space to invert the selection correctly\n const xScaleRange = xScale.range()\n xScale.range(xRange)\n const selectedDomain = s.map(n => +xScale.invert(n)) as [number, number]\n\n if (userDriven) {\n // Constraint the selection if configured\n const xDomain = xScale.domain() as [number, number]\n const xDomainLength = Math.abs(xDomain[1] - xDomain[0])\n const selectionLength = Math.abs(selectedDomain[1] - selectedDomain[0])\n\n if (config.selectionMinLength >= xDomainLength) {\n console.warn('Unovis | Brush: Configured `selectionMinLength` is bigger than the brush domain')\n }\n\n if ((selectionLength < config.selectionMinLength) && (config.selectionMinLength < xDomainLength)) {\n const selection = config.selection ?? this._selection\n const range = [xScale(selection[0]), xScale(selection[1])] as [number, number]\n this.brush.call(this.brushBehaviour.move, range) // Will trigger the 'brush end' callback with `range`\n // Restore the X scale range\n xScale.range(xScaleRange)\n return\n } else {\n this._selection = selectedDomain\n // Restore the X scale range\n xScale.range(xScaleRange)\n }\n }\n\n this._updateSelection(s)\n if (!this._firstRender) config.onBrush(selectedDomain, event, userDriven)\n }\n }\n\n _onBrushStart (event: D3BrushEvent<Datum>): void {\n const { config } = this\n\n this._onBrush(event)\n if (!this._firstRender) config.onBrushStart(this._selection, event, !!event?.sourceEvent)\n }\n\n _onBrushMove (event: D3BrushEvent<Datum>): void {\n const { config } = this\n\n this._onBrush(event)\n if (!this._firstRender) config.onBrushMove(this._selection, event, !!event?.sourceEvent)\n }\n\n _onBrushEnd (event: D3BrushEvent<Datum>): void {\n const { config } = this\n\n this._onBrush(event)\n if (!this._firstRender) config.onBrushEnd(this._selection, event, !!event?.sourceEvent)\n }\n}\n"],"names":["s.brush","s.unselected","s.handleLine","s"],"mappings":";;;;;;;;;;AAsBM,MAAO,KAAa,SAAQ,eAAuE,CAAA;AAevG,IAAA,WAAA,CAAa,MAAoC,EAAA;AAC/C,QAAA,KAAK,EAAE,CAAA;AAdT,QAAA,IAAA,CAAA,SAAS,GAAG,KAAK,CAAA;AACjB,QAAA,IAAA,CAAA,MAAM,GAAuB,IAAI,WAAW,EAAE,CAAA;QAI9C,IAAc,CAAA,cAAA,GAA2B,MAAM,EAAE,CAAA;AACjD,QAAA,IAAA,CAAA,MAAM,GAAG;AACP,YAAA,CAAC,KAAK,CAAC,SAAS,CAAC,KAAK,GAAG,EAAE;SAC5B,CAAA;QAEO,IAAU,CAAA,UAAA,GAA4B,IAAI,CAAA;QAC1C,IAAY,CAAA,YAAA,GAAG,IAAI,CAAA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AA,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;QACpB,IAAI,CAAC,IAAI,CAAC,YAAY;YAAE,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,UAAU,EAAE,KAAK,EAAE,CAAC,EAAC,KAAK,aAAL,KAAK,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAL,KAAK,CAAE,WAAW,CAAA,CAAC,CAAA;KAC1F;AAED,IAAA,YAAY,CAAE,KAA0B,EAAA;AACtC,QAAA,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAA;AAEvB,QAAA,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;QACpB,IAAI,CAAC,IAAI,CAAC,YAAY;YAAE,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU,EAAE,KAAK,EAAE,CAAC,EAAC,KAAK,aAAL,KAAK,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAL,KAAK,CAAE,WAAW,CAAA,CAAC,CAAA;KACzF;AAED,IAAA,WAAW,CAAE,KAA0B,EAAA;AACrC,QAAA,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAA;AAEvB,QAAA,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;QACpB,IAAI,CAAC,IAAI,CAAC,YAAY;YAAE,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,UAAU,EAAE,KAAK,EAAE,CAAC,EAAC,KAAK,aAAL,KAAK,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAL,KAAK,CAAE,WAAW,CAAA,CAAC,CAAA;KACxF;;AAhNM,KAAS,CAAA,SAAA,GAAGC,KAAC;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../src/components/brush/index.ts"],"sourcesContent":["import { BrushBehavior, brushX, D3BrushEvent } from 'd3-brush'\nimport { Selection } from 'd3-selection'\n\n// Core\nimport { XYComponentCore } from 'core/xy-component'\n\n// Utils\nimport { isNumber, clamp } from 'utils/data'\nimport { smartTransition } from 'utils/d3'\n\n// Types\nimport { Arrangement } from 'types/position'\n\n// Config\nimport { BrushDefaultConfig, BrushConfigInterface } from './config'\n\n// Local Types\nimport { BrushDirection, BrushHandleType } from './types'\n\n// Styles\nimport * as s from './style'\n\nexport class Brush<Datum> extends XYComponentCore<Datum, BrushConfigInterface<Datum>> {\n static selectors = s\n protected _defaultConfig = BrushDefaultConfig as BrushConfigInterface<Datum>\n clippable = false // Don't apply clipping path to this component. See XYContainer\n public config: BrushConfigInterface<Datum> = this._defaultConfig\n brush: Selection<SVGGElement, unknown, SVGGElement, unknown>\n unselectedRange: Selection<SVGRectElement, BrushHandleType, SVGGElement, unknown>\n handleLines: Selection<SVGLineElement, BrushHandleType, SVGGElement, unknown>\n brushBehaviour: BrushBehavior<unknown> = brushX()\n events = {\n [Brush.selectors.brush]: {},\n }\n\n private _selection: [number, number] | null = null\n private _firstRender = true\n\n constructor (config?: BrushConfigInterface<Datum>) {\n super()\n if (config) this.setConfig(config)\n\n this.brush = this.g\n .append('g')\n .attr('class', s.brush)\n\n const directions: BrushHandleType[] = [{ type: BrushDirection.West }, { type: BrushDirection.East }]\n this.unselectedRange = this.g\n .selectAll(`.${s.unselected}`)\n .data(directions)\n .enter().append('rect')\n .attr('class', s.unselected)\n\n this.handleLines = this.g\n .selectAll(`.${s.handleLine}`)\n .data(directions)\n .enter().append('line')\n .attr('class', s.handleLine)\n }\n\n _render (customDuration?: number): void {\n const { brushBehaviour, config } = this\n const duration = isNumber(customDuration) ? customDuration : config.duration\n const xScale = this.xScale\n\n brushBehaviour\n .extent([[0, 0], [this._width, this._height]])\n .on('start', this._onBrushStart.bind(this))\n .on('brush', this._onBrushMove.bind(this))\n .on('end', this._onBrushEnd.bind(this))\n\n this.brush\n .call(brushBehaviour)\n .classed('non-draggable', !config.draggable)\n\n const yRange = [this._height, 0]\n const h = yRange[0] - yRange[1]\n\n this.g.selectAll('.handle')\n .attr('y', yRange[1])\n .attr('height', h)\n\n this.unselectedRange\n .attr('y', yRange[1])\n .attr('height', h)\n\n this.handleLines\n .attr('y1', yRange[1] + 10)\n .attr('y2', yRange[1] + h - 10)\n\n // We save the X scale range and set it to the available horizontal space to calculate the selection range in pixels correctly\n const xRange = [0, this._width]\n const xScaleRange = xScale.range()\n xScale.range(xRange)\n const selectionMin = clamp(xScale((config.selection || this._selection)?.[0]) ?? 0, xRange[0], xRange[1])\n const selectionMax = clamp(xScale((config.selection || this._selection)?.[1]) ?? 0, xRange[0], xRange[1])\n xScale.range(xScaleRange) // Restore the X scale range\n\n const selectionLength = selectionMax - selectionMin\n const brushRange = (selectionLength ? [selectionMin, selectionMax] : xRange) as [number, number]\n this._positionHandles(brushRange)\n\n smartTransition(this.brush, duration)\n .call(brushBehaviour.move, brushRange) // Sets up the brush and calls brush events\n .on('end interrupt', () => { this._firstRender = false })\n // We track the first render to not trigger user events on component initialization\n if (!duration) this._firstRender = false\n }\n\n _updateSelection (s: [number, number]): void {\n const xRange = [0, this._width]\n this.unselectedRange\n .attr('x', d => d.type === BrushDirection.West ? xRange[0] : s[1])\n .attr('width', d => {\n const length = d.type === BrushDirection.West ? s[0] - xRange[0] : xRange[1] - s[1]\n const lengthClamped = clamp(length, 0, xRange[1] - xRange[0])\n return lengthClamped\n })\n\n this._positionHandles(s)\n\n // D3 sets brush handle height to be too long, so we need to update it\n const yRange = [this._height, 0]\n const h = yRange[0] - yRange[1]\n this.g.selectAll('.handle')\n .attr('y', yRange[1])\n .attr('height', h)\n }\n\n private _positionHandles (s: [number, number]): void {\n const { config } = this\n\n this.brush.selectAll<SVGRectElement, BrushHandleType>('.handle')\n .attr('width', config.handleWidth)\n .attr('x', d => {\n if (!s) return 0\n const west = d.type === BrushDirection.West\n const inside = config.handlePosition === Arrangement.Inside\n\n if (west) return s[0] + (inside ? 0 : -config.handleWidth)\n else return s[1] + (inside ? -config.handleWidth : 0)\n })\n\n this.handleLines\n .attr('transform', d => {\n if (!s) return null\n const west = d.type === BrushDirection.West\n const inside = config.handlePosition === Arrangement.Inside\n return `translate(${west\n ? s[0] - (-1) ** Number(inside) * config.handleWidth / 2\n : s[1] + (-1) ** Number(inside) * config.handleWidth / 2},0)`\n })\n }\n\n _onBrush (event: D3BrushEvent<Datum>): void {\n const { config } = this\n const xScale = this.xScale\n const xRange = [0, this._width]\n const s = (event?.selection || xRange) as [number, number]\n const userDriven = !!event?.sourceEvent\n // Handle edge cases:\n // (event?.selection === null) happens when user clicks to reset the selection\n // (s?.[0] === s?.[1]) happens when user drags the selection out of range\n if (userDriven && (\n (event?.selection === null) || // happens when user clicks to reset the selection\n (s?.[0] === s?.[1]) || // happens when user drags the selection out of range\n (s?.[0] < xRange[0]) || //\n (s?.[0] > xRange[1]) || // happens when you drag the brush and the domain updates\n (s?.[1] < xRange[0]) || // to a smaller one and brush goes out of range\n (s?.[1] > xRange[1]) //\n )) {\n this.brush.call(this.brushBehaviour.move, xRange) // Will trigger the 'brush end' callback with `range`\n return\n }\n\n // When you reset selection by clicking on a non-selected brush area, D3 triggers the brush event twice.\n // The first call will have equal selection coordinates (e.g. [441, 441]), the second call will have the full range (e.g. [0, 700]).\n // To avoid unnecessary render from the first call we skip it\n if (s[0] !== s[1] && isNumber(s[0]) && isNumber(s[1])) {\n // We save the X scale range and set it to the available horizontal space to invert the selection correctly\n const xScaleRange = xScale.range()\n xScale.range(xRange)\n const selectedDomain = s.map(n => +xScale.invert(n)) as [number, number]\n\n if (userDriven) {\n // Constraint the selection if configured\n const xDomain = xScale.domain() as [number, number]\n const xDomainLength = Math.abs(xDomain[1] - xDomain[0])\n const selectionLength = Math.abs(selectedDomain[1] - selectedDomain[0])\n\n if (config.selectionMinLength >= xDomainLength) {\n console.warn('Unovis | Brush: Configured `selectionMinLength` is bigger than the brush domain')\n }\n\n if ((selectionLength < config.selectionMinLength) && (config.selectionMinLength < xDomainLength)) {\n const selection = config.selection ?? this._selection\n const range = [xScale(selection[0]), xScale(selection[1])] as [number, number]\n this.brush.call(this.brushBehaviour.move, range) // Will trigger the 'brush end' callback with `range`\n // Restore the X scale range\n xScale.range(xScaleRange)\n return\n } else {\n this._selection = selectedDomain\n // Restore the X scale range\n xScale.range(xScaleRange)\n }\n }\n\n this._updateSelection(s)\n if (!this._firstRender) config.onBrush(selectedDomain, event, userDriven)\n }\n }\n\n _onBrushStart (event: D3BrushEvent<Datum>): void {\n const { config } = this\n\n this._onBrush(event)\n if (!this._firstRender) config.onBrushStart(this._selection, event, !!event?.sourceEvent)\n }\n\n _onBrushMove (event: D3BrushEvent<Datum>): void {\n const { config } = this\n\n this._onBrush(event)\n if (!this._firstRender) config.onBrushMove(this._selection, event, !!event?.sourceEvent)\n }\n\n _onBrushEnd (event: D3BrushEvent<Datum>): void {\n const { config } = this\n\n this._onBrush(event)\n if (!this._firstRender) config.onBrushEnd(this._selection, event, !!event?.sourceEvent)\n }\n}\n"],"names":["s.brush","s.unselected","s.handleLine","s"],"mappings":";;;;;;;;;;AAsBM,MAAO,KAAa,SAAQ,eAAmD,CAAA;AAgBnF,IAAA,WAAA,CAAa,MAAoC,EAAA;AAC/C,QAAA,KAAK,EAAE,CAAA;QAfC,IAAc,CAAA,cAAA,GAAG,kBAAiD,CAAA;AAC5E,QAAA,IAAA,CAAA,SAAS,GAAG,KAAK,CAAA;AACV,QAAA,IAAA,CAAA,MAAM,GAAgC,IAAI,CAAC,cAAc,CAAA;QAIhE,IAAc,CAAA,cAAA,GAA2B,MAAM,EAAE,CAAA;AACjD,QAAA,IAAA,CAAA,MAAM,GAAG;AACP,YAAA,CAAC,KAAK,CAAC,SAAS,CAAC,KAAK,GAAG,EAAE;SAC5B,CAAA;QAEO,IAAU,CAAA,UAAA,GAA4B,IAAI,CAAA;QAC1C,IAAY,CAAA,YAAA,GAAG,IAAI,CAAA;AAIzB,QAAA,IAAI,MAAM;AAAE,YAAA,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAA;AAElC,QAAA,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC;aAChB,MAAM,CAAC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K,aAAL,KAAK,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAL,KAAK,CAAE,WAAW,CAAA,CAAC,CAAA;KAC1F;AAED,IAAA,YAAY,CAAE,KAA0B,EAAA;AACtC,QAAA,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAA;AAEvB,QAAA,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;QACpB,IAAI,CAAC,IAAI,CAAC,YAAY;YAAE,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU,EAAE,KAAK,EAAE,CAAC,EAAC,KAAK,aAAL,KAAK,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAL,KAAK,CAAE,WAAW,CAAA,CAAC,CAAA;KACzF;AAED,IAAA,WAAW,CAAE,KAA0B,EAAA;AACrC,QAAA,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAA;AAEvB,QAAA,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;QACpB,IAAI,CAAC,IAAI,CAAC,YAAY;YAAE,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,UAAU,EAAE,KAAK,EAAE,CAAC,EAAC,KAAK,aAAL,KAAK,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAL,KAAK,CAAE,WAAW,CAAA,CAAC,CAAA;KACxF;;AAjNM,KAAS,CAAA,SAAA,GAAGC,KAAC;;;;"}
@@ -1,4 +1,3 @@
1
- import { Config } from "../../core/config";
2
1
  import { BulletLegendItemInterface, BulletShape } from './types';
3
2
  export interface BulletLegendConfigInterface {
4
3
  /** Legend items. Array of `BulletLegendItemInterface`:
@@ -26,12 +25,4 @@ export interface BulletLegendConfigInterface {
26
25
  /** Bullet shape: `BulletShape.Circle`, `BulletShape.Line` or `BulletShape.Square`. Default: `BulletShape.Circle` */
27
26
  bulletShape?: BulletShape;
28
27
  }
29
- export declare class BulletLegendConfig extends Config implements BulletLegendConfigInterface {
30
- items: BulletLegendItemInterface[];
31
- labelClassName: string;
32
- onLegendItemClick: any;
33
- labelFontSize: any;
34
- labelMaxWidth: any;
35
- bulletSize: any;
36
- bulletShape: BulletShape;
37
- }
28
+ export declare const BulletLegendDefaultConfig: BulletLegendConfigInterface;
@@ -1,18 +1,15 @@
1
- import { Config } from '../../core/config/index.js';
2
1
  import { BulletShape } from './types.js';
3
2
 
4
- class BulletLegendConfig extends Config {
5
- constructor() {
6
- super(...arguments);
7
- this.items = [];
8
- this.labelClassName = '';
9
- this.onLegendItemClick = undefined;
10
- this.labelFontSize = null;
11
- this.labelMaxWidth = null;
12
- this.bulletSize = null;
13
- this.bulletShape = BulletShape.Circle;
14
- }
15
- }
3
+ // Local Types
4
+ const BulletLegendDefaultConfig = {
5
+ items: [],
6
+ labelClassName: '',
7
+ onLegendItemClick: undefined,
8
+ labelFontSize: null,
9
+ labelMaxWidth: null,
10
+ bulletSize: null,
11
+ bulletShape: BulletShape.Circle,
12
+ };
16
13
 
17
- export { BulletLegendConfig };
14
+ export { BulletLegendDefaultConfig };
18
15
  //# sourceMappingURL=config.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sources":["../../../src/components/bullet-legend/config.ts"],"sourcesContent":["import { Config } from 'core/config'\n\n// Local Types\nimport { BulletLegendItemInterface, BulletShape } from './types'\n\nexport interface BulletLegendConfigInterface {\n /** Legend items. Array of `BulletLegendItemInterface`:\n * ```\n * {\n * name: string | number;\n * color?: string;\n * inactive?: boolean;\n * hidden?: boolean;\n * pointer?: boolean;\n * }\n * ```\n * Default: `[]` */\n items: BulletLegendItemInterface[];\n /** Apply a specific class to the labels. Default: `''` */\n labelClassName?: string;\n /** Callback function for the legend item click. Default: `undefined` */\n onLegendItemClick?: ((d: BulletLegendItemInterface, i: number) => void);\n /** Label text (<span> element) font-size CSS. Default: `null` */\n labelFontSize?: string | null;\n /** Label text (<span> element) max-width CSS property. Default: `null` */\n labelMaxWidth?: string | null;\n /** Bullet shape size, mapped to the width and height CSS properties. Default: `null` */\n bulletSize?: string | null;\n /** Bullet shape: `BulletShape.Circle`, `BulletShape.Line` or `BulletShape.Square`. Default: `BulletShape.Circle` */\n bulletShape?: BulletShape;\n}\n\nexport class BulletLegendConfig extends Config implements BulletLegendConfigInterface {\n items: BulletLegendItemInterface[] = []\n labelClassName = ''\n onLegendItemClick = undefined\n labelFontSize = null\n labelMaxWidth = null\n bulletSize = null\n bulletShape = BulletShape.Circle\n}\n"],"names":[],"mappings":";;;AAgCM,MAAO,kBAAmB,SAAQ,MAAM,CAAA;AAA9C,IAAA,WAAA,GAAA;;QACE,IAAK,CAAA,KAAA,GAAgC,EAAE,CAAA;QACvC,IAAc,CAAA,cAAA,GAAG,EAAE,CAAA;QACnB,IAAiB,CAAA,iBAAA,GAAG,SAAS,CAAA;QAC7B,IAAa,CAAA,aAAA,GAAG,IAAI,CAAA;QACpB,IAAa,CAAA,aAAA,GAAG,IAAI,CAAA;QACpB,IAAU,CAAA,UAAA,GAAG,IAAI,CAAA;AACjB,QAAA,IAAA,CAAA,WAAW,GAAG,WAAW,CAAC,MAAM,CAAA;KACjC;AAAA;;;;"}
1
+ {"version":3,"file":"config.js","sources":["../../../src/components/bullet-legend/config.ts"],"sourcesContent":["// Local Types\nimport { BulletLegendItemInterface, BulletShape } from './types'\n\nexport interface BulletLegendConfigInterface {\n /** Legend items. Array of `BulletLegendItemInterface`:\n * ```\n * {\n * name: string | number;\n * color?: string;\n * inactive?: boolean;\n * hidden?: boolean;\n * pointer?: boolean;\n * }\n * ```\n * Default: `[]` */\n items: BulletLegendItemInterface[];\n /** Apply a specific class to the labels. Default: `''` */\n labelClassName?: string;\n /** Callback function for the legend item click. Default: `undefined` */\n onLegendItemClick?: ((d: BulletLegendItemInterface, i: number) => void);\n /** Label text (<span> element) font-size CSS. Default: `null` */\n labelFontSize?: string | null;\n /** Label text (<span> element) max-width CSS property. Default: `null` */\n labelMaxWidth?: string | null;\n /** Bullet shape size, mapped to the width and height CSS properties. Default: `null` */\n bulletSize?: string | null;\n /** Bullet shape: `BulletShape.Circle`, `BulletShape.Line` or `BulletShape.Square`. Default: `BulletShape.Circle` */\n bulletShape?: BulletShape;\n}\n\nexport const BulletLegendDefaultConfig: BulletLegendConfigInterface = {\n items: [],\n labelClassName: '',\n onLegendItemClick: undefined,\n labelFontSize: null,\n labelMaxWidth: null,\n bulletSize: null,\n bulletShape: BulletShape.Circle,\n}\n"],"names":[],"mappings":";;AAAA;AA8Ba,MAAA,yBAAyB,GAAgC;AACpE,IAAA,KAAK,EAAE,EAAE;AACT,IAAA,cAAc,EAAE,EAAE;AAClB,IAAA,iBAAiB,EAAE,SAAS;AAC5B,IAAA,aAAa,EAAE,IAAI;AACnB,IAAA,aAAa,EAAE,IAAI;AACnB,IAAA,UAAU,EAAE,IAAI;IAChB,WAAW,EAAE,WAAW,CAAC,MAAM;;;;;"}
@@ -1,13 +1,14 @@
1
1
  import { Selection } from 'd3-selection';
2
- import { BulletLegendConfig, BulletLegendConfigInterface } from './config';
2
+ import { BulletLegendConfigInterface } from './config';
3
3
  import { BulletLegendItemInterface } from './types';
4
4
  import * as s from './style';
5
5
  export declare class BulletLegend {
6
6
  static selectors: typeof s;
7
+ protected _defaultConfig: BulletLegendConfigInterface;
8
+ config: BulletLegendConfigInterface;
7
9
  div: Selection<HTMLDivElement, unknown, null, undefined>;
8
10
  element: HTMLElement;
9
- prevConfig: BulletLegendConfig;
10
- config: BulletLegendConfig;
11
+ prevConfig: BulletLegendConfigInterface;
11
12
  protected _container: HTMLElement;
12
13
  private _colorAccessor;
13
14
  constructor(element: HTMLElement, config?: BulletLegendConfigInterface);
@@ -1,11 +1,14 @@
1
1
  import { select } from 'd3-selection';
2
- import { BulletLegendConfig } from './config.js';
2
+ import { merge } from '../../utils/data.js';
3
+ import { BulletLegendDefaultConfig } from './config.js';
3
4
  import { createBullets, updateBullets } from './modules/shape.js';
4
5
  import * as style from './style.js';
5
6
  import { root, item, bullet, label, clickable } from './style.js';
6
7
 
7
8
  class BulletLegend {
8
9
  constructor(element, config) {
10
+ this._defaultConfig = BulletLegendDefaultConfig;
11
+ this.config = this._defaultConfig;
9
12
  this._colorAccessor = (d) => d.color;
10
13
  this._container = element;
11
14
  // Create SVG element for visualizations
@@ -18,7 +21,7 @@ class BulletLegend {
18
21
  }
19
22
  update(config) {
20
23
  this.prevConfig = this.config;
21
- this.config = new BulletLegendConfig().init(config);
24
+ this.config = merge(this._defaultConfig, config);
22
25
  this.render();
23
26
  }
24
27
  render() {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/components/bullet-legend/index.ts"],"sourcesContent":["import { select, Selection } from 'd3-selection'\n\n// Config\nimport { BulletLegendConfig, BulletLegendConfigInterface } from './config'\n\n// Local Types\nimport { BulletLegendItemInterface } from './types'\n\n// Modules\nimport { createBullets, updateBullets } from './modules/shape'\n\n// Styles\nimport * as s from './style'\n\nexport class BulletLegend {\n static selectors = s\n div: Selection<HTMLDivElement, unknown, null, undefined>\n element: HTMLElement\n prevConfig: BulletLegendConfig\n config: BulletLegendConfig\n protected _container: HTMLElement\n\n private _colorAccessor = (d: BulletLegendItemInterface): string => d.color\n\n constructor (element: HTMLElement, config?: BulletLegendConfigInterface) {\n this._container = element\n\n // Create SVG element for visualizations\n this.div = select(this._container)\n .append('div')\n .attr('class', s.root)\n\n this.element = this.div.node()\n\n if (config) this.update(config)\n }\n\n update (config: BulletLegendConfigInterface): void {\n this.prevConfig = this.config\n this.config = new BulletLegendConfig().init(config)\n this.render()\n }\n\n render (): void {\n const { config } = this\n const legendItems = this.div.selectAll<HTMLDivElement, unknown>(`.${s.item}`)\n .data(config.items)\n\n const legendItemsEnter = legendItems.enter()\n .append('div')\n .attr('class', s.item)\n .on('click', this._onItemClick.bind(this))\n\n legendItemsEnter.append('span')\n .attr('class', s.bullet)\n .call(createBullets, config)\n\n legendItemsEnter.append('span')\n .attr('class', s.label)\n .classed(config.labelClassName, true)\n .style('max-width', config.labelMaxWidth)\n .style('font-size', config.labelFontSize)\n\n const legendItemsMerged = legendItemsEnter.merge(legendItems)\n legendItemsMerged\n .classed(s.clickable, d => !!config.onLegendItemClick && this._isItemClickable(d))\n .style('display', (d: BulletLegendItemInterface) => d.hidden ? 'none' : null)\n\n legendItemsMerged.select<HTMLSpanElement>(`.${s.bullet}`)\n .style('min-width', config.bulletSize)\n .style('height', config.bulletSize)\n .call(updateBullets, this.config, this._colorAccessor)\n\n legendItemsMerged.select(`.${s.label}`)\n .text((d: BulletLegendItemInterface) => d.name)\n\n legendItems.exit().remove()\n }\n\n _isItemClickable (item: BulletLegendItemInterface): boolean {\n return item.pointer === undefined ? true : item.pointer\n }\n\n _onItemClick (event: MouseEvent, d: BulletLegendItemInterface): void {\n const { config: { onLegendItemClick } } = this\n\n const legendItems = this.div.selectAll(`.${s.item}`).nodes() as HTMLElement[]\n const index = legendItems.indexOf(event.currentTarget as HTMLElement)\n if (onLegendItemClick) onLegendItemClick(d, index)\n }\n\n public destroy (): void {\n this.div.remove()\n }\n}\n"],"names":["s.root","s.item","s.bullet","s.label","s.clickable","s"],"mappings":";;;;;;MAca,YAAY,CAAA;IAUvB,WAAa,CAAA,OAAoB,EAAE,MAAoC,EAAA;QAF/D,IAAc,CAAA,cAAA,GAAG,CAAC,CAA4B,KAAa,CAAC,CAAC,KAAK,CAAA;AAGxE,QAAA,IAAI,CAAC,UAAU,GAAG,OAAO,CAAA;;QAGzB,IAAI,CAAC,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC;aAC/B,MAAM,CAAC,KAAK,CAAC;AACb,aAAA,IAAI,CAAC,OAAO,EAAEA,IAAM,CAAC,CAAA;QAExB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAA;AAE9B,QAAA,IAAI,MAAM;AAAE,YAAA,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;KAChC;AAED,IAAA,MAAM,CAAE,MAAmC,EAAA;AACzC,QAAA,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,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MAAM,EAAE,CAAA;KAClB;;AA9EM,YAAS,CAAA,SAAA,GAAGI,KAAC;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../src/components/bullet-legend/index.ts"],"sourcesContent":["import { select, Selection } from 'd3-selection'\n\n// Utils\nimport { merge } from 'utils/data'\n\n// Config\nimport { BulletLegendDefaultConfig, BulletLegendConfigInterface } from './config'\n\n// Local Types\nimport { BulletLegendItemInterface } from './types'\n\n// Modules\nimport { createBullets, updateBullets } from './modules/shape'\n\n// Styles\nimport * as s from './style'\n\nexport class BulletLegend {\n static selectors = s\n protected _defaultConfig = BulletLegendDefaultConfig as BulletLegendConfigInterface\n public config: BulletLegendConfigInterface = this._defaultConfig\n\n div: Selection<HTMLDivElement, unknown, null, undefined>\n element: HTMLElement\n prevConfig: BulletLegendConfigInterface\n protected _container: HTMLElement\n\n private _colorAccessor = (d: BulletLegendItemInterface): string => d.color\n\n constructor (element: HTMLElement, config?: BulletLegendConfigInterface) {\n this._container = element\n\n // Create SVG element for visualizations\n this.div = select(this._container)\n .append('div')\n .attr('class', s.root)\n\n this.element = this.div.node()\n\n if (config) this.update(config)\n }\n\n update (config: BulletLegendConfigInterface): void {\n this.prevConfig = this.config\n this.config = merge(this._defaultConfig, config)\n this.render()\n }\n\n render (): void {\n const { config } = this\n const legendItems = this.div.selectAll<HTMLDivElement, unknown>(`.${s.item}`)\n .data(config.items)\n\n const legendItemsEnter = legendItems.enter()\n .append('div')\n .attr('class', s.item)\n .on('click', this._onItemClick.bind(this))\n\n legendItemsEnter.append('span')\n .attr('class', s.bullet)\n .call(createBullets, config)\n\n legendItemsEnter.append('span')\n .attr('class', s.label)\n .classed(config.labelClassName, true)\n .style('max-width', config.labelMaxWidth)\n .style('font-size', config.labelFontSize)\n\n const legendItemsMerged = legendItemsEnter.merge(legendItems)\n legendItemsMerged\n .classed(s.clickable, d => !!config.onLegendItemClick && this._isItemClickable(d))\n .style('display', (d: BulletLegendItemInterface) => d.hidden ? 'none' : null)\n\n legendItemsMerged.select<HTMLSpanElement>(`.${s.bullet}`)\n .style('min-width', config.bulletSize)\n .style('height', config.bulletSize)\n .call(updateBullets, this.config, this._colorAccessor)\n\n legendItemsMerged.select(`.${s.label}`)\n .text((d: BulletLegendItemInterface) => d.name)\n\n legendItems.exit().remove()\n }\n\n _isItemClickable (item: BulletLegendItemInterface): boolean {\n return item.pointer === undefined ? true : item.pointer\n }\n\n _onItemClick (event: MouseEvent, d: BulletLegendItemInterface): void {\n const { config: { onLegendItemClick } } = this\n\n const legendItems = this.div.selectAll(`.${s.item}`).nodes() as HTMLElement[]\n const index = legendItems.indexOf(event.currentTarget as HTMLElement)\n if (onLegendItemClick) onLegendItemClick(d, index)\n }\n\n public destroy (): void {\n this.div.remove()\n }\n}\n"],"names":["s.root","s.item","s.bullet","s.label","s.clickable","s"],"mappings":";;;;;;;MAiBa,YAAY,CAAA;IAYvB,WAAa,CAAA,OAAoB,EAAE,MAAoC,EAAA;QAV7D,IAAc,CAAA,cAAA,GAAG,yBAAwD,CAAA;AAC5E,QAAA,IAAA,CAAA,MAAM,GAAgC,IAAI,CAAC,cAAc,CAAA;QAOxD,IAAc,CAAA,cAAA,GAAG,CAAC,CAA4B,KAAa,CAAC,CAAC,KAAK,CAAA;AAGxE,QAAA,IAAI,CAAC,UAAU,GAAG,OAAO,CAAA;;QAGzB,IAAI,CAAC,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC;aAC/B,MAAM,CAAC,KAAK,CAAC;AACb,aAAA,IAAI,CAAC,OAAO,EAAEA,IAAM,CAAC,CAAA;QAExB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAA;AAE9B,QAAA,IAAI,MAAM;AAAE,YAAA,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;KAChC;AAED,IAAA,MAAM,CAAE,MAAmC,EAAA;AACzC,QAAA,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,MAAM,CAAA;Q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A;KAClB;;AAhFM,YAAS,CAAA,SAAA,GAAGI,KAAC;;;;"}
@@ -1,15 +1,15 @@
1
- import { ComponentConfigInterface, ComponentConfig } from "../../core/component/config";
1
+ import { ComponentConfigInterface } from "../../core/component/config";
2
2
  import { ColorAccessor, GenericAccessor, NumericAccessor, StringAccessor } from "../../types/accessor";
3
- import { ChordInputLink, ChordInputNode, ChordLabelAlignment, ChordNodeDatum } from './types';
3
+ import { ChordInputLink, ChordInputNode, ChordLabelAlignment, ChordLinkDatum, ChordNodeDatum } from './types';
4
4
  export interface ChordDiagramConfigInterface<N extends ChordInputNode, L extends ChordInputLink> extends ComponentConfigInterface {
5
5
  /** Node id or index to highlight. Overrides default hover behavior if supplied. Default: `undefined` */
6
6
  highlightedNodeId?: number | string;
7
7
  /** Link ids or index values to highlight. Overrides default hover behavior if supplied. Default: [] */
8
8
  highlightedLinkIds?: (number | string)[];
9
9
  /** Link color accessor function. Default: `var(--vis-chord-diagram-link-fill-color)` */
10
- linkColor?: ColorAccessor<L>;
10
+ linkColor?: ColorAccessor<ChordLinkDatum<N, L>>;
11
11
  /** Link value accessor function. Default: `l => l.value` */
12
- linkValue?: NumericAccessor<L>;
12
+ linkValue?: NumericAccessor<ChordLinkDatum<N, L>>;
13
13
  /** Array of node hierarchy levels. Data records are supposed to have corresponding properties, e.g. ['level1', 'level2']. Default: `[]` */
14
14
  nodeLevels?: string[];
15
15
  /** Node width in pixels. Default: `15` */
@@ -23,28 +23,12 @@ export interface ChordDiagramConfigInterface<N extends ChordInputNode, L extends
23
23
  /** Node label alignment. Default: `ChordLabelAlignment.Along` */
24
24
  nodeLabelAlignment?: GenericAccessor<ChordLabelAlignment | string, ChordNodeDatum<N>>;
25
25
  /** Pad angle in radians. Constant value or accessor function. Default: `0.02` */
26
- padAngle?: NumericAccessor<N>;
26
+ padAngle?: NumericAccessor<ChordNodeDatum<N>>;
27
27
  /** Corner radius constant value or accessor function. Default: `2` */
28
- cornerRadius?: NumericAccessor<N>;
28
+ cornerRadius?: NumericAccessor<ChordNodeDatum<N>>;
29
29
  /** Angular range of the diagram. Default: `[0, 2 * Math.PI]` */
30
30
  angleRange?: [number, number];
31
31
  /** The exponent property of the radius scale. Default: `2` */
32
32
  radiusScaleExponent?: number;
33
33
  }
34
- export declare class ChordDiagramConfig<N extends ChordInputNode, L extends ChordInputLink> extends ComponentConfig implements ChordDiagramConfigInterface<N, L> {
35
- duration: number;
36
- highlightedNodeId: any;
37
- highlightedLinkIds: any[];
38
- linkColor: any;
39
- linkValue: (d: L) => number;
40
- nodeLevels: any[];
41
- nodeWidth: number;
42
- nodeColor: (d: ChordNodeDatum<N>) => string;
43
- nodeLabel: (d: ChordNodeDatum<N>) => string;
44
- nodeLabelColor: any;
45
- nodeLabelAlignment: ChordLabelAlignment;
46
- padAngle: number;
47
- cornerRadius: number;
48
- angleRange: [number, number];
49
- radiusScaleExponent: number;
50
- }
34
+ export declare const ChordDiagramDefaultConfig: ChordDiagramConfigInterface<ChordInputNode, ChordInputLink>;
@@ -1,27 +1,8 @@
1
- import { ComponentConfig } from '../../core/component/config.js';
1
+ import { ComponentDefaultConfig } from '../../core/component/config.js';
2
2
  import { ChordLabelAlignment } from './types.js';
3
3
 
4
- /* eslint-disable dot-notation */
5
- class ChordDiagramConfig extends ComponentConfig {
6
- constructor() {
7
- super(...arguments);
8
- this.duration = 800;
9
- this.highlightedNodeId = undefined;
10
- this.highlightedLinkIds = [];
11
- this.linkColor = undefined;
12
- this.linkValue = (d) => d['value'];
13
- this.nodeLevels = [];
14
- this.nodeWidth = 15;
15
- this.nodeColor = (d) => d['color'];
16
- this.nodeLabel = (d) => { var _a; return (_a = d['label']) !== null && _a !== void 0 ? _a : d['key']; };
17
- this.nodeLabelColor = undefined;
18
- this.nodeLabelAlignment = ChordLabelAlignment.Along;
19
- this.padAngle = 0.02;
20
- this.cornerRadius = 2;
21
- this.angleRange = [0, 2 * Math.PI];
22
- this.radiusScaleExponent = 2;
23
- }
24
- }
4
+ // Core
5
+ const ChordDiagramDefaultConfig = Object.assign(Object.assign({}, ComponentDefaultConfig), { duration: 800, highlightedNodeId: undefined, highlightedLinkIds: [], linkColor: undefined, linkValue: (d) => d.value, nodeLevels: [], nodeWidth: 15, nodeColor: (d) => d.color, nodeLabel: (d) => { var _a; return (_a = d.label) !== null && _a !== void 0 ? _a : d.key; }, nodeLabelColor: undefined, nodeLabelAlignment: ChordLabelAlignment.Along, padAngle: 0.02, cornerRadius: 2, angleRange: [0, 2 * Math.PI], radiusScaleExponent: 2 });
25
6
 
26
- export { ChordDiagramConfig };
7
+ export { ChordDiagramDefaultConfig };
27
8
  //# sourceMappingURL=config.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sources":["../../../src/components/chord-diagram/config.ts"],"sourcesContent":["/* eslint-disable dot-notation */\n\n// Core\nimport { ComponentConfigInterface, ComponentConfig } from 'core/component/config'\n\n// Types\nimport { ColorAccessor, GenericAccessor, NumericAccessor, StringAccessor } from 'types/accessor'\n\n// Local Types\nimport { ChordInputLink, ChordInputNode, ChordLabelAlignment, ChordNodeDatum } from './types'\n\nexport interface ChordDiagramConfigInterface<N extends ChordInputNode, L extends ChordInputLink> extends ComponentConfigInterface {\n /** Node id or index to highlight. Overrides default hover behavior if supplied. Default: `undefined` */\n highlightedNodeId?: number | string;\n /** Link ids or index values to highlight. Overrides default hover behavior if supplied. Default: [] */\n highlightedLinkIds?: (number | string)[];\n /** Link color accessor function. Default: `var(--vis-chord-diagram-link-fill-color)` */\n linkColor?: ColorAccessor<L>;\n /** Link value accessor function. Default: `l => l.value` */\n linkValue?: NumericAccessor<L>;\n /** Array of node hierarchy levels. Data records are supposed to have corresponding properties, e.g. ['level1', 'level2']. Default: `[]` */\n nodeLevels?: string[];\n /** Node width in pixels. Default: `15` */\n nodeWidth?: number;\n /** Node color accessor function ot constant value. Default: `d => d.color` */\n nodeColor?: ColorAccessor<ChordNodeDatum<N>>;\n /** Node label accessor function. Default: `d => d.label ?? d.key` */\n nodeLabel?: StringAccessor<ChordNodeDatum<N>>;\n /** Node label color accessor function. Default: `undefined` */\n nodeLabelColor?: StringAccessor<ChordNodeDatum<N>>;\n /** Node label alignment. Default: `ChordLabelAlignment.Along` */\n nodeLabelAlignment?: GenericAccessor<ChordLabelAlignment | string, ChordNodeDatum<N>>;\n /** Pad angle in radians. Constant value or accessor function. Default: `0.02` */\n padAngle?: NumericAccessor<N>;\n /** Corner radius constant value or accessor function. Default: `2` */\n cornerRadius?: NumericAccessor<N>;\n /** Angular range of the diagram. Default: `[0, 2 * Math.PI]` */\n angleRange?: [number, number];\n /** The exponent property of the radius scale. Default: `2` */\n radiusScaleExponent?: number;\n}\n\nexport class ChordDiagramConfig<N extends ChordInputNode, L extends ChordInputLink> extends ComponentConfig implements ChordDiagramConfigInterface<N, L> {\n duration = 800\n highlightedNodeId = undefined\n highlightedLinkIds = []\n linkColor = undefined\n linkValue = (d: L): number => d['value']\n nodeLevels = []\n nodeWidth = 15\n nodeColor = (d: ChordNodeDatum<N>): string => d['color']\n nodeLabel = (d: ChordNodeDatum<N>): string => d['label'] ?? d['key']\n nodeLabelColor = undefined\n nodeLabelAlignment = ChordLabelAlignment.Along\n padAngle = 0.02\n cornerRadius = 2\n angleRange: [number, number] = [0, 2 * Math.PI]\n radiusScaleExponent = 2\n}\n"],"names":[],"mappings":";;;AAAA;AA0CM,MAAO,kBAAuE,SAAQ,eAAe,CAAA;AAA3G,IAAA,WAAA,GAAA;;QACE,IAAQ,CAAA,QAAA,GAAG,GAAG,CAAA;QACd,IAAiB,CAAA,iBAAA,GAAG,SAAS,CAAA;QAC7B,IAAkB,CAAA,kBAAA,GAAG,EAAE,CAAA;QACvB,IAAS,CAAA,SAAA,GAAG,SAAS,CAAA;QACrB,IAAS,CAAA,SAAA,GAAG,CAAC,CAAI,KAAa,CAAC,CAAC,OAAO,CAAC,CAAA;QACxC,IAAU,CAAA,UAAA,GAAG,EAAE,CAAA;QACf,IAAS,CAAA,SAAA,GAAG,EAAE,CAAA;QACd,IAAS,CAAA,SAAA,GAAG,CAAC,CAAoB,KAAa,CAAC,CAAC,OAAO,CAAC,CAAA;AACxD,QAAA,IAAA,CAAA,SAAS,GAAG,CAAC,CAAoB,KAAY,EAAA,IAAA,EAAA,CAAA,CAAC,OAAA,CAAA,EAAA,GAAA,CAAC,CAAC,OAAO,CAAC,mCAAI,CAAC,CAAC,KAAK,CAAC,CAAA,EAAA,CAAA;QACpE,IAAc,CAAA,cAAA,GAAG,SAAS,CAAA;AAC1B,QAAA,IAAA,CAAA,kBAAkB,GAAG,mBAAmB,CAAC,KAAK,CAAA;QAC9C,IAAQ,CAAA,QAAA,GAAG,IAAI,CAAA;QACf,IAAY,CAAA,YAAA,GAAG,CAAC,CAAA;QAChB,IAAU,CAAA,UAAA,GAAqB,CAAC,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC,CAAA;QAC/C,IAAmB,CAAA,mBAAA,GAAG,CAAC,CAAA;KACxB;AAAA;;;;"}
1
+ {"version":3,"file":"config.js","sources":["../../../src/components/chord-diagram/config.ts"],"sourcesContent":["// Core\nimport { ComponentConfigInterface, ComponentDefaultConfig } from 'core/component/config'\n\n// Types\nimport { ColorAccessor, GenericAccessor, NumericAccessor, StringAccessor } from 'types/accessor'\n\n// Local Types\nimport { ChordInputLink, ChordInputNode, ChordLabelAlignment, ChordLinkDatum, ChordNodeDatum } from './types'\n\nexport interface ChordDiagramConfigInterface<N extends ChordInputNode, L extends ChordInputLink> extends ComponentConfigInterface {\n /** Node id or index to highlight. Overrides default hover behavior if supplied. Default: `undefined` */\n highlightedNodeId?: number | string;\n /** Link ids or index values to highlight. Overrides default hover behavior if supplied. Default: [] */\n highlightedLinkIds?: (number | string)[];\n /** Link color accessor function. Default: `var(--vis-chord-diagram-link-fill-color)` */\n linkColor?: ColorAccessor<ChordLinkDatum<N, L>>;\n /** Link value accessor function. Default: `l => l.value` */\n linkValue?: NumericAccessor<ChordLinkDatum<N, L>>;\n /** Array of node hierarchy levels. Data records are supposed to have corresponding properties, e.g. ['level1', 'level2']. Default: `[]` */\n nodeLevels?: string[];\n /** Node width in pixels. Default: `15` */\n nodeWidth?: number;\n /** Node color accessor function ot constant value. Default: `d => d.color` */\n nodeColor?: ColorAccessor<ChordNodeDatum<N>>;\n /** Node label accessor function. Default: `d => d.label ?? d.key` */\n nodeLabel?: StringAccessor<ChordNodeDatum<N>>;\n /** Node label color accessor function. Default: `undefined` */\n nodeLabelColor?: StringAccessor<ChordNodeDatum<N>>;\n /** Node label alignment. Default: `ChordLabelAlignment.Along` */\n nodeLabelAlignment?: GenericAccessor<ChordLabelAlignment | string, ChordNodeDatum<N>>;\n /** Pad angle in radians. Constant value or accessor function. Default: `0.02` */\n padAngle?: NumericAccessor<ChordNodeDatum<N>>;\n /** Corner radius constant value or accessor function. Default: `2` */\n cornerRadius?: NumericAccessor<ChordNodeDatum<N>>;\n /** Angular range of the diagram. Default: `[0, 2 * Math.PI]` */\n angleRange?: [number, number];\n /** The exponent property of the radius scale. Default: `2` */\n radiusScaleExponent?: number;\n}\n\nexport const ChordDiagramDefaultConfig: ChordDiagramConfigInterface<ChordInputNode, ChordInputLink> = {\n ...ComponentDefaultConfig,\n duration: 800,\n highlightedNodeId: undefined,\n highlightedLinkIds: [],\n linkColor: undefined,\n linkValue: (d: ChordInputNode): number => (d as { value: number }).value,\n nodeLevels: [],\n nodeWidth: 15,\n nodeColor: (d: unknown): string => (d as { color: string }).color,\n nodeLabel: (d: unknown): string => (d as { label: string }).label ?? (d as { key: string }).key,\n nodeLabelColor: undefined,\n nodeLabelAlignment: ChordLabelAlignment.Along,\n padAngle: 0.02,\n cornerRadius: 2,\n angleRange: [0, 2 * Math.PI],\n radiusScaleExponent: 2,\n}\n"],"names":[],"mappings":";;;AAAA;MAwCa,yBAAyB,GAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EACjC,sBAAsB,CACzB,EAAA,EAAA,QAAQ,EAAE,GAAG,EACb,iBAAiB,EAAE,SAAS,EAC5B,kBAAkB,EAAE,EAAE,EACtB,SAAS,EAAE,SAAS,EACpB,SAAS,EAAE,CAAC,CAAiB,KAAc,CAAuB,CAAC,KAAK,EACxE,UAAU,EAAE,EAAE,EACd,SAAS,EAAE,EAAE,EACb,SAAS,EAAE,CAAC,CAAU,KAAc,CAAuB,CAAC,KAAK,EACjE,SAAS,EAAE,CAAC,CAAU,eAAa,OAAA,CAAA,EAAA,GAAC,CAAuB,CAAC,KAAK,MAAA,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,EAAA,GAAK,CAAqB,CAAC,GAAG,CAAA,EAAA,EAC/F,cAAc,EAAE,SAAS,EACzB,kBAAkB,EAAE,mBAAmB,CAAC,KAAK,EAC7C,QAAQ,EAAE,IAAI,EACd,YAAY,EAAE,CAAC,EACf,UAAU,EAAE,CAAC,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC,EAC5B,mBAAmB,EAAE,CAAC,EAAA;;;;"}
@@ -4,11 +4,12 @@ import { ComponentCore } from "../../core/component";
4
4
  import { GraphData, GraphDataModel } from "../../data-models/graph";
5
5
  import { Spacing } from "../../types/spacing";
6
6
  import { ChordInputNode, ChordInputLink, ChordDiagramData, ChordNode, ChordRibbon } from './types';
7
- import { ChordDiagramConfig, ChordDiagramConfigInterface } from './config';
7
+ import { ChordDiagramConfigInterface } from './config';
8
8
  import * as s from './style';
9
- export declare class ChordDiagram<N extends ChordInputNode, L extends ChordInputLink> extends ComponentCore<ChordDiagramData<N, L>, ChordDiagramConfig<N, L>, ChordDiagramConfigInterface<N, L>> {
9
+ export declare class ChordDiagram<N extends ChordInputNode, L extends ChordInputLink> extends ComponentCore<ChordDiagramData<N, L>, ChordDiagramConfigInterface<N, L>> {
10
10
  static selectors: typeof s;
11
- config: ChordDiagramConfig<N, L>;
11
+ protected _defaultConfig: ChordDiagramConfigInterface<N, L>;
12
+ config: ChordDiagramConfigInterface<N, L>;
12
13
  datamodel: GraphDataModel<N, L>;
13
14
  nodeGroup: Selection<SVGGElement, unknown, SVGGElement, unknown>;
14
15
  linkGroup: Selection<SVGGElement, unknown, SVGGElement, unknown>;
@@ -5,10 +5,10 @@ import { scalePow } from 'd3-scale';
5
5
  import { arc } from 'd3-shape';
6
6
  import { ComponentCore } from '../../core/component/index.js';
7
7
  import { GraphDataModel } from '../../data-models/graph.js';
8
- import { getValue, getString, isNumber, getNumber, groupBy } from '../../utils/data.js';
8
+ import { getValue, getString, getNumber, isNumber, groupBy } from '../../utils/data.js';
9
9
  import { estimateStringPixelLength } from '../../utils/text.js';
10
10
  import { ChordLabelAlignment } from './types.js';
11
- import { ChordDiagramConfig } from './config.js';
11
+ import { ChordDiagramDefaultConfig } from './config.js';
12
12
  import { createNode, updateNode, removeNode } from './modules/node.js';
13
13
  import { LABEL_PADDING, createLabel, updateLabel, removeLabel } from './modules/label.js';
14
14
  import { createLink, updateLink, removeLink } from './modules/link.js';
@@ -18,7 +18,8 @@ import { links, nodes, labels, transparent, link, highlightedLink, node, highlig
18
18
  class ChordDiagram extends ComponentCore {
19
19
  constructor(config) {
20
20
  super();
21
- this.config = new ChordDiagramConfig();
21
+ this._defaultConfig = ChordDiagramDefaultConfig;
22
+ this.config = this._defaultConfig;
22
23
  this.datamodel = new GraphDataModel();
23
24
  this.arcGen = arc();
24
25
  this.radiusScale = scalePow();
@@ -35,7 +36,7 @@ class ChordDiagram extends ComponentCore {
35
36
  },
36
37
  };
37
38
  if (config)
38
- this.config.init(config);
39
+ this.setConfig(config);
39
40
  this.linkGroup = this.g.append('g').attr('class', links);
40
41
  this.nodeGroup = this.g.append('g').attr('class', nodes);
41
42
  this.labelGroup = this.g.append('g').attr('class', labels);
@@ -86,7 +87,7 @@ class ChordDiagram extends ComponentCore {
86
87
  const partitionData = partition()
87
88
  .size([this.config.angleRange[1], 1])(hierarchyData);
88
89
  partitionData.each((node, i) => {
89
- this._calculateRadialPosition(node, this.config.padAngle);
90
+ this._calculateRadialPosition(node, getNumber(node.data, this.config.padAngle));
90
91
  // Add hierarchy data for non leaf nodes
91
92
  if (node.children) {
92
93
  node.data = Object.assign(node.data, {
@@ -116,7 +117,7 @@ class ChordDiagram extends ComponentCore {
116
117
  this.arcGen
117
118
  .startAngle(d => d.x0)
118
119
  .endAngle(d => d.x1)
119
- .cornerRadius(d => getNumber(d, config.cornerRadius))
120
+ .cornerRadius(d => getNumber(d.data, config.cornerRadius))
120
121
  .innerRadius(d => this.radiusScale(d.y1) - getNumber(d, config.nodeWidth))
121
122
  .outerRadius(d => this.radiusScale(d.y1));
122
123
  // Center the view
@@ -175,7 +176,7 @@ class ChordDiagram extends ComponentCore {
175
176
  // TODO: Replace with d3-group
176
177
  const nestGen = nest();
177
178
  config.nodeLevels.forEach(levelAccessor => {
178
- nestGen.key(d => d[levelAccessor]);
179
+ nestGen.key((d) => d[levelAccessor]);
179
180
  });
180
181
  const root = { key: 'root', values: nestGen.entries(nodes) };
181
182
  const hierarchyNodes = hierarchy(root, d => d.values)