@unovis/ts 1.3.0-beta.2 → 1.3.0-beta.3

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 (227) hide show
  1. package/components/area/config.d.ts +10 -6
  2. package/components/area/config.js +12 -3
  3. package/components/area/config.js.map +1 -1
  4. package/components/area/index.d.ts +6 -5
  5. package/components/area/index.js +9 -10
  6. package/components/area/index.js.map +1 -1
  7. package/components/axis/config.d.ts +27 -3
  8. package/components/axis/config.js +30 -3
  9. package/components/axis/config.js.map +1 -1
  10. package/components/axis/index.d.ts +3 -4
  11. package/components/axis/index.js +4 -7
  12. package/components/axis/index.js.map +1 -1
  13. package/components/brush/config.d.ts +12 -2
  14. package/components/brush/config.js +20 -11
  15. package/components/brush/config.js.map +1 -1
  16. package/components/brush/index.d.ts +3 -4
  17. package/components/brush/index.js +3 -4
  18. package/components/brush/index.js.map +1 -1
  19. package/components/bullet-legend/config.d.ts +10 -1
  20. package/components/bullet-legend/config.js +14 -11
  21. package/components/bullet-legend/config.js.map +1 -1
  22. package/components/bullet-legend/index.d.ts +3 -4
  23. package/components/bullet-legend/index.js +2 -5
  24. package/components/bullet-legend/index.js.map +1 -1
  25. package/components/chord-diagram/config.d.ts +23 -7
  26. package/components/chord-diagram/config.js +22 -3
  27. package/components/chord-diagram/config.js.map +1 -1
  28. package/components/chord-diagram/index.d.ts +3 -4
  29. package/components/chord-diagram/index.js +6 -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 +2 -3
  39. package/components/chord-diagram/types.js.map +1 -1
  40. package/components/crosshair/config.d.ts +14 -4
  41. package/components/crosshair/config.js +16 -3
  42. package/components/crosshair/config.js.map +1 -1
  43. package/components/crosshair/index.d.ts +3 -4
  44. package/components/crosshair/index.js +3 -4
  45. package/components/crosshair/index.js.map +1 -1
  46. package/components/donut/config.d.ts +19 -2
  47. package/components/donut/config.js +24 -5
  48. package/components/donut/config.js.map +1 -1
  49. package/components/donut/index.d.ts +3 -4
  50. package/components/donut/index.js +4 -5
  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 +11 -1
  55. package/components/flow-legend/config.js +16 -11
  56. package/components/flow-legend/config.js.map +1 -1
  57. package/components/flow-legend/index.d.ts +3 -4
  58. package/components/flow-legend/index.js +2 -5
  59. package/components/flow-legend/index.js.map +1 -1
  60. package/components/free-brush/config.d.ts +12 -2
  61. package/components/free-brush/config.js +20 -11
  62. package/components/free-brush/config.js.map +1 -1
  63. package/components/free-brush/index.d.ts +3 -4
  64. package/components/free-brush/index.js +5 -6
  65. package/components/free-brush/index.js.map +1 -1
  66. package/components/graph/config.d.ts +75 -3
  67. package/components/graph/config.js +78 -12
  68. package/components/graph/config.js.map +1 -1
  69. package/components/graph/index.d.ts +7 -8
  70. package/components/graph/index.js +3 -4
  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.map +1 -1
  74. package/components/graph/modules/link/helper.d.ts +5 -5
  75. package/components/graph/modules/link/helper.js.map +1 -1
  76. package/components/graph/modules/link/index.d.ts +6 -6
  77. package/components/graph/modules/link/index.js.map +1 -1
  78. package/components/graph/modules/node/index.d.ts +6 -6
  79. package/components/graph/modules/node/index.js +2 -2
  80. package/components/graph/modules/node/index.js.map +1 -1
  81. package/components/graph/modules/panel/helper.d.ts +4 -4
  82. package/components/graph/modules/panel/helper.js.map +1 -1
  83. package/components/graph/modules/panel/index.d.ts +3 -3
  84. package/components/graph/modules/panel/index.js.map +1 -1
  85. package/components/grouped-bar/config.d.ts +13 -5
  86. package/components/grouped-bar/config.js +16 -5
  87. package/components/grouped-bar/config.js.map +1 -1
  88. package/components/grouped-bar/index.d.ts +3 -4
  89. package/components/grouped-bar/index.js +3 -4
  90. package/components/grouped-bar/index.js.map +1 -1
  91. package/components/leaflet-flow-map/config.d.ts +16 -2
  92. package/components/leaflet-flow-map/config.js +21 -3
  93. package/components/leaflet-flow-map/config.js.map +1 -1
  94. package/components/leaflet-flow-map/index.d.ts +3 -4
  95. package/components/leaflet-flow-map/index.js +2 -3
  96. package/components/leaflet-flow-map/index.js.map +1 -1
  97. package/components/leaflet-map/config.d.ts +59 -4
  98. package/components/leaflet-map/config.js +67 -23
  99. package/components/leaflet-map/config.js.map +1 -1
  100. package/components/leaflet-map/index.d.ts +3 -4
  101. package/components/leaflet-map/index.js +3 -4
  102. package/components/leaflet-map/index.js.map +1 -1
  103. package/components/leaflet-map/modules/map.d.ts +3 -3
  104. package/components/leaflet-map/modules/map.js.map +1 -1
  105. package/components/leaflet-map/modules/utils.d.ts +4 -4
  106. package/components/leaflet-map/modules/utils.js +2 -6
  107. package/components/leaflet-map/modules/utils.js.map +1 -1
  108. package/components/leaflet-map/renderer/mapboxgl-layer.d.ts +2 -2
  109. package/components/leaflet-map/renderer/mapboxgl-layer.js.map +1 -1
  110. package/components/line/config.d.ts +11 -6
  111. package/components/line/config.js +13 -3
  112. package/components/line/config.js.map +1 -1
  113. package/components/line/index.d.ts +3 -4
  114. package/components/line/index.js +4 -5
  115. package/components/line/index.js.map +1 -1
  116. package/components/nested-donut/config.d.ts +21 -2
  117. package/components/nested-donut/config.js +24 -3
  118. package/components/nested-donut/config.js.map +1 -1
  119. package/components/nested-donut/index.d.ts +3 -4
  120. package/components/nested-donut/index.js +3 -4
  121. package/components/nested-donut/index.js.map +1 -1
  122. package/components/nested-donut/modules/arc.d.ts +3 -3
  123. package/components/nested-donut/modules/arc.js.map +1 -1
  124. package/components/nested-donut/modules/label.d.ts +2 -2
  125. package/components/nested-donut/modules/label.js.map +1 -1
  126. package/components/sankey/config.d.ts +47 -2
  127. package/components/sankey/config.js +57 -10
  128. package/components/sankey/config.js.map +1 -1
  129. package/components/sankey/index.d.ts +3 -4
  130. package/components/sankey/index.js +2 -3
  131. package/components/sankey/index.js.map +1 -1
  132. package/components/sankey/modules/label.d.ts +7 -7
  133. package/components/sankey/modules/label.js.map +1 -1
  134. package/components/sankey/modules/link.d.ts +2 -2
  135. package/components/sankey/modules/link.js.map +1 -1
  136. package/components/sankey/modules/node.d.ts +7 -7
  137. package/components/sankey/modules/node.js +1 -1
  138. package/components/sankey/modules/node.js.map +1 -1
  139. package/components/scatter/config.d.ts +16 -4
  140. package/components/scatter/config.js +19 -5
  141. package/components/scatter/config.js.map +1 -1
  142. package/components/scatter/index.d.ts +3 -4
  143. package/components/scatter/index.js +5 -5
  144. package/components/scatter/index.js.map +1 -1
  145. package/components/scatter/modules/point.d.ts +2 -2
  146. package/components/scatter/modules/point.js.map +1 -1
  147. package/components/scatter/modules/utils.d.ts +2 -2
  148. package/components/scatter/modules/utils.js.map +1 -1
  149. package/components/stacked-bar/config.d.ts +13 -5
  150. package/components/stacked-bar/config.js +16 -5
  151. package/components/stacked-bar/config.js.map +1 -1
  152. package/components/stacked-bar/index.d.ts +3 -4
  153. package/components/stacked-bar/index.js +3 -4
  154. package/components/stacked-bar/index.js.map +1 -1
  155. package/components/timeline/config.d.ts +16 -5
  156. package/components/timeline/config.js +21 -9
  157. package/components/timeline/config.js.map +1 -1
  158. package/components/timeline/index.d.ts +3 -4
  159. package/components/timeline/index.js +3 -4
  160. package/components/timeline/index.js.map +1 -1
  161. package/components/tooltip/config.d.ts +15 -1
  162. package/components/tooltip/config.js +16 -12
  163. package/components/tooltip/config.js.map +1 -1
  164. package/components/tooltip/index.d.ts +3 -4
  165. package/components/tooltip/index.js +3 -5
  166. package/components/tooltip/index.js.map +1 -1
  167. package/components/topojson-map/config.d.ts +36 -4
  168. package/components/topojson-map/config.js +38 -3
  169. package/components/topojson-map/config.js.map +1 -1
  170. package/components/topojson-map/index.d.ts +3 -4
  171. package/components/topojson-map/index.js +4 -4
  172. package/components/topojson-map/index.js.map +1 -1
  173. package/components/vis-controls/config.d.ts +5 -1
  174. package/components/vis-controls/config.js +9 -6
  175. package/components/vis-controls/config.js.map +1 -1
  176. package/components/vis-controls/index.d.ts +2 -3
  177. package/components/vis-controls/index.js +2 -5
  178. package/components/vis-controls/index.js.map +1 -1
  179. package/components/xy-labels/config.d.ts +16 -4
  180. package/components/xy-labels/config.js +20 -5
  181. package/components/xy-labels/config.js.map +1 -1
  182. package/components/xy-labels/index.d.ts +3 -4
  183. package/components/xy-labels/index.js +2 -3
  184. package/components/xy-labels/index.js.map +1 -1
  185. package/components/xy-labels/modules/label.d.ts +3 -3
  186. package/components/xy-labels/modules/label.js +1 -1
  187. package/components/xy-labels/modules/label.js.map +1 -1
  188. package/containers/single-container/config.d.ts +4 -2
  189. package/containers/single-container/config.js +8 -3
  190. package/containers/single-container/config.js.map +1 -1
  191. package/containers/single-container/index.d.ts +3 -4
  192. package/containers/single-container/index.js +2 -2
  193. package/containers/single-container/index.js.map +1 -1
  194. package/containers/xy-container/config.d.ts +22 -2
  195. package/containers/xy-container/config.js +26 -3
  196. package/containers/xy-container/config.js.map +1 -1
  197. package/containers/xy-container/index.d.ts +2 -5
  198. package/containers/xy-container/index.js +2 -2
  199. package/containers/xy-container/index.js.map +1 -1
  200. package/core/component/config.d.ts +6 -1
  201. package/core/component/config.js +12 -6
  202. package/core/component/config.js.map +1 -1
  203. package/core/component/index.d.ts +5 -7
  204. package/core/component/index.js +7 -8
  205. package/core/component/index.js.map +1 -1
  206. package/core/config/index.d.ts +3 -0
  207. package/core/config/index.js +16 -0
  208. package/core/config/index.js.map +1 -0
  209. package/core/container/config.d.ts +21 -1
  210. package/core/container/config.js +25 -21
  211. package/core/container/config.js.map +1 -1
  212. package/core/container/index.d.ts +4 -5
  213. package/core/container/index.js +3 -4
  214. package/core/container/index.js.map +1 -1
  215. package/core/xy-component/config.d.ts +10 -2
  216. package/core/xy-component/config.js +16 -7
  217. package/core/xy-component/config.js.map +1 -1
  218. package/core/xy-component/index.d.ts +4 -5
  219. package/core/xy-component/index.js +0 -2
  220. package/core/xy-component/index.js.map +1 -1
  221. package/data-models/map-graph.d.ts +1 -1
  222. package/data-models/map-graph.js +1 -1
  223. package/data-models/map-graph.js.map +1 -1
  224. package/package.json +1 -1
  225. package/types/accessor.d.ts +1 -1
  226. package/utils/data.d.ts +1 -1
  227. package/utils/data.js.map +1 -1
@@ -1,15 +1,13 @@
1
- import { XYComponentConfigInterface } from "../../core/xy-component/config";
1
+ import { XYComponentConfigInterface, XYComponentConfig } from "../../core/xy-component/config";
2
2
  import { CurveType } from "../../types/curve";
3
- import { ColorAccessor, GenericAccessor, StringAccessor } from "../../types/accessor";
3
+ import { GenericAccessor, StringAccessor } from "../../types/accessor";
4
4
  export interface LineConfigInterface<Datum> extends XYComponentConfigInterface<Datum> {
5
- /** Line color accessor function. The whole data array will be passed as the first argument. Default: `undefined` */
6
- color?: ColorAccessor<Datum[]>;
7
5
  /** Curve type from the CurveType enum. Default: `CurveType.MonotoneX` */
8
6
  curveType?: CurveType;
9
7
  /** Line width in pixels. Default: `2` */
10
8
  lineWidth?: number;
11
9
  /** Line dash array, see SVG's stroke-dasharray. Default: `undefined` */
12
- lineDashArray?: GenericAccessor<number[], Datum[]>;
10
+ lineDashArray?: GenericAccessor<number[], Datum>;
13
11
  /** When a data point has an `undefined`, `NaN`, or other no-data value, they'll be replaced with a value specified here.
14
12
  * Setting this property to `undefined` will lead to having the line break when there's no data, and continue when
15
13
  * the data appears again. If you set it to `null`, the values will be treated as numerical `0` values and the line
@@ -22,4 +20,11 @@ export interface LineConfigInterface<Datum> extends XYComponentConfigInterface<D
22
20
  /** Optional link cursor. Default: `null` */
23
21
  cursor?: StringAccessor<Datum[]>;
24
22
  }
25
- export declare const LineDefaultConfig: LineConfigInterface<unknown>;
23
+ export declare class LineConfig<Datum> extends XYComponentConfig<Datum> implements LineConfigInterface<Datum> {
24
+ curveType: CurveType;
25
+ lineWidth: number;
26
+ lineDashArray: any;
27
+ fallbackValue: any;
28
+ highlightOnHover: boolean;
29
+ cursor: any;
30
+ }
@@ -1,7 +1,17 @@
1
- import { XYComponentDefaultConfig } from '../../core/xy-component/config.js';
1
+ import { XYComponentConfig } from '../../core/xy-component/config.js';
2
2
  import { CurveType } from '../../types/curve.js';
3
3
 
4
- const LineDefaultConfig = Object.assign(Object.assign({}, XYComponentDefaultConfig), { curveType: CurveType.MonotoneX, lineWidth: 2, lineDashArray: undefined, fallbackValue: undefined, highlightOnHover: false, cursor: null });
4
+ class LineConfig extends XYComponentConfig {
5
+ constructor() {
6
+ super(...arguments);
7
+ this.curveType = CurveType.MonotoneX;
8
+ this.lineWidth = 2;
9
+ this.lineDashArray = undefined;
10
+ this.fallbackValue = undefined;
11
+ this.highlightOnHover = false;
12
+ this.cursor = null;
13
+ }
14
+ }
5
15
 
6
- export { LineDefaultConfig };
16
+ export { LineConfig };
7
17
  //# sourceMappingURL=config.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sources":["../../../src/components/line/config.ts"],"sourcesContent":["import { XYComponentConfigInterface, XYComponentDefaultConfig } from 'core/xy-component/config'\n\n// Types\nimport { CurveType } from 'types/curve'\nimport { ColorAccessor, GenericAccessor, StringAccessor } from 'types/accessor'\n\nexport interface LineConfigInterface<Datum> extends XYComponentConfigInterface<Datum> {\n /** Line color accessor function. The whole data array will be passed as the first argument. Default: `undefined` */\n color?: ColorAccessor<Datum[]>;\n /** Curve type from the CurveType enum. Default: `CurveType.MonotoneX` */\n curveType?: CurveType;\n /** Line width in pixels. Default: `2` */\n lineWidth?: number;\n /** Line dash array, see SVG's stroke-dasharray. Default: `undefined` */\n lineDashArray?: GenericAccessor<number[], Datum[]>;\n /** When a data point has an `undefined`, `NaN`, or other no-data value, they'll be replaced with a value specified here.\n * Setting this property to `undefined` will lead to having the line break when there's no data, and continue when\n * the data appears again. If you set it to `null`, the values will be treated as numerical `0` values and the line\n * won't break; however if the whole dataset consists of only `null`s, the line won't be displayed.\n * Default: `undefined`\n */\n fallbackValue?: number | undefined | null;\n /** Highlight line on hover. Default: `false` */\n highlightOnHover?: boolean;\n /** Optional link cursor. Default: `null` */\n cursor?: StringAccessor<Datum[]>;\n}\n\nexport const LineDefaultConfig: LineConfigInterface<unknown> = {\n ...XYComponentDefaultConfig,\n curveType: CurveType.MonotoneX,\n lineWidth: 2,\n lineDashArray: undefined,\n fallbackValue: undefined,\n highlightOnHover: false,\n cursor: null,\n}\n"],"names":[],"mappings":";;;AA4BO,MAAM,iBAAiB,GAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EACzB,wBAAwB,CAC3B,EAAA,EAAA,SAAS,EAAE,SAAS,CAAC,SAAS,EAC9B,SAAS,EAAE,CAAC,EACZ,aAAa,EAAE,SAAS,EACxB,aAAa,EAAE,SAAS,EACxB,gBAAgB,EAAE,KAAK,EACvB,MAAM,EAAE,IAAI;;;;"}
1
+ {"version":3,"file":"config.js","sources":["../../../src/components/line/config.ts"],"sourcesContent":["import { XYComponentConfigInterface, XYComponentConfig } from 'core/xy-component/config'\n\n// Types\nimport { CurveType } from 'types/curve'\nimport { GenericAccessor, StringAccessor } from 'types/accessor'\n\nexport interface LineConfigInterface<Datum> extends XYComponentConfigInterface<Datum> {\n /** Curve type from the CurveType enum. Default: `CurveType.MonotoneX` */\n curveType?: CurveType;\n /** Line width in pixels. Default: `2` */\n lineWidth?: number;\n /** Line dash array, see SVG's stroke-dasharray. Default: `undefined` */\n lineDashArray?: GenericAccessor<number[], Datum>;\n /** When a data point has an `undefined`, `NaN`, or other no-data value, they'll be replaced with a value specified here.\n * Setting this property to `undefined` will lead to having the line break when there's no data, and continue when\n * the data appears again. If you set it to `null`, the values will be treated as numerical `0` values and the line\n * won't break; however if the whole dataset consists of only `null`s, the line won't be displayed.\n * Default: `undefined`\n */\n fallbackValue?: number | undefined | null;\n /** Highlight line on hover. Default: `false` */\n highlightOnHover?: boolean;\n /** Optional link cursor. Default: `null` */\n cursor?: StringAccessor<Datum[]>;\n}\n\nexport class LineConfig<Datum> extends XYComponentConfig<Datum> implements LineConfigInterface<Datum> {\n curveType = CurveType.MonotoneX\n lineWidth = 2\n lineDashArray = undefined\n fallbackValue = undefined\n highlightOnHover = false\n cursor = null\n}\n"],"names":[],"mappings":";;;AA0BM,MAAO,UAAkB,SAAQ,iBAAwB,CAAA;AAA/D,IAAA,WAAA,GAAA;;AACE,QAAA,IAAA,CAAA,SAAS,GAAG,SAAS,CAAC,SAAS,CAAA;QAC/B,IAAS,CAAA,SAAA,GAAG,CAAC,CAAA;QACb,IAAa,CAAA,aAAA,GAAG,SAAS,CAAA;QACzB,IAAa,CAAA,aAAA,GAAG,SAAS,CAAA;QACzB,IAAgB,CAAA,gBAAA,GAAG,KAAK,CAAA;QACxB,IAAM,CAAA,MAAA,GAAG,IAAI,CAAA;KACd;AAAA;;;;"}
@@ -1,12 +1,11 @@
1
1
  import { CurveFactoryLineOnly, Line as LineGenInterface } from 'd3-shape';
2
2
  import { XYComponentCore } from "../../core/xy-component";
3
3
  import { Spacing } from "../../types/spacing";
4
- import { LineConfigInterface } from './config';
4
+ import { LineConfig, LineConfigInterface } from './config';
5
5
  import * as s from './style';
6
- export declare class Line<Datum> extends XYComponentCore<Datum, LineConfigInterface<Datum>> {
6
+ export declare class Line<Datum> extends XYComponentCore<Datum, LineConfig<Datum>, LineConfigInterface<Datum>> {
7
7
  static selectors: typeof s;
8
- protected _defaultConfig: LineConfigInterface<Datum>;
9
- config: LineConfigInterface<Datum>;
8
+ config: LineConfig<Datum>;
10
9
  lineGen: LineGenInterface<{
11
10
  x: number;
12
11
  y: number;
@@ -7,15 +7,14 @@ import { smartTransition } from '../../utils/d3.js';
7
7
  import { getColor } from '../../utils/color.js';
8
8
  import { Curve, CurveType } from '../../types/curve.js';
9
9
  import { Direction } from '../../types/direction.js';
10
- import { LineDefaultConfig } from './config.js';
10
+ import { LineConfig } from './config.js';
11
11
  import * as style from './style.js';
12
12
  import { line as line$1, linePath, lineSelectionHelper, dim } from './style.js';
13
13
 
14
14
  class Line extends XYComponentCore {
15
15
  constructor(config) {
16
16
  super();
17
- this._defaultConfig = LineDefaultConfig;
18
- this.config = this._defaultConfig;
17
+ this.config = new LineConfig();
19
18
  this.curve = Curve[CurveType.MonotoneX];
20
19
  this.events = {
21
20
  [Line.selectors.line]: {
@@ -24,7 +23,7 @@ class Line extends XYComponentCore {
24
23
  },
25
24
  };
26
25
  if (config)
27
- this.setConfig(config);
26
+ this.config.init(config);
28
27
  }
29
28
  get bleed() {
30
29
  const { config: { lineWidth } } = this;
@@ -99,7 +98,7 @@ class Line extends XYComponentCore {
99
98
  const linePath$1 = group.select(`.${linePath}`);
100
99
  const lineSelectionHelper$1 = group.select(`.${lineSelectionHelper}`);
101
100
  const isLineVisible = d.visible;
102
- const dashArray = getValue(data, config.lineDashArray, i);
101
+ const dashArray = getValue(d, config.lineDashArray, i);
103
102
  const transition = smartTransition(linePath$1, duration)
104
103
  .attr('stroke', getColor(data, config.color, i))
105
104
  .attr('stroke-width', config.lineWidth)
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/components/line/index.ts"],"sourcesContent":["import { select } from 'd3-selection'\nimport { Transition } from 'd3-transition'\nimport { CurveFactoryLineOnly, Line as LineGenInterface, line } from 'd3-shape'\nimport { interpolatePath } from 'd3-interpolate-path'\n\n// Core\nimport { XYComponentCore } from 'core/xy-component'\n\n// Utils\nimport { getNumber, getString, getValue, isArray, isNumber } from 'utils/data'\nimport { smartTransition } from 'utils/d3'\nimport { getColor } from 'utils/color'\n\n// Types\nimport { NumericAccessor } from 'types/accessor'\nimport { Spacing } from 'types/spacing'\nimport { Curve, CurveType } from 'types/curve'\nimport { Direction } from 'types/direction'\n\n// Local Types\nimport { LineData, LineDatum } from './types'\n\n// Config\nimport { LineDefaultConfig, LineConfigInterface } from './config'\n\n// Styles\nimport * as s from './style'\n\nexport class Line<Datum> extends XYComponentCore<Datum, LineConfigInterface<Datum>> {\n static selectors = s\n protected _defaultConfig = LineDefaultConfig as LineConfigInterface<Datum>\n public config: LineConfigInterface<Datum> = this._defaultConfig\n lineGen: LineGenInterface<{ x: number; y: number; defined: boolean }>\n curve: CurveFactoryLineOnly = Curve[CurveType.MonotoneX]\n events = {\n [Line.selectors.line]: {\n mouseover: this._highlight.bind(this),\n mouseleave: this._resetHighlight.bind(this),\n },\n }\n\n constructor (config?: LineConfigInterface<Datum>) {\n super()\n if (config) this.setConfig(config)\n }\n\n get bleed (): Spacing {\n const { config: { lineWidth } } = this\n const yDomain = this.yScale.domain() as [number, number]\n const yDirection = this.yScale.range()[0] > this.yScale.range()[1]\n ? Direction.North\n : Direction.South\n const isYDirectionSouth = yDirection === Direction.South\n\n const isLineThick = lineWidth > 3\n const isLineVeryThick = lineWidth >= 10\n return {\n top: !isLineVeryThick && (\n (!isYDirectionSouth && (yDomain[1] === 0)) || (isYDirectionSouth && (yDomain[0] === 0))\n ) ? 0 : lineWidth / 2,\n bottom: !isLineVeryThick && (\n (!isYDirectionSouth && (yDomain[0] === 0)) || (isYDirectionSouth && (yDomain[1] === 0))\n ) ? 0 : lineWidth / 2,\n left: isLineThick ? lineWidth / 2 : 0,\n right: isLineThick ? lineWidth / 2 : 0,\n }\n }\n\n _render (customDuration?: number): void {\n super._render(customDuration)\n const { config, datamodel: { data } } = this\n const duration = isNumber(customDuration) ? customDuration : config.duration\n\n this.curve = Curve[config.curveType]\n this.lineGen = line<{ x: number; y: number; defined: boolean }>()\n .x(d => d.x)\n .y(d => d.y)\n .defined(d => d.defined)\n .curve(this.curve)\n\n const yAccessors = (isArray(config.y) ? config.y : [config.y]) as NumericAccessor<Datum>[]\n const lineDataX = data.map((d, i) => this.xScale(getNumber(d, config.x, i)))\n const lineData: LineData[] = yAccessors.map(a => {\n const ld: LineDatum[] = data.map((d, i) => {\n const rawValue = getNumber(d, a, i)\n // If `rawValue` is not numerical or if it's not finite (`NaN`, `undefined`, ...), we replace it with `config.fallbackValue`\n const value = (isNumber(rawValue) || (rawValue === null)) && isFinite(rawValue) ? rawValue : config.fallbackValue\n return {\n x: lineDataX[i],\n y: this.yScale(value ?? 0),\n defined: isFinite(value),\n value,\n }\n })\n\n const defined = ld.reduce((def, d) => (d.defined || def), false)\n // If the line consists only of `null` values, we'll still render it but it'll be invisible.\n // Such trick allows us to have better animated transitions.\n const visible = defined && ld.some(d => d.value !== null)\n return {\n values: ld,\n defined,\n visible,\n }\n })\n\n const lines = this.g\n .selectAll<SVGGElement, LineData>(`.${s.line}`)\n .data(lineData)\n\n const linesEnter = lines.enter().append('g')\n .attr('class', s.line)\n\n linesEnter\n .append('path')\n .attr('class', s.linePath)\n .attr('stroke', (d, i) => getColor(data, config.color, i))\n .attr('stroke-opacity', 0)\n .attr('stroke-width', config.lineWidth)\n\n linesEnter\n .append('path')\n .attr('class', s.lineSelectionHelper)\n .attr('d', this._emptyPath())\n\n const linesMerged = linesEnter.merge(lines)\n linesMerged.style('cursor', (d, i) => getString(data, config.cursor, i))\n linesMerged.each((d, i, elements) => {\n const group = select(elements[i])\n const linePath = group.select<SVGPathElement>(`.${s.linePath}`)\n const lineSelectionHelper = group.select(`.${s.lineSelectionHelper}`)\n\n const isLineVisible = d.visible\n const dashArray = getValue<Datum[], number[]>(data, config.lineDashArray, i)\n const transition = smartTransition(linePath, duration)\n .attr('stroke', getColor(data, config.color, i))\n .attr('stroke-width', config.lineWidth)\n .attr('stroke-opacity', isLineVisible ? 1 : 0)\n .style('stroke-dasharray', dashArray?.join(' ') ?? null) // We use `.style` because there's also a default CSS-variable for stroke-dasharray\n\n const hasUndefinedSegments = d.values.some(d => !d.defined)\n const svgPathD = this.lineGen(d.values)\n\n if (duration && !hasUndefinedSegments) {\n const previous = linePath.attr('d') || this._emptyPath()\n const next = svgPathD || this._emptyPath()\n const t = transition as Transition<SVGPathElement, LineData, SVGGElement, LineData>\n t.attrTween('d', () => interpolatePath(previous, next))\n } else if (d.visible) {\n transition.attr('d', svgPathD)\n }\n\n lineSelectionHelper\n .attr('d', svgPathD)\n .attr('visibility', isLineVisible ? null : 'hidden')\n })\n\n smartTransition(lines.exit(), duration)\n .style('opacity', 0)\n .remove()\n }\n\n private _emptyPath (): string {\n const xRange = this.xScale.range()\n const yRange = this.yScale.range()\n return `M${xRange[0]},${yRange[0]} L${xRange[1]},${yRange[0]}`\n }\n\n private _highlight (datum, i, els): void {\n const { config } = this\n\n if (config.highlightOnHover) {\n this.g\n .selectAll(`.${s.line}`)\n .classed(s.dim, d => d !== datum)\n }\n }\n\n private _resetHighlight (d, i, els): void {\n const { config } = this\n\n if (config.highlightOnHover) {\n this.g\n .selectAll(`.${s.line}`)\n .classed(s.dim, false)\n }\n }\n}\n"],"names":["s.line","s.linePath","s.lineSelectionHelper","linePath","lineSelectionHelper","s.dim","s"],"mappings":";;;;;;;;;;;;;AA4BM,MAAO,IAAY,SAAQ,eAAkD,CAAA;AAajF,IAAA,WAAA,CAAa,MAAmC,EAAA;AAC9C,QAAA,KAAK,EAAE,CAAA;QAZC,IAAc,CAAA,cAAA,GAAG,iBAA+C,CAAA;AACnE,QAAA,IAAA,CAAA,MAAM,GAA+B,IAAI,CAAC,cAAc,CAAA;AAE/D,QAAA,IAAA,CAAA,KAAK,GAAyB,KAAK,CAAC,SAAS,CAAC,SAAS,CAAC,CAAA;AACxD,QAAA,IAAA,CAAA,MAAM,GAAG;AACP,YAAA,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,GAAG;gBACrB,SAAS,EAAE,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC;gBACrC,UAAU,EAAE,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC;AAC5C,aAAA;SACF,CAAA;AAIC,QAAA,IAAI,MAAM;AAAE,YAAA,IAAI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C;AACpC,aAAA,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC;AACnB,aAAA,MAAM,EAAE,CAAA;KACZ;IAEO,UAAU,GAAA;QAChB,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAA;QAClC,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAA;QAClC,OAAO,CAAA,CAAA,EAAI,MAAM,CAAC,CAAC,CAAC,CAAI,CAAA,EAAA,MAAM,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC,CAAC,CAAC,CAAA,CAAA,EAAI,MAAM,CAAC,CAAC,CAAC,CAAA,CAAE,CAAA;KAC/D;AAEO,IAAA,UAAU,CAAE,KAAK,EAAE,CAAC,EAAE,GAAG,EAAA;AAC/B,QAAA,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAA;QAEvB,IAAI,MAAM,CAAC,gBAAgB,EAAE;AAC3B,YAAA,IAAI,CAAC,CAAC;AACH,iBAAA,SAAS,CAAC,CAAI,CAAA,EAAAJ,MAAM,EAAE,CAAC;AACvB,iBAAA,OAAO,CAACK,GAAK,EAAE,CAAC,IAAI,CAAC,KAAK,KAAK,CAAC,CAAA;AACpC,SAAA;KACF;AAEO,IAAA,eAAe,CAAE,CAAC,EAAE,CAAC,EAAE,GAAG,EAAA;AAChC,QAAA,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAA;QAEvB,IAAI,MAAM,CAAC,gBAAgB,EAAE;AAC3B,YAAA,IAAI,CAAC,CAAC;AACH,iBAAA,SAAS,CAAC,CAAI,CAAA,EAAAL,MAAM,EAAE,CAAC;AACvB,iBAAA,OAAO,CAACK,GAAK,EAAE,KAAK,CAAC,CAAA;AACzB,SAAA;KACF;;AA7JM,IAAS,CAAA,SAAA,GAAGC,KAAC;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../src/components/line/index.ts"],"sourcesContent":["import { select } from 'd3-selection'\nimport { Transition } from 'd3-transition'\nimport { CurveFactoryLineOnly, Line as LineGenInterface, line } from 'd3-shape'\nimport { interpolatePath } from 'd3-interpolate-path'\n\n// Core\nimport { XYComponentCore } from 'core/xy-component'\n\n// Utils\nimport { getNumber, getString, getValue, isArray, isNumber } from 'utils/data'\nimport { smartTransition } from 'utils/d3'\nimport { getColor } from 'utils/color'\n\n// Types\nimport { NumericAccessor } from 'types/accessor'\nimport { Spacing } from 'types/spacing'\nimport { Curve, CurveType } from 'types/curve'\nimport { Direction } from 'types/direction'\n\n// Local Types\nimport { LineData, LineDatum } from './types'\n\n// Config\nimport { LineConfig, LineConfigInterface } from './config'\n\n// Styles\nimport * as s from './style'\n\nexport class Line<Datum> extends XYComponentCore<Datum, LineConfig<Datum>, LineConfigInterface<Datum>> {\n static selectors = s\n config: LineConfig<Datum> = new LineConfig()\n lineGen: LineGenInterface<{ x: number; y: number; defined: boolean }>\n curve: CurveFactoryLineOnly = Curve[CurveType.MonotoneX]\n events = {\n [Line.selectors.line]: {\n mouseover: this._highlight.bind(this),\n mouseleave: this._resetHighlight.bind(this),\n },\n }\n\n constructor (config?: LineConfigInterface<Datum>) {\n super()\n if (config) this.config.init(config)\n }\n\n get bleed (): Spacing {\n const { config: { lineWidth } } = this\n const yDomain = this.yScale.domain() as [number, number]\n const yDirection = this.yScale.range()[0] > this.yScale.range()[1]\n ? Direction.North\n : Direction.South\n const isYDirectionSouth = yDirection === Direction.South\n\n const isLineThick = lineWidth > 3\n const isLineVeryThick = lineWidth >= 10\n return {\n top: !isLineVeryThick && (\n (!isYDirectionSouth && (yDomain[1] === 0)) || (isYDirectionSouth && (yDomain[0] === 0))\n ) ? 0 : lineWidth / 2,\n bottom: !isLineVeryThick && (\n (!isYDirectionSouth && (yDomain[0] === 0)) || (isYDirectionSouth && (yDomain[1] === 0))\n ) ? 0 : lineWidth / 2,\n left: isLineThick ? lineWidth / 2 : 0,\n right: isLineThick ? lineWidth / 2 : 0,\n }\n }\n\n _render (customDuration?: number): void {\n super._render(customDuration)\n const { config, datamodel: { data } } = this\n const duration = isNumber(customDuration) ? customDuration : config.duration\n\n this.curve = Curve[config.curveType]\n this.lineGen = line<{ x: number; y: number; defined: boolean }>()\n .x(d => d.x)\n .y(d => d.y)\n .defined(d => d.defined)\n .curve(this.curve)\n\n const yAccessors = (isArray(config.y) ? config.y : [config.y]) as NumericAccessor<Datum>[]\n const lineDataX = data.map((d, i) => this.xScale(getNumber(d, config.x, i)))\n const lineData: LineData[] = yAccessors.map(a => {\n const ld: LineDatum[] = data.map((d, i) => {\n const rawValue = getNumber(d, a, i)\n // If `rawValue` is not numerical or if it's not finite (`NaN`, `undefined`, ...), we replace it with `config.fallbackValue`\n const value = (isNumber(rawValue) || (rawValue === null)) && isFinite(rawValue) ? rawValue : config.fallbackValue\n return {\n x: lineDataX[i],\n y: this.yScale(value ?? 0),\n defined: isFinite(value),\n value,\n }\n })\n\n const defined = ld.reduce((def, d) => (d.defined || def), false)\n // If the line consists only of `null` values, we'll still render it but it'll be invisible.\n // Such trick allows us to have better animated transitions.\n const visible = defined && ld.some(d => d.value !== null)\n return {\n values: ld,\n defined,\n visible,\n }\n })\n\n const lines = this.g\n .selectAll<SVGGElement, LineData>(`.${s.line}`)\n .data(lineData)\n\n const linesEnter = lines.enter().append('g')\n .attr('class', s.line)\n\n linesEnter\n .append('path')\n .attr('class', s.linePath)\n .attr('stroke', (d, i) => getColor(data, config.color, i))\n .attr('stroke-opacity', 0)\n .attr('stroke-width', config.lineWidth)\n\n linesEnter\n .append('path')\n .attr('class', s.lineSelectionHelper)\n .attr('d', this._emptyPath())\n\n const linesMerged = linesEnter.merge(lines)\n linesMerged.style('cursor', (d, i) => getString(data, config.cursor, i))\n linesMerged.each((d, i, elements) => {\n const group = select(elements[i])\n const linePath = group.select<SVGPathElement>(`.${s.linePath}`)\n const lineSelectionHelper = group.select(`.${s.lineSelectionHelper}`)\n\n const isLineVisible = d.visible\n const dashArray = getValue<LineData, number[]>(d, config.lineDashArray, i)\n const transition = smartTransition(linePath, duration)\n .attr('stroke', getColor(data, config.color, i))\n .attr('stroke-width', config.lineWidth)\n .attr('stroke-opacity', isLineVisible ? 1 : 0)\n .style('stroke-dasharray', dashArray?.join(' ') ?? null) // We use `.style` because there's also a default CSS-variable for stroke-dasharray\n\n const hasUndefinedSegments = d.values.some(d => !d.defined)\n const svgPathD = this.lineGen(d.values)\n\n if (duration && !hasUndefinedSegments) {\n const previous = linePath.attr('d') || this._emptyPath()\n const next = svgPathD || this._emptyPath()\n const t = transition as Transition<SVGPathElement, LineData, SVGGElement, LineData>\n t.attrTween('d', () => interpolatePath(previous, next))\n } else if (d.visible) {\n transition.attr('d', svgPathD)\n }\n\n lineSelectionHelper\n .attr('d', svgPathD)\n .attr('visibility', isLineVisible ? null : 'hidden')\n })\n\n smartTransition(lines.exit(), duration)\n .style('opacity', 0)\n .remove()\n }\n\n private _emptyPath (): string {\n const xRange = this.xScale.range()\n const yRange = this.yScale.range()\n return `M${xRange[0]},${yRange[0]} L${xRange[1]},${yRange[0]}`\n }\n\n private _highlight (datum, i, els): void {\n const { config } = this\n\n if (config.highlightOnHover) {\n this.g\n .selectAll(`.${s.line}`)\n .classed(s.dim, d => d !== datum)\n }\n }\n\n private _resetHighlight (d, i, els): void {\n const { config } = this\n\n if (config.highlightOnHover) {\n this.g\n .selectAll(`.${s.line}`)\n .classed(s.dim, false)\n }\n }\n}\n"],"names":["s.line","s.linePath","s.lineSelectionHelper","linePath","lineSelectionHelper","s.dim","s"],"mappings":";;;;;;;;;;;;;AA4BM,MAAO,IAAY,SAAQ,eAAqE,CAAA;AAYpG,IAAA,WAAA,CAAa,MAAmC,EAAA;AAC9C,QAAA,KAAK,EAAE,CAAA;AAXT,QAAA,IAAA,CAAA,MAAM,GAAsB,IAAI,UAAU,EAAE,CAAA;AAE5C,QAAA,IAAA,CAAA,KAAK,GAAyB,KAAK,CAAC,SAAS,CAAC,SAAS,CAAC,CAAA;AACxD,QAAA,IAAA,CAAA,MAAM,GAAG;AACP,YA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AAS,CAAC,CAAI,CAAA,EAAAL,MAAM,EAAE,CAAC;AACvB,iBAAA,OAAO,CAACK,GAAK,EAAE,KAAK,CAAC,CAAA;AACzB,SAAA;KACF;;AA5JM,IAAS,CAAA,SAAA,GAAGC,KAAC;;;;"}
@@ -1,4 +1,4 @@
1
- import { ComponentConfigInterface } from "../../core/component/config";
1
+ import { ComponentConfigInterface, ComponentConfig } from "../../core/component/config";
2
2
  import { ColorAccessor, GenericAccessor, NumericAccessor, StringAccessor } from "../../types/accessor";
3
3
  import { NestedDonutDirection, NestedDonutLayerSettings, NestedDonutSegment } from './types';
4
4
  export interface NestedDonutConfigInterface<Datum> extends ComponentConfigInterface {
@@ -46,4 +46,23 @@ export interface NestedDonutConfigInterface<Datum> extends ComponentConfigInterf
46
46
  */
47
47
  showEmptySegments?: boolean;
48
48
  }
49
- export declare const NestedDonutDefaultConfig: NestedDonutConfigInterface<unknown>;
49
+ export declare class NestedDonutConfig<Datum> extends ComponentConfig implements NestedDonutConfigInterface<Datum> {
50
+ angleRange: [number, number];
51
+ centralLabel: any;
52
+ centralSubLabel: any;
53
+ centralSubLabelWrap: boolean;
54
+ cornerRadius: number;
55
+ direction: NestedDonutDirection;
56
+ emptySegmentAngle: number;
57
+ hideOverflowingSegmentLabels: boolean;
58
+ layers: StringAccessor<Datum>[];
59
+ layerPadding: number;
60
+ layerSettings: any;
61
+ segmentColor: any;
62
+ segmentLabel: any;
63
+ segmentLabelColor: any;
64
+ showBackground: boolean;
65
+ showEmptySegments: boolean;
66
+ sort: any;
67
+ value: any;
68
+ }
@@ -1,8 +1,29 @@
1
- import { ComponentDefaultConfig } from '../../core/component/config.js';
1
+ import { ComponentConfig } from '../../core/component/config.js';
2
2
  import { NestedDonutDirection } from './types.js';
3
3
 
4
4
  // Core
5
- const NestedDonutDefaultConfig = Object.assign(Object.assign({}, ComponentDefaultConfig), { angleRange: [0, 2 * Math.PI], centralLabel: undefined, centralSubLabel: undefined, centralSubLabelWrap: true, cornerRadius: 0, direction: NestedDonutDirection.Inwards, emptySegmentAngle: Math.PI / 180, hideOverflowingSegmentLabels: true, layers: [], layerPadding: 0, layerSettings: undefined, segmentColor: undefined, segmentLabel: undefined, segmentLabelColor: undefined, showBackground: false, showEmptySegments: false, sort: undefined, value: undefined });
5
+ class NestedDonutConfig extends ComponentConfig {
6
+ constructor() {
7
+ super(...arguments);
8
+ this.angleRange = [0, 2 * Math.PI];
9
+ this.centralLabel = undefined;
10
+ this.centralSubLabel = undefined;
11
+ this.centralSubLabelWrap = true;
12
+ this.cornerRadius = 0;
13
+ this.direction = NestedDonutDirection.Inwards;
14
+ this.emptySegmentAngle = Math.PI / 180;
15
+ this.hideOverflowingSegmentLabels = true;
16
+ this.layerPadding = 0;
17
+ this.layerSettings = undefined;
18
+ this.segmentColor = undefined;
19
+ this.segmentLabel = undefined;
20
+ this.segmentLabelColor = undefined;
21
+ this.showBackground = false;
22
+ this.showEmptySegments = false;
23
+ this.sort = undefined;
24
+ this.value = undefined;
25
+ }
26
+ }
6
27
 
7
- export { NestedDonutDefaultConfig };
28
+ export { NestedDonutConfig };
8
29
  //# sourceMappingURL=config.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sources":["../../../src/components/nested-donut/config.ts"],"sourcesContent":["// Core\nimport { ComponentConfigInterface, ComponentDefaultConfig } from 'core/component/config'\n\n// Types\nimport { ColorAccessor, GenericAccessor, NumericAccessor, StringAccessor } from 'types/accessor'\nimport { NestedDonutDirection, NestedDonutLayerSettings, NestedDonutSegment } from './types'\n\nexport interface NestedDonutConfigInterface<Datum> extends ComponentConfigInterface {\n /** Diagram angle range. Default: `[0, 2 * Math.PI]` */\n angleRange?: [number, number];\n /** Direction of hierarchy flow from root to leaf.\n * `NestedDonutDirection.Inwards` starts from the outer most radius and works towards center\n * `NestedDonutDirection.Outwards` starts from the inner most radius the consecutive layers outward.\n * Default: `NestedDonutDirection.Inwards`\n */\n direction?: NestedDonutDirection | string;\n /* Numeric accessor for segment size value. Default: `undefined`. */\n value?: NumericAccessor<Datum>;\n\n /** Central label text. Default: `undefined` */\n centralLabel?: string;\n /** Central sub-label accessor function or text. Default: `undefined` */\n centralSubLabel?: string;\n /** Enables wrapping for the sub-label. Default: `true` */\n centralSubLabelWrap?: boolean;\n /**\n * Show donut background. The color is configurable via\n * the `--vis-nested-donut-background-color` and `--vis-dark-nested-donut-background-color` CSS variables.\n * Default: `false`\n */\n showBackground?: boolean;\n /** Sort function for segments. Default `undefined` */\n sort?: (a: NestedDonutSegment<Datum>, b: NestedDonutSegment<Datum>) => number;\n\n // Layers\n /** Array of accessor functions to defined the nested groups */\n layers: StringAccessor<Datum>[];\n /* Layer settings */\n layerSettings?: GenericAccessor<NestedDonutLayerSettings, number>;\n /* Space between layers */\n layerPadding?: number;\n\n // Segments\n /** Corner Radius. Default: `0` */\n cornerRadius?: number;\n /** Angular size for empty segments in radians. Default: `Math.PI / 180` */\n emptySegmentAngle?: number;\n /** Hide segment labels when they don't fit. Default: `true` */\n hideOverflowingSegmentLabels?: boolean;\n /** Color accessor function for segments. Default: `undefined` */\n segmentColor?: ColorAccessor<NestedDonutSegment<Datum>>;\n /** Segment label accessor function. Default `undefined` */\n segmentLabel?: StringAccessor<NestedDonutSegment<Datum>>;\n /** Color accessor function for segment labels */\n segmentLabelColor?: ColorAccessor<NestedDonutSegment<Datum>>;\n /** When true, the component will display empty segments (the ones that have `0` values) as tiny slices.\n * Default: `false`\n */\n showEmptySegments?: boolean;\n}\n\nexport const NestedDonutDefaultConfig: NestedDonutConfigInterface<unknown> = {\n ...ComponentDefaultConfig,\n angleRange: [0, 2 * Math.PI],\n centralLabel: undefined,\n centralSubLabel: undefined,\n centralSubLabelWrap: true,\n cornerRadius: 0,\n direction: NestedDonutDirection.Inwards,\n emptySegmentAngle: Math.PI / 180,\n hideOverflowingSegmentLabels: true,\n layers: [],\n layerPadding: 0,\n layerSettings: undefined,\n segmentColor: undefined,\n segmentLabel: undefined,\n segmentLabelColor: undefined,\n showBackground: false,\n showEmptySegments: false,\n sort: undefined,\n value: undefined,\n}\n"],"names":[],"mappings":";;;AAAA;MA6Da,wBAAwB,GAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EAChC,sBAAsB,CACzB,EAAA,EAAA,UAAU,EAAE,CAAC,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC,EAC5B,YAAY,EAAE,SAAS,EACvB,eAAe,EAAE,SAAS,EAC1B,mBAAmB,EAAE,IAAI,EACzB,YAAY,EAAE,CAAC,EACf,SAAS,EAAE,oBAAoB,CAAC,OAAO,EACvC,iBAAiB,EAAE,IAAI,CAAC,EAAE,GAAG,GAAG,EAChC,4BAA4B,EAAE,IAAI,EAClC,MAAM,EAAE,EAAE,EACV,YAAY,EAAE,CAAC,EACf,aAAa,EAAE,SAAS,EACxB,YAAY,EAAE,SAAS,EACvB,YAAY,EAAE,SAAS,EACvB,iBAAiB,EAAE,SAAS,EAC5B,cAAc,EAAE,KAAK,EACrB,iBAAiB,EAAE,KAAK,EACxB,IAAI,EAAE,SAAS,EACf,KAAK,EAAE,SAAS;;;;"}
1
+ {"version":3,"file":"config.js","sources":["../../../src/components/nested-donut/config.ts"],"sourcesContent":["// Core\nimport { ComponentConfigInterface, ComponentConfig } from 'core/component/config'\n\n// Types\nimport { ColorAccessor, GenericAccessor, NumericAccessor, StringAccessor } from 'types/accessor'\nimport { NestedDonutDirection, NestedDonutLayerSettings, NestedDonutSegment } from './types'\n\nexport interface NestedDonutConfigInterface<Datum> extends ComponentConfigInterface {\n /** Diagram angle range. Default: `[0, 2 * Math.PI]` */\n angleRange?: [number, number];\n /** Direction of hierarchy flow from root to leaf.\n * `NestedDonutDirection.Inwards` starts from the outer most radius and works towards center\n * `NestedDonutDirection.Outwards` starts from the inner most radius the consecutive layers outward.\n * Default: `NestedDonutDirection.Inwards`\n */\n direction?: NestedDonutDirection | string;\n /* Numeric accessor for segment size value. Default: `undefined`. */\n value?: NumericAccessor<Datum>;\n\n /** Central label text. Default: `undefined` */\n centralLabel?: string;\n /** Central sub-label accessor function or text. Default: `undefined` */\n centralSubLabel?: string;\n /** Enables wrapping for the sub-label. Default: `true` */\n centralSubLabelWrap?: boolean;\n /**\n * Show donut background. The color is configurable via\n * the `--vis-nested-donut-background-color` and `--vis-dark-nested-donut-background-color` CSS variables.\n * Default: `false`\n */\n showBackground?: boolean;\n /** Sort function for segments. Default `undefined` */\n sort?: (a: NestedDonutSegment<Datum>, b: NestedDonutSegment<Datum>) => number;\n\n // Layers\n /** Array of accessor functions to defined the nested groups */\n layers: StringAccessor<Datum>[];\n /* Layer settings */\n layerSettings?: GenericAccessor<NestedDonutLayerSettings, number>;\n /* Space between layers */\n layerPadding?: number;\n\n // Segments\n /** Corner Radius. Default: `0` */\n cornerRadius?: number;\n /** Angular size for empty segments in radians. Default: `Math.PI / 180` */\n emptySegmentAngle?: number;\n /** Hide segment labels when they don't fit. Default: `true` */\n hideOverflowingSegmentLabels?: boolean;\n /** Color accessor function for segments. Default: `undefined` */\n segmentColor?: ColorAccessor<NestedDonutSegment<Datum>>;\n /** Segment label accessor function. Default `undefined` */\n segmentLabel?: StringAccessor<NestedDonutSegment<Datum>>;\n /** Color accessor function for segment labels */\n segmentLabelColor?: ColorAccessor<NestedDonutSegment<Datum>>;\n /** When true, the component will display empty segments (the ones that have `0` values) as tiny slices.\n * Default: `false`\n */\n showEmptySegments?: boolean;\n}\n\nexport class NestedDonutConfig<Datum> extends ComponentConfig implements NestedDonutConfigInterface<Datum> {\n angleRange = [0, 2 * Math.PI] as [number, number]\n centralLabel = undefined\n centralSubLabel = undefined\n centralSubLabelWrap = true\n cornerRadius = 0\n direction = NestedDonutDirection.Inwards\n emptySegmentAngle = Math.PI / 180\n hideOverflowingSegmentLabels = true\n layers: StringAccessor<Datum>[]\n layerPadding = 0\n layerSettings = undefined\n segmentColor = undefined\n segmentLabel = undefined\n segmentLabelColor = undefined\n showBackground = false\n showEmptySegments = false\n sort = undefined\n value = undefined\n}\n"],"names":[],"mappings":";;;AAAA;AA6DM,MAAO,iBAAyB,SAAQ,eAAe,CAAA;AAA7D,IAAA,WAAA,GAAA;;QACE,IAAU,CAAA,UAAA,GAAG,CAAC,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,EAAE,CAAqB,CAAA;QACjD,IAAY,CAAA,YAAA,GAAG,SAAS,CAAA;QACxB,IAAe,CAAA,eAAA,GAAG,SAAS,CAAA;QAC3B,IAAmB,CAAA,mBAAA,GAAG,IAAI,CAAA;QAC1B,IAAY,CAAA,YAAA,GAAG,CAAC,CAAA;AAChB,QAAA,IAAA,CAAA,SAAS,GAAG,oBAAoB,CAAC,OAAO,CAAA;AACxC,QAAA,IAAA,CAAA,iBAAiB,GAAG,IAAI,CAAC,EAAE,GAAG,GAAG,CAAA;QACjC,IAA4B,CAAA,4BAAA,GAAG,IAAI,CAAA;QAEnC,IAAY,CAAA,YAAA,GAAG,CAAC,CAAA;QAChB,IAAa,CAAA,aAAA,GAAG,SAAS,CAAA;QACzB,IAAY,CAAA,YAAA,GAAG,SAAS,CAAA;QACxB,IAAY,CAAA,YAAA,GAAG,SAAS,CAAA;QACxB,IAAiB,CAAA,iBAAA,GAAG,SAAS,CAAA;QAC7B,IAAc,CAAA,cAAA,GAAG,KAAK,CAAA;QACtB,IAAiB,CAAA,iBAAA,GAAG,KAAK,CAAA;QACzB,IAAI,CAAA,IAAA,GAAG,SAAS,CAAA;QAChB,IAAK,CAAA,KAAA,GAAG,SAAS,CAAA;KAClB;AAAA;;;;"}
@@ -3,9 +3,9 @@ import { ScaleLinear } from 'd3-scale';
3
3
  import { ComponentCore } from "../../core/component";
4
4
  import { SeriesDataModel } from "../../data-models/series";
5
5
  import { NestedDonutSegment } from './types';
6
- import { NestedDonutConfigInterface } from './config';
6
+ import { NestedDonutConfig, NestedDonutConfigInterface } from './config';
7
7
  import * as s from './style';
8
- export declare class NestedDonut<Datum> extends ComponentCore<Datum[], NestedDonutConfigInterface<Datum>> {
8
+ export declare class NestedDonut<Datum> extends ComponentCore<Datum[], NestedDonutConfig<Datum>, NestedDonutConfigInterface<Datum>> {
9
9
  static selectors: typeof s;
10
10
  static cssVariables: {
11
11
  nestedDonutFontFamily: "--vis-nested-donut-font-family";
@@ -25,8 +25,7 @@ export declare class NestedDonut<Datum> extends ComponentCore<Datum[], NestedDon
25
25
  darkNestedDonutCentralLabelTextColor: "--vis-dark-nested-donut-central-label-text-color";
26
26
  darkNestedDonutCentralSublabelTextColor: "--vis-dark-nested-donut-central-sublabel-text-color";
27
27
  };
28
- protected _defaultConfig: NestedDonutConfigInterface<Datum>;
29
- config: NestedDonutConfigInterface<Datum>;
28
+ config: NestedDonutConfig<Datum>;
30
29
  datamodel: SeriesDataModel<Datum>;
31
30
  arcBackground: Selection<SVGGElement, unknown, SVGGElement, unknown>;
32
31
  arcGroup: Selection<SVGGElement, unknown, SVGGElement, unknown>;
@@ -12,7 +12,7 @@ import { getPixelValue } from '../../utils/misc.js';
12
12
  import { cssvar } from '../../utils/style.js';
13
13
  import { wrapSVGText } from '../../utils/text.js';
14
14
  import { NestedDonutSegmentLabelAlignment, NestedDonutDirection } from './types.js';
15
- import { NestedDonutDefaultConfig } from './config.js';
15
+ import { NestedDonutConfig } from './config.js';
16
16
  import { createArc, updateArc, removeArc } from './modules/arc.js';
17
17
  import { createLabel, updateLabel, removeLabel } from './modules/label.js';
18
18
  import * as style from './style.js';
@@ -21,14 +21,13 @@ import { segmentsGroup, centralLabel, centralSubLabel, background, segment, segm
21
21
  class NestedDonut extends ComponentCore {
22
22
  constructor(config) {
23
23
  super();
24
- this._defaultConfig = NestedDonutDefaultConfig;
25
- this.config = this._defaultConfig;
24
+ this.config = new NestedDonutConfig();
26
25
  this.datamodel = new SeriesDataModel();
27
26
  this.arcGen = arc();
28
27
  this.colorScale = scaleLinear();
29
28
  this.events = {};
30
29
  if (config)
31
- this.setConfig(config);
30
+ this.config.init(config);
32
31
  this.arcBackground = this.g.append('g');
33
32
  this.arcGroup = this.g.append('g')
34
33
  .attr('class', segmentsGroup);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/components/nested-donut/index.ts"],"sourcesContent":["import { Selection } from 'd3-selection'\nimport { arc, pie } from 'd3-shape'\nimport { hierarchy, partition } from 'd3-hierarchy'\nimport { scaleLinear, ScaleLinear } from 'd3-scale'\nimport { group } from 'd3-array'\n\n// Core\nimport { ComponentCore } from 'core/component'\nimport { SeriesDataModel } from 'data-models/series'\n\n// Types\nimport { VerticalAlign } from 'types/text'\n\n// Utils\nimport { getColor } from 'utils/color'\nimport { smartTransition } from 'utils/d3'\nimport { getNumber, getString, getValue, isNumber, isNumberWithinRange, merge } from 'utils/data'\nimport { getPixelValue } from 'utils/misc'\nimport { cssvar } from 'utils/style'\nimport { wrapSVGText } from 'utils/text'\n\n// Local Types\nimport { NestedDonutDirection, NestedDonutSegment, NestedDonutLayer, NestedDonutSegmentLabelAlignment } from './types'\n\n// Config\nimport { NestedDonutDefaultConfig, NestedDonutConfigInterface } from './config'\n\n// Modules\nimport { createArc, updateArc, removeArc } from './modules/arc'\nimport { createLabel, updateLabel, removeLabel } from './modules/label'\n\n// Styles\nimport * as s from './style'\n\nexport class NestedDonut<Datum> extends ComponentCore<\nDatum[],\nNestedDonutConfigInterface<Datum>\n> {\n static selectors = s\n static cssVariables = s.variables\n protected _defaultConfig = NestedDonutDefaultConfig as NestedDonutConfigInterface<Datum>\n public config: NestedDonutConfigInterface<Datum> = this._defaultConfig\n datamodel: SeriesDataModel<Datum> = new SeriesDataModel()\n\n arcBackground: Selection<SVGGElement, unknown, SVGGElement, unknown>\n arcGroup: Selection<SVGGElement, unknown, SVGGElement, unknown>\n centralLabel: Selection<SVGTextElement, unknown, SVGGElement, unknown>\n centralSubLabel: Selection<SVGTextElement, unknown, SVGGElement, unknown>\n\n arcGen = arc<Partial<NestedDonutSegment<Datum>>>()\n colorScale: ScaleLinear<string, string> = scaleLinear()\n\n events = { }\n\n constructor (config?: NestedDonutConfigInterface<Datum>) {\n super()\n if (config) this.setConfig(config)\n this.arcBackground = this.g.append('g')\n this.arcGroup = this.g.append('g')\n .attr('class', s.segmentsGroup)\n this.centralLabel = this.g.append('text')\n .attr('class', s.centralLabel)\n this.centralSubLabel = this.g.append('text')\n .attr('class', s.centralSubLabel)\n }\n\n _render (customDuration?: number): void {\n const { config } = this\n const duration = isNumber(customDuration) ? customDuration : config.duration\n\n const layers = this._getLayerSettings()\n const data = this._getHierarchyData(layers)\n\n this.arcGen\n .startAngle(d => d.x0)\n .endAngle(d => d.x1)\n .innerRadius(d => d.y0)\n .outerRadius(d => d.y1)\n .cornerRadius(config.cornerRadius)\n\n this.arcGroup.attr('transform', `translate(${this._width / 2},${this._height / 2})`)\n this.arcBackground.attr('transform', `translate(${this._width / 2},${this._height / 2})`)\n this.centralLabel.attr('transform', `translate(${this._width / 2},${this._height / 2})`)\n this.centralSubLabel.attr('transform', `translate(${this._width / 2},${this._height / 2})`)\n\n // Layer backgrounds\n const backgrounds = this.arcBackground\n .selectAll<SVGPathElement, NestedDonutLayer>(`.${s.background}`)\n .data(layers, d => d._id)\n\n const backgroundsEnter = backgrounds.enter().append('path')\n .attr('class', s.background)\n .attr('visibility', config.showBackground ? null : 'hidden')\n\n const backgroundsMerged = backgrounds.merge(backgroundsEnter)\n .style('transition', `fill ${duration}ms`)\n .style('fill', d => d.backgroundColor)\n\n smartTransition(backgroundsMerged, duration)\n .attr('d', d => this.arcGen({\n x0: config.angleRange?.[0] ?? 0,\n x1: config.angleRange?.[1] ?? 2 * Math.PI,\n y0: d._innerRadius,\n y1: d._outerRadius,\n }))\n\n smartTransition(backgrounds.exit(), duration)\n .style('opacity', 0)\n .remove()\n\n // Segments\n const segments = this.arcGroup.selectAll<SVGGElement, NestedDonutSegment<Datum>>(`${s.segment}`)\n .data(data, d => d._id)\n\n const segmentsEnter = segments.enter()\n .append('g')\n .attr('class', s.segment)\n\n segments.merge(segmentsEnter)\n smartTransition(segments.exit(), duration)\n .attr('class', s.segmentExit)\n .style('opacity', 0)\n .remove()\n\n // Segment arcs\n const arcs = this.arcGroup\n .selectAll<SVGPathElement, NestedDonutSegment<Datum>>(`.${s.segmentArc}`)\n .data(data, d => d._id)\n\n const arcsEnter = segmentsEnter.append('path')\n .attr('class', s.segmentArc)\n .call(createArc, config)\n\n arcs.merge(arcsEnter)\n .call(updateArc, config, this.arcGen, duration)\n\n arcs.exit<NestedDonutSegment<Datum>>()\n .attr('class', s.segmentExit)\n .call(removeArc, duration)\n\n // Segment labels\n const labels = this.arcGroup\n .selectAll<SVGTextElement, NestedDonutSegment<Datum>>(`.${s.segmentLabel}`)\n .data(data, d => d._id)\n\n const labelsEnter = segmentsEnter.append('text')\n .attr('class', s.segmentLabel)\n .call(createLabel, this.arcGen)\n\n labels.merge(labelsEnter)\n .call(updateLabel, config, this.arcGen, duration)\n\n labels.exit<NestedDonutSegment<Datum>>()\n .call(removeLabel, duration)\n\n // Chart labels\n this.centralLabel\n .attr('dy', config.centralSubLabel ? '-0.55em' : null)\n .text(config.centralLabel ?? null)\n\n this.centralSubLabel\n .attr('dy', config.centralLabel ? '0.55em' : null)\n .text(config.centralSubLabel ?? null)\n\n if (config.centralSubLabelWrap) wrapSVGText(this.centralSubLabel, layers[0]._innerRadius * 1.9, VerticalAlign.Top)\n }\n\n private _getHierarchyData (layers: NestedDonutLayer[]): NestedDonutSegment<Datum>[] {\n const { config, datamodel: { data } } = this\n\n const layerAccessors = config.layers?.map(layerAccessor => (i: number) => getString(data[i], layerAccessor, i))\n const nestedData = group(data.keys(), ...layerAccessors as [(i: number) => string])\n\n const rootNode = config.value !== undefined\n ? hierarchy(nestedData).sum(index => typeof index === 'number' && getNumber(data[index], config.value, index))\n : hierarchy(nestedData).count()\n\n const partitionData = partition().size([config.angleRange[1], 1])(rootNode) as NestedDonutSegment<Datum>\n\n partitionData\n .each(node => {\n node.data = {\n key: node.data[0] as string,\n values: (node.data[1])?.length ? node.data[1].map((index: number) => data[index]) : [],\n root: node.parent?.data.root ?? node.data[0],\n }\n node._id = `root${partitionData.path(node).map(d => d.data.key).join('->')}`\n if (isNumberWithinRange(node.depth - 1, [0, layers.length - 1])) {\n node._layer = layers[node.depth - 1]\n node.y0 = node._layer._innerRadius\n node.y1 = node._layer._outerRadius\n }\n })\n .eachAfter(node => node.children?.forEach(ch => node.data.values.push(...ch.data.values)))\n .eachBefore(node => {\n if (!node.children || node.depth === rootNode.height - 1) return\n\n const positions = pie<NestedDonutSegment<Datum>>()\n .startAngle(node.parent ? node.x0 : config.angleRange?.[0])\n .endAngle(node.parent ? node.x1 : config.angleRange?.[1])\n .value(d => config.showEmptySegments && d.value === 0\n ? config.emptySegmentAngle\n : (d.x1 - d.x0))\n .sort(config.sort)(node.children)\n\n const opacity = scaleLinear()\n .domain([-1, node.children.length])\n .range([node._state?.fillOpacity ?? 1, 0])\n\n node.children.forEach((child, i) => {\n child._index = i\n child.x0 = positions[i].startAngle\n child.x1 = positions[i].endAngle\n\n // Default to parent's fill if segmentColor accessor is not provided\n const color = getColor(child, config.segmentColor, positions[i].index, child.depth !== 1)\n child._state = {\n fill: color ?? node._state.fill,\n fillOpacity: color === null ? opacity(positions[i].index) : null,\n }\n })\n })\n\n const segments = partitionData.descendants().filter(d => d.parent?.value && d.data.key)\n return segments\n }\n\n private _getLayerSettings (): NestedDonutLayer[] {\n const { direction, layers, layerPadding, layerSettings } = this.config\n\n const outerRadius = Math.min(this._width, this._height) / 2\n\n const defaultLayerSettings = {\n backgroundColor: cssvar(s.variables.nestedDonutBackgroundColor),\n labelAlignment: NestedDonutSegmentLabelAlignment.Perpendicular,\n width: outerRadius * 0.75 / layers.length,\n }\n const layerItems = layers.reduceRight((arr, _, i) => {\n const layerId = direction === NestedDonutDirection.Outwards ? i : arr.length\n const layerConfig = merge(defaultLayerSettings, getValue(layerId, layerSettings))\n const radius = arr.length ? arr[0]._innerRadius - layerPadding : outerRadius\n const layerWidth = getPixelValue(layerConfig.width)\n if (layerWidth === null) {\n console.warn(`Unovis | Nested Donut: Could not parse width ${layerConfig.width}. Setting to default.`)\n }\n arr.unshift({\n ...layerConfig,\n _id: layerId,\n _outerRadius: radius,\n _innerRadius: radius - (layerWidth ?? defaultLayerSettings.width),\n })\n return arr\n }, new Array<NestedDonutLayer>())\n\n return direction === NestedDonutDirection.Inwards ? layerItems.reverse() : layerItems\n }\n}\n"],"names":["s.segmentsGroup","s.centralLabel","s.centralSubLabel","s.background","s.segment","s.segmentExit","s.segmentArc","s.segmentLabel","s.variables","s"],"mappings":";;;;;;;;;;;;;;;;;;;;AAkCM,MAAO,WAAmB,SAAQ,aAGvC,CAAA;AAiBC,IAAA,WAAA,CAAa,MAA0C,EAAA;AACrD,QAAA,KAAK,EAAE,CAAA;QAfC,IAAc,CAAA,cAAA,GAAG,wBAA6D,CAAA;AACjF,QAAA,IAAA,CAAA,MAAM,GAAsC,IAAI,CAAC,cAAc,CAAA;AACtE,QAAA,IAAA,CAAA,SAAS,GAA2B,IAAI,eAAe,EAAE,CAAA;QAOzD,IAAM,CAAA,MAAA,GAAG,GAAG,EAAsC,CAAA;QAClD,IAAU,CAAA,UAAA,GAAgC,WAAW,EAAE,CAAA;QAEvD,IAAM,CAAA,MAAA,GAAG,EAAG,CAAA;AAIV,QAAA,IAAI,MAAM;AAAE,YAAA,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAA;QAClC,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;QACvC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;AAC/B,aAAA,IAAI,CAAC,OAAO,EAAEA,aAAe,CAAC,CAAA;QACjC,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC;AACtC,aAAA,IAAI,CAAC,OAAO,EAAEC,YAAc,CAAC,CAAA;QAChC,IAAI,CAAC,eAAe,GAAG,IAAI,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AAC,KAAK,CAAuB,qBAAA,CAAA,CAAC,CAAA;AACvG,aAAA;AACD,YAAA,GAAG,CAAC,OAAO,CACN,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EAAA,WAAW,CACd,EAAA,EAAA,GAAG,EAAE,OAAO,EACZ,YAAY,EAAE,MAAM,EACpB,YAAY,EAAE,MAAM,IAAI,UAAU,KAAA,IAAA,IAAV,UAAU,KAAA,KAAA,CAAA,GAAV,UAAU,GAAI,oBAAoB,CAAC,KAAK,CAAC,IACjE,CAAA;AACF,YAAA,OAAO,GAAG,CAAA;AACZ,SAAC,EAAE,IAAI,KAAK,EAAoB,CAAC,CAAA;AAEjC,QAAA,OAAO,SAAS,KAAK,oBAAoB,CAAC,OAAO,GAAG,UAAU,CAAC,OAAO,EAAE,GAAG,UAAU,CAAA;KACtF;;AAzNM,WAAS,CAAA,SAAA,GAAGC,KAAC,CAAA;AACb,WAAA,CAAA,YAAY,GAAGD,SAAW;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../src/components/nested-donut/index.ts"],"sourcesContent":["import { Selection } from 'd3-selection'\nimport { arc, pie } from 'd3-shape'\nimport { hierarchy, partition } from 'd3-hierarchy'\nimport { scaleLinear, ScaleLinear } from 'd3-scale'\nimport { group } from 'd3-array'\n\n// Core\nimport { ComponentCore } from 'core/component'\nimport { SeriesDataModel } from 'data-models/series'\n\n// Types\nimport { VerticalAlign } from 'types/text'\n\n// Utils\nimport { getColor } from 'utils/color'\nimport { smartTransition } from 'utils/d3'\nimport { getNumber, getString, getValue, isNumber, isNumberWithinRange, merge } from 'utils/data'\nimport { getPixelValue } from 'utils/misc'\nimport { cssvar } from 'utils/style'\nimport { wrapSVGText } from 'utils/text'\n\n// Local Types\nimport { NestedDonutDirection, NestedDonutSegment, NestedDonutLayer, NestedDonutSegmentLabelAlignment } from './types'\n\n// Config\nimport { NestedDonutConfig, NestedDonutConfigInterface } from './config'\n\n// Modules\nimport { createArc, updateArc, removeArc } from './modules/arc'\nimport { createLabel, updateLabel, removeLabel } from './modules/label'\n\n// Styles\nimport * as s from './style'\n\nexport class NestedDonut<Datum> extends ComponentCore<\nDatum[],\nNestedDonutConfig<Datum>,\nNestedDonutConfigInterface<Datum>\n> {\n static selectors = s\n static cssVariables = s.variables\n config: NestedDonutConfig<Datum> = new NestedDonutConfig()\n datamodel: SeriesDataModel<Datum> = new SeriesDataModel()\n\n arcBackground: Selection<SVGGElement, unknown, SVGGElement, unknown>\n arcGroup: Selection<SVGGElement, unknown, SVGGElement, unknown>\n centralLabel: Selection<SVGTextElement, unknown, SVGGElement, unknown>\n centralSubLabel: Selection<SVGTextElement, unknown, SVGGElement, unknown>\n\n arcGen = arc<Partial<NestedDonutSegment<Datum>>>()\n colorScale: ScaleLinear<string, string> = scaleLinear()\n\n events = { }\n\n constructor (config?: NestedDonutConfigInterface<Datum>) {\n super()\n if (config) this.config.init(config)\n this.arcBackground = this.g.append('g')\n this.arcGroup = this.g.append('g')\n .attr('class', s.segmentsGroup)\n this.centralLabel = this.g.append('text')\n .attr('class', s.centralLabel)\n this.centralSubLabel = this.g.append('text')\n .attr('class', s.centralSubLabel)\n }\n\n _render (customDuration?: number): void {\n const { config } = this\n const duration = isNumber(customDuration) ? customDuration : config.duration\n\n const layers = this._getLayerSettings()\n const data = this._getHierarchyData(layers)\n\n this.arcGen\n .startAngle(d => d.x0)\n .endAngle(d => d.x1)\n .innerRadius(d => d.y0)\n .outerRadius(d => d.y1)\n .cornerRadius(config.cornerRadius)\n\n this.arcGroup.attr('transform', `translate(${this._width / 2},${this._height / 2})`)\n this.arcBackground.attr('transform', `translate(${this._width / 2},${this._height / 2})`)\n this.centralLabel.attr('transform', `translate(${this._width / 2},${this._height / 2})`)\n this.centralSubLabel.attr('transform', `translate(${this._width / 2},${this._height / 2})`)\n\n // Layer backgrounds\n const backgrounds = this.arcBackground\n .selectAll<SVGPathElement, NestedDonutLayer>(`.${s.background}`)\n .data(layers, d => d._id)\n\n const backgroundsEnter = backgrounds.enter().append('path')\n .attr('class', s.background)\n .attr('visibility', config.showBackground ? null : 'hidden')\n\n const backgroundsMerged = backgrounds.merge(backgroundsEnter)\n .style('transition', `fill ${duration}ms`)\n .style('fill', d => d.backgroundColor)\n\n smartTransition(backgroundsMerged, duration)\n .attr('d', d => this.arcGen({\n x0: config.angleRange?.[0] ?? 0,\n x1: config.angleRange?.[1] ?? 2 * Math.PI,\n y0: d._innerRadius,\n y1: d._outerRadius,\n }))\n\n smartTransition(backgrounds.exit(), duration)\n .style('opacity', 0)\n .remove()\n\n // Segments\n const segments = this.arcGroup.selectAll<SVGGElement, NestedDonutSegment<Datum>>(`${s.segment}`)\n .data(data, d => d._id)\n\n const segmentsEnter = segments.enter()\n .append('g')\n .attr('class', s.segment)\n\n segments.merge(segmentsEnter)\n smartTransition(segments.exit(), duration)\n .attr('class', s.segmentExit)\n .style('opacity', 0)\n .remove()\n\n // Segment arcs\n const arcs = this.arcGroup\n .selectAll<SVGPathElement, NestedDonutSegment<Datum>>(`.${s.segmentArc}`)\n .data(data, d => d._id)\n\n const arcsEnter = segmentsEnter.append('path')\n .attr('class', s.segmentArc)\n .call(createArc, config)\n\n arcs.merge(arcsEnter)\n .call(updateArc, config, this.arcGen, duration)\n\n arcs.exit<NestedDonutSegment<Datum>>()\n .attr('class', s.segmentExit)\n .call(removeArc, duration)\n\n // Segment labels\n const labels = this.arcGroup\n .selectAll<SVGTextElement, NestedDonutSegment<Datum>>(`.${s.segmentLabel}`)\n .data(data, d => d._id)\n\n const labelsEnter = segmentsEnter.append('text')\n .attr('class', s.segmentLabel)\n .call(createLabel, this.arcGen)\n\n labels.merge(labelsEnter)\n .call(updateLabel, config, this.arcGen, duration)\n\n labels.exit<NestedDonutSegment<Datum>>()\n .call(removeLabel, duration)\n\n // Chart labels\n this.centralLabel\n .attr('dy', config.centralSubLabel ? '-0.55em' : null)\n .text(config.centralLabel ?? null)\n\n this.centralSubLabel\n .attr('dy', config.centralLabel ? '0.55em' : null)\n .text(config.centralSubLabel ?? null)\n\n if (config.centralSubLabelWrap) wrapSVGText(this.centralSubLabel, layers[0]._innerRadius * 1.9, VerticalAlign.Top)\n }\n\n private _getHierarchyData (layers: NestedDonutLayer[]): NestedDonutSegment<Datum>[] {\n const { config, datamodel: { data } } = this\n\n const layerAccessors = config.layers?.map(layerAccessor => (i: number) => getString(data[i], layerAccessor, i))\n const nestedData = group(data.keys(), ...layerAccessors as [(i: number) => string])\n\n const rootNode = config.value !== undefined\n ? hierarchy(nestedData).sum(index => typeof index === 'number' && getNumber(data[index], config.value, index))\n : hierarchy(nestedData).count()\n\n const partitionData = partition().size([config.angleRange[1], 1])(rootNode) as NestedDonutSegment<Datum>\n\n partitionData\n .each(node => {\n node.data = {\n key: node.data[0] as string,\n values: (node.data[1])?.length ? node.data[1].map((index: number) => data[index]) : [],\n root: node.parent?.data.root ?? node.data[0],\n }\n node._id = `root${partitionData.path(node).map(d => d.data.key).join('->')}`\n if (isNumberWithinRange(node.depth - 1, [0, layers.length - 1])) {\n node._layer = layers[node.depth - 1]\n node.y0 = node._layer._innerRadius\n node.y1 = node._layer._outerRadius\n }\n })\n .eachAfter(node => node.children?.forEach(ch => node.data.values.push(...ch.data.values)))\n .eachBefore(node => {\n if (!node.children || node.depth === rootNode.height - 1) return\n\n const positions = pie<NestedDonutSegment<Datum>>()\n .startAngle(node.parent ? node.x0 : config.angleRange?.[0])\n .endAngle(node.parent ? node.x1 : config.angleRange?.[1])\n .value(d => config.showEmptySegments && d.value === 0\n ? config.emptySegmentAngle\n : (d.x1 - d.x0))\n .sort(config.sort)(node.children)\n\n const opacity = scaleLinear()\n .domain([-1, node.children.length])\n .range([node._state?.fillOpacity ?? 1, 0])\n\n node.children.forEach((child, i) => {\n child._index = i\n child.x0 = positions[i].startAngle\n child.x1 = positions[i].endAngle\n\n // Default to parent's fill if segmentColor accessor is not provided\n const color = getColor(child, config.segmentColor, positions[i].index, child.depth !== 1)\n child._state = {\n fill: color ?? node._state.fill,\n fillOpacity: color === null ? opacity(positions[i].index) : null,\n }\n })\n })\n\n const segments = partitionData.descendants().filter(d => d.parent?.value && d.data.key)\n return segments\n }\n\n private _getLayerSettings (): NestedDonutLayer[] {\n const { direction, layers, layerPadding, layerSettings } = this.config\n\n const outerRadius = Math.min(this._width, this._height) / 2\n\n const defaultLayerSettings = {\n backgroundColor: cssvar(s.variables.nestedDonutBackgroundColor),\n labelAlignment: NestedDonutSegmentLabelAlignment.Perpendicular,\n width: outerRadius * 0.75 / layers.length,\n }\n const layerItems = layers.reduceRight((arr, _, i) => {\n const layerId = direction === NestedDonutDirection.Outwards ? i : arr.length\n const layerConfig = merge(defaultLayerSettings, getValue(layerId, layerSettings))\n const radius = arr.length ? arr[0]._innerRadius - layerPadding : outerRadius\n const layerWidth = getPixelValue(layerConfig.width)\n if (layerWidth === null) {\n console.warn(`Unovis | Nested Donut: Could not parse width ${layerConfig.width}. Setting to default.`)\n }\n arr.unshift({\n ...layerConfig,\n _id: layerId,\n _outerRadius: radius,\n _innerRadius: radius - (layerWidth ?? defaultLayerSettings.width),\n })\n return arr\n }, new Array<NestedDonutLayer>())\n\n return direction === NestedDonutDirection.Inwards ? layerItems.reverse() : layerItems\n }\n}\n"],"names":["s.segmentsGroup","s.centralLabel","s.centralSubLabel","s.background","s.segment","s.segmentExit","s.segmentArc","s.segmentLabel","s.variables","s"],"mappings":";;;;;;;;;;;;;;;;;;;;AAkCM,MAAO,WAAmB,SAAQ,aAIvC,CAAA;AAgBC,IAAA,WAAA,CAAa,MAA0C,EAAA;AACrD,QAAA,KAAK,EAAE,CAAA;AAdT,QAAA,IAAA,CAAA,MAAM,GAA6B,IAAI,iBAAiB,EAAE,CAAA;AAC1D,QAAA,IAAA,CAAA,SAAS,GAA2B,IAAI,eAAe,EAAE,CAAA;QAOzD,IAAM,CAAA,MAAA,GAAG,GAAG,EAAsC,CAAA;QAClD,IAAU,CAAA,UAAA,GAAgC,WAAW,EAAE,CAAA;QAEvD,IAAM,CAAA,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edDonutConfigInterface } from '../config';
4
+ import { NestedDonutConfig } from '../config';
5
5
  declare type AnimState = {
6
6
  x0: number;
7
7
  x1: number;
@@ -11,7 +11,7 @@ declare type AnimState = {
11
11
  export interface ArcNode extends SVGElement {
12
12
  _animState?: AnimState;
13
13
  }
14
- export declare function createArc<Datum>(selection: Selection<SVGPathElement, NestedDonutSegment<Datum>, SVGGElement, unknown>, config: NestedDonutConfigInterface<Datum>): void;
15
- export declare function updateArc<Datum>(selection: Selection<SVGPathElement, NestedDonutSegment<Datum>, SVGGElement, unknown>, config: NestedDonutConfigInterface<Datum>, arcGen: Arc<any, AnimState>, duration: number): void;
14
+ export declare function createArc<Datum>(selection: Selection<SVGPathElement, NestedDonutSegment<Datum>, SVGGElement, unknown>, config: NestedDonutConfig<Datum>): void;
15
+ export declare function updateArc<Datum>(selection: Selection<SVGPathElement, NestedDonutSegment<Datum>, SVGGElement, unknown>, config: NestedDonutConfig<Datum>, arcGen: Arc<any, AnimState>, duration: number): void;
16
16
  export declare function removeArc<Datum>(selection: Selection<SVGPathElement, NestedDonutSegment<Datum>, SVGGElement, unknown>, duration: number): void;
17
17
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"arc.js","sources":["../../../../src/components/nested-donut/modules/arc.ts"],"sourcesContent":["import { Selection } from 'd3-selection'\nimport { Transition } from 'd3-transition'\nimport { interpolate } from 'd3-interpolate'\nimport { Arc } from 'd3-shape'\n\n// Utils\nimport { getColor } from 'utils/color'\nimport { smartTransition } from 'utils/d3'\n\n// Local Types\nimport { NestedDonutSegment } from '../types'\n\n// Config\nimport { NestedDonutConfigInterface } from '../config'\n\ntype AnimState = { x0: number; x1: number; y0: number; y1: number }\nexport interface ArcNode extends SVGElement {\n _animState?: AnimState;\n}\n\nexport function createArc<Datum> (\n selection: Selection<SVGPathElement, NestedDonutSegment<Datum>, SVGGElement, unknown>,\n config: NestedDonutConfigInterface<Datum>\n): void {\n selection\n .style('fill', d => getColor(d, config.segmentColor) ?? d._state?.fill)\n .style('opacity', 0)\n .each((d, i, els) => {\n const arcNode: ArcNode = els[i]\n const angleCenter = (d.x0 + d.x1) / 2\n const angleHalfWidth = (d.x1 - d.x0) / 2\n arcNode._animState = {\n x0: angleCenter - angleHalfWidth,\n x1: angleCenter + angleHalfWidth,\n y0: d.y0,\n y1: d.y1,\n }\n })\n}\n\nexport function updateArc<Datum> (\n selection: Selection<SVGPathElement, NestedDonutSegment<Datum>, SVGGElement, unknown>,\n config: NestedDonutConfigInterface<Datum>,\n arcGen: Arc<any, AnimState>,\n duration: number\n): void {\n selection\n .style('transition', `fill ${duration}ms`) // Animate color with CSS because we're using CSS-variables\n .style('fill', d => d._state.fill)\n .style('fill-opacity', d => d._state.fillOpacity)\n\n if (duration) {\n const transition = smartTransition(selection, duration)\n .style('opacity', 1) as Transition<SVGPathElement, NestedDonutSegment<Datum>, SVGGElement, ArcNode>\n\n transition.attrTween('d', (d, i, els) => {\n const arcNode: ArcNode = els[i]\n const nextAnimState = { x0: d.x0, x1: d.x1, y0: d.y0, y1: d.y1 }\n const datum = interpolate(arcNode._animState, nextAnimState)\n return (t: number): string => {\n arcNode._animState = datum(t)\n return arcGen(arcNode._animState)\n }\n })\n } else {\n selection.attr('d', arcGen)\n .style('opacity', 1)\n }\n}\n\nexport function removeArc<Datum> (\n selection: Selection<SVGPathElement, NestedDonutSegment<Datum>, SVGGElement, unknown>,\n duration: number\n): void {\n smartTransition(selection, duration)\n .style('opacity', 0)\n .remove()\n}\n"],"names":[],"mappings":";;;;AAoBgB,SAAA,SAAS,CACvB,SAAqF,EACrF,MAAyC,EAAA;IAEzC,SAAS;SACN,KAAK,CAAC,MAAM,EAAE,CAAC,IAAG,EAAA,IAAA,EAAA,EAAA,EAAA,CAAA,CAAC,OAAA,CAAA,EAAA,GAAA,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC,YAAY,CAAC,MAAA,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,EAAA,GAAI,CAAA,EAAA,GAA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,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,KAAI;AACtC,YAAA,MAAM,OAAO,GAAY,GAAG,CAAC,CAAC,CAAC,CAAA;YAC/B,MAAM,aAAa,GAAG,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,CAAA;YAChE,MAAM,KAAK,GAAG,WAAW,CAAC,OAAO,CAAC,UAAU,EAAE,aAAa,CAAC,CAAA;YAC5D,OAAO,CAAC,CAAS,KAAY;AAC3B,gBAAA,OAAO,CAAC,UAAU,GAAG,KAAK,CAAC,CAAC,CAAC,CAAA;AAC7B,gBAAA,OAAO,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,CAAA;AACnC,aAAC,CAAA;AACH,SAAC,CAAC,CAAA;AACH,KAAA;AAAM,SAAA;AACL,QAAA,SAAS,CAAC,IAAI,CAAC,GAAG,EAAE,MAAM,CAAC;AACxB,aAAA,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC,CAAA;AACvB,KAAA;AACH,CAAC;AAEe,SAAA,SAAS,CACvB,SAAqF,EACrF,QAAgB,EAAA;AAEhB,IAAA,eAAe,CAAC,SAAS,EAAE,QAAQ,CAAC;AACjC,SAAA,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC;AACnB,SAAA,MAAM,EAAE,CAAA;AACb;;;;"}
1
+ {"version":3,"file":"arc.js","sources":["../../../../src/components/nested-donut/modules/arc.ts"],"sourcesContent":["import { Selection } from 'd3-selection'\nimport { Transition } from 'd3-transition'\nimport { interpolate } from 'd3-interpolate'\nimport { Arc } from 'd3-shape'\n\n// Utils\nimport { getColor } from 'utils/color'\nimport { smartTransition } from 'utils/d3'\n\n// Local Types\nimport { NestedDonutSegment } from '../types'\n\n// Config\nimport { NestedDonutConfig } from '../config'\n\ntype AnimState = { x0: number; x1: number; y0: number; y1: number }\nexport interface ArcNode extends SVGElement {\n _animState?: AnimState;\n}\n\nexport function createArc<Datum> (\n selection: Selection<SVGPathElement, NestedDonutSegment<Datum>, SVGGElement, unknown>,\n config: NestedDonutConfig<Datum>\n): void {\n selection\n .style('fill', d => getColor(d, config.segmentColor) ?? d._state?.fill)\n .style('opacity', 0)\n .each((d, i, els) => {\n const arcNode: ArcNode = els[i]\n const angleCenter = (d.x0 + d.x1) / 2\n const angleHalfWidth = (d.x1 - d.x0) / 2\n arcNode._animState = {\n x0: angleCenter - angleHalfWidth,\n x1: angleCenter + angleHalfWidth,\n y0: d.y0,\n y1: d.y1,\n }\n })\n}\n\nexport function updateArc<Datum> (\n selection: Selection<SVGPathElement, NestedDonutSegment<Datum>, SVGGElement, unknown>,\n config: NestedDonutConfig<Datum>,\n arcGen: Arc<any, AnimState>,\n duration: number\n): void {\n selection\n .style('transition', `fill ${duration}ms`) // Animate color with CSS because we're using CSS-variables\n .style('fill', d => d._state.fill)\n .style('fill-opacity', d => d._state.fillOpacity)\n\n if (duration) {\n const transition = smartTransition(selection, duration)\n .style('opacity', 1) as Transition<SVGPathElement, NestedDonutSegment<Datum>, SVGGElement, ArcNode>\n\n transition.attrTween('d', (d, i, els) => {\n const arcNode: ArcNode = els[i]\n const nextAnimState = { x0: d.x0, x1: d.x1, y0: d.y0, y1: d.y1 }\n const datum = interpolate(arcNode._animState, nextAnimState)\n return (t: number): string => {\n arcNode._animState = datum(t)\n return arcGen(arcNode._animState)\n }\n })\n } else {\n selection.attr('d', arcGen)\n .style('opacity', 1)\n }\n}\n\nexport function removeArc<Datum> (\n selection: Selection<SVGPathElement, NestedDonutSegment<Datum>, SVGGElement, unknown>,\n duration: number\n): void {\n smartTransition(selection, duration)\n .style('opacity', 0)\n .remove()\n}\n"],"names":[],"mappings":";;;;AAoBgB,SAAA,SAAS,CACvB,SAAqF,EACrF,MAAgC,EAAA;IAEhC,SAAS;SACN,KAAK,CAAC,MAAM,EAAE,CAA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
3
+ import { NestedDonutConfig } from '../config';
4
4
  import { NestedDonutSegment } from '../types';
5
5
  export declare function createLabel<Datum>(selection: Selection<SVGTextElement, NestedDonutSegment<Datum>, SVGGElement, unknown>, arcGen: Arc<unknown, NestedDonutSegment<Datum>>): void;
6
- export declare function updateLabel<Datum>(selection: Selection<SVGTextElement, NestedDonutSegment<Datum>, SVGGElement, unknown>, config: NestedDonutConfigInterface<Datum>, arcGen: Arc<unknown, NestedDonutSegment<Datum>>, duration: number): void;
6
+ export declare function updateLabel<Datum>(selection: Selection<SVGTextElement, NestedDonutSegment<Datum>, SVGGElement, unknown>, config: NestedDonutConfig<Datum>, arcGen: Arc<unknown, NestedDonutSegment<Datum>>, duration: number): void;
7
7
  export declare function removeLabel<Datum>(selection: Selection<SVGTextElement, NestedDonutSegment<Datum>, SVGGElement, unknown>, duration: number): void;
@@ -1 +1 @@
1
- {"version":3,"file":"label.js","sources":["../../../../src/components/nested-donut/modules/label.ts"],"sourcesContent":["import { Selection, select } from 'd3-selection'\nimport { color } from 'd3-color'\nimport { Arc } from 'd3-shape'\n\n// Utils\nimport { getColor, getHexValue, rgbaToRgb, rgbToBrightness } from 'utils/color'\nimport { smartTransition } from 'utils/d3'\nimport { getString } from 'utils/data'\nimport { getCSSVariableValueInPixels } from 'utils/misc'\nimport { cssvar } from 'utils/style'\nimport { wrapSVGText } from 'utils/text'\n\n// Config\nimport { NestedDonutConfigInterface } from '../config'\n\n// Local Types\nimport { NestedDonutSegment, NestedDonutSegmentLabelAlignment } from '../types'\n\n// Styles\nimport { variables } from '../style'\n\nfunction getLabelFillColor<Datum> (\n d: NestedDonutSegment<Datum>,\n element: SVGElement\n): string {\n const c = color(d._state.fill) ?? color(getHexValue(d._state.fill, element))\n const rgb = c?.rgb()\n\n // If shading, we adjust segment color before calculating brightness ratio\n const colorParsed = rgb && d._state.fillOpacity\n ? rgbaToRgb(\n `rgba(${rgb.r},${rgb.g},${rgb.b},${d._state.fillOpacity})`,\n getHexValue(cssvar(variables.nestedDonutBackgroundColor), element)\n ) : rgb\n\n const brightness = colorParsed ? rgbToBrightness(colorParsed) : 0\n return cssvar(brightness > 0.65 ? variables.nestedDonutSegmentLabelTextColorLight : variables.nestedDonutSegmentLabelTextColorDark)\n}\n\nfunction getLabelTransform<Datum> (\n d: NestedDonutSegment<Datum>,\n arcGen: Arc<unknown, NestedDonutSegment<Datum>>\n): string {\n const translate = `translate(${arcGen.centroid(d)})`\n const degree = 180 / Math.PI * (arcGen.startAngle()(d) + arcGen.endAngle()(d)) / 2 - 90\n switch (d._layer.labelAlignment) {\n case NestedDonutSegmentLabelAlignment.Along:\n return `${translate} rotate(${degree + 90})`\n case NestedDonutSegmentLabelAlignment.Perpendicular:\n return `${translate} rotate(${degree > 90 ? degree - 180 : degree})`\n default:\n return `${translate}`\n }\n}\n\nfunction getLabelBounds<Datum> (\n d: NestedDonutSegment<Datum>\n): { width: number; height: number } {\n const arcWidth = d.y1 - d.y0\n const arcLength = d._layer._innerRadius * (d.x1 - d.x0)\n const bandwidth = Math.max(Math.abs(Math.cos(d.x0 + (d.x1 - d.x0) / 2 - Math.PI / 2) * arcWidth), arcWidth)\n switch (d._layer.labelAlignment) {\n case NestedDonutSegmentLabelAlignment.Perpendicular:\n return { width: arcWidth, height: arcLength }\n case NestedDonutSegmentLabelAlignment.Along:\n return { width: arcLength, height: arcWidth }\n case NestedDonutSegmentLabelAlignment.Straight:\n return { width: bandwidth, height: bandwidth }\n }\n}\n\nexport function createLabel<Datum> (\n selection: Selection<SVGTextElement, NestedDonutSegment<Datum>, SVGGElement, unknown>,\n arcGen: Arc<unknown, NestedDonutSegment<Datum>>\n): void {\n selection\n .attr('transform', d => getLabelTransform(d, arcGen))\n .style('visibility', null)\n .style('opacity', 0)\n}\n\n\nexport function updateLabel<Datum> (\n selection: Selection<SVGTextElement, NestedDonutSegment<Datum>, SVGGElement, unknown>,\n config: NestedDonutConfigInterface<Datum>,\n arcGen: Arc<unknown, NestedDonutSegment<Datum>>,\n duration: number\n): void {\n selection\n .text(d => getString(d, config.segmentLabel) ?? d.data.key)\n .style('transition', `fill ${duration}ms`)\n .style('fill', (d, i, els) => getColor(d, config.segmentLabelColor) ?? getLabelFillColor(d, els[i]))\n .each((d, i, els) => {\n const bounds = getLabelBounds(d)\n const label = select(els[i]).call(wrapSVGText, bounds.width)\n\n const { width, height } = label.node().getBBox()\n\n if (config.hideOverflowingSegmentLabels && (width > bounds.width || height > bounds.height) && 'hidden') {\n label.attr('visibility', 'hidden')\n } else {\n const fontSize = getCSSVariableValueInPixels(cssvar(variables.nestedDonutSegmentLabelFontSize), els[i])\n const len = label.selectChildren().size() - 1\n label.attr('dy', -fontSize / 2 * len)\n }\n })\n\n smartTransition(selection, duration)\n .attr('transform', d => getLabelTransform(d, arcGen))\n .style('opacity', 1)\n}\n\nexport function removeLabel<Datum> (\n selection: Selection<SVGTextElement, NestedDonutSegment<Datum>, SVGGElement, unknown>,\n duration: number\n): void {\n smartTransition(selection, duration)\n .style('opacity', 0)\n .remove()\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAqBA,SAAS,iBAAiB,CACxB,CAA4B,EAC5B,OAAmB,EAAA;;IAEnB,MAAM,CAAC,GAAG,CAAA,EAAA,GAAA,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,MAAA,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,EAAA,GAAI,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAA;IAC5E,MAAM,GAAG,GAAG,CAAC,KAAD,IAAA,IAAA,CAAC,uBAAD,CAAC,CAAE,GAAG,EAAE,CAAA;;IAGpB,MAAM,WAAW,GAAG,GAAG,IAAI,CAAC,CAAC,MAAM,CAAC,WAAW;AAC7C,UAAE,SAAS,CACT,CAAQ,KAAA,EAAA,GAAG,CAAC,CAAC,CAAA,CAAA,EAAI,GAAG,CAAC,CAAC,CAAI,CAAA,EAAA,G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;YACvG,MAAM,GAAG,GAAG,KAAK,CAAC,cAAc,EAAE,CAAC,IAAI,EAAE,GAAG,CAAC,CAAA;AAC7C,YAAA,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,QAAQ,GAAG,CAAC,GAAG,GAAG,CAAC,CAAA;AACtC,SAAA;AACH,KAAC,CAAC,CAAA;AAEJ,IAAA,eAAe,CAAC,SAAS,EAAE,QAAQ,CAAC;AACjC,SAAA,IAAI,CAAC,WAAW,EAAE,CAAC,IAAI,iBAAiB,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;AACpD,SAAA,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC,CAAA;AACxB,CAAC;AAEe,SAAA,WAAW,CACzB,SAAqF,EACrF,QAAgB,EAAA;AAEhB,IAAA,eAAe,CAAC,SAAS,EAAE,QAAQ,CAAC;AACjC,SAAA,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC;AACnB,SAAA,MAAM,EAAE,CAAA;AACb;;;;"}
1
+ {"version":3,"file":"label.js","sources":["../../../../src/components/nested-donut/modules/label.ts"],"sourcesContent":["import { Selection, select } from 'd3-selection'\nimport { color } from 'd3-color'\nimport { Arc } from 'd3-shape'\n\n// Utils\nimport { getColor, getHexValue, rgbaToRgb, rgbToBrightness } from 'utils/color'\nimport { smartTransition } from 'utils/d3'\nimport { getString } from 'utils/data'\nimport { getCSSVariableValueInPixels } from 'utils/misc'\nimport { cssvar } from 'utils/style'\nimport { wrapSVGText } from 'utils/text'\n\n// Config\nimport { NestedDonutConfig } from '../config'\n\n// Local Types\nimport { NestedDonutSegment, NestedDonutSegmentLabelAlignment } from '../types'\n\n// Styles\nimport { variables } from '../style'\n\nfunction getLabelFillColor<Datum> (\n d: NestedDonutSegment<Datum>,\n element: SVGElement\n): string {\n const c = color(d._state.fill) ?? color(getHexValue(d._state.fill, element))\n const rgb = c?.rgb()\n\n // If shading, we adjust segment color before calculating brightness ratio\n const colorParsed = rgb && d._state.fillOpacity\n ? rgbaToRgb(\n `rgba(${rgb.r},${rgb.g},${rgb.b},${d._state.fillOpacity})`,\n getHexValue(cssvar(variables.nestedDonutBackgroundColor), element)\n ) : rgb\n\n const brightness = colorParsed ? rgbToBrightness(colorParsed) : 0\n return cssvar(brightness > 0.65 ? variables.nestedDonutSegmentLabelTextColorLight : variables.nestedDonutSegmentLabelTextColorDark)\n}\n\nfunction getLabelTransform<Datum> (\n d: NestedDonutSegment<Datum>,\n arcGen: Arc<unknown, NestedDonutSegment<Datum>>\n): string {\n const translate = `translate(${arcGen.centroid(d)})`\n const degree = 180 / Math.PI * (arcGen.startAngle()(d) + arcGen.endAngle()(d)) / 2 - 90\n switch (d._layer.labelAlignment) {\n case NestedDonutSegmentLabelAlignment.Along:\n return `${translate} rotate(${degree + 90})`\n case NestedDonutSegmentLabelAlignment.Perpendicular:\n return `${translate} rotate(${degree > 90 ? degree - 180 : degree})`\n default:\n return `${translate}`\n }\n}\n\nfunction getLabelBounds<Datum> (\n d: NestedDonutSegment<Datum>\n): { width: number; height: number } {\n const arcWidth = d.y1 - d.y0\n const arcLength = d._layer._innerRadius * (d.x1 - d.x0)\n const bandwidth = Math.max(Math.abs(Math.cos(d.x0 + (d.x1 - d.x0) / 2 - Math.PI / 2) * arcWidth), arcWidth)\n switch (d._layer.labelAlignment) {\n case NestedDonutSegmentLabelAlignment.Perpendicular:\n return { width: arcWidth, height: arcLength }\n case NestedDonutSegmentLabelAlignment.Along:\n return { width: arcLength, height: arcWidth }\n case NestedDonutSegmentLabelAlignment.Straight:\n return { width: bandwidth, height: bandwidth }\n }\n}\n\nexport function createLabel<Datum> (\n selection: Selection<SVGTextElement, NestedDonutSegment<Datum>, SVGGElement, unknown>,\n arcGen: Arc<unknown, NestedDonutSegment<Datum>>\n): void {\n selection\n .attr('transform', d => getLabelTransform(d, arcGen))\n .style('visibility', null)\n .style('opacity', 0)\n}\n\n\nexport function updateLabel<Datum> (\n selection: Selection<SVGTextElement, NestedDonutSegment<Datum>, SVGGElement, unknown>,\n config: NestedDonutConfig<Datum>,\n arcGen: Arc<unknown, NestedDonutSegment<Datum>>,\n duration: number\n): void {\n selection\n .text(d => getString(d, config.segmentLabel) ?? d.data.key)\n .style('transition', `fill ${duration}ms`)\n .style('fill', (d, i, els) => getColor(d, config.segmentLabelColor) ?? getLabelFillColor(d, els[i]))\n .each((d, i, els) => {\n const bounds = getLabelBounds(d)\n const label = select(els[i]).call(wrapSVGText, bounds.width)\n\n const { width, height } = label.node().getBBox()\n\n if (config.hideOverflowingSegmentLabels && (width > bounds.width || height > bounds.height) && 'hidden') {\n label.attr('visibility', 'hidden')\n } else {\n const fontSize = getCSSVariableValueInPixels(cssvar(variables.nestedDonutSegmentLabelFontSize), els[i])\n const len = label.selectChildren().size() - 1\n label.attr('dy', -fontSize / 2 * len)\n }\n })\n\n smartTransition(selection, duration)\n .attr('transform', d => getLabelTransform(d, arcGen))\n .style('opacity', 1)\n}\n\nexport function removeLabel<Datum> (\n selection: Selection<SVGTextElement, NestedDonutSegment<Datum>, SVGGElement, unknown>,\n duration: number\n): void {\n smartTransition(selection, duration)\n .style('opacity', 0)\n .remove()\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAqBA,SAAS,iBAAiB,CACxB,CAA4B,EAC5B,OAAmB,EAAA;;IAEnB,MAAM,CAAC,GAAG,CAAA,EAAA,GAAA,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,MAAA,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,EAAA,GAAI,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAA;IAC5E,MAAM,GAAG,GAAG,CAAC,KAAD,IAAA,IAAA,CAAC,uBAAD,CAAC,CAAE,GAAG,EAAE,CAAA;;IAGpB,MAAM,WAAW,GAAG,GAAG,IAAI,CAAC,CAAC,MAAM,CAAC,WAAW;AAC7C,UAAE,SAAS,CACT,CAAQ,KAAA,EAAA,GAAG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,SAAS,CAAC,+BAA+B,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;YACvG,MAAM,GAAG,GAAG,KAAK,CAAC,cAAc,EAAE,CAAC,IAAI,EAAE,GAAG,CAAC,CAAA;AAC7C,YAAA,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,QAAQ,GAAG,CAAC,GAAG,GAAG,CAAC,CAAA;AACtC,SAAA;AACH,KAAC,CAAC,CAAA;AAEJ,IAAA,eAAe,CAAC,SAAS,EAAE,QAAQ,CAAC;AACjC,SAAA,IAAI,CAAC,WAAW,EAAE,CAAC,IAAI,iBAAiB,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;AACpD,SAAA,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC,CAAA;AACxB,CAAC;AAEe,SAAA,WAAW,CACzB,SAAqF,EACrF,QAAgB,EAAA;AAEhB,IAAA,eAAe,CAAC,SAAS,EAAE,QAAQ,CAAC;AACjC,SAAA,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC;AACnB,SAAA,MAAM,EAAE,CAAA;AACb;;;;"}
@@ -1,4 +1,4 @@
1
- import { ComponentConfigInterface } from "../../core/component/config";
1
+ import { ComponentConfigInterface, ComponentConfig } from "../../core/component/config";
2
2
  import { ColorAccessor, GenericAccessor, NumericAccessor, StringAccessor } from "../../types/accessor";
3
3
  import { TrimMode, VerticalAlign, FitMode } from "../../types/text";
4
4
  import { Position } from "../../types/position";
@@ -114,4 +114,49 @@ export interface SankeyConfigInterface<N extends SankeyInputNode, L extends Sank
114
114
  */
115
115
  subLabelToLabelInlineWidthRatio?: number;
116
116
  }
117
- export declare const SankeyDefaultConfig: SankeyConfigInterface<SankeyInputNode, SankeyInputLink>;
117
+ export declare class SankeyConfig<N extends SankeyInputNode, L extends SankeyInputLink> extends ComponentConfig implements SankeyConfigInterface<N, L> {
118
+ heightNormalizationCoeff: number;
119
+ exitTransitionType: SankeyExitTransitionType;
120
+ enterTransitionType: SankeyEnterTransitionType;
121
+ id: (d: SankeyInputNode | SankeyInputLink, i: number) => string;
122
+ highlightSubtreeOnHover: boolean;
123
+ highlightDuration: number;
124
+ highlightDelay: number;
125
+ iterations: number;
126
+ linkSort: (link2: L, link1: L) => number;
127
+ nodeSort: any;
128
+ nodeWidth: number;
129
+ nodeAlign: SankeyNodeAlign;
130
+ nodeHorizontalSpacing: number;
131
+ nodeMinHeight: number;
132
+ nodeMaxHeight: number;
133
+ nodePadding: number;
134
+ nodeColor: (d: SankeyNode<N, L>) => string;
135
+ nodeFixedValue: (d: N) => number;
136
+ showSingleNode: boolean;
137
+ nodeCursor: any;
138
+ nodeIcon: any;
139
+ nodeIconColor: any;
140
+ label: (d: SankeyNode<N, L>) => string;
141
+ labelPosition: Position;
142
+ labelVerticalAlign: VerticalAlign;
143
+ labelBackground: boolean;
144
+ labelTextSeparator: string[];
145
+ labelFit: FitMode;
146
+ labelTrimMode: TrimMode;
147
+ labelForceWordBreak: boolean;
148
+ labelFontSize: any;
149
+ labelCursor: any;
150
+ labelColor: any;
151
+ labelMaxWidth: number;
152
+ labelExpandTrimmedOnHover: boolean;
153
+ labelVisibility: any;
154
+ subLabel: any;
155
+ subLabelFontSize: any;
156
+ subLabelColor: any;
157
+ subLabelPlacement: SankeySubLabelPlacement;
158
+ subLabelToLabelInlineWidthRatio: number;
159
+ linkValue: (d: L) => number;
160
+ linkColor: (d: SankeyLink<N, L>) => string;
161
+ linkCursor: any;
162
+ }