@unovis/ts 1.1.0-beta.3 → 1.1.0-beta.6

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 (150) hide show
  1. package/components/axis/config.d.ts +1 -1
  2. package/components/axis/config.js.map +1 -1
  3. package/components/bullet-legend/config.d.ts +11 -1
  4. package/components/bullet-legend/config.js.map +1 -1
  5. package/components/bullet-legend/index.d.ts +1 -1
  6. package/components/bullet-legend/index.js.map +1 -1
  7. package/components/chord-diagram/config.d.ts +13 -11
  8. package/components/chord-diagram/config.js +3 -3
  9. package/components/chord-diagram/config.js.map +1 -1
  10. package/components/chord-diagram/index.d.ts +1 -8
  11. package/components/chord-diagram/index.js +93 -68
  12. package/components/chord-diagram/index.js.map +1 -1
  13. package/components/chord-diagram/modules/label.d.ts +2 -2
  14. package/components/chord-diagram/modules/label.js +54 -69
  15. package/components/chord-diagram/modules/label.js.map +1 -1
  16. package/components/chord-diagram/modules/link.d.ts +6 -5
  17. package/components/chord-diagram/modules/link.js +34 -6
  18. package/components/chord-diagram/modules/link.js.map +1 -1
  19. package/components/chord-diagram/modules/node.d.ts +3 -3
  20. package/components/chord-diagram/modules/node.js +7 -7
  21. package/components/chord-diagram/modules/node.js.map +1 -1
  22. package/components/chord-diagram/style.js +3 -2
  23. package/components/chord-diagram/style.js.map +1 -1
  24. package/components/chord-diagram/types.d.ts +18 -4
  25. package/components/chord-diagram/types.js.map +1 -1
  26. package/components/donut/index.js.map +1 -1
  27. package/components/donut/modules/arc.d.ts +3 -3
  28. package/components/donut/modules/arc.js.map +1 -1
  29. package/components/flow-legend/index.d.ts +3 -3
  30. package/components/flow-legend/index.js.map +1 -1
  31. package/components/free-brush/config.d.ts +11 -11
  32. package/components/free-brush/config.js.map +1 -1
  33. package/components/free-brush/index.js.map +1 -1
  34. package/components/graph/config.d.ts +4 -17
  35. package/components/graph/config.js +2 -14
  36. package/components/graph/config.js.map +1 -1
  37. package/components/graph/index.d.ts +5 -5
  38. package/components/graph/index.js +65 -86
  39. package/components/graph/index.js.map +1 -1
  40. package/components/graph/modules/layout-helpers.d.ts +11 -4
  41. package/components/graph/modules/layout-helpers.js +11 -3
  42. package/components/graph/modules/layout-helpers.js.map +1 -1
  43. package/components/graph/modules/layout.d.ts +6 -6
  44. package/components/graph/modules/layout.js +20 -10
  45. package/components/graph/modules/layout.js.map +1 -1
  46. package/components/graph/modules/link/helper.d.ts +4 -4
  47. package/components/graph/modules/link/helper.js.map +1 -1
  48. package/components/graph/modules/link/index.d.ts +5 -5
  49. package/components/graph/modules/link/index.js +2 -1
  50. package/components/graph/modules/link/index.js.map +1 -1
  51. package/components/graph/modules/node/helper.d.ts +2 -2
  52. package/components/graph/modules/node/helper.js.map +1 -1
  53. package/components/graph/modules/node/index.d.ts +1 -1
  54. package/components/graph/modules/node/index.js.map +1 -1
  55. package/components/graph/modules/panel/helper.d.ts +9 -7
  56. package/components/graph/modules/panel/helper.js +29 -28
  57. package/components/graph/modules/panel/helper.js.map +1 -1
  58. package/components/graph/modules/panel/index.d.ts +1 -1
  59. package/components/graph/modules/panel/index.js +34 -39
  60. package/components/graph/modules/panel/index.js.map +1 -1
  61. package/components/graph/modules/shape.d.ts +3 -4
  62. package/components/graph/modules/shape.js.map +1 -1
  63. package/components/graph/types.d.ts +7 -4
  64. package/components/graph/types.js.map +1 -1
  65. package/components/grouped-bar/config.d.ts +1 -1
  66. package/components/grouped-bar/config.js.map +1 -1
  67. package/components/leaflet-map/config.d.ts +1 -1
  68. package/components/leaflet-map/config.js.map +1 -1
  69. package/components/leaflet-map/index.js +10 -6
  70. package/components/leaflet-map/index.js.map +1 -1
  71. package/components/leaflet-map/modules/map.d.ts +2 -2
  72. package/components/leaflet-map/modules/map.js.map +1 -1
  73. package/components/leaflet-map/modules/node.d.ts +4 -4
  74. package/components/leaflet-map/modules/node.js +11 -4
  75. package/components/leaflet-map/modules/node.js.map +1 -1
  76. package/components/leaflet-map/modules/selectionRing.d.ts +2 -2
  77. package/components/leaflet-map/modules/selectionRing.js.map +1 -1
  78. package/components/leaflet-map/renderer/mapboxgl/mapboxgl-settings.json.js +783 -789
  79. package/components/leaflet-map/renderer/mapboxgl/mapboxgl-settings.json.js.map +1 -1
  80. package/components/leaflet-map/style.js +1 -1
  81. package/components/leaflet-map/style.js.map +1 -1
  82. package/components/leaflet-map/types.d.ts +1 -1
  83. package/components/leaflet-map/types.js.map +1 -1
  84. package/components/line/index.js.map +1 -1
  85. package/components/sankey/index.js +1 -1
  86. package/components/sankey/index.js.map +1 -1
  87. package/components/sankey/modules/link.js.map +1 -1
  88. package/components/scatter/index.js.map +1 -1
  89. package/components/stacked-bar/config.d.ts +1 -1
  90. package/components/stacked-bar/config.js.map +1 -1
  91. package/components/timeline/index.js.map +1 -1
  92. package/components/vis-controls/config.d.ts +1 -1
  93. package/components/vis-controls/config.js.map +1 -1
  94. package/components/vis-controls/index.d.ts +3 -3
  95. package/components/vis-controls/index.js.map +1 -1
  96. package/components/xy-labels/index.js +2 -1
  97. package/components/xy-labels/index.js.map +1 -1
  98. package/components.d.ts +0 -2
  99. package/components.js +0 -1
  100. package/components.js.map +1 -1
  101. package/containers/single-container/index.d.ts +2 -1
  102. package/containers/single-container/index.js +23 -10
  103. package/containers/single-container/index.js.map +1 -1
  104. package/containers/xy-container/index.js +14 -6
  105. package/containers/xy-container/index.js.map +1 -1
  106. package/core/config/index.js +1 -1
  107. package/core/config/index.js.map +1 -1
  108. package/core/container/config.d.ts +4 -0
  109. package/core/container/config.js.map +1 -1
  110. package/core/container/index.d.ts +6 -5
  111. package/core/container/index.js +37 -28
  112. package/core/container/index.js.map +1 -1
  113. package/data-models/graph.d.ts +6 -6
  114. package/data-models/graph.js +10 -4
  115. package/data-models/graph.js.map +1 -1
  116. package/data-models/map-graph.d.ts +5 -7
  117. package/data-models/map-graph.js +4 -1
  118. package/data-models/map-graph.js.map +1 -1
  119. package/index.js +0 -2
  120. package/index.js.map +1 -1
  121. package/package.json +1 -1
  122. package/types.d.ts +0 -1
  123. package/types.js +0 -1
  124. package/types.js.map +1 -1
  125. package/utils/data.js +6 -2
  126. package/utils/data.js.map +1 -1
  127. package/utils/misc.d.ts +0 -10
  128. package/utils/misc.js +1 -5
  129. package/utils/misc.js.map +1 -1
  130. package/components/radial-dendrogram/config.d.ts +0 -34
  131. package/components/radial-dendrogram/config.js +0 -20
  132. package/components/radial-dendrogram/config.js.map +0 -1
  133. package/components/radial-dendrogram/index.d.ts +0 -22
  134. package/components/radial-dendrogram/index.js +0 -98
  135. package/components/radial-dendrogram/index.js.map +0 -1
  136. package/components/radial-dendrogram/modules/label.d.ts +0 -8
  137. package/components/radial-dendrogram/modules/label.js +0 -70
  138. package/components/radial-dendrogram/modules/label.js.map +0 -1
  139. package/components/radial-dendrogram/modules/link.d.ts +0 -19
  140. package/components/radial-dendrogram/modules/link.js +0 -59
  141. package/components/radial-dendrogram/modules/link.js.map +0 -1
  142. package/components/radial-dendrogram/modules/node.d.ts +0 -16
  143. package/components/radial-dendrogram/modules/node.js +0 -51
  144. package/components/radial-dendrogram/modules/node.js.map +0 -1
  145. package/components/radial-dendrogram/style.d.ts +0 -6
  146. package/components/radial-dendrogram/style.js +0 -54
  147. package/components/radial-dendrogram/style.js.map +0 -1
  148. package/components/radial-dendrogram/types.d.ts +0 -34
  149. package/components/radial-dendrogram/types.js +0 -8
  150. package/components/radial-dendrogram/types.js.map +0 -1
@@ -44,7 +44,7 @@ export interface AxisConfigInterface<Datum> extends Partial<XYComponentConfigInt
44
44
  /** Font size of the tick text as CSS string. Default: `null` */
45
45
  tickTextFontSize?: string | null;
46
46
  /** Text alignment for ticks: `TextAlign.Left`, `TextAlign.Center` or `TextAlign.Right`. Default: `undefined` */
47
- tickTextAlign?: TextAlign;
47
+ tickTextAlign?: TextAlign | string;
48
48
  /** The spacing in pixels between the tick and it's label. Default: `8` */
49
49
  tickPadding?: number;
50
50
  }
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sources":["../../../src/components/axis/config.ts"],"sourcesContent":["import { XYComponentConfigInterface, XYComponentConfig } from 'core/xy-component/config'\n\n// Types\nimport { AxisType } from 'components/axis/types'\nimport { Position } from 'types/position'\nimport { FitMode, TrimMode, TextAlign } from 'types/text'\n\n// We extend partial XY config interface because x and y properties are optional for Axis\nexport interface AxisConfigInterface<Datum> extends Partial<XYComponentConfigInterface<Datum>> {\n /** Axis position: `Position.Top`, `Position.Bottom`, `Position.Right` or `Position.Left`. Default: `undefined` */\n position?: Position | string;\n /** Axis type: `AxisType.X` or `AxisType.Y` */\n type?: AxisType | string;\n /** Extend the axis domain line to be full width or full height. Default: `true` */\n fullSize?: boolean;\n /** Axis label. Default: `undefined` */\n label?: string;\n /** Font size of the axis label as CSS string. Default: `null` */\n labelFontSize?: string | null;\n /** Distance between the axis and the label in pixels. Default: `8` */\n labelMargin?: number;\n /** Sets whether to draw the grid lines or not. Default: `true` */\n gridLine?: boolean;\n /** Sets whether to draw the tick lines or not. Default: `true` */\n tickLine?: boolean;\n /** Sets whether to draw the domain line or not. Default: `true` */\n domainLine?: boolean;\n /** Draw the min and max axis ticks only. Default: `false` */\n minMaxTicksOnly?: boolean;\n /** Tick label formatter function. Default: `undefined` */\n tickFormat?: ((tick: number, i: number, ticks: number[]) => string) | ((tick: Date, i: number, ticks: Date[]) => string);\n /** Explicitly set tick values. Default: `undefined` */\n tickValues?: number[];\n /** Set the approximate number of axis ticks (will be passed to D3's axis constructor). Default: `undefined` */\n numTicks?: number;\n /** Tick text fit mode: `FitMode.Wrap` or `FitMode.Trim`. Default: `FitMode.Wrap`. */\n tickTextFitMode?: FitMode | string;\n /** Maximum number of characters for tick text wrapping. Default: `undefined` */\n tickTextLength?: number;\n /** Maximum width in pixels for the tick text to be wrapped or trimmed. Default: `undefined` */\n tickTextWidth?: number;\n /** Tick text wrapping separator. String or array of strings. Default: `' '` */\n tickTextSeparator?: string | string[];\n /** Force word break for ticks when they don't fit. Default: `false` */\n tickTextForceWordBreak?: boolean;\n /** Tick text trim mode: `TrimMode.Start`, `TrimMode.Middle` or `TrimMode.End`. Default: `TrimMode.Middle` */\n tickTextTrimType?: TrimMode | string;\n /** Font size of the tick text as CSS string. Default: `null` */\n tickTextFontSize?: string | null;\n /** Text alignment for ticks: `TextAlign.Left`, `TextAlign.Center` or `TextAlign.Right`. Default: `undefined` */\n tickTextAlign?: TextAlign;\n /** The spacing in pixels between the tick and it's label. Default: `8` */\n tickPadding?: number;\n}\n\nexport class AxisConfig<Datum> extends XYComponentConfig<Datum> implements AxisConfigInterface<Datum> {\n position = undefined\n type = undefined\n label = undefined\n labelFontSize = null\n gridLine = true\n tickLine = true\n domainLine = true\n numTicks = undefined\n minMaxTicksOnly = false\n tickTextLength = undefined\n tickTextWidth = undefined\n tickTextSeparator = ' '\n tickTextForceWordBreak = false\n tickTextTrimType = TrimMode.Middle\n tickTextFitMode = FitMode.Wrap\n tickTextFontSize = null\n tickTextAlign = undefined\n labelMargin = 8\n tickFormat = undefined\n tickValues = undefined\n fullSize = true\n tickPadding = 8\n}\n"],"names":[],"mappings":";;;AAuDM,MAAO,UAAkB,SAAQ,iBAAwB,CAAA;AAA/D,IAAA,WAAA,GAAA;;QACE,IAAQ,CAAA,QAAA,GAAG,SAAS,CAAA;QACpB,IAAI,CAAA,IAAA,GAAG,SAAS,CAAA;QAChB,IAAK,CAAA,KAAA,GAAG,SAAS,CAAA;QACjB,IAAa,CAAA,aAAA,GAAG,IAAI,CAAA;QACpB,IAAQ,CAAA,QAAA,GAAG,IAAI,CAAA;QACf,IAAQ,CAAA,QAAA,GAAG,IAAI,CAAA;QACf,IAAU,CAAA,UAAA,GAAG,IAAI,CAAA;QACjB,IAAQ,CAAA,QAAA,GAAG,SAAS,CAAA;QACpB,IAAe,CAAA,eAAA,GAAG,KAAK,CAAA;QACvB,IAAc,CAAA,cAAA,GAAG,SAAS,CAAA;QAC1B,IAAa,CAAA,aAAA,GAAG,SAAS,CAAA;QACzB,IAAiB,CAAA,iBAAA,GAAG,GAAG,CAAA;QACvB,IAAsB,CAAA,sBAAA,GAAG,KAAK,CAAA;AAC9B,QAAA,IAAA,CAAA,gBAAgB,GAAG,QAAQ,CAAC,MAAM,CAAA;AAClC,QAAA,IAAA,CAAA,eAAe,GAAG,OAAO,CAAC,IAAI,CAAA;QAC9B,IAAgB,CAAA,gBAAA,GAAG,IAAI,CAAA;QACvB,IAAa,CAAA,aAAA,GAAG,SAAS,CAAA;QACzB,IAAW,CAAA,WAAA,GAAG,CAAC,CAAA;QACf,IAAU,CAAA,UAAA,GAAG,SAAS,CAAA;QACtB,IAAU,CAAA,UAAA,GAAG,SAAS,CAAA;QACtB,IAAQ,CAAA,QAAA,GAAG,IAAI,CAAA;QACf,IAAW,CAAA,WAAA,GAAG,CAAC,CAAA;KAChB;AAAA;;;;"}
1
+ {"version":3,"file":"config.js","sources":["../../../src/components/axis/config.ts"],"sourcesContent":["import { XYComponentConfigInterface, XYComponentConfig } from 'core/xy-component/config'\n\n// Types\nimport { AxisType } from 'components/axis/types'\nimport { Position } from 'types/position'\nimport { FitMode, TrimMode, TextAlign } from 'types/text'\n\n// We extend partial XY config interface because x and y properties are optional for Axis\nexport interface AxisConfigInterface<Datum> extends Partial<XYComponentConfigInterface<Datum>> {\n /** Axis position: `Position.Top`, `Position.Bottom`, `Position.Right` or `Position.Left`. Default: `undefined` */\n position?: Position | string;\n /** Axis type: `AxisType.X` or `AxisType.Y` */\n type?: AxisType | string;\n /** Extend the axis domain line to be full width or full height. Default: `true` */\n fullSize?: boolean;\n /** Axis label. Default: `undefined` */\n label?: string;\n /** Font size of the axis label as CSS string. Default: `null` */\n labelFontSize?: string | null;\n /** Distance between the axis and the label in pixels. Default: `8` */\n labelMargin?: number;\n /** Sets whether to draw the grid lines or not. Default: `true` */\n gridLine?: boolean;\n /** Sets whether to draw the tick lines or not. Default: `true` */\n tickLine?: boolean;\n /** Sets whether to draw the domain line or not. Default: `true` */\n domainLine?: boolean;\n /** Draw the min and max axis ticks only. Default: `false` */\n minMaxTicksOnly?: boolean;\n /** Tick label formatter function. Default: `undefined` */\n tickFormat?: ((tick: number, i: number, ticks: number[]) => string) | ((tick: Date, i: number, ticks: Date[]) => string);\n /** Explicitly set tick values. Default: `undefined` */\n tickValues?: number[];\n /** Set the approximate number of axis ticks (will be passed to D3's axis constructor). Default: `undefined` */\n numTicks?: number;\n /** Tick text fit mode: `FitMode.Wrap` or `FitMode.Trim`. Default: `FitMode.Wrap`. */\n tickTextFitMode?: FitMode | string;\n /** Maximum number of characters for tick text wrapping. Default: `undefined` */\n tickTextLength?: number;\n /** Maximum width in pixels for the tick text to be wrapped or trimmed. Default: `undefined` */\n tickTextWidth?: number;\n /** Tick text wrapping separator. String or array of strings. Default: `' '` */\n tickTextSeparator?: string | string[];\n /** Force word break for ticks when they don't fit. Default: `false` */\n tickTextForceWordBreak?: boolean;\n /** Tick text trim mode: `TrimMode.Start`, `TrimMode.Middle` or `TrimMode.End`. Default: `TrimMode.Middle` */\n tickTextTrimType?: TrimMode | string;\n /** Font size of the tick text as CSS string. Default: `null` */\n tickTextFontSize?: string | null;\n /** Text alignment for ticks: `TextAlign.Left`, `TextAlign.Center` or `TextAlign.Right`. Default: `undefined` */\n tickTextAlign?: TextAlign | string;\n /** The spacing in pixels between the tick and it's label. Default: `8` */\n tickPadding?: number;\n}\n\nexport class AxisConfig<Datum> extends XYComponentConfig<Datum> implements AxisConfigInterface<Datum> {\n position = undefined\n type = undefined\n label = undefined\n labelFontSize = null\n gridLine = true\n tickLine = true\n domainLine = true\n numTicks = undefined\n minMaxTicksOnly = false\n tickTextLength = undefined\n tickTextWidth = undefined\n tickTextSeparator = ' '\n tickTextForceWordBreak = false\n tickTextTrimType = TrimMode.Middle\n tickTextFitMode = FitMode.Wrap\n tickTextFontSize = null\n tickTextAlign = undefined\n labelMargin = 8\n tickFormat = undefined\n tickValues = undefined\n fullSize = true\n tickPadding = 8\n}\n"],"names":[],"mappings":";;;AAuDM,MAAO,UAAkB,SAAQ,iBAAwB,CAAA;AAA/D,IAAA,WAAA,GAAA;;QACE,IAAQ,CAAA,QAAA,GAAG,SAAS,CAAA;QACpB,IAAI,CAAA,IAAA,GAAG,SAAS,CAAA;QAChB,IAAK,CAAA,KAAA,GAAG,SAAS,CAAA;QACjB,IAAa,CAAA,aAAA,GAAG,IAAI,CAAA;QACpB,IAAQ,CAAA,QAAA,GAAG,IAAI,CAAA;QACf,IAAQ,CAAA,QAAA,GAAG,IAAI,CAAA;QACf,IAAU,CAAA,UAAA,GAAG,IAAI,CAAA;QACjB,IAAQ,CAAA,QAAA,GAAG,SAAS,CAAA;QACpB,IAAe,CAAA,eAAA,GAAG,KAAK,CAAA;QACvB,IAAc,CAAA,cAAA,GAAG,SAAS,CAAA;QAC1B,IAAa,CAAA,aAAA,GAAG,SAAS,CAAA;QACzB,IAAiB,CAAA,iBAAA,GAAG,GAAG,CAAA;QACvB,IAAsB,CAAA,sBAAA,GAAG,KAAK,CAAA;AAC9B,QAAA,IAAA,CAAA,gBAAgB,GAAG,QAAQ,CAAC,MAAM,CAAA;AAClC,QAAA,IAAA,CAAA,eAAe,GAAG,OAAO,CAAC,IAAI,CAAA;QAC9B,IAAgB,CAAA,gBAAA,GAAG,IAAI,CAAA;QACvB,IAAa,CAAA,aAAA,GAAG,SAAS,CAAA;QACzB,IAAW,CAAA,WAAA,GAAG,CAAC,CAAA;QACf,IAAU,CAAA,UAAA,GAAG,SAAS,CAAA;QACtB,IAAU,CAAA,UAAA,GAAG,SAAS,CAAA;QACtB,IAAQ,CAAA,QAAA,GAAG,IAAI,CAAA;QACf,IAAW,CAAA,WAAA,GAAG,CAAC,CAAA;KAChB;AAAA;;;;"}
@@ -1,7 +1,17 @@
1
1
  import { Config } from "../../core/config";
2
2
  import { BulletLegendItemInterface } from './types';
3
3
  export interface BulletLegendConfigInterface {
4
- /** Legend items array BulletLegendItemInterface[]. Default: `[]` */
4
+ /** Legend items. Array of `BulletLegendItemInterface`:
5
+ * ```
6
+ * {
7
+ * name: string | number;
8
+ * color?: string;
9
+ * inactive?: boolean;
10
+ * hidden?: boolean;
11
+ * pointer?: boolean;
12
+ * }
13
+ * ```
14
+ * Default: `[]` */
5
15
  items: BulletLegendItemInterface[];
6
16
  /** Apply a specific class to the labels. Default: `''` */
7
17
  labelClassName?: string;
@@ -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 } from './types'\n\nexport interface BulletLegendConfigInterface {\n /** Legend items array BulletLegendItemInterface[]. 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 circle size, mapped to the width and height CSS properties. Default: `null` */\n bulletSize?: string | null;\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}\n"],"names":[],"mappings":";;AAoBM,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;KAClB;AAAA;;;;"}
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 } 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 circle size, mapped to the width and height CSS properties. Default: `null` */\n bulletSize?: string | null;\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}\n"],"names":[],"mappings":";;AA8BM,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;KAClB;AAAA;;;;"}
@@ -4,7 +4,7 @@ import { BulletLegendItemInterface } from './types';
4
4
  import * as s from './style';
5
5
  export declare class BulletLegend {
6
6
  static selectors: typeof s;
7
- div: Selection<HTMLElement, any, HTMLElement, any>;
7
+ div: Selection<HTMLDivElement, unknown, null, undefined>;
8
8
  element: HTMLElement;
9
9
  prevConfig: BulletLegendConfig;
10
10
  config: BulletLegendConfig;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/components/bullet-legend/index.ts"],"sourcesContent":["import { select, Selection } from 'd3-selection'\nimport { color } from 'd3-color'\n\n// Utils\nimport { getColor } from 'utils/color'\n\n// Config\nimport { BulletLegendConfig, BulletLegendConfigInterface } from './config'\n\n// Local Types\nimport { BulletLegendItemInterface } from './types'\n\n// Styles\nimport * as s from './style'\n\nexport class BulletLegend {\n static selectors = s\n div: Selection<HTMLElement, any, HTMLElement, any>\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(`.${s.item}`)\n .data(config.items) as Selection<HTMLDivElement, any, HTMLDivElement, any>\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 .style('width', config.bulletSize)\n .style('height', config.bulletSize)\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 const legendBulletsToUpdate = legendItemsMerged.select(`.${s.bullet}`)\n legendBulletsToUpdate.style('background-color', (d: BulletLegendItemInterface, i) => getColor(d, this._colorAccessor, i))\n .style('border-color', (d: BulletLegendItemInterface, i) => getColor(d, this._colorAccessor, i))\n legendBulletsToUpdate.each((d, i, elements) => {\n if (d.inactive) {\n const bulletColor = window.getComputedStyle(elements[i] as Element).getPropertyValue('background-color')\n const transparentColor = color(bulletColor)\n transparentColor.opacity = 0.4\n select(elements[i])\n .style('background-color', transparentColor.toString())\n }\n })\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":";;;;;;;MAea,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,MAAM,CAAA;QAC7B,IAAI,CAAC,MAAM,G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A,WAAW,CAAC,IAAI,EAAE,CAAC,MAAM,EAAE,CAAA;KAC5B;AAED,IAAA,gBAAgB,CAAE,IAA+B,EAAA;AAC/C,QAAA,OAAO,IAAI,CAAC,OAAO,KAAK,SAAS,GAAG,IAAI,GAAG,IAAI,CAAC,OAAO,CAAA;KACxD;IAED,YAAY,CAAE,KAAiB,EAAE,CAA4B,EAAA;QAC3D,MAAM,EAAE,MAAM,EAAE,EAAE,iBAAiB,EAAE,EAAE,GAAG,IAAI,CAAA;AAE9C,QAAA,MAAM,WAAW,GAAG,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,CAAI,CAAA,EAAAF,IAAM,CAAA,CAAE,CAAC,CAAC,KAAK,EAAmB,CAAA;QAC7E,MAAM,KAAK,GAAG,WAAW,CAAC,OAAO,CAAC,KAAK,CAAC,aAA4B,CAAC,CAAA;AACrE,QAAA,IAAI,iBAAiB;AAAE,YAAA,iBAAiB,CAAC,CAAC,EAAE,KAAK,CAAC,CAAA;KACnD;IAEM,OAAO,GAAA;AACZ,QAAA,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,CAAA;KAClB;;AAtFM,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'\nimport { color } from 'd3-color'\n\n// Utils\nimport { getColor } from 'utils/color'\n\n// Config\nimport { BulletLegendConfig, BulletLegendConfigInterface } from './config'\n\n// Local Types\nimport { BulletLegendItemInterface } from './types'\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 .style('width', config.bulletSize)\n .style('height', config.bulletSize)\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 const legendBulletsToUpdate = legendItemsMerged.select(`.${s.bullet}`)\n legendBulletsToUpdate.style('background-color', (d: BulletLegendItemInterface, i) => getColor(d, this._colorAccessor, i))\n .style('border-color', (d: BulletLegendItemInterface, i) => getColor(d, this._colorAccessor, i))\n legendBulletsToUpdate.each((d, i, elements) => {\n if (d.inactive) {\n const bulletColor = window.getComputedStyle(elements[i] as Element).getPropertyValue('background-color')\n const transparentColor = color(bulletColor)\n transparentColor.opacity = 0.4\n select(elements[i])\n .style('background-color', transparentColor.toString())\n }\n })\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":";;;;;;;MAea,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,MAAM,CAAA;QAC7B,IAAI,CAAC,MAAM,GAAG,IAAI,kBAAkB,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;QACnD,IAAI,CAAC,MAAM,EAAE,CAAA;KACd;IAED,MAAM,GAAA;AACJ,QAAA,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAA;AACvB,QAAA,MAAM,WAAW,GAAG,IAAI,CAAC,GAAG,CAAC,SAAS,CAA0B,CAAI,CAAA,EAAAC,IAAM,EAAE,CAAC;AAC1E,aAAA,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;AAErB,QAAA,MAAM,gBAAgB,GAAG,WAAW,CAAC,KAAK,EAAE;aACzC,MAAM,CAAC,KAAK,CAAC;AACb,aAAA,IAAI,CAAC,OAAO,EAAEA,IAAM,CAAC;AACrB,aAAA,EAAE,CAAC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,CAAC,KAAK,CAAC,aAA4B,CAAC,CAAA;AACrE,QAAA,IAAI,iBAAiB;AAAE,YAAA,iBAAiB,CAAC,CAAC,EAAE,KAAK,CAAC,CAAA;KACnD;IAEM,OAAO,GAAA;AACZ,QAAA,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,CAAA;KAClB;;AAtFM,YAAS,CAAA,SAAA,GAAGI,KAAC;;;;"}
@@ -1,8 +1,9 @@
1
1
  import { ComponentConfigInterface, ComponentConfig } from "../../core/component/config";
2
- import { ColorAccessor, NumericAccessor, StringAccessor } from "../../types/accessor";
3
- import { CurveType } from "../../types/curve";
4
- import { ChordInputLink, ChordInputNode, ChordLabelAlignment, ChordNode } from './types';
2
+ import { ColorAccessor, GenericAccessor, NumericAccessor, StringAccessor } from "../../types/accessor";
3
+ import { ChordInputLink, ChordInputNode, ChordLabelAlignment, ChordNodeDatum } from './types';
5
4
  export interface ChordDiagramConfigInterface<N extends ChordInputNode, L extends ChordInputLink> extends ComponentConfigInterface {
5
+ /** Link color accessor function. Default: `var(--vis-chord-diagram-link-fill-color)` */
6
+ linkColor?: ColorAccessor<L>;
6
7
  /** Link value accessor function. Default: `l => l.value` */
7
8
  linkValue?: NumericAccessor<L>;
8
9
  /** Array of node hierarchy levels. Data records are supposed to have corresponding properties, e.g. ['level1', 'level2']. Default: `[]` */
@@ -10,33 +11,34 @@ export interface ChordDiagramConfigInterface<N extends ChordInputNode, L extends
10
11
  /** Node width in pixels. Default: `15` */
11
12
  nodeWidth?: number;
12
13
  /** Node color accessor function ot constant value. Default: `d => d.color` */
13
- nodeColor?: ColorAccessor<ChordNode<N>>;
14
+ nodeColor?: ColorAccessor<ChordNodeDatum<N>>;
14
15
  /** Node label accessor function. Default: `d => d.label ?? d.key` */
15
- nodeLabel?: StringAccessor<N>;
16
+ nodeLabel?: StringAccessor<ChordNodeDatum<N>>;
17
+ /** Node label color accessor function. Default: `undefined` */
18
+ nodeLabelColor?: StringAccessor<ChordNodeDatum<N>>;
16
19
  /** Node label alignment. Default: `ChordLabelAlignment.Along` */
17
- nodeLabelAlignment?: ChordLabelAlignment | string;
20
+ nodeLabelAlignment?: GenericAccessor<ChordLabelAlignment | string, ChordNodeDatum<N>>;
18
21
  /** Pad angle in radians. Constant value or accessor function. Default: `0.02` */
19
22
  padAngle?: NumericAccessor<N>;
20
23
  /** Corner radius constant value or accessor function. Default: `2` */
21
24
  cornerRadius?: NumericAccessor<N>;
22
25
  /** Angular range of the diagram. Default: `[0, 2 * Math.PI]` */
23
26
  angleRange?: [number, number];
24
- /** Curve type. Default: `CurveType.CatmullRom` */
25
- curveType?: CurveType;
26
27
  /** The exponent property of the radius scale. Default: `2` */
27
28
  radiusScaleExponent?: number;
28
29
  }
29
30
  export declare class ChordDiagramConfig<N extends ChordInputNode, L extends ChordInputLink> extends ComponentConfig implements ChordDiagramConfigInterface<N, L> {
30
31
  duration: number;
32
+ linkColor: any;
31
33
  linkValue: (d: L) => number;
32
34
  nodeLevels: any[];
33
35
  nodeWidth: number;
34
- nodeColor: any;
35
- nodeLabel: (d: N) => string;
36
+ nodeColor: (d: ChordNodeDatum<N>) => string;
37
+ nodeLabel: (d: ChordNodeDatum<N>) => string;
38
+ nodeLabelColor: any;
36
39
  nodeLabelAlignment: ChordLabelAlignment;
37
40
  padAngle: number;
38
41
  cornerRadius: number;
39
42
  angleRange: [number, number];
40
- curveType: CurveType;
41
43
  radiusScaleExponent: number;
42
44
  }
@@ -1,5 +1,4 @@
1
1
  import { ComponentConfig } from '../../core/component/config.js';
2
- import { CurveType } from '../../types/curve.js';
3
2
  import { ChordLabelAlignment } from './types.js';
4
3
 
5
4
  /* eslint-disable dot-notation */
@@ -7,16 +6,17 @@ class ChordDiagramConfig extends ComponentConfig {
7
6
  constructor() {
8
7
  super(...arguments);
9
8
  this.duration = 800;
9
+ this.linkColor = undefined;
10
10
  this.linkValue = (d) => d['value'];
11
11
  this.nodeLevels = [];
12
12
  this.nodeWidth = 15;
13
- this.nodeColor = undefined;
13
+ this.nodeColor = (d) => d['color'];
14
14
  this.nodeLabel = (d) => { var _a; return (_a = d['label']) !== null && _a !== void 0 ? _a : d['key']; };
15
+ this.nodeLabelColor = undefined;
15
16
  this.nodeLabelAlignment = ChordLabelAlignment.Along;
16
17
  this.padAngle = 0.02;
17
18
  this.cornerRadius = 2;
18
19
  this.angleRange = [0, 2 * Math.PI];
19
- this.curveType = CurveType.CatmullRom;
20
20
  this.radiusScaleExponent = 2;
21
21
  }
22
22
  }
@@ -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, NumericAccessor, StringAccessor } from 'types/accessor'\nimport { CurveType } from 'types/curve'\n\n// Local Types\nimport { ChordInputLink, ChordInputNode, ChordLabelAlignment, ChordNode } from './types'\n\nexport interface ChordDiagramConfigInterface<N extends ChordInputNode, L extends ChordInputLink> extends ComponentConfigInterface {\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<ChordNode<N>>;\n /** Node label accessor function. Default: `d => d.label ?? d.key` */\n nodeLabel?: StringAccessor<N>;\n /** Node label alignment. Default: `ChordLabelAlignment.Along` */\n nodeLabelAlignment?: ChordLabelAlignment | string;\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 /** Curve type. Default: `CurveType.CatmullRom` */\n curveType?: CurveType;\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 linkValue = (d: L): number => d['value']\n nodeLevels = []\n nodeWidth = 15\n nodeColor = undefined\n nodeLabel = (d: N): string => d['label'] ?? d['key']\n nodeLabelAlignment = ChordLabelAlignment.Along\n padAngle = 0.02\n cornerRadius = 2\n angleRange: [number, number] = [0, 2 * Math.PI]\n curveType = CurveType.CatmullRom\n radiusScaleExponent = 2\n}\n"],"names":[],"mappings":";;;;AAAA;AAqCM,MAAO,kBAAuE,SAAQ,eAAe,CAAA;AAA3G,IAAA,WAAA,GAAA;;QACE,IAAQ,CAAA,QAAA,GAAG,GAAG,CAAA;QACd,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,SAAS,CAAA;AACrB,QAAA,IAAA,CAAA,SAAS,GAAG,CAAC,CAAI,KAAY,EAAA,IAAA,EAAA,CAAA,CAAC,OAAA,CAAA,EAAA,GAAA,CAAC,CAAC,OAAO,CAAC,mCAAI,CAAC,CAAC,KAAK,CAAC,CAAA,EAAA,CAAA;AACpD,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;AAC/C,QAAA,IAAA,CAAA,SAAS,GAAG,SAAS,CAAC,UAAU,CAAA;QAChC,IAAmB,CAAA,mBAAA,GAAG,CAAC,CAAA;KACxB;AAAA;;;;"}
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 /** 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 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;AAsCM,MAAO,kBAAuE,SAAQ,eAAe,CAAA;AAA3G,IAAA,WAAA,GAAA;;QACE,IAAQ,CAAA,QAAA,GAAG,GAAG,CAAA;QACd,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;;;;"}
@@ -3,7 +3,7 @@ import { ScalePower } from 'd3-scale';
3
3
  import { ComponentCore } from "../../core/component";
4
4
  import { GraphDataModel } from "../../data-models/graph";
5
5
  import { Spacing } from "../../types/spacing";
6
- import { ChordInputNode, ChordInputLink, ChordDiagramData, ChordNode, ChordRibbon, ChordRibbonPoint } from './types';
6
+ import { ChordInputNode, ChordInputLink, ChordDiagramData, ChordNode, ChordRibbon } from './types';
7
7
  import { ChordDiagramConfig, ChordDiagramConfigInterface } from './config';
8
8
  import * as s from './style';
9
9
  export declare class ChordDiagram<N extends ChordInputNode, L extends ChordInputLink> extends ComponentCore<ChordDiagramData<N, L>, ChordDiagramConfig<N, L>, ChordDiagramConfigInterface<N, L>> {
@@ -15,11 +15,9 @@ export declare class ChordDiagram<N extends ChordInputNode, L extends ChordInput
15
15
  labelGroup: Selection<SVGGElement, unknown, SVGGElement, unknown>;
16
16
  arcGen: import("d3-shape").Arc<any, ChordNode<N>>;
17
17
  radiusScale: ScalePower<number, number>;
18
- linkAreaGen: import("d3-shape").Area<ChordRibbonPoint>;
19
18
  private _nodes;
20
19
  private _links;
21
20
  private _rootNode;
22
- private _hierarchyNodes;
23
21
  events: {
24
22
  [x: string]: {
25
23
  mouseover: (d: ChordNode<N>) => void;
@@ -30,11 +28,6 @@ export declare class ChordDiagram<N extends ChordInputNode, L extends ChordInput
30
28
  };
31
29
  };
32
30
  constructor(config?: ChordDiagramConfigInterface<N, L>);
33
- setData(data: {
34
- nodes: N[];
35
- links?: L[];
36
- }): void;
37
- setConfig(config: ChordDiagramConfigInterface<N, L>): void;
38
31
  get bleed(): Spacing;
39
32
  _render(customDuration?: number): void;
40
33
  private _getHierarchyNodes;
@@ -1,19 +1,20 @@
1
1
  import { nest } from 'd3-collection';
2
- import { hierarchy, partition } from 'd3-hierarchy';
3
- import { arc, area } from 'd3-shape';
2
+ import { partition, hierarchy } from 'd3-hierarchy';
3
+ import { arc, line } from 'd3-shape';
4
4
  import { scalePow } from 'd3-scale';
5
5
  import { max } from 'd3-array';
6
6
  import { ComponentCore } from '../../core/component/index.js';
7
7
  import { GraphDataModel } from '../../data-models/graph.js';
8
- import { isNumber, getNumber, groupBy } from '../../utils/data.js';
8
+ import { getValue, getString, isNumber, getNumber, groupBy } from '../../utils/data.js';
9
+ import { estimateStringPixelLength } from '../../utils/text.js';
9
10
  import { Curve } from '../../types/curve.js';
10
11
  import { ChordLabelAlignment } from './types.js';
11
12
  import { ChordDiagramConfig } from './config.js';
12
13
  import { createNode, updateNode, removeNode } from './modules/node.js';
13
- import { createLabel, updateLabel, removeLabel } from './modules/label.js';
14
+ import { LABEL_PADDING, createLabel, updateLabel, removeLabel } from './modules/label.js';
14
15
  import { createLink, updateLink, removeLink } from './modules/link.js';
15
16
  import * as style from './style.js';
16
- import { nodes, links, labels, link, node, gLabel, labelExit, hoveredNode, hoveredLink, transparent } from './style.js';
17
+ import { links, nodes, labels, link, node, gLabel, labelExit, hoveredNode, hoveredLink, transparent } from './style.js';
17
18
 
18
19
  class ChordDiagram extends ComponentCore {
19
20
  constructor(config) {
@@ -22,7 +23,6 @@ class ChordDiagram extends ComponentCore {
22
23
  this.datamodel = new GraphDataModel();
23
24
  this.arcGen = arc();
24
25
  this.radiusScale = scalePow();
25
- this.linkAreaGen = area();
26
26
  this._nodes = [];
27
27
  this._links = [];
28
28
  this.events = {
@@ -37,26 +37,43 @@ class ChordDiagram extends ComponentCore {
37
37
  };
38
38
  if (config)
39
39
  this.config.init(config);
40
- this.linkGroup = this.g.append('g').attr('class', nodes);
41
- this.nodeGroup = this.g.append('g').attr('class', links);
40
+ this.linkGroup = this.g.append('g').attr('class', links);
41
+ this.nodeGroup = this.g.append('g').attr('class', nodes);
42
42
  this.labelGroup = this.g.append('g').attr('class', labels);
43
43
  }
44
- setData(data) {
45
- this.datamodel.data = data;
46
- this._hierarchyNodes = this._getHierarchyNodes();
47
- }
48
- setConfig(config) {
49
- super.setConfig(config);
50
- this._hierarchyNodes = this._getHierarchyNodes();
51
- }
52
44
  get bleed() {
53
- return { top: 4, bottom: 4, left: 4, right: 4 };
45
+ const { config } = this;
46
+ let top = 0;
47
+ let bottom = 0;
48
+ let right = 0;
49
+ let left = 0;
50
+ const padding = 4 + LABEL_PADDING * 2;
51
+ this._nodes.forEach(n => {
52
+ var _a;
53
+ const nodeLabelAlignment = getValue(n.data, config.nodeLabelAlignment);
54
+ if (n.height === 0 && nodeLabelAlignment === ChordLabelAlignment.Perpendicular) {
55
+ const labelWidth = estimateStringPixelLength((_a = getString(n.data, config.nodeLabel)) !== null && _a !== void 0 ? _a : '', 16);
56
+ const [x, y] = this.arcGen.centroid(n);
57
+ if (x < 0)
58
+ left = Math.max(left, labelWidth);
59
+ else
60
+ right = Math.max(right, labelWidth);
61
+ if (y < 0)
62
+ top = Math.max(top, labelWidth);
63
+ else
64
+ bottom = Math.max(bottom, labelWidth);
65
+ }
66
+ });
67
+ left += padding;
68
+ right += padding;
69
+ bottom += padding;
70
+ top += padding;
71
+ return { top, bottom, left, right };
54
72
  }
55
73
  _render(customDuration) {
56
- var _a, _b;
57
74
  super._render(customDuration);
58
- const { config, config: { nodeLabelAlignment, radiusScaleExponent }, radiusScale } = this;
59
- const nodes = this._hierarchyNodes;
75
+ const { config, config: { radiusScaleExponent }, radiusScale } = this;
76
+ const nodes = this._getHierarchyNodes();
60
77
  const duration = isNumber(customDuration) ? customDuration : config.duration;
61
78
  this.arcGen
62
79
  .startAngle(d => d.x0)
@@ -64,53 +81,54 @@ class ChordDiagram extends ComponentCore {
64
81
  .cornerRadius(d => getNumber(d, config.cornerRadius))
65
82
  .innerRadius(d => this.radiusScale(d.y1) - getNumber(d, config.nodeWidth))
66
83
  .outerRadius(d => this.radiusScale(d.y1));
67
- const curveGen = Curve[config.curveType];
68
- if ('alpha' in curveGen)
69
- (_b = (_a = curveGen).alpha) === null || _b === void 0 ? void 0 : _b.call(_a, 0.25);
70
- this.linkAreaGen
71
- .x0(d => d.x0)
72
- .x1(d => d.x1)
73
- .y0(d => d.y0)
74
- .y1(d => d.y1)
75
- .curve(curveGen);
76
- const hierarchyData = hierarchy(nodes, (d) => d.values);
77
- hierarchyData.sum((d) => {
78
- var _a;
79
- return (_a = d._state) === null || _a === void 0 ? void 0 : _a.value;
80
- });
81
- let radius = Math.min(this._width, this._height) / 2 - max([this.bleed.top, this.bleed.bottom, this.bleed.left, this.bleed.right]);
82
- let labelWidth = nodeLabelAlignment === ChordLabelAlignment.Perpendicular ? radius / (hierarchyData.height + 1) - config.nodeWidth : 0;
83
- radius = radius - labelWidth;
84
+ const linkLineGen = line().curve(Curve.catmullRom.alpha(0.25));
85
+ const hierarchyData = nodes;
86
+ const partitionData = partition().size([config.angleRange[1], 1])(hierarchyData);
87
+ this._calculateRadialPosition(partitionData);
88
+ const size = Math.min(this._width, this._height);
89
+ const radius = size / 2 - max([this.bleed.top, this.bleed.bottom, this.bleed.left, this.bleed.right]);
90
+ const labelWidth = size - radius - config.nodeWidth;
84
91
  radiusScale
85
92
  .exponent(radiusScaleExponent)
86
93
  .range([0, radius]);
87
- labelWidth -= labelWidth / (hierarchyData.height + 1);
88
- const partitionData = partition().size([config.angleRange[1], 1])(hierarchyData);
89
- this._calculateRadialPosition(partitionData);
90
94
  const partitionDataWithRoot = partitionData.descendants();
91
95
  this._rootNode = partitionDataWithRoot.find(d => d.depth === 0);
92
96
  this._nodes = partitionDataWithRoot.filter(d => d.depth !== 0); // Filter out the root node
93
97
  this._links = this._getRibbons(partitionData);
94
98
  // Create Node and Link state objects
95
- this._nodes.forEach(node => { node._state = {}; });
99
+ this._nodes.forEach((node, i) => {
100
+ // Add hierarchy data for non leaf nodes
101
+ if (node.children) {
102
+ node.data = Object.assign(node.data, {
103
+ depth: node.depth,
104
+ height: node.height,
105
+ value: node.value,
106
+ ancestors: node.ancestors().map(d => d.data.key),
107
+ });
108
+ }
109
+ node.x0 = Number.isNaN(node.x0) ? 0 : node.x0;
110
+ node.x1 = Number.isNaN(node.x1) ? 0 : node.x1;
111
+ node.uid = `${this.uid}-n${i}`;
112
+ node._state = {};
113
+ });
96
114
  this._links.forEach(link => { link._state = {}; });
97
115
  // Center the view
98
116
  this.g.attr('transform', `translate(${this._width / 2},${this._height / 2})`);
99
117
  // Links
100
118
  const linksSelection = this.linkGroup
101
119
  .selectAll(`.${link}`)
102
- .data(this._links);
120
+ .data(this._links, d => String(d.data._id));
103
121
  const linksEnter = linksSelection.enter().append('path')
104
122
  .attr('class', link)
105
- .call(createLink, this.linkAreaGen);
123
+ .call(createLink, linkLineGen);
106
124
  const linksMerged = linksSelection.merge(linksEnter);
107
- linksMerged.call(updateLink, this.linkAreaGen, duration);
125
+ linksMerged.call(updateLink, config, linkLineGen, duration);
108
126
  linksSelection.exit()
109
127
  .call(removeLink, duration);
110
128
  // Nodes
111
129
  const nodesSelection = this.nodeGroup
112
130
  .selectAll(`.${node}`)
113
- .data(this._nodes);
131
+ .data(this._nodes, d => String(d.uid));
114
132
  const nodesEnter = nodesSelection.enter().append('path')
115
133
  .attr('class', node)
116
134
  .call(createNode, config);
@@ -121,7 +139,7 @@ class ChordDiagram extends ComponentCore {
121
139
  // Labels
122
140
  const labels = this.labelGroup
123
141
  .selectAll(`.${gLabel}`)
124
- .data(this._nodes);
142
+ .data(this._nodes, d => String(d.uid));
125
143
  const labelEnter = labels.enter().append('g')
126
144
  .attr('class', gLabel)
127
145
  .call(createLabel, config, radiusScale);
@@ -139,19 +157,22 @@ class ChordDiagram extends ComponentCore {
139
157
  l.source._state.value = (l.source._state.value || 0) + getNumber(l, config.linkValue);
140
158
  l.target._state.value = (l.target._state.value || 0) + getNumber(l, config.linkValue);
141
159
  });
142
- // Todo: replace with d3 group
160
+ // TODO: Replace with d3-group
143
161
  const nestGen = nest();
144
162
  config.nodeLevels.forEach(levelAccessor => {
145
163
  nestGen.key(d => d[levelAccessor]);
146
164
  });
147
- return { key: 'root', values: nestGen.entries(nodes) };
165
+ const root = { key: 'root', values: nestGen.entries(nodes) };
166
+ const hierarchyNodes = hierarchy(root, d => d.values)
167
+ .sum((d) => { var _a; return (_a = d._state) === null || _a === void 0 ? void 0 : _a.value; });
168
+ return hierarchyNodes;
148
169
  }
149
170
  _getRibbons(partitionData) {
150
171
  const { config, datamodel: { links } } = this;
151
- const findNode = (nodes, id) => nodes.find(n => n.data.id === id);
172
+ const findNode = (nodes, id) => nodes.find(n => n.data._id === id);
152
173
  const leafNodes = partitionData.leaves();
153
- const groupedBySource = groupBy(links, d => d.source.id);
154
- const groupedByTarget = groupBy(links, d => d.target.id);
174
+ const groupedBySource = groupBy(links, d => d.source._id);
175
+ const groupedByTarget = groupBy(links, d => d.target._id);
155
176
  const getNodesInRibbon = (source, target, partitionHeight, nodes = []) => {
156
177
  nodes[source.height] = source;
157
178
  nodes[partitionHeight * 2 - target.height] = target;
@@ -164,33 +185,33 @@ class ChordDiagram extends ComponentCore {
164
185
  var _a;
165
186
  if (!link._state.points)
166
187
  link._state.points = [];
167
- const sourceLeaf = findNode(leafNodes, link.source.id);
168
- const targetLeaf = findNode(leafNodes, link.target.id);
188
+ const sourceLeaf = findNode(leafNodes, link.source._id);
189
+ const targetLeaf = findNode(leafNodes, link.target._id);
169
190
  const nodesInRibbon = getNodesInRibbon(type === 'out' ? sourceLeaf : targetLeaf, type === 'out' ? targetLeaf : sourceLeaf, partitionData.height);
170
191
  const currNode = nodesInRibbon[depth];
171
192
  const len = currNode.x1 - currNode.x0;
172
193
  const x0 = (_a = currNode._prevX1) !== null && _a !== void 0 ? _a : currNode.x0;
173
194
  const x1 = x0 + len * getNumber(link, config.linkValue) / currNode.value;
174
195
  currNode._prevX1 = x1;
175
- const converted = this._convertRadialToCartesian(type === 'out' ? x0 : x1, type === 'out' ? x1 : x0, currNode.y1, 0);
176
196
  const pointIdx = type === 'out' ? depth : partitionData.height * 2 - 1 - depth;
177
- link._state.points[pointIdx] = { x0: converted.x0, x1: converted.x1, y0: converted.y0, y1: converted.y1 };
197
+ link._state.points[pointIdx] = this._convertRadialToCartesian(Math.min(x0, x1), Math.max(x0, x1), currNode.y1, config.nodeWidth);
178
198
  });
179
199
  };
180
200
  leafNodes.forEach(leafNode => {
181
- const outLinks = groupedBySource[leafNode.data.id] || [];
182
- const inLinks = groupedByTarget[leafNode.data.id] || [];
201
+ const outLinks = groupedBySource[leafNode.data._id] || [];
202
+ const inLinks = groupedByTarget[leafNode.data._id] || [];
183
203
  for (let depth = 0; depth < partitionData.height; depth += 1) {
184
204
  calculatePoints(outLinks, 'out', depth);
185
205
  calculatePoints(inLinks, 'in', depth);
186
206
  }
187
207
  });
188
- const ribbons = links.map((l) => {
189
- const sourceNode = findNode(leafNodes, l.source.id);
190
- const targetNode = findNode(leafNodes, l.target.id);
208
+ const ribbons = links.map(l => {
209
+ const sourceNode = findNode(leafNodes, l.source._id);
210
+ const targetNode = findNode(leafNodes, l.target._id);
191
211
  return {
192
212
  source: sourceNode,
193
213
  target: targetNode,
214
+ data: l,
194
215
  points: l._state.points,
195
216
  _state: {},
196
217
  };
@@ -198,15 +219,17 @@ class ChordDiagram extends ComponentCore {
198
219
  return ribbons;
199
220
  }
200
221
  _convertRadialToCartesian(x0, x1, y, nodeWidth) {
201
- const r0 = this.radiusScale(y) - nodeWidth / 2;
222
+ const r = Math.max(this.radiusScale(y) - nodeWidth, 0);
202
223
  const a0 = x0 - Math.PI / 2;
203
- const r1 = this.radiusScale(y) - nodeWidth / 2;
204
224
  const a1 = x1 - Math.PI / 2;
205
225
  return {
206
- x0: r0 * Math.cos(a0),
207
- x1: r1 * Math.cos(a1),
208
- y0: r0 * Math.sin(a0),
209
- y1: r1 * Math.sin(a1),
226
+ a0,
227
+ a1,
228
+ r,
229
+ x0: r * Math.cos(a0),
230
+ x1: r * Math.cos(a1),
231
+ y0: r * Math.sin(a0),
232
+ y1: r * Math.sin(a1),
210
233
  };
211
234
  }
212
235
  _calculateRadialPosition(hierarchyNode, scalingCoeff = 0.95, nodePadding = 0.02) {
@@ -269,8 +292,10 @@ class ChordDiagram extends ComponentCore {
269
292
  this._nodes.forEach(n => { delete n._state.hovered; });
270
293
  this._links.forEach(l => { delete l._state.hovered; });
271
294
  }
272
- this.nodeGroup.selectAll(`.${node}`).classed(hoveredNode, (d) => d._state.hovered);
273
- this.linkGroup.selectAll(`.${link}`).classed(hoveredLink, (d) => d._state.hovered);
295
+ this.nodeGroup.selectAll(`.${node}`)
296
+ .classed(hoveredNode, d => d._state.hovered);
297
+ this.linkGroup.selectAll(`.${link}`)
298
+ .classed(hoveredLink, d => d._state.hovered);
274
299
  this.g.classed(transparent, !!links);
275
300
  }
276
301
  }