@unovis/ts 1.1.2-beta.0 → 1.1.2-beta.2

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 (36) hide show
  1. package/components/axis/style.js +11 -2
  2. package/components/axis/style.js.map +1 -1
  3. package/components/nested-donut/config.d.ts +57 -0
  4. package/components/nested-donut/config.js +26 -0
  5. package/components/nested-donut/config.js.map +1 -0
  6. package/components/nested-donut/index.d.ts +40 -0
  7. package/components/nested-donut/index.js +160 -0
  8. package/components/nested-donut/index.js.map +1 -0
  9. package/components/nested-donut/modules/arc.d.ts +17 -0
  10. package/components/nested-donut/modules/arc.js +50 -0
  11. package/components/nested-donut/modules/arc.js.map +1 -0
  12. package/components/nested-donut/modules/label.d.ts +7 -0
  13. package/components/nested-donut/modules/label.js +74 -0
  14. package/components/nested-donut/modules/label.js.map +1 -0
  15. package/components/nested-donut/style.d.ts +26 -0
  16. package/components/nested-donut/style.js +75 -0
  17. package/components/nested-donut/style.js.map +1 -0
  18. package/components/nested-donut/types.d.ts +33 -0
  19. package/components/nested-donut/types.js +18 -0
  20. package/components/nested-donut/types.js.map +1 -0
  21. package/components.d.ts +2 -0
  22. package/components.js +1 -0
  23. package/components.js.map +1 -1
  24. package/index.js +2 -0
  25. package/index.js.map +1 -1
  26. package/package.json +1 -1
  27. package/styles/index.d.ts +1 -0
  28. package/styles/index.js +2 -1
  29. package/styles/index.js.map +1 -1
  30. package/types.d.ts +1 -0
  31. package/types.js +1 -0
  32. package/types.js.map +1 -1
  33. package/utils/style.d.ts +1 -1
  34. package/utils/style.js.map +1 -1
  35. package/utils/text.js +12 -6
  36. package/utils/text.js.map +1 -1
@@ -8,20 +8,26 @@ const globalStyles = injectGlobal `
8
8
  // Undefined by default to allow proper fallback to var(--vis-font-family)
9
9
  /* --vis-axis-font-family: */
10
10
  --vis-axis-tick-color: #e8e9ef;
11
+ /* --vis-axis-domain-color: // Undefined by default to allow fallback to var(--vis-axis-tick-color) */
11
12
  --vis-axis-tick-label-color: #6c778c;
12
13
  --vis-axis-grid-color: #e8e9ef;
13
14
  --vis-axis-label-color: #6c778c;
14
15
  --vis-axis-tick-label-font-size: 12px;
15
16
  --vis-axis-label-font-size: 14px;
17
+ --vis-axis-tick-line-width: 1px;
18
+ --vis-axis-grid-line-width: 1px;
19
+ /* --vis-axis-domain-line-width: // Undefined by default to allow fallback to var(--vis-axis-grid-line-width) */
16
20
 
17
21
  --vis-dark-axis-tick-color: #6c778c;
22
+ /* --vis-dark-axis-domain-color: // Undefined by default to allow fallback to var(--vis-dark-axis-tick-color) */
18
23
  --vis-dark-axis-tick-label-color: #e8e9ef;
19
24
  --vis-dark-axis-grid-color: #6c778c;
20
- --vis-dark-axis-label-color:#fefefe;
25
+ --vis-dark-axis-label-color: #fefefe;
21
26
  }
22
27
 
23
28
  body.theme-dark ${`.${root}`} {
24
29
  --vis-axis-tick-color: var(--vis-dark-axis-tick-color);
30
+ --vis-axis-domain-color: var(--vis-dark-axis-domain-color);
25
31
  --vis-axis-tick-label-color: var(--vis-dark-axis-tick-label-color);
26
32
  --vis-axis-grid-color: var(--vis-dark-axis-grid-color);
27
33
  --vis-axis-label-color: var(--vis-dark-axis-label-color);
@@ -39,7 +45,8 @@ const axis = css `
39
45
  user-select: none;
40
46
 
41
47
  .domain {
42
- stroke: var(--vis-axis-tick-color);
48
+ stroke: var(--vis-axis-domain-color, var(--vis-axis-tick-color));
49
+ stroke-width: var(--vis-axis-domain-line-width, var(--vis-axis-grid-line-width));
43
50
  }
44
51
 
45
52
  &${`.${hideTickLine}`} {
@@ -63,6 +70,7 @@ const grid = css `
63
70
 
64
71
  line {
65
72
  stroke: var(--vis-axis-grid-color);
73
+ stroke-width: var(--vis-axis-grid-line-width);
66
74
  }
67
75
  `;
68
76
  const tick = css `
@@ -73,6 +81,7 @@ const tick = css `
73
81
 
74
82
  line {
75
83
  stroke: var(--vis-axis-tick-color);
84
+ stroke-width: var(--vis-axis-tick-line-width);
76
85
  }
77
86
 
78
87
  text, tspan {
@@ -1 +1 @@
1
- {"version":3,"file":"style.js","sources":["../../../src/components/axis/style.ts"],"sourcesContent":["import { css, injectGlobal } from '@emotion/css'\n\nexport const root = css`\n label: axis-component;\n`\n\nexport const globalStyles = injectGlobal`\n :root {\n // Undefined by default to allow proper fallback to var(--vis-font-family)\n /* --vis-axis-font-family: */\n --vis-axis-tick-color: #e8e9ef;\n --vis-axis-tick-label-color: #6c778c;\n --vis-axis-grid-color: #e8e9ef;\n --vis-axis-label-color: #6c778c;\n --vis-axis-tick-label-font-size: 12px;\n --vis-axis-label-font-size: 14px;\n\n --vis-dark-axis-tick-color: #6c778c;\n --vis-dark-axis-tick-label-color: #e8e9ef;\n --vis-dark-axis-grid-color: #6c778c;\n --vis-dark-axis-label-color:#fefefe;\n }\n\n body.theme-dark ${`.${root}`} {\n --vis-axis-tick-color: var(--vis-dark-axis-tick-color);\n --vis-axis-tick-label-color: var(--vis-dark-axis-tick-label-color);\n --vis-axis-grid-color: var(--vis-dark-axis-grid-color);\n --vis-axis-label-color: var(--vis-dark-axis-label-color);\n }\n`\n\nexport const hideTickLine = css`\n label: hide-tick-line;\n`\n\nexport const hideDomain = css`\n label: hide-domain;\n`\n\nexport const axis = css`\n label: axis;\n\n user-select: none;\n\n .domain {\n stroke: var(--vis-axis-tick-color);\n }\n\n &${`.${hideTickLine}`} {\n .tick > line {\n opacity: 0;\n }\n }\n\n &${`.${hideDomain}`} {\n .domain {\n opacity: 0;\n }\n }\n`\n\nexport const grid = css`\n label: grid;\n\n .domain {\n opacity: 0;\n }\n\n line {\n stroke: var(--vis-axis-grid-color);\n }\n`\n\nexport const tick = css`\n label: tick;\n\n stroke: none;\n font-size: var(--vis-axis-tick-label-font-size);\n\n line {\n stroke: var(--vis-axis-tick-color);\n }\n\n text, tspan {\n fill: var(--vis-axis-tick-label-color);\n font-family: var(--vis-axis-font-family, var(--vis-font-family));\n stroke: none;\n }\n`\n\nexport const label = css`\n label: label;\n fill: var(--vis-axis-label-color);\n font-size: var(--vis-axis-label-font-size);\n font-family: var(--vis-axis-font-family, var(--vis-font-family));\n text-anchor: middle;\n`\n\nexport const tickText = css`\n label: tick-text;\n`\n"],"names":[],"mappings":";;AAEO,MAAM,IAAI,GAAG,GAAG,CAAA,CAAA;;EAEtB;AAEM,MAAM,YAAY,GAAG,YAAY,CAAA,CAAA;;;;;;;;;;;;;;;;;AAiBpB,kBAAA,EAAA,CAAA,CAAA,EAAI,IAAI,CAAE,CAAA,CAAA;;;;;;EAM7B;AAEM,MAAM,YAAY,GAAG,GAAG,CAAA,CAAA;;EAE9B;AAEM,MAAM,UAAU,GAAG,GAAG,CAAA,CAAA;;EAE5B;AAEM,MAAM,IAAI,GAAG,GAAG,CAAA,CAAA;;;;;;;;;AASlB,GAAA,EAAA,CAAA,CAAA,EAAI,YAAY,CAAE,CAAA,CAAA;;;;;;AAMlB,GAAA,EAAA,CAAA,CAAA,EAAI,UAAU,CAAE,CAAA,CAAA;;;;;EAKpB;AAEM,MAAM,IAAI,GAAG,GAAG,CAAA,CAAA;;;;;;;;;;EAUtB;AAEM,MAAM,IAAI,GAAG,GAAG,CAAA,CAAA;;;;;;;;;;;;;;;EAetB;AAEM,MAAM,KAAK,GAAG,GAAG,CAAA,CAAA;;;;;;EAMvB;AAEM,MAAM,QAAQ,GAAG,GAAG,CAAA,CAAA;;;;;;"}
1
+ {"version":3,"file":"style.js","sources":["../../../src/components/axis/style.ts"],"sourcesContent":["import { css, injectGlobal } from '@emotion/css'\n\nexport const root = css`\n label: axis-component;\n`\n\nexport const globalStyles = injectGlobal`\n :root {\n // Undefined by default to allow proper fallback to var(--vis-font-family)\n /* --vis-axis-font-family: */\n --vis-axis-tick-color: #e8e9ef;\n /* --vis-axis-domain-color: // Undefined by default to allow fallback to var(--vis-axis-tick-color) */\n --vis-axis-tick-label-color: #6c778c;\n --vis-axis-grid-color: #e8e9ef;\n --vis-axis-label-color: #6c778c;\n --vis-axis-tick-label-font-size: 12px;\n --vis-axis-label-font-size: 14px;\n --vis-axis-tick-line-width: 1px;\n --vis-axis-grid-line-width: 1px;\n /* --vis-axis-domain-line-width: // Undefined by default to allow fallback to var(--vis-axis-grid-line-width) */\n\n --vis-dark-axis-tick-color: #6c778c;\n /* --vis-dark-axis-domain-color: // Undefined by default to allow fallback to var(--vis-dark-axis-tick-color) */\n --vis-dark-axis-tick-label-color: #e8e9ef;\n --vis-dark-axis-grid-color: #6c778c;\n --vis-dark-axis-label-color: #fefefe;\n }\n\n body.theme-dark ${`.${root}`} {\n --vis-axis-tick-color: var(--vis-dark-axis-tick-color);\n --vis-axis-domain-color: var(--vis-dark-axis-domain-color);\n --vis-axis-tick-label-color: var(--vis-dark-axis-tick-label-color);\n --vis-axis-grid-color: var(--vis-dark-axis-grid-color);\n --vis-axis-label-color: var(--vis-dark-axis-label-color);\n }\n`\n\nexport const hideTickLine = css`\n label: hide-tick-line;\n`\n\nexport const hideDomain = css`\n label: hide-domain;\n`\n\nexport const axis = css`\n label: axis;\n\n user-select: none;\n\n .domain {\n stroke: var(--vis-axis-domain-color, var(--vis-axis-tick-color));\n stroke-width: var(--vis-axis-domain-line-width, var(--vis-axis-grid-line-width));\n }\n\n &${`.${hideTickLine}`} {\n .tick > line {\n opacity: 0;\n }\n }\n\n &${`.${hideDomain}`} {\n .domain {\n opacity: 0;\n }\n }\n`\n\nexport const grid = css`\n label: grid;\n\n .domain {\n opacity: 0;\n }\n\n line {\n stroke: var(--vis-axis-grid-color);\n stroke-width: var(--vis-axis-grid-line-width);\n }\n`\n\nexport const tick = css`\n label: tick;\n\n stroke: none;\n font-size: var(--vis-axis-tick-label-font-size);\n\n line {\n stroke: var(--vis-axis-tick-color);\n stroke-width: var(--vis-axis-tick-line-width);\n }\n\n text, tspan {\n fill: var(--vis-axis-tick-label-color);\n font-family: var(--vis-axis-font-family, var(--vis-font-family));\n stroke: none;\n }\n`\n\nexport const label = css`\n label: label;\n fill: var(--vis-axis-label-color);\n font-size: var(--vis-axis-label-font-size);\n font-family: var(--vis-axis-font-family, var(--vis-font-family));\n text-anchor: middle;\n`\n\nexport const tickText = css`\n label: tick-text;\n`\n"],"names":[],"mappings":";;AAEO,MAAM,IAAI,GAAG,GAAG,CAAA,CAAA;;EAEtB;AAEM,MAAM,YAAY,GAAG,YAAY,CAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;AAsBpB,kBAAA,EAAA,CAAA,CAAA,EAAI,IAAI,CAAE,CAAA,CAAA;;;;;;;EAO7B;AAEM,MAAM,YAAY,GAAG,GAAG,CAAA,CAAA;;EAE9B;AAEM,MAAM,UAAU,GAAG,GAAG,CAAA,CAAA;;EAE5B;AAEM,MAAM,IAAI,GAAG,GAAG,CAAA,CAAA;;;;;;;;;;AAUlB,GAAA,EAAA,CAAA,CAAA,EAAI,YAAY,CAAE,CAAA,CAAA;;;;;;AAMlB,GAAA,EAAA,CAAA,CAAA,EAAI,UAAU,CAAE,CAAA,CAAA;;;;;EAKpB;AAEM,MAAM,IAAI,GAAG,GAAG,CAAA,CAAA;;;;;;;;;;;EAWtB;AAEM,MAAM,IAAI,GAAG,GAAG,CAAA,CAAA;;;;;;;;;;;;;;;;EAgBtB;AAEM,MAAM,KAAK,GAAG,GAAG,CAAA,CAAA;;;;;;EAMvB;AAEM,MAAM,QAAQ,GAAG,GAAG,CAAA,CAAA;;;;;;"}
@@ -0,0 +1,57 @@
1
+ import { ComponentConfigInterface, ComponentConfig } from "../../core/component/config";
2
+ import { ColorAccessor, GenericAccessor, NumericAccessor, StringAccessor } from "../../types/accessor";
3
+ import { NestedDonutDirection, NestedDonutLayerSettings, NestedDonutSegment } from './types';
4
+ export interface NestedDonutConfigInterface<Datum> extends ComponentConfigInterface {
5
+ /** Diagram angle range. Default: `[0, 2 * Math.PI]` */
6
+ angleRange?: [number, number];
7
+ /** Direction of hierarchy flow from root to leaf.
8
+ * `NestedDonutDirection.Inwards` starts from the outer most radius and works towards center
9
+ * `NestedDonutDirection.Outwards` starts from the inner most radius the consecutive layers outward.
10
+ * Default: `NestedDonutDirection.Inwards`
11
+ */
12
+ direction?: NestedDonutDirection | string;
13
+ value?: NumericAccessor<Datum>;
14
+ /** Central label text. Default: `undefined` */
15
+ centralLabel?: string;
16
+ /** Central sub-label accessor function or text. Default: `undefined` */
17
+ centralSubLabel?: string;
18
+ /** Enables wrapping for the sub-label. Default: `true` */
19
+ centralSubLabelWrap?: boolean;
20
+ /**
21
+ * Show donut background. The color is configurable via
22
+ * the `--vis-nested-donut-background-color` and `--vis-dark-nested-donut-background-color` CSS variables.
23
+ * Default: `false`
24
+ */
25
+ showBackground?: boolean;
26
+ /** Array of accessor functions to defined the nested groups */
27
+ layers: StringAccessor<Datum>[];
28
+ layerSettings?: GenericAccessor<NestedDonutLayerSettings, number>;
29
+ layerPadding?: number;
30
+ /** Corner Radius. Default: `0` */
31
+ cornerRadius?: number;
32
+ /** Hide segment labels when they don't fit. Default: `true` */
33
+ hideOverflowingSegmentLabels?: boolean;
34
+ /** Color accessor function for segments. Default: `undefined` */
35
+ segmentColor?: ColorAccessor<NestedDonutSegment<Datum>>;
36
+ /** Segment label accessor function. Default `undefined` */
37
+ segmentLabel?: StringAccessor<NestedDonutSegment<Datum>>;
38
+ /** Color accessor function for segment labels */
39
+ segmentLabelColor?: ColorAccessor<NestedDonutSegment<Datum>>;
40
+ }
41
+ export declare class NestedDonutConfig<Datum> extends ComponentConfig implements NestedDonutConfigInterface<Datum> {
42
+ angleRange: [number, number];
43
+ centralLabel: any;
44
+ centralSubLabel: any;
45
+ centralSubLabelWrap: boolean;
46
+ cornerRadius: number;
47
+ direction: NestedDonutDirection;
48
+ hideOverflowingSegmentLabels: boolean;
49
+ layers: StringAccessor<Datum>[];
50
+ layerPadding: number;
51
+ layerSettings: any;
52
+ segmentColor: any;
53
+ segmentLabel: any;
54
+ segmentLabelColor: any;
55
+ showBackground: boolean;
56
+ value: any;
57
+ }
@@ -0,0 +1,26 @@
1
+ import { ComponentConfig } from '../../core/component/config.js';
2
+ import { NestedDonutDirection } from './types.js';
3
+
4
+ // Core
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.hideOverflowingSegmentLabels = true;
15
+ this.layerPadding = 0;
16
+ this.layerSettings = undefined;
17
+ this.segmentColor = undefined;
18
+ this.segmentLabel = undefined;
19
+ this.segmentLabelColor = undefined;
20
+ this.showBackground = false;
21
+ this.value = undefined;
22
+ }
23
+ }
24
+
25
+ export { NestedDonutConfig };
26
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
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\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 /** 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}\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 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 value = undefined\n}\n"],"names":[],"mappings":";;;AAAA;AAqDM,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;QACxC,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,IAAK,CAAA,KAAA,GAAG,SAAS,CAAA;KAClB;AAAA;;;;"}
@@ -0,0 +1,40 @@
1
+ import { Selection } from 'd3-selection';
2
+ import { ScaleLinear } from 'd3-scale';
3
+ import { ComponentCore } from "../../core/component";
4
+ import { SeriesDataModel } from "../../data-models/series";
5
+ import { NestedDonutSegment } from './types';
6
+ import { NestedDonutConfig, NestedDonutConfigInterface } from './config';
7
+ import * as s from './style';
8
+ export declare class NestedDonut<Datum> extends ComponentCore<Datum[], NestedDonutConfig<Datum>, NestedDonutConfigInterface<Datum>> {
9
+ static selectors: typeof s;
10
+ static cssVariables: {
11
+ nestedDonutBackgroundColor: "--vis-nested-donut-background-color";
12
+ nestedDonutFontFamily: "--vis-nested-donut-font-family";
13
+ nestedDonutCentralLabelFontSize: "--vis-nested-donut-central-label-font-size";
14
+ nestedDonutCentralLabelFontWeight: "--vis-nested-donut-central-label-font-weight";
15
+ nestedDonutCentralLabelTextColor: "--vis-nested-donut-central-label-text-color";
16
+ nestedDonutCentralSublabelFontSize: "--vis-nested-donut-central-sublabel-font-size";
17
+ nestedDonutCentralSublabelFontWeight: "--vis-nested-donut-central-sublabel-font-weight";
18
+ nestedDonutCentralSublabelTextColor: "--vis-nested-donut-central-sublabel-text-color";
19
+ nestedDonutSegmentStrokeWidth: "--vis-nested-donut-segment-stroke-width";
20
+ nestedDonutSegmentStrokeColor: "--vis-nested-donut-segment-stroke-color";
21
+ nestedDonutSegmentLabelTextColorLight: "--vis-nested-donut-segment-label-text-color-light";
22
+ nestedDonutSegmentLabelTextColorDark: "--vis-nested-donut-segment-label-text-color-dark";
23
+ darkNestedDonutBackgroundColor: "--vis-dark-nested-donut-background-color";
24
+ darkNestedDonutCentralLabelTextColor: "--vis-dark-nested-donut-central-label-text-color";
25
+ darkNestedDonutCentralSublabelTextColor: "--vis-dark-nested-donut-central-sublabel-text-color";
26
+ };
27
+ config: NestedDonutConfig<Datum>;
28
+ datamodel: SeriesDataModel<Datum>;
29
+ arcBackground: Selection<SVGGElement, unknown, SVGGElement, unknown>;
30
+ arcGroup: Selection<SVGGElement, unknown, SVGGElement, unknown>;
31
+ centralLabel: Selection<SVGTextElement, unknown, SVGGElement, unknown>;
32
+ centralSubLabel: Selection<SVGTextElement, unknown, SVGGElement, unknown>;
33
+ arcGen: import("d3-shape").Arc<any, Partial<NestedDonutSegment<Datum>>>;
34
+ colorScale: ScaleLinear<string, string>;
35
+ events: {};
36
+ constructor(config?: NestedDonutConfigInterface<Datum>);
37
+ _render(customDuration?: number): void;
38
+ private _getHierarchyData;
39
+ private _getLayerSettings;
40
+ }
@@ -0,0 +1,160 @@
1
+ import { arc } from 'd3-shape';
2
+ import { hierarchy, partition } from 'd3-hierarchy';
3
+ import { scaleLinear } from 'd3-scale';
4
+ import { group } from 'd3-array';
5
+ import { ComponentCore } from '../../core/component/index.js';
6
+ import { SeriesDataModel } from '../../data-models/series.js';
7
+ import { VerticalAlign } from '../../types/text.js';
8
+ import { getColor, getHexValue } from '../../utils/color.js';
9
+ import { isNumber, getString, getNumber, isNumberWithinRange, merge, getValue } from '../../utils/data.js';
10
+ import { smartTransition } from '../../utils/d3.js';
11
+ import { wrapSVGText } from '../../utils/text.js';
12
+ import { NestedDonutDirection, defaultLayerSettings } from './types.js';
13
+ import { NestedDonutConfig } from './config.js';
14
+ import { createArc, updateArc, removeArc } from './modules/arc.js';
15
+ import { createLabel, updateLabel, removeLabel } from './modules/label.js';
16
+ import * as style from './style.js';
17
+ import { segmentsGroup, centralLabel, centralSubLabel, background, segment, segmentExit, segmentArc, segmentLabel, variables } from './style.js';
18
+
19
+ class NestedDonut extends ComponentCore {
20
+ constructor(config) {
21
+ super();
22
+ this.config = new NestedDonutConfig();
23
+ this.datamodel = new SeriesDataModel();
24
+ this.arcGen = arc();
25
+ this.colorScale = scaleLinear();
26
+ this.events = {};
27
+ if (config)
28
+ this.config.init(config);
29
+ this.arcBackground = this.g.append('g');
30
+ this.arcGroup = this.g.append('g')
31
+ .attr('class', segmentsGroup);
32
+ this.centralLabel = this.g.append('text')
33
+ .attr('class', centralLabel);
34
+ this.centralSubLabel = this.g.append('text')
35
+ .attr('class', centralSubLabel);
36
+ }
37
+ _render(customDuration) {
38
+ var _a, _b;
39
+ const { config } = this;
40
+ const duration = isNumber(customDuration) ? customDuration : config.duration;
41
+ const layers = this._getLayerSettings();
42
+ const data = this._getHierarchyData(layers);
43
+ this.arcGen
44
+ .startAngle(d => d.x0)
45
+ .endAngle(d => d.x1)
46
+ .innerRadius(d => d.y0)
47
+ .outerRadius(d => d.y1)
48
+ .cornerRadius(config.cornerRadius);
49
+ this.g.attr('transform', `translate(${this._width / 2},${this._height / 2})`);
50
+ // Layer backgrounds
51
+ const backgrounds = this.arcBackground
52
+ .selectAll(`.${background}`)
53
+ .data(layers, d => d._id);
54
+ const backgroundsEnter = backgrounds.enter().append('path')
55
+ .attr('class', background)
56
+ .attr('visibility', config.showBackground ? null : 'hidden');
57
+ const backgroundsMerged = backgrounds.merge(backgroundsEnter);
58
+ smartTransition(backgroundsMerged, duration)
59
+ .attr('d', d => {
60
+ var _a, _b, _c, _d, _e, _f, _g, _h;
61
+ return this.arcGen({
62
+ x0: (_d = (_b = (_a = config.angleRange) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : (_c = config.angleRange) === null || _c === void 0 ? void 0 : _c[0]) !== null && _d !== void 0 ? _d : 0,
63
+ x1: (_h = (_f = (_e = config.angleRange) === null || _e === void 0 ? void 0 : _e[1]) !== null && _f !== void 0 ? _f : (_g = config.angleRange) === null || _g === void 0 ? void 0 : _g[1]) !== null && _h !== void 0 ? _h : 2 * Math.PI,
64
+ y0: d._innerRadius,
65
+ y1: d._outerRadius,
66
+ });
67
+ });
68
+ // Segments
69
+ const segments = this.arcGroup.selectAll(`${segment}`)
70
+ .data(data, d => d._id);
71
+ const segmentsEnter = segments.enter()
72
+ .append('g')
73
+ .attr('class', segment);
74
+ segments.merge(segmentsEnter);
75
+ smartTransition(segments.exit(), duration)
76
+ .attr('class', segmentExit)
77
+ .style('opacity', 0)
78
+ .remove();
79
+ // Segment arcs
80
+ const arcs = this.arcGroup
81
+ .selectAll(`.${segmentArc}`)
82
+ .data(data, d => d._id);
83
+ const arcsEnter = segmentsEnter.append('path')
84
+ .attr('class', segmentArc)
85
+ .call(createArc, config);
86
+ arcs.merge(arcsEnter)
87
+ .call(updateArc, config, this.arcGen, duration);
88
+ arcs.exit()
89
+ .attr('class', segmentExit)
90
+ .call(removeArc, duration);
91
+ // Segment labels
92
+ const labels = this.arcGroup
93
+ .selectAll(`.${segmentLabel}`)
94
+ .data(data, d => d._id);
95
+ const labelsEnter = segmentsEnter.append('text')
96
+ .attr('class', segmentLabel)
97
+ .call(createLabel, this.arcGen);
98
+ labels.merge(labelsEnter)
99
+ .call(updateLabel, config, this.arcGen, duration);
100
+ labels.exit()
101
+ .call(removeLabel, duration);
102
+ // Chart labels
103
+ this.centralLabel
104
+ .attr('dy', config.centralSubLabel ? '-0.55em' : null)
105
+ .text((_a = config.centralLabel) !== null && _a !== void 0 ? _a : null);
106
+ this.centralSubLabel
107
+ .attr('dy', config.centralLabel ? '0.55em' : null)
108
+ .text((_b = config.centralSubLabel) !== null && _b !== void 0 ? _b : null);
109
+ if (config.centralSubLabelWrap)
110
+ wrapSVGText(this.centralSubLabel, layers[0]._innerRadius * 1.9, VerticalAlign.Top);
111
+ }
112
+ _getHierarchyData(layers) {
113
+ var _a;
114
+ const { config, datamodel: { data } } = this;
115
+ const layerAccessors = (_a = config.layers) === null || _a === void 0 ? void 0 : _a.map(layerAccessor => (i) => getString(data[i], layerAccessor, i));
116
+ const nestedData = group(data.keys(), ...layerAccessors);
117
+ const rootNode = config.value
118
+ ? hierarchy(nestedData).sum(index => typeof index === 'number' && getNumber(data[index], config.value, index))
119
+ : hierarchy(nestedData).count();
120
+ const partitionData = partition().size([config.angleRange[1], 1])(rootNode);
121
+ partitionData.eachBefore(node => {
122
+ var _a, _b, _c, _d;
123
+ const scale = this.colorScale.domain([-1, (_a = node.children) === null || _a === void 0 ? void 0 : _a.length]);
124
+ if (isNumberWithinRange(node.depth - 1, [0, layers.length - 1])) {
125
+ node._layer = layers[node.depth - 1];
126
+ node._id = [this.uid, node._layer._id, node._index].join('-');
127
+ node.y0 = node._layer._innerRadius;
128
+ node.y1 = node._layer._outerRadius;
129
+ }
130
+ const key = node.data[0];
131
+ node.data = { key: key, root: (_c = (_b = node.parent) === null || _b === void 0 ? void 0 : _b.data.root) !== null && _c !== void 0 ? _c : key };
132
+ (_d = node.children) === null || _d === void 0 ? void 0 : _d.forEach((child, i) => {
133
+ var _a;
134
+ child._index = i;
135
+ child._state = {
136
+ fill: (_a = getColor(child, config.segmentColor, i, child.depth !== 1)) !== null && _a !== void 0 ? _a : scale.range(['#fff', getHexValue(node._state.fill, this.element)])(i),
137
+ };
138
+ });
139
+ });
140
+ const segments = partitionData.descendants().filter(d => d.parent && d.children && d.data.key);
141
+ return segments;
142
+ }
143
+ _getLayerSettings() {
144
+ const { direction, layers, layerPadding, layerSettings } = this.config;
145
+ const outerRadius = Math.min(this._width, this._height) / 2;
146
+ const layerItems = layers.reduceRight((arr, _, i) => {
147
+ const layerId = direction === NestedDonutDirection.Outwards ? i : arr.length;
148
+ const layerConfig = merge(defaultLayerSettings, getValue(layerId, layerSettings));
149
+ const radius = arr.length ? arr[0]._innerRadius - layerPadding : outerRadius;
150
+ arr.unshift(Object.assign(Object.assign({}, layerConfig), { _id: layerId, _outerRadius: radius, _innerRadius: radius - layerConfig.width }));
151
+ return arr;
152
+ }, new Array());
153
+ return direction === NestedDonutDirection.Inwards ? layerItems.reverse() : layerItems;
154
+ }
155
+ }
156
+ NestedDonut.selectors = style;
157
+ NestedDonut.cssVariables = variables;
158
+
159
+ export { NestedDonut };
160
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../../src/components/nested-donut/index.ts"],"sourcesContent":["import { Selection } from 'd3-selection'\nimport { arc } 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, getHexValue } from 'utils/color'\nimport { getNumber, getString, getValue, isNumber, isNumberWithinRange, merge } from 'utils/data'\nimport { smartTransition } from 'utils/d3'\nimport { wrapSVGText } from 'utils/text'\n\n// Local Types\nimport { NestedDonutDirection, NestedDonutSegment, defaultLayerSettings, NestedDonutLayer } 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.g.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 smartTransition(backgroundsMerged, duration)\n .attr('d', d => this.arcGen({\n x0: config.angleRange?.[0] ?? config.angleRange?.[0] ?? 0,\n x1: config.angleRange?.[1] ?? config.angleRange?.[1] ?? 2 * Math.PI,\n y0: d._innerRadius,\n y1: d._outerRadius,\n }))\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 const rootNode = config.value\n ? hierarchy(nestedData).sum(index => typeof index === 'number' && getNumber(data[index], config.value, index))\n : hierarchy(nestedData).count()\n const partitionData = partition().size([config.angleRange[1], 1])(rootNode) as NestedDonutSegment<Datum>\n\n partitionData.eachBefore(node => {\n const scale = this.colorScale.domain([-1, node.children?.length])\n\n if (isNumberWithinRange(node.depth - 1, [0, layers.length - 1])) {\n node._layer = layers[node.depth - 1]\n node._id = [this.uid, node._layer._id, node._index].join('-')\n node.y0 = node._layer._innerRadius\n node.y1 = node._layer._outerRadius\n }\n const key = node.data[0] as string\n node.data = { key: key, root: node.parent?.data.root ?? key }\n\n node.children?.forEach((child, i) => {\n child._index = i\n child._state = {\n fill:\n getColor(child, config.segmentColor, i, child.depth !== 1) ??\n scale.range(['#fff', getHexValue(node._state.fill, this.element)])(i),\n }\n })\n })\n const segments = partitionData.descendants().filter(d => d.parent && d.children && 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 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 arr.unshift({\n ...layerConfig,\n _id: layerId,\n _outerRadius: radius,\n _innerRadius: radius - layerConfig.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","s.variables"],"mappings":";;;;;;;;;;;;;;;;;;AAgCM,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,MAAA,GAAG,EAAG,CAAA;AAIV,QAAA,IAAI,MAAM;AAAE,YAAA,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;QACpC,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;QACvC,IAA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A,EAAA,WAAW,KACd,GAAG,EAAE,OAAO,EACZ,YAAY,EAAE,MAAM,EACpB,YAAY,EAAE,MAAM,GAAG,WAAW,CAAC,KAAK,EAAA,CAAA,CACxC,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;;AA5KM,WAAS,CAAA,SAAA,GAAGC,KAAC,CAAA;AACb,WAAA,CAAA,YAAY,GAAGC,SAAW;;;;"}
@@ -0,0 +1,17 @@
1
+ import { Selection } from 'd3-selection';
2
+ import { Arc } from 'd3-shape';
3
+ import { NestedDonutSegment } from '../types';
4
+ import { NestedDonutConfig } from '../config';
5
+ declare type AnimState = {
6
+ x0: number;
7
+ x1: number;
8
+ y0: number;
9
+ y1: number;
10
+ };
11
+ export interface ArcNode extends SVGElement {
12
+ _animState?: AnimState;
13
+ }
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
+ export declare function removeArc<Datum>(selection: Selection<SVGPathElement, NestedDonutSegment<Datum>, SVGGElement, unknown>, duration: number): void;
17
+ export {};
@@ -0,0 +1,50 @@
1
+ import { interpolate } from 'd3-interpolate';
2
+ import { getColor } from '../../../utils/color.js';
3
+ import { smartTransition } from '../../../utils/d3.js';
4
+
5
+ function createArc(selection, config) {
6
+ selection
7
+ .style('fill', d => { var _a; return (_a = getColor(d, config.segmentColor)) !== null && _a !== void 0 ? _a : d._state.fill; })
8
+ .style('opacity', 0)
9
+ .each((d, i, els) => {
10
+ const arcNode = els[i];
11
+ const angleCenter = (d.x0 + d.x1) / 2;
12
+ const angleHalfWidth = (d.x1 - d.x0) / 2;
13
+ arcNode._animState = {
14
+ x0: angleCenter - angleHalfWidth,
15
+ x1: angleCenter + angleHalfWidth,
16
+ y0: d.y0,
17
+ y1: d.y1,
18
+ };
19
+ });
20
+ }
21
+ function updateArc(selection, config, arcGen, duration) {
22
+ selection
23
+ .style('transition', `fill ${duration}ms`) // Animate color with CSS because we're using CSS-variables
24
+ .style('fill', d => { var _a; return (_a = getColor(d, config.segmentColor)) !== null && _a !== void 0 ? _a : d._state.fill; });
25
+ if (duration) {
26
+ const transition = smartTransition(selection, duration)
27
+ .style('opacity', 1);
28
+ transition.attrTween('d', (d, i, els) => {
29
+ const arcNode = els[i];
30
+ const nextAnimState = { x0: d.x0, x1: d.x1, y0: d.y0, y1: d.y1 };
31
+ const datum = interpolate(arcNode._animState, nextAnimState);
32
+ return (t) => {
33
+ arcNode._animState = datum(t);
34
+ return arcGen(arcNode._animState);
35
+ };
36
+ });
37
+ }
38
+ else {
39
+ selection.attr('d', arcGen)
40
+ .style('opacity', 1);
41
+ }
42
+ }
43
+ function removeArc(selection, duration) {
44
+ smartTransition(selection, duration)
45
+ .style('opacity', 0)
46
+ .remove();
47
+ }
48
+
49
+ export { createArc, removeArc, updateArc };
50
+ //# sourceMappingURL=arc.js.map
@@ -0,0 +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 { 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 => getColor(d, config.segmentColor) ?? d._state.fill)\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,CAAC,IAAI,EAAA,IAAA,EAAA,CAAA,CAAA,OAAA,CAAA,EAAA,GAAA,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC,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pD,aAAA,KAAK,CAAC,SAAS,EAAE,CAAC,CAAgF,CAAA;AAErG,QAAA,UAAU,CAAC,SAAS,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;;;;"}
@@ -0,0 +1,7 @@
1
+ import { Selection } from 'd3-selection';
2
+ import { Arc } from 'd3-shape';
3
+ import { NestedDonutConfig } from '../config';
4
+ import { NestedDonutSegment } from '../types';
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: NestedDonutConfig<Datum>, arcGen: Arc<unknown, NestedDonutSegment<Datum>>, duration: number): void;
7
+ export declare function removeLabel<Datum>(selection: Selection<SVGTextElement, NestedDonutSegment<Datum>, SVGGElement, unknown>, duration: number): void;
@@ -0,0 +1,74 @@
1
+ import { select } from 'd3-selection';
2
+ import { color } from 'd3-color';
3
+ import { UNOVIS_TEXT_DEFAULT } from '../../../styles/index.js';
4
+ import { getColor, hexToBrightness } from '../../../utils/color.js';
5
+ import { smartTransition } from '../../../utils/d3.js';
6
+ import { getString } from '../../../utils/data.js';
7
+ import { cssvar } from '../../../utils/style.js';
8
+ import { wrapSVGText } from '../../../utils/text.js';
9
+ import { NestedDonutSegmentLabelAlignment } from '../types.js';
10
+ import { variables } from '../style.js';
11
+
12
+ function getLabelFillColor(d, config) {
13
+ var _a;
14
+ const c = (_a = getColor(d, config.segmentColor)) !== null && _a !== void 0 ? _a : d._state.fill;
15
+ const colorParsed = color(c);
16
+ const brightness = colorParsed ? hexToBrightness(colorParsed.hex()) : 0;
17
+ return cssvar(brightness > 0.65 ? variables.nestedDonutSegmentLabelTextColorLight : variables.nestedDonutSegmentLabelTextColorDark);
18
+ }
19
+ function getLabelTransform(d, arcGen) {
20
+ const translate = `translate(${arcGen.centroid(d)})`;
21
+ const degree = 180 / Math.PI * (arcGen.startAngle()(d) + arcGen.endAngle()(d)) / 2 - 90;
22
+ switch (d._layer.labelAlignment) {
23
+ case NestedDonutSegmentLabelAlignment.Along:
24
+ return `${translate} rotate(${degree + 90})`;
25
+ case NestedDonutSegmentLabelAlignment.Perpendicular:
26
+ return `${translate} rotate(${degree > 90 ? degree - 180 : degree})`;
27
+ default:
28
+ return `${translate}`;
29
+ }
30
+ }
31
+ function getLabelBounds(d) {
32
+ const arcWidth = d.y1 - d.y0;
33
+ const arcLength = d._layer._innerRadius * (d.x1 - d.x0);
34
+ const bandwidth = Math.max(Math.abs(Math.cos(d.x0 + (d.x1 - d.x0) / 2 - Math.PI / 2) * d._layer.width), arcWidth);
35
+ switch (d._layer.labelAlignment) {
36
+ case NestedDonutSegmentLabelAlignment.Perpendicular:
37
+ return { width: arcWidth, height: arcLength };
38
+ case NestedDonutSegmentLabelAlignment.Along:
39
+ return { width: arcLength, height: arcWidth };
40
+ case NestedDonutSegmentLabelAlignment.Straight:
41
+ return { width: bandwidth, height: bandwidth };
42
+ }
43
+ }
44
+ function createLabel(selection, arcGen) {
45
+ selection
46
+ .attr('transform', d => getLabelTransform(d, arcGen))
47
+ .style('visibility', null)
48
+ .style('opacity', 0);
49
+ }
50
+ function updateLabel(selection, config, arcGen, duration) {
51
+ selection
52
+ .text(d => { var _a; return (_a = getString(d, config.segmentLabel)) !== null && _a !== void 0 ? _a : d.data.key; })
53
+ .style('transition', `fill ${duration}ms`)
54
+ .style('fill', d => { var _a; return (_a = getColor(d, config.segmentLabelColor)) !== null && _a !== void 0 ? _a : getLabelFillColor(d, config); })
55
+ .each((d, i, els) => {
56
+ const bounds = getLabelBounds(d);
57
+ const label = select(els[i]).call(wrapSVGText, bounds.width);
58
+ const offset = label.selectChildren().size() - 1;
59
+ const { width, height } = label.node().getBBox();
60
+ label.attr('dy', -offset * UNOVIS_TEXT_DEFAULT.fontSize + (2 * offset))
61
+ .attr('visibility', config.hideOverflowingSegmentLabels && (width > bounds.width || height > bounds.height) && 'hidden');
62
+ });
63
+ smartTransition(selection, duration)
64
+ .attr('transform', d => getLabelTransform(d, arcGen))
65
+ .style('opacity', 1);
66
+ }
67
+ function removeLabel(selection, duration) {
68
+ smartTransition(selection, duration)
69
+ .style('opacity', 0)
70
+ .remove();
71
+ }
72
+
73
+ export { createLabel, removeLabel, updateLabel };
74
+ //# sourceMappingURL=label.js.map
@@ -0,0 +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 { UNOVIS_TEXT_DEFAULT } from 'styles'\nimport { getColor, hexToBrightness } from 'utils/color'\nimport { smartTransition } from 'utils/d3'\nimport { getString } from 'utils/data'\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 config: NestedDonutConfig<Datum>\n): string {\n const c = getColor(d, config.segmentColor) ?? d._state.fill\n const colorParsed = color(c)\n const brightness = colorParsed ? hexToBrightness(colorParsed.hex()) : 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) * d._layer.width), 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 => getColor(d, config.segmentLabelColor) ?? getLabelFillColor(d, config))\n .each((d, i, els) => {\n const bounds = getLabelBounds(d)\n const label = select(els[i]).call(wrapSVGText, bounds.width)\n const offset = label.selectChildren().size() - 1\n const { width, height } = label.node().getBBox()\n\n label.attr('dy', -offset * UNOVIS_TEXT_DEFAULT.fontSize + (2 * offset))\n .attr('visibility', config.hideOverflowingSegmentLabels && (width > bounds.width || height > bounds.height) && 'hidden')\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,MAAgC,EAAA;;AAEhC,IAAA,MAAM,CAAC,GAAG,CAAA,EAAA,GAAA,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC,YAAY,CAAC,MAAI,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,EAAA,GAAA,CAAC,CA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AAI,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;;;;"}
@@ -0,0 +1,26 @@
1
+ export declare const root: string;
2
+ export declare const segmentsGroup: string;
3
+ export declare const variables: {
4
+ nestedDonutBackgroundColor: "--vis-nested-donut-background-color";
5
+ nestedDonutFontFamily: "--vis-nested-donut-font-family";
6
+ nestedDonutCentralLabelFontSize: "--vis-nested-donut-central-label-font-size";
7
+ nestedDonutCentralLabelFontWeight: "--vis-nested-donut-central-label-font-weight";
8
+ nestedDonutCentralLabelTextColor: "--vis-nested-donut-central-label-text-color";
9
+ nestedDonutCentralSublabelFontSize: "--vis-nested-donut-central-sublabel-font-size";
10
+ nestedDonutCentralSublabelFontWeight: "--vis-nested-donut-central-sublabel-font-weight";
11
+ nestedDonutCentralSublabelTextColor: "--vis-nested-donut-central-sublabel-text-color";
12
+ nestedDonutSegmentStrokeWidth: "--vis-nested-donut-segment-stroke-width";
13
+ nestedDonutSegmentStrokeColor: "--vis-nested-donut-segment-stroke-color";
14
+ nestedDonutSegmentLabelTextColorLight: "--vis-nested-donut-segment-label-text-color-light";
15
+ nestedDonutSegmentLabelTextColorDark: "--vis-nested-donut-segment-label-text-color-dark";
16
+ darkNestedDonutBackgroundColor: "--vis-dark-nested-donut-background-color";
17
+ darkNestedDonutCentralLabelTextColor: "--vis-dark-nested-donut-central-label-text-color";
18
+ darkNestedDonutCentralSublabelTextColor: "--vis-dark-nested-donut-central-sublabel-text-color";
19
+ };
20
+ export declare const background: string;
21
+ export declare const segment: string;
22
+ export declare const segmentExit: string;
23
+ export declare const segmentArc: string;
24
+ export declare const segmentLabel: string;
25
+ export declare const centralLabel: string;
26
+ export declare const centralSubLabel: string;
@@ -0,0 +1,75 @@
1
+ import { css } from '@emotion/css';
2
+ import { getCssVarNames, injectGlobalCssVariables } from '../../utils/style.js';
3
+
4
+ const cssVarDefaults = {
5
+ '--vis-nested-donut-background-color': '#E7E9F3',
6
+ // Undefined by default to allow proper fallback to var(--vis-font-family)
7
+ '--vis-nested-donut-font-family': undefined,
8
+ // Central label
9
+ '--vis-nested-donut-central-label-font-size': '16px',
10
+ '--vis-nested-donut-central-label-font-weight': 600,
11
+ '--vis-nested-donut-central-label-text-color': '#5b5f6d',
12
+ // Central sub-label
13
+ '--vis-nested-donut-central-sublabel-font-size': '12px;',
14
+ '--vis-nested-donut-central-sublabel-font-weight': 500,
15
+ '--vis-nested-donut-central-sublabel-text-color': '#5b5f6d',
16
+ // Segments
17
+ '--vis-nested-donut-segment-stroke-width': '1px',
18
+ '--vis-nested-donut-segment-stroke-color': undefined,
19
+ '--vis-nested-donut-segment-label-text-color-light': '#5b5f6d',
20
+ '--vis-nested-donut-segment-label-text-color-dark': '#fff',
21
+ /* Dark theme */
22
+ '--vis-dark-nested-donut-background-color': '#18160C',
23
+ '--vis-dark-nested-donut-central-label-text-color': '#fff',
24
+ '--vis-dark-nested-donut-central-sublabel-text-color': '#fff',
25
+ };
26
+ const root = css `
27
+ label: nested-donut-component;
28
+ `;
29
+ const segmentsGroup = css `
30
+ label: nested-donut-segments-group;
31
+ `;
32
+ const variables = getCssVarNames(cssVarDefaults);
33
+ injectGlobalCssVariables(cssVarDefaults, root);
34
+ const background = css `
35
+ label: background;
36
+ fill: var(--vis-donut-background-color);
37
+ `;
38
+ const segment = css `
39
+ label: segment;
40
+ `;
41
+ const segmentExit = css `
42
+ label: segment-exit;
43
+ `;
44
+ const segmentArc = css `
45
+ label: segment-arc;
46
+ stroke-width: var(--vis-nested-donut-segment-stroke-width);
47
+ stroke: var(--vis-nested-donut-segment-stroke-color, var(--vis-donut-background-color));
48
+ `;
49
+ const segmentLabel = css `
50
+ label: segment-label;
51
+ text-anchor: middle;
52
+ dominant-baseline: middle;
53
+ user-select: none;
54
+ `;
55
+ const centralLabel = css `
56
+ label: central-label;
57
+ text-anchor: middle;
58
+ dominant-baseline: middle;
59
+ font-size: var(--vis-nested-donut-central-label-font-size);
60
+ font-family: var(--vis-nested-donut-central-label-font-family, var(--vis-font-family));
61
+ font-weight: var(--vis-nested-donut-central-label-font-weight);
62
+ fill: var(--vis-nested-donut-central-label-text-color);
63
+ `;
64
+ const centralSubLabel = css `
65
+ label: central-sub-label;
66
+ text-anchor: middle;
67
+ dominant-baseline: middle;
68
+ font-size: var(--vis-nested-donut-central-sublabel-font-size);
69
+ font-family: var(--vis-nested-donut-central-sublabel-font-family, var(--vis-font-family));
70
+ font-weight: var(--vis-nested-donut-central-sublabel-font-weight);
71
+ fill: var(--vis-nested-donut-central-sublabel-text-color);
72
+ `;
73
+
74
+ export { background, centralLabel, centralSubLabel, root, segment, segmentArc, segmentExit, segmentLabel, segmentsGroup, variables };
75
+ //# sourceMappingURL=style.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"style.js","sources":["../../../src/components/nested-donut/style.ts"],"sourcesContent":["import { css } from '@emotion/css'\n\n// Utils\nimport { getCssVarNames, injectGlobalCssVariables } from 'utils/style'\n\nconst cssVarDefaults = {\n '--vis-nested-donut-background-color': '#E7E9F3',\n // Undefined by default to allow proper fallback to var(--vis-font-family)\n '--vis-nested-donut-font-family': undefined,\n\n // Central label\n '--vis-nested-donut-central-label-font-size': '16px',\n '--vis-nested-donut-central-label-font-weight': 600,\n '--vis-nested-donut-central-label-text-color': '#5b5f6d',\n\n // Central sub-label\n '--vis-nested-donut-central-sublabel-font-size': '12px;',\n '--vis-nested-donut-central-sublabel-font-weight': 500,\n '--vis-nested-donut-central-sublabel-text-color': '#5b5f6d',\n\n // Segments\n '--vis-nested-donut-segment-stroke-width': '1px',\n '--vis-nested-donut-segment-stroke-color': undefined,\n '--vis-nested-donut-segment-label-text-color-light': '#5b5f6d',\n '--vis-nested-donut-segment-label-text-color-dark': '#fff',\n\n /* Dark theme */\n '--vis-dark-nested-donut-background-color': '#18160C',\n '--vis-dark-nested-donut-central-label-text-color': '#fff',\n '--vis-dark-nested-donut-central-sublabel-text-color': '#fff',\n}\n\nexport const root = css`\n label: nested-donut-component;\n`\n\nexport const segmentsGroup = css`\n label: nested-donut-segments-group;\n`\n\nexport const variables = getCssVarNames(cssVarDefaults)\ninjectGlobalCssVariables(cssVarDefaults, root)\n\nexport const background = css`\n label: background;\n fill: var(--vis-donut-background-color);\n`\n\nexport const segment = css`\n label: segment;\n `\n\nexport const segmentExit = css`\n label: segment-exit;\n`\n\nexport const segmentArc = css`\n label: segment-arc;\n stroke-width: var(--vis-nested-donut-segment-stroke-width);\n stroke: var(--vis-nested-donut-segment-stroke-color, var(--vis-donut-background-color));\n`\n\nexport const segmentLabel = css`\n label: segment-label;\n text-anchor: middle;\n dominant-baseline: middle;\n user-select: none;\n`\n\nexport const centralLabel = css`\n label: central-label;\n text-anchor: middle;\n dominant-baseline: middle;\n font-size: var(--vis-nested-donut-central-label-font-size);\n font-family: var(--vis-nested-donut-central-label-font-family, var(--vis-font-family));\n font-weight: var(--vis-nested-donut-central-label-font-weight);\n fill: var(--vis-nested-donut-central-label-text-color);\n`\n\nexport const centralSubLabel = css`\n label: central-sub-label;\n text-anchor: middle;\n dominant-baseline: middle;\n font-size: var(--vis-nested-donut-central-sublabel-font-size);\n font-family: var(--vis-nested-donut-central-sublabel-font-family, var(--vis-font-family));\n font-weight: var(--vis-nested-donut-central-sublabel-font-weight);\n fill: var(--vis-nested-donut-central-sublabel-text-color);\n`\n"],"names":[],"mappings":";;;AAKA,MAAM,cAAc,GAAG;AACrB,IAAA,qCAAqC,EAAE,SAAS;;AAEhD,IAAA,gCAAgC,EAAE,SAAS;;AAG3C,IAAA,4CAA4C,EAAE,MAAM;AACpD,IAAA,8CAA8C,EAAE,GAAG;AACnD,IAAA,6CAA6C,EAAE,SAAS;;AAGxD,IAAA,+CAA+C,EAAE,OAAO;AACxD,IAAA,iDAAiD,EAAE,GAAG;AACtD,IAAA,gDAAgD,EAAE,SAAS;;AAG3D,IAAA,yCAAyC,EAAE,KAAK;AAChD,IAAA,yCAAyC,EAAE,SAAS;AACpD,IAAA,mDAAmD,EAAE,SAAS;AAC9D,IAAA,kDAAkD,EAAE,MAAM;;AAG1D,IAAA,0CAA0C,EAAE,SAAS;AACrD,IAAA,kDAAkD,EAAE,MAAM;AAC1D,IAAA,qDAAqD,EAAE,MAAM;CAC9D,CAAA;AAEM,MAAM,IAAI,GAAG,GAAG,CAAA,CAAA;;EAEtB;AAEM,MAAM,aAAa,GAAG,GAAG,CAAA,CAAA;;EAE/B;MAEY,SAAS,GAAG,cAAc,CAAC,cAAc,EAAC;AACvD,wBAAwB,CAAC,cAAc,EAAE,IAAI,CAAC,CAAA;AAEvC,MAAM,UAAU,GAAG,GAAG,CAAA,CAAA;;;EAG5B;AAEM,MAAM,OAAO,GAAG,GAAG,CAAA,CAAA;;GAExB;AAEK,MAAM,WAAW,GAAG,GAAG,CAAA,CAAA;;EAE7B;AAEM,MAAM,UAAU,GAAG,GAAG,CAAA,CAAA;;;;EAI5B;AAEM,MAAM,YAAY,GAAG,GAAG,CAAA,CAAA;;;;;EAK9B;AAEM,MAAM,YAAY,GAAG,GAAG,CAAA,CAAA;;;;;;;;EAQ9B;AAEM,MAAM,eAAe,GAAG,GAAG,CAAA,CAAA;;;;;;;;;;;;"}
@@ -0,0 +1,33 @@
1
+ import { HierarchyRectangularNode } from 'd3-hierarchy';
2
+ export declare type NestedDonutSegmentDatum<Datum> = {
3
+ key: string;
4
+ root: string;
5
+ values?: Datum[];
6
+ };
7
+ export declare type NestedDonutSegment<Datum> = HierarchyRectangularNode<NestedDonutSegmentDatum<Datum>> & {
8
+ _id: string;
9
+ _layer: NestedDonutLayer;
10
+ _index?: number;
11
+ _state?: {
12
+ fill?: string;
13
+ };
14
+ };
15
+ export declare enum NestedDonutDirection {
16
+ Inwards = "inwards",
17
+ Outwards = "outwards"
18
+ }
19
+ export declare enum NestedDonutSegmentLabelAlignment {
20
+ Along = "along",
21
+ Perpendicular = "perpendicular",
22
+ Straight = "straight"
23
+ }
24
+ export declare type NestedDonutLayerSettings = {
25
+ labelAlignment?: NestedDonutSegmentLabelAlignment;
26
+ width?: number;
27
+ };
28
+ export declare type NestedDonutLayer = NestedDonutLayerSettings & {
29
+ _id: number;
30
+ _innerRadius: number;
31
+ _outerRadius: number;
32
+ };
33
+ export declare const defaultLayerSettings: NestedDonutLayerSettings;
@@ -0,0 +1,18 @@
1
+ var NestedDonutDirection;
2
+ (function (NestedDonutDirection) {
3
+ NestedDonutDirection["Inwards"] = "inwards";
4
+ NestedDonutDirection["Outwards"] = "outwards";
5
+ })(NestedDonutDirection || (NestedDonutDirection = {}));
6
+ var NestedDonutSegmentLabelAlignment;
7
+ (function (NestedDonutSegmentLabelAlignment) {
8
+ NestedDonutSegmentLabelAlignment["Along"] = "along";
9
+ NestedDonutSegmentLabelAlignment["Perpendicular"] = "perpendicular";
10
+ NestedDonutSegmentLabelAlignment["Straight"] = "straight";
11
+ })(NestedDonutSegmentLabelAlignment || (NestedDonutSegmentLabelAlignment = {}));
12
+ const defaultLayerSettings = {
13
+ labelAlignment: NestedDonutSegmentLabelAlignment.Perpendicular,
14
+ width: 50,
15
+ };
16
+
17
+ export { NestedDonutDirection, NestedDonutSegmentLabelAlignment, defaultLayerSettings };
18
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sources":["../../../src/components/nested-donut/types.ts"],"sourcesContent":["import { HierarchyRectangularNode } from 'd3-hierarchy'\n\nexport type NestedDonutSegmentDatum<Datum> = {\n key: string;\n root: string;\n values?: Datum[];\n}\n\nexport type NestedDonutSegment<Datum> = HierarchyRectangularNode<NestedDonutSegmentDatum<Datum>> & {\n _id: string;\n _layer: NestedDonutLayer;\n _index?: number;\n _state?: {\n fill?: string;\n };\n}\n\nexport enum NestedDonutDirection {\n Inwards = 'inwards',\n Outwards = 'outwards',\n}\n\nexport enum NestedDonutSegmentLabelAlignment {\n Along = 'along',\n Perpendicular = 'perpendicular',\n Straight = 'straight',\n}\n\nexport type NestedDonutLayerSettings = {\n labelAlignment?: NestedDonutSegmentLabelAlignment;\n width?: number;\n}\n\nexport type NestedDonutLayer = NestedDonutLayerSettings & {\n _id: number;\n _innerRadius: number;\n _outerRadius: number;\n}\n\nexport const defaultLayerSettings: NestedDonutLayerSettings = {\n labelAlignment: NestedDonutSegmentLabelAlignment.Perpendicular,\n width: 50,\n}\n\n"],"names":[],"mappings":"IAiBY,qBAGX;AAHD,CAAA,UAAY,oBAAoB,EAAA;AAC9B,IAAA,oBAAA,CAAA,SAAA,CAAA,GAAA,SAAmB,CAAA;AACnB,IAAA,oBAAA,CAAA,UAAA,CAAA,GAAA,UAAqB,CAAA;AACvB,CAAC,EAHW,oBAAoB,KAApB,oBAAoB,GAG/B,EAAA,CAAA,CAAA,CAAA;IAEW,iCAIX;AAJD,CAAA,UAAY,gCAAgC,EAAA;AAC1C,IAAA,gCAAA,CAAA,OAAA,CAAA,GAAA,OAAe,CAAA;AACf,IAAA,gCAAA,CAAA,eAAA,CAAA,GAAA,eAA+B,CAAA;AAC/B,IAAA,gCAAA,CAAA,UAAA,CAAA,GAAA,UAAqB,CAAA;AACvB,CAAC,EAJW,gCAAgC,KAAhC,gCAAgC,GAI3C,EAAA,CAAA,CAAA,CAAA;AAaY,MAAA,oBAAoB,GAA6B;IAC5D,cAAc,EAAE,gCAAgC,CAAC,aAAa;AAC9D,IAAA,KAAK,EAAE,EAAE;;;;;"}
package/components.d.ts CHANGED
@@ -25,6 +25,7 @@ export { VisControls } from './components/vis-controls';
25
25
  export { Donut } from './components/donut';
26
26
  export { FreeBrush } from './components/free-brush';
27
27
  export { XYLabels } from './components/xy-labels';
28
+ export { NestedDonut } from './components/nested-donut';
28
29
  export type { LineConfigInterface } from './components/line/config';
29
30
  export type { StackedBarConfigInterface } from './components/stacked-bar/config';
30
31
  export type { GroupedBarConfigInterface } from './components/grouped-bar/config';
@@ -47,3 +48,4 @@ export type { VisControlsConfigInterface } from './components/vis-controls/confi
47
48
  export type { DonutConfigInterface } from './components/donut/config';
48
49
  export type { FreeBrushConfigInterface } from './components/free-brush/config';
49
50
  export type { XYLabelsConfigInterface } from './components/xy-labels/config';
51
+ export type { NestedDonutConfigInterface } from './components/nested-donut/config';
package/components.js CHANGED
@@ -23,6 +23,7 @@ export { VisControls } from './components/vis-controls/index.js';
23
23
  export { Donut } from './components/donut/index.js';
24
24
  export { FreeBrush } from './components/free-brush/index.js';
25
25
  export { XYLabels } from './components/xy-labels/index.js';
26
+ export { NestedDonut } from './components/nested-donut/index.js';
26
27
 
27
28
  // Core
28
29
  //# sourceMappingURL=components.js.map
package/components.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"components.js","sources":["../src/components.ts"],"sourcesContent":["// Core\nexport { ComponentCore } from 'core/component'\nexport type { ComponentConfigInterface } from 'core/component/config'\nexport { XYComponentCore } from 'core/xy-component'\nexport type { XYComponentConfigInterface } from 'core/xy-component/config'\n\n// Components\nexport { Tooltip } from 'components/tooltip'\nexport { Line } from './components/line'\nexport { StackedBar } from './components/stacked-bar'\nexport { GroupedBar } from './components/grouped-bar'\nexport { Axis } from './components/axis'\nexport { Scatter } from './components/scatter'\nexport { Brush } from './components/brush'\nexport { BulletLegend } from './components/bullet-legend'\nexport { FlowLegend } from './components/flow-legend'\nexport { Crosshair } from './components/crosshair'\nexport { Timeline } from './components/timeline'\nexport { Sankey } from './components/sankey'\nexport { Area } from './components/area'\nexport { TopoJSONMap } from './components/topojson-map'\nexport { LeafletMap } from './components/leaflet-map'\nexport { MapLibreArcticDark, MapLibreArcticLight } from './components/leaflet-map/renderer/map-style'\nexport { LeafletFlowMap } from './components/leaflet-flow-map'\nexport { ChordDiagram } from './components/chord-diagram'\nexport { Graph } from './components/graph'\nexport { VisControls } from './components/vis-controls'\nexport { Donut } from './components/donut'\nexport { FreeBrush } from './components/free-brush'\nexport { XYLabels } from './components/xy-labels'\n\n// Config Interfaces\nexport type { LineConfigInterface } from './components/line/config'\nexport type { StackedBarConfigInterface } from './components/stacked-bar/config'\nexport type { GroupedBarConfigInterface } from './components/grouped-bar/config'\nexport type { ScatterConfigInterface } from './components/scatter/config'\nexport type { TooltipConfigInterface } from './components/tooltip/config'\nexport type { BrushConfigInterface } from './components/brush/config'\nexport type { AxisConfigInterface } from './components/axis/config'\nexport type { BulletLegendConfigInterface } from './components/bullet-legend/config'\nexport type { FlowLegendConfigInterface } from './components/flow-legend/config'\nexport type { CrosshairConfigInterface } from './components/crosshair/config'\nexport type { TimelineConfigInterface } from './components/timeline/config'\nexport type { SankeyConfigInterface } from './components/sankey/config'\nexport type { AreaConfigInterface } from './components/area/config'\nexport type { TopoJSONMapConfigInterface } from './components/topojson-map/config'\nexport type { LeafletMapConfigInterface } from './components/leaflet-map/config'\nexport type { LeafletFlowMapConfigInterface } from './components/leaflet-flow-map/config'\nexport type { ChordDiagramConfigInterface } from './components/chord-diagram/config'\nexport type { GraphConfigInterface } from './components/graph/config'\nexport type { VisControlsConfigInterface } from './components/vis-controls/config'\nexport type { DonutConfigInterface } from './components/donut/config'\nexport type { FreeBrushConfigInterface } from './components/free-brush/config'\nexport type { XYLabelsConfigInterface } from './components/xy-labels/config'\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA"}
1
+ {"version":3,"file":"components.js","sources":["../src/components.ts"],"sourcesContent":["// Core\nexport { ComponentCore } from 'core/component'\nexport type { ComponentConfigInterface } from 'core/component/config'\nexport { XYComponentCore } from 'core/xy-component'\nexport type { XYComponentConfigInterface } from 'core/xy-component/config'\n\n// Components\nexport { Tooltip } from 'components/tooltip'\nexport { Line } from './components/line'\nexport { StackedBar } from './components/stacked-bar'\nexport { GroupedBar } from './components/grouped-bar'\nexport { Axis } from './components/axis'\nexport { Scatter } from './components/scatter'\nexport { Brush } from './components/brush'\nexport { BulletLegend } from './components/bullet-legend'\nexport { FlowLegend } from './components/flow-legend'\nexport { Crosshair } from './components/crosshair'\nexport { Timeline } from './components/timeline'\nexport { Sankey } from './components/sankey'\nexport { Area } from './components/area'\nexport { TopoJSONMap } from './components/topojson-map'\nexport { LeafletMap } from './components/leaflet-map'\nexport { MapLibreArcticDark, MapLibreArcticLight } from './components/leaflet-map/renderer/map-style'\nexport { LeafletFlowMap } from './components/leaflet-flow-map'\nexport { ChordDiagram } from './components/chord-diagram'\nexport { Graph } from './components/graph'\nexport { VisControls } from './components/vis-controls'\nexport { Donut } from './components/donut'\nexport { FreeBrush } from './components/free-brush'\nexport { XYLabels } from './components/xy-labels'\nexport { NestedDonut } from './components/nested-donut'\n\n// Config Interfaces\nexport type { LineConfigInterface } from './components/line/config'\nexport type { StackedBarConfigInterface } from './components/stacked-bar/config'\nexport type { GroupedBarConfigInterface } from './components/grouped-bar/config'\nexport type { ScatterConfigInterface } from './components/scatter/config'\nexport type { TooltipConfigInterface } from './components/tooltip/config'\nexport type { BrushConfigInterface } from './components/brush/config'\nexport type { AxisConfigInterface } from './components/axis/config'\nexport type { BulletLegendConfigInterface } from './components/bullet-legend/config'\nexport type { FlowLegendConfigInterface } from './components/flow-legend/config'\nexport type { CrosshairConfigInterface } from './components/crosshair/config'\nexport type { TimelineConfigInterface } from './components/timeline/config'\nexport type { SankeyConfigInterface } from './components/sankey/config'\nexport type { AreaConfigInterface } from './components/area/config'\nexport type { TopoJSONMapConfigInterface } from './components/topojson-map/config'\nexport type { LeafletMapConfigInterface } from './components/leaflet-map/config'\nexport type { LeafletFlowMapConfigInterface } from './components/leaflet-flow-map/config'\nexport type { ChordDiagramConfigInterface } from './components/chord-diagram/config'\nexport type { GraphConfigInterface } from './components/graph/config'\nexport type { VisControlsConfigInterface } from './components/vis-controls/config'\nexport type { DonutConfigInterface } from './components/donut/config'\nexport type { FreeBrushConfigInterface } from './components/free-brush/config'\nexport type { XYLabelsConfigInterface } from './components/xy-labels/config'\nexport type { NestedDonutConfigInterface } from './components/nested-donut/config'\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA"}
package/index.js CHANGED
@@ -33,6 +33,7 @@ export { VisControls } from './components/vis-controls/index.js';
33
33
  export { Donut } from './components/donut/index.js';
34
34
  export { FreeBrush } from './components/free-brush/index.js';
35
35
  export { XYLabels } from './components/xy-labels/index.js';
36
+ export { NestedDonut } from './components/nested-donut/index.js';
36
37
  export { Curve, CurveType } from './types/curve.js';
37
38
  export { Symbol, SymbolType } from './types/symbol.js';
38
39
  export { Scale, ScaleDimension } from './types/scale.js';
@@ -50,4 +51,5 @@ export { SankeyEnterTransitionType, SankeyExitTransitionType, SankeyLayout, Sank
50
51
  export { VisControlsOrientation } from './components/vis-controls/types.js';
51
52
  export { FreeBrushMode } from './components/free-brush/types.js';
52
53
  export { XYLabelPositioning } from './components/xy-labels/types.js';
54
+ export { NestedDonutDirection, NestedDonutSegmentLabelAlignment, defaultLayerSettings } from './components/nested-donut/types.js';
53
55
  //# sourceMappingURL=index.js.map
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@unovis/ts",
3
3
  "description": "Modular data visualization framework for React, Angular, Svelte, and vanilla TypeScript or JavaScript",
4
- "version": "1.1.2-beta.0",
4
+ "version": "1.1.2-beta.2",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/f5/unovis.git",
package/styles/index.d.ts CHANGED
@@ -2,6 +2,7 @@ import { UnovisText } from "../types/text";
2
2
  export declare const UNOVIS_ICON_FONT_FAMILY_DEFAULT: any;
3
3
  export declare const UNOVIS_FONT_WH_RATIO_DEFAULT: number;
4
4
  export declare const UNOVIS_TEXT_SEPARATOR_DEFAULT: string[];
5
+ export declare const UNOVIS_TEXT_HYPHEN_CHARACTER_DEFAULT: string;
5
6
  export declare const UNOVIS_TEXT_DEFAULT: UnovisText;
6
7
  export declare const variables: void;
7
8
  export declare function getFontWidthToHeightRatio(context?: HTMLElement | SVGGElement | undefined): number;
package/styles/index.js CHANGED
@@ -5,6 +5,7 @@ import { getCSSColorVariable, getLighterColor, colors, getDarkerColor, colorsDar
5
5
  const UNOVIS_ICON_FONT_FAMILY_DEFAULT = (globalThis === null || globalThis === void 0 ? void 0 : globalThis.UNOVIS_ICON_FONT_FAMILY) || 'FontAwesome';
6
6
  const UNOVIS_FONT_WH_RATIO_DEFAULT = (globalThis === null || globalThis === void 0 ? void 0 : globalThis.UNOVIS_FONT_W2H_RATIO_DEFAULT) || 0.5;
7
7
  const UNOVIS_TEXT_SEPARATOR_DEFAULT = (globalThis === null || globalThis === void 0 ? void 0 : globalThis.UNOVIS_TEXT_SEPARATOR_DEFAULT) || [' ', '-', '.', ','];
8
+ const UNOVIS_TEXT_HYPHEN_CHARACTER_DEFAULT = (globalThis === null || globalThis === void 0 ? void 0 : globalThis.UNOVIS_TEXT_HYPHEN_CHARACTER_DEFAULT) || '-';
8
9
  const UNOVIS_TEXT_DEFAULT = (globalThis === null || globalThis === void 0 ? void 0 : globalThis.UNOVIS_TEXT_DEFAULT) || {
9
10
  text: '',
10
11
  fontSize: 12,
@@ -34,5 +35,5 @@ function getFontWidthToHeightRatio(context = window === null || window === void
34
35
  return context ? +getCSSVariableValue('var(--vis-font-wh-ratio)', context) : UNOVIS_FONT_WH_RATIO_DEFAULT;
35
36
  }
36
37
 
37
- export { UNOVIS_FONT_WH_RATIO_DEFAULT, UNOVIS_ICON_FONT_FAMILY_DEFAULT, UNOVIS_TEXT_DEFAULT, UNOVIS_TEXT_SEPARATOR_DEFAULT, getFontWidthToHeightRatio, variables };
38
+ export { UNOVIS_FONT_WH_RATIO_DEFAULT, UNOVIS_ICON_FONT_FAMILY_DEFAULT, UNOVIS_TEXT_DEFAULT, UNOVIS_TEXT_HYPHEN_CHARACTER_DEFAULT, UNOVIS_TEXT_SEPARATOR_DEFAULT, getFontWidthToHeightRatio, variables };
38
39
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/styles/index.ts"],"sourcesContent":["import { injectGlobal } from '@emotion/css'\nimport { getCSSVariableValue } from 'utils/misc'\nimport { UnovisText } from 'types/text'\nimport { colors, colorsDark, getCSSColorVariable, getLighterColor, getDarkerColor } from './colors'\n\nexport const UNOVIS_ICON_FONT_FAMILY_DEFAULT = globalThis?.UNOVIS_ICON_FONT_FAMILY || 'FontAwesome'\nexport const UNOVIS_FONT_WH_RATIO_DEFAULT: number = globalThis?.UNOVIS_FONT_W2H_RATIO_DEFAULT || 0.5\nexport const UNOVIS_TEXT_SEPARATOR_DEFAULT: string[] = globalThis?.UNOVIS_TEXT_SEPARATOR_DEFAULT || [' ', '-', '.', ',']\nexport const UNOVIS_TEXT_DEFAULT: UnovisText = globalThis?.UNOVIS_TEXT_DEFAULT || {\n text: '',\n fontSize: 12,\n fontFamily: 'var(--vis-font-family)',\n lineHeight: 1.25,\n marginTop: 0,\n marginBottom: 0,\n}\n\nexport const variables = injectGlobal`\n :root {\n label: vis-root-styles;\n --vis-font-family: Inter, Arial, \"Helvetica Neue\", Helvetica, sans-serif;\n --vis-font-wh-ratio: ${UNOVIS_FONT_WH_RATIO_DEFAULT};\n --vis-color-main: var(${getCSSColorVariable(0)});\n --vis-color-main-light: ${getLighterColor(colors[0])};\n --vis-color-main-dark: ${getDarkerColor(colors[0])};\n --vis-color-grey: #2a2a2a;\n ${colors.map((c, i) => `${getCSSColorVariable(i)}: ${c};`)}\n ${colorsDark.map((c, i) => `--vis-dark-color${i}: ${c};`)}\n\n body.theme-dark {\n ${colors.map((c, i) => `${getCSSColorVariable(i)}: var(--vis-dark-color${i});`)}\n }\n }\n`\n\nexport function getFontWidthToHeightRatio (context: HTMLElement | SVGGElement | undefined = window?.document.body): number {\n return context ? +getCSSVariableValue('var(--vis-font-wh-ratio)', context) : UNOVIS_FONT_WH_RATIO_DEFAULT\n}\n"],"names":[],"mappings":";;;;AAKO,MAAM,+BAA+B,GAAG,CAAA,UAAU,KAAA,IAAA,IAAV,UAAU,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAV,UAAU,CAAE,uBAAuB,KAAI,cAAa;AAC5F,MAAM,4BAA4B,GAAW,CAAA,UAAU,KAAA,IAAA,IAAV,UAAU,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAV,UAAU,CAAE,6BAA6B,KAAI,IAAG;MACvF,6BAA6B,GAAa,CAAA,UAAU,KAAA,IAAA,IAAV,UAAU,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAV,UAAU,CAAE,6BAA6B,KAAI,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAC;AACjH,MAAM,mBAAmB,GAAe,CAAA,UAAU,KAAV,IAAA,IAAA,UAAU,KAAV,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,UAAU,CAAE,mBAAmB,KAAI;AAChF,IAAA,IAAI,EAAE,EAAE;AACR,IAAA,QAAQ,EAAE,EAAE;AACZ,IAAA,UAAU,EAAE,wBAAwB;AACpC,IAAA,UAAU,EAAE,IAAI;AAChB,IAAA,SAAS,EAAE,CAAC;AACZ,IAAA,YAAY,EAAE,CAAC;EAChB;AAEM,MAAM,SAAS,GAAG,YAAY,CAAA,CAAA;;;;2BAIV,4BAA4B,CAAA;4BAC3B,mBAAmB,CAAC,CAAC,CAAC,CAAA;AACpB,4BAAA,EAAA,eAAe,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAA;AAC3B,2BAAA,EAAA,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAA;;AAEhD,IAAA,EAAA,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAA,EAAG,mBAAmB,CAAC,CAAC,CAAC,CAAK,EAAA,EAAA,CAAC,GAAG,CAAC,CAAA;AACxD,IAAA,EAAA,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAmB,gBAAA,EAAA,CAAC,CAAK,EAAA,EAAA,CAAC,GAAG,CAAC,CAAA;;;AAGrD,MAAA,EAAA,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAA,EAAG,mBAAmB,CAAC,CAAC,CAAC,CAAyB,sBAAA,EAAA,CAAC,IAAI,CAAC,CAAA;;;EAGpF;AAEe,SAAA,yBAAyB,CAAE,OAAA,GAAiD,MAAM,KAAA,IAAA,IAAN,MAAM,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAN,MAAM,CAAE,QAAQ,CAAC,IAAI,EAAA;AAC/G,IAAA,OAAO,OAAO,GAAG,CAAC,mBAAmB,CAAC,0BAA0B,EAAE,OAAO,CAAC,GAAG,4BAA4B,CAAA;AAC3G;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../src/styles/index.ts"],"sourcesContent":["import { injectGlobal } from '@emotion/css'\nimport { getCSSVariableValue } from 'utils/misc'\nimport { UnovisText } from 'types/text'\nimport { colors, colorsDark, getCSSColorVariable, getLighterColor, getDarkerColor } from './colors'\n\nexport const UNOVIS_ICON_FONT_FAMILY_DEFAULT = globalThis?.UNOVIS_ICON_FONT_FAMILY || 'FontAwesome'\nexport const UNOVIS_FONT_WH_RATIO_DEFAULT: number = globalThis?.UNOVIS_FONT_W2H_RATIO_DEFAULT || 0.5\nexport const UNOVIS_TEXT_SEPARATOR_DEFAULT: string[] = globalThis?.UNOVIS_TEXT_SEPARATOR_DEFAULT || [' ', '-', '.', ',']\nexport const UNOVIS_TEXT_HYPHEN_CHARACTER_DEFAULT: string = globalThis?.UNOVIS_TEXT_HYPHEN_CHARACTER_DEFAULT || '-'\nexport const UNOVIS_TEXT_DEFAULT: UnovisText = globalThis?.UNOVIS_TEXT_DEFAULT || {\n text: '',\n fontSize: 12,\n fontFamily: 'var(--vis-font-family)',\n lineHeight: 1.25,\n marginTop: 0,\n marginBottom: 0,\n}\n\nexport const variables = injectGlobal`\n :root {\n label: vis-root-styles;\n --vis-font-family: Inter, Arial, \"Helvetica Neue\", Helvetica, sans-serif;\n --vis-font-wh-ratio: ${UNOVIS_FONT_WH_RATIO_DEFAULT};\n --vis-color-main: var(${getCSSColorVariable(0)});\n --vis-color-main-light: ${getLighterColor(colors[0])};\n --vis-color-main-dark: ${getDarkerColor(colors[0])};\n --vis-color-grey: #2a2a2a;\n ${colors.map((c, i) => `${getCSSColorVariable(i)}: ${c};`)}\n ${colorsDark.map((c, i) => `--vis-dark-color${i}: ${c};`)}\n\n body.theme-dark {\n ${colors.map((c, i) => `${getCSSColorVariable(i)}: var(--vis-dark-color${i});`)}\n }\n }\n`\n\nexport function getFontWidthToHeightRatio (context: HTMLElement | SVGGElement | undefined = window?.document.body): number {\n return context ? +getCSSVariableValue('var(--vis-font-wh-ratio)', context) : UNOVIS_FONT_WH_RATIO_DEFAULT\n}\n"],"names":[],"mappings":";;;;AAKO,MAAM,+BAA+B,GAAG,CAAA,UAAU,KAAA,IAAA,IAAV,UAAU,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAV,UAAU,CAAE,uBAAuB,KAAI,cAAa;AAC5F,MAAM,4BAA4B,GAAW,CAAA,UAAU,KAAA,IAAA,IAAV,UAAU,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAV,UAAU,CAAE,6BAA6B,KAAI,IAAG;MACvF,6BAA6B,GAAa,CAAA,UAAU,KAAA,IAAA,IAAV,UAAU,KAAA,KAAA,CAAA,GAAA,KAAA,CAA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I,CAAC,CAAA;;;EAGpF;AAEe,SAAA,yBAAyB,CAAE,OAAA,GAAiD,MAAM,KAAA,IAAA,IAAN,MAAM,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAN,MAAM,CAAE,QAAQ,CAAC,IAAI,EAAA;AAC/G,IAAA,OAAO,OAAO,GAAG,CAAC,mBAAmB,CAAC,0BAA0B,EAAE,OAAO,CAAC,GAAG,4BAA4B,CAAA;AAC3G;;;;"}
package/types.d.ts CHANGED
@@ -24,3 +24,4 @@ export * from "./components/vis-controls/types";
24
24
  export * from "./components/free-brush/types";
25
25
  export * from "./components/bullet-legend/types";
26
26
  export * from "./components/xy-labels/types";
27
+ export * from "./components/nested-donut/types";
package/types.js CHANGED
@@ -24,6 +24,7 @@ export { VisControlsOrientation } from './components/vis-controls/types.js';
24
24
  export { FreeBrushMode } from './components/free-brush/types.js';
25
25
  import './components/bullet-legend/types.js';
26
26
  export { XYLabelPositioning } from './components/xy-labels/types.js';
27
+ export { NestedDonutDirection, NestedDonutSegmentLabelAlignment, defaultLayerSettings } from './components/nested-donut/types.js';
27
28
 
28
29
  /* eslint-disable max-len */
29
30
  //# sourceMappingURL=types.js.map
package/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sources":["../src/types.ts"],"sourcesContent":["/* eslint-disable max-len */\n// Global Types\nexport * from 'types/accessor'\nexport * from 'types/curve'\nexport * from 'types/symbol'\nexport * from 'types/scale'\nexport * from 'types/position'\nexport * from 'types/shape'\nexport * from 'types/component'\nexport * from 'types/text'\nexport * from 'types/map'\nexport * from 'types/spacing'\nexport * from 'types/graph'\nexport * from 'types/data'\nexport * from 'types/direction'\n\n// Component Types\nexport * from 'core/component/types'\nexport * from 'components/crosshair/types'\nexport * from 'components/axis/types'\nexport * from 'components/chord-diagram/types'\nexport * from 'components/topojson-map/types'\nexport * from 'components/leaflet-map/types'\nexport * from 'components/leaflet-map/renderer/map-style'\nexport * from 'components/graph/types'\nexport * from 'components/sankey/types'\nexport * from 'components/vis-controls/types'\nexport * from 'components/free-brush/types'\nexport * from 'components/bullet-legend/types'\nexport * from 'components/xy-labels/types'\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA"}
1
+ {"version":3,"file":"types.js","sources":["../src/types.ts"],"sourcesContent":["/* eslint-disable max-len */\n// Global Types\nexport * from 'types/accessor'\nexport * from 'types/curve'\nexport * from 'types/symbol'\nexport * from 'types/scale'\nexport * from 'types/position'\nexport * from 'types/shape'\nexport * from 'types/component'\nexport * from 'types/text'\nexport * from 'types/map'\nexport * from 'types/spacing'\nexport * from 'types/graph'\nexport * from 'types/data'\nexport * from 'types/direction'\n\n// Component Types\nexport * from 'core/component/types'\nexport * from 'components/crosshair/types'\nexport * from 'components/axis/types'\nexport * from 'components/chord-diagram/types'\nexport * from 'components/topojson-map/types'\nexport * from 'components/leaflet-map/types'\nexport * from 'components/leaflet-map/renderer/map-style'\nexport * from 'components/graph/types'\nexport * from 'components/sankey/types'\nexport * from 'components/vis-controls/types'\nexport * from 'components/free-brush/types'\nexport * from 'components/bullet-legend/types'\nexport * from 'components/xy-labels/types'\nexport * from 'components/nested-donut/types'\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA"}
package/utils/style.d.ts CHANGED
@@ -2,5 +2,5 @@ import type { KebabToCamelCase, RemovePrefix } from "./type";
2
2
  export declare function getCssVarNames<T extends Record<string, unknown>, Prefix extends string = '--vis-'>(cssVarsObject: T, prefix?: Prefix): {
3
3
  [Property in Extract<keyof T, string> as KebabToCamelCase<RemovePrefix<Property, Prefix>>]: Property;
4
4
  };
5
- export declare function injectGlobalCssVariables<T extends Record<string, string | undefined>>(cssVarsObject: T, componentRootClassName: string): void;
5
+ export declare function injectGlobalCssVariables<T extends Record<string, string | number | undefined>>(cssVarsObject: T, componentRootClassName: string): void;
6
6
  export declare function cssvar<T extends string>(name: T): `var(${T})`;
@@ -1 +1 @@
1
- {"version":3,"file":"style.js","sources":["../../src/utils/style.ts"],"sourcesContent":["import { injectGlobal } from '@emotion/css'\n\nimport { kebabCaseToCamel } from 'utils/text'\nimport type { KebabToCamelCase, RemovePrefix } from 'utils/type'\n\nexport function getCssVarNames<\n T extends Record<string, unknown>,\n Prefix extends string = '--vis-',\n> (cssVarsObject: T, prefix?: Prefix): {\n [Property in Extract<keyof T, string> as KebabToCamelCase<RemovePrefix<Property, Prefix>>]: Property\n} {\n const defaultPrefix = '--vis-'\n const entries = Object.entries(cssVarsObject)\n return Object.fromEntries(\n entries.map(([key]) => [kebabCaseToCamel(key.replace(prefix ?? defaultPrefix, '')), key])\n ) as {\n [Property in Extract<keyof T, string> as KebabToCamelCase<RemovePrefix<Property, Prefix>>]: Property\n }\n}\n\nexport function injectGlobalCssVariables<T extends Record<string, string | undefined>> (\n cssVarsObject: T,\n componentRootClassName: string\n): void {\n injectGlobal({\n ':root': cssVarsObject,\n [`body.theme-dark .${componentRootClassName}`]: Object.keys(cssVarsObject)\n .filter(key => key.includes('--vis-dark'))\n .map(key => ({\n [key.replace('--vis-dark', '--vis')]: `var(${key})`,\n })),\n })\n}\n\nexport function cssvar<T extends string> (name: T): `var(${T})` {\n return `var(${name})` as `var(${T})`\n}\n"],"names":[],"mappings":";;;AAKgB,SAAA,cAAc,CAG3B,aAAgB,EAAE,MAAe,EAAA;IAGlC,MAAM,aAAa,GAAG,QAAQ,CAAA;IAC9B,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,CAAA;AAC7C,IAAA,OAAO,MAAM,CAAC,WAAW,CACvB,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,gBAAgB,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,KAAA,IAAA,IAAN,MAAM,KAAA,KAAA,CAAA,GAAN,MAAM,GAAI,aAAa,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAG1F,CAAA;AACH,CAAC;AAEe,SAAA,wBAAwB,CACtC,aAAgB,EAChB,sBAA8B,EAAA;AAE9B,IAAA,YAAY,CAAC;AACX,QAAA,OAAO,EAAE,aAAa;QACtB,CAAC,CAAA,iBAAA,EAAoB,sBAAsB,CAAA,CAAE,GAAG,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC;aACvE,MAAM,CAAC,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;AACzC,aAAA,GAAG,CAAC,GAAG,KAAK;AACX,YAAA,CAAC,GAAG,CAAC,OAAO,CAAC,YAAY,EAAE,OAAO,CAAC,GAAG,CAAO,IAAA,EAAA,GAAG,CAAG,CAAA,CAAA;AACpD,SAAA,CAAC,CAAC;AACN,KAAA,CAAC,CAAA;AACJ,CAAC;AAEK,SAAU,MAAM,CAAoB,IAAO,EAAA;IAC/C,OAAO,CAAA,IAAA,EAAO,IAAI,CAAA,CAAA,CAAkB,CAAA;AACtC;;;;"}
1
+ {"version":3,"file":"style.js","sources":["../../src/utils/style.ts"],"sourcesContent":["import { injectGlobal } from '@emotion/css'\n\nimport { kebabCaseToCamel } from 'utils/text'\nimport type { KebabToCamelCase, RemovePrefix } from 'utils/type'\n\nexport function getCssVarNames<\n T extends Record<string, unknown>,\n Prefix extends string = '--vis-',\n> (cssVarsObject: T, prefix?: Prefix): {\n [Property in Extract<keyof T, string> as KebabToCamelCase<RemovePrefix<Property, Prefix>>]: Property\n} {\n const defaultPrefix = '--vis-'\n const entries = Object.entries(cssVarsObject)\n return Object.fromEntries(\n entries.map(([key]) => [kebabCaseToCamel(key.replace(prefix ?? defaultPrefix, '')), key])\n ) as {\n [Property in Extract<keyof T, string> as KebabToCamelCase<RemovePrefix<Property, Prefix>>]: Property\n }\n}\n\nexport function injectGlobalCssVariables<T extends Record<string, string | number | undefined>> (\n cssVarsObject: T,\n componentRootClassName: string\n): void {\n injectGlobal({\n ':root': cssVarsObject,\n [`body.theme-dark .${componentRootClassName}`]: Object.keys(cssVarsObject)\n .filter(key => key.includes('--vis-dark'))\n .map(key => ({\n [key.replace('--vis-dark', '--vis')]: `var(${key})`,\n })),\n })\n}\n\nexport function cssvar<T extends string> (name: T): `var(${T})` {\n return `var(${name})` as `var(${T})`\n}\n"],"names":[],"mappings":";;;AAKgB,SAAA,cAAc,CAG3B,aAAgB,EAAE,MAAe,EAAA;IAGlC,MAAM,aAAa,GAAG,QAAQ,CAAA;IAC9B,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,CAAA;AAC7C,IAAA,OAAO,MAAM,CAAC,WAAW,CACvB,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,gBAAgB,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,KAAA,IAAA,IAAN,MAAM,KAAA,KAAA,CAAA,GAAN,MAAM,GAAI,aAAa,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAG1F,CAAA;AACH,CAAC;AAEe,SAAA,wBAAwB,CACtC,aAAgB,EAChB,sBAA8B,EAAA;AAE9B,IAAA,YAAY,CAAC;AACX,QAAA,OAAO,EAAE,aAAa;QACtB,CAAC,CAAA,iBAAA,EAAoB,sBAAsB,CAAA,CAAE,GAAG,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC;aACvE,MAAM,CAAC,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;AACzC,aAAA,GAAG,CAAC,GAAG,KAAK;AACX,YAAA,CAAC,GAAG,CAAC,OAAO,CAAC,YAAY,EAAE,OAAO,CAAC,GAAG,CAAO,IAAA,EAAA,GAAG,CAAG,CAAA,CAAA;AACpD,SAAA,CAAC,CAAC;AACN,KAAA,CAAC,CAAA;AACJ,CAAC;AAEK,SAAU,MAAM,CAAoB,IAAO,EAAA;IAC/C,OAAO,CAAA,IAAA,EAAO,IAAI,CAAA,CAAA,CAAkB,CAAA;AACtC;;;;"}
package/utils/text.js CHANGED
@@ -2,7 +2,7 @@ import { sum } from 'd3-array';
2
2
  import { TrimMode, VerticalAlign, TextAlign } from '../types/text.js';
3
3
  import { flatten, isArray, merge } from './data.js';
4
4
  import { getTextAnchorFromTextAlign } from '../types/svg.js';
5
- import { getFontWidthToHeightRatio, UNOVIS_TEXT_SEPARATOR_DEFAULT, UNOVIS_TEXT_DEFAULT } from '../styles/index.js';
5
+ import { getFontWidthToHeightRatio, UNOVIS_TEXT_HYPHEN_CHARACTER_DEFAULT, UNOVIS_TEXT_SEPARATOR_DEFAULT, UNOVIS_TEXT_DEFAULT } from '../styles/index.js';
6
6
 
7
7
  /**
8
8
  * Converts a kebab-case string to camelCase.
@@ -251,7 +251,7 @@ function breakTextIntoLines(textBlock, width = undefined, fastMode = true, separ
251
251
  if (subLineLengthPx > width) {
252
252
  let breakIndex = (line.trim()).length - 2; // Place at least 2 characters onto the next line
253
253
  while (breakIndex > 0) {
254
- const subLine = `${line.substring(0, breakIndex)}-`; // Use hyphen when force breaking words
254
+ const subLine = `${line.substring(0, breakIndex)}${UNOVIS_TEXT_HYPHEN_CHARACTER_DEFAULT}`; // Use hyphen when force breaking words
255
255
  const subLinePx = fastMode
256
256
  ? estimateStringPixelLength(subLine, textBlock.fontSize, textBlock.fontWidthToHeightRatio)
257
257
  : getPreciseStringLengthPx(subLine, textBlock.fontFamily, textBlock.fontSize);
@@ -303,14 +303,20 @@ function getWrappedText(text, width = undefined, height = undefined, fastMode =
303
303
  const dh = text.fontSize * text.lineHeight;
304
304
  // Iterate over lines and handle text overflow based on the height limit if provided
305
305
  for (let k = 0; k < lines.length; k += 1) {
306
- const line = lines[k];
306
+ let line = lines[k];
307
307
  h += dh;
308
308
  if (height && (h + dh) > height && (k !== lines.length - 1)) {
309
+ // Remove hyphen character from the end of the line if it's there
310
+ const lastCharacter = line.charAt(line.length - 1);
311
+ if (lastCharacter === UNOVIS_TEXT_HYPHEN_CHARACTER_DEFAULT) {
312
+ line = line.substr(0, lines[k].length - 1);
313
+ }
314
+ const lineWithEllipsis = `${line} …`;
309
315
  const textLengthPx = fastMode
310
- ? estimateStringPixelLength(line, text.fontSize, text.fontWidthToHeightRatio)
311
- : getPreciseStringLengthPx(line, text.fontFamily, text.fontSize);
316
+ ? estimateStringPixelLength(lineWithEllipsis, text.fontSize, text.fontWidthToHeightRatio)
317
+ : getPreciseStringLengthPx(lineWithEllipsis, text.fontFamily, text.fontSize);
312
318
  if (textLengthPx < width) {
313
- lines[k] += ' …';
319
+ lines[k] = lineWithEllipsis;
314
320
  }
315
321
  else {
316
322
  lines[k] = `${lines[k].substr(0, lines[k].length - 2)}…`;
package/utils/text.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"text.js","sources":["../../src/utils/text.ts"],"sourcesContent":["import { Selection } from 'd3-selection'\nimport { sum } from 'd3-array'\n\n// Types\nimport { TextAlign, TrimMode, UnovisText, UnovisTextFrameOptions, UnovisTextOptions, UnovisWrappedText, VerticalAlign } from 'types/text'\n\n// Utils\nimport { flatten, isArray, merge } from 'utils/data'\nimport { getTextAnchorFromTextAlign } from 'types/svg'\n\n// Styles\nimport { getFontWidthToHeightRatio, UNOVIS_TEXT_DEFAULT, UNOVIS_TEXT_SEPARATOR_DEFAULT } from 'styles/index'\n\n/**\n * Converts a kebab-case string to camelCase.\n *\n * @param {string} str - The kebab-case string to be converted.\n * @returns {string} The resulting camelCase string.\n */\nexport function kebabCaseToCamel (str: string): string {\n return str.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase())\n}\n\n/**\n * Converts a given string to kebab-case.\n * @param {string} str - The input string to be converted to kebab-case.\n * @returns {string} - The kebab-cased string.\n */\nexport function kebabCase (str: string): string {\n return str.match(/[A-Z]{2,}(?=[A-Z][a-z0-9]*|\\b)|[A-Z]?[a-z0-9]*|[A-Z]|[0-9]+/g)\n ?.filter(Boolean)\n .map(x => x.toLowerCase())\n .join('-')\n}\n\n/**\n * Trims the input string from the start, leaving only the specified maximum length.\n * @param {string} [str=''] - The input string to be trimmed.\n * @param {number} [maxLength=15] - The maximum allowed length of the trimmed string.\n * @returns {string} - The trimmed string.\n */\nexport function trimStringStart (str = '', maxLength = 15): string {\n return str.length > maxLength ? `…${str.substr(str.length - maxLength, maxLength)}` : str\n}\n\n/**\n * Trims the input string from the middle, leaving only the specified maximum length.\n * @param {string} [str=''] - The input string to be trimmed.\n * @param {number} [maxLength=15] - The maximum allowed length of the trimmed string.\n * @returns {string} - The trimmed string.\n */\nexport function trimStringMiddle (str = '', maxLength = 15): string {\n const dist = Math.floor((maxLength - 3) / 2)\n return str.length > maxLength ? `${str.substr(0, dist)}…${str.substr(-dist, dist)}` : str\n}\n\n/**\n * Trims the input string from the end, leaving only the specified maximum length.\n * @param {string} [str=''] - The input string to be trimmed.\n * @param {number} [maxLength=15] - The maximum allowed length of the trimmed string.\n * @returns {string} - The trimmed string.\n */\nexport function trimStringEnd (str = '', maxLength = 15): string {\n return str.length > maxLength ? `${str.substr(0, maxLength)}…` : str\n}\n\n/**\n * Trims the input string according to the specified trim mode.\n * @param {string} [str=''] - The input string to be trimmed.\n * @param {number} [length=15] - The maximum allowed length of the trimmed string.\n * @param {TrimMode} [type=TrimMode.Middle] - The trim mode to be applied.\n * @returns {string} - The trimmed string.\n */\nexport function trimString (str = '', length = 15, type = TrimMode.Middle): string {\n let result = trimStringEnd(str, length)\n if (type === TrimMode.Start) result = trimStringStart(str, length)\n else if (type === TrimMode.Middle) result = trimStringMiddle(str, length)\n return result\n}\n\n/**\n * Splits the input string according to the specified separators.\n * @param {string} text - The input string to be split.\n * @param {string[]} [separators=[' ']] - The array of separators to be used for splitting.\n * @returns {string[]} - The array of split words.\n */\nexport function splitString (text: string, separators = [' ']): string[] {\n let result = [text] as any[]\n for (let i = 0; i < separators.length; i++) {\n const sep = separators[i]\n result.forEach((d, id) => {\n const separated = d.split(sep)\n const words = separated.map((word, j) => `${word}${j === separated.length - 1 ? '' : sep}`)\n result[id] = words\n })\n result = flatten(result)\n }\n\n return result\n}\n\n/**\n * Wraps an SVG text element to fit within the specified width.\n * @param {Selection<SVGTextElement, any, SVGElement, any>} textElement - The SVG text element to be wrapped.\n * @param {number} width - The maximum allowed width for the text element.\n * @param {(string | string[])} [separator=[' ', '-', '.', ',']] - The separator(s) to be used for wrapping.\n */\nexport function wrapSVGText (\n textElement: Selection<SVGTextElement, any, SVGElement, any>,\n width: number,\n separator: string | string[] = [' ', '-', '.', ',']\n): void {\n const text = textElement.text()\n if (!text) return\n\n // Wrap\n const separators = (isArray(separator) ? separator : [separator]) as string[]\n const words = splitString(text, separators)\n const x = parseFloat(textElement.attr('x')) || 0\n\n textElement.text('')\n let tspan = textElement.append('tspan').attr('x', x)\n let tspanContent = `${words[0]}`\n tspan.text(tspanContent)\n\n words.forEach((word, i) => {\n if (i === 0) return\n\n const tspanText = `${tspanContent}${word}`\n tspan.text(tspanText)\n const tspanWidth = tspan.node().getComputedTextLength()\n if (tspanWidth > width) {\n tspan.text(tspanContent.trim())\n\n tspan = textElement.append('tspan')\n .attr('x', x)\n .attr('dy', '1.2em')\n .text(word)\n\n tspanContent = word\n } else tspanContent += word\n })\n}\n\n/**\n * Trims an SVG text element based on the specified max width, trim type, and other options.\n * @param {Selection<SVGTextElement, any, SVGElement, any>} svgTextSelection - The D3 selection of the SVG text element to be trimmed.\n * @param {number} [maxWidth=50] - The maximum width of the text element.\n * @param {TrimMode} [trimType=TrimMode.Middle] - The type of trim (start, middle, or end).\n * @param {boolean} [fastMode=true] - Whether to use a fast estimation method for text length calculation.\n * @param {number} [fontSize=0] - The font size of the text.\n * @param {number} [fontWidthToHeightRatio=getFontWidthToHeightRatio()] - The font width to height ratio.\n * @returns {boolean} True if the text was trimmed, false otherwise.\n */\nexport function trimSVGText (\n svgTextSelection: Selection<SVGTextElement, any, SVGElement, any>,\n maxWidth = 50,\n trimType = TrimMode.Middle,\n fastMode = true,\n fontSize = +window.getComputedStyle(svgTextSelection.node())?.fontSize || 0,\n fontWidthToHeightRatio = getFontWidthToHeightRatio()\n): boolean {\n const text = svgTextSelection.text()\n const textLength = text.length\n\n const textWidth = fastMode ? fontSize * textLength * fontWidthToHeightRatio : svgTextSelection.node().getComputedTextLength()\n const tolerance = 1.1\n const maxCharacters = Math.ceil(textLength * maxWidth / (tolerance * textWidth))\n if (maxCharacters < textLength) {\n svgTextSelection.text(trimString(text, maxCharacters, trimType))\n return true\n }\n\n return false\n}\n\n/**\n * Estimates the length of a string in pixels.\n * @param {string} str - The string to be measured.\n * @param {number} fontSize - The font size of the string.\n * @param {number} [fontWidthToHeightRatio=getFontWidthToHeightRatio()] - The font width to height ratio.\n * @returns {number} The estimated length of the string in pixels.\n */\nexport function estimateStringPixelLength (\n str: string,\n fontSize: number,\n fontWidthToHeightRatio = getFontWidthToHeightRatio()\n): number {\n return str.length * fontSize * fontWidthToHeightRatio || 0\n}\n\n/**\n * Calculates the precise length of a string in pixels.\n * @param {string} str - The string to be measured.\n * @param {string} [fontFamily] - The font family of the string.\n * @param {(string | number)} [fontSize] - The font size of the string.\n * @returns {number} The precise length of the string in pixels.\n */\nexport function getPreciseStringLengthPx (str: string, fontFamily?: string, fontSize?: string | number): number {\n const svgNS = 'http://www.w3.org/2000/svg'\n const svg = document.createElementNS(svgNS, 'svg')\n const text = document.createElementNS(svgNS, 'text')\n\n text.textContent = str\n text.setAttribute('font-size', `${fontSize}`)\n text.setAttribute('font-family', fontFamily)\n\n svg.appendChild(text)\n document.body.appendChild(svg)\n const length = text.getComputedTextLength()\n document.body.removeChild(svg)\n\n return length\n}\n\n/**\n * Estimates the dimensions of an SVG text element.\n *\n * @export\n * @param {Selection<SVGTextElement, any, SVGElement, any>} svgTextSelection - The D3 selection of the SVG text element.\n * @param {number} fontSize - The font size.\n * @param {number} [dy=0.32] - The line height scaling factor.\n * @param {boolean} [fastMode=true] - Whether to use a fast estimation method or a more accurate one.\n * @param {number} [fontWidthToHeightRatio] - The font width-to-height ratio.\n * @returns {{width: number, height: number}} - The estimated dimensions of the text element.\n */\nexport function estimateTextSize (\n svgTextSelection: Selection<SVGTextElement, any, SVGElement, any>,\n fontSize: number,\n dy = 0.32,\n fastMode = true,\n fontWidthToHeightRatio?: number\n): { width: number; height: number } {\n fontWidthToHeightRatio = fontWidthToHeightRatio || getFontWidthToHeightRatio()\n const tspanSelection = svgTextSelection.selectAll('tspan')\n\n const lines = tspanSelection.size() || 1\n const height = svgTextSelection.text() ? 0.85 * fontSize * lines * (1 + dy) - dy : 0\n\n let width = 0\n if (tspanSelection.empty()) {\n const textLength = svgTextSelection.text().length\n width = fastMode ? fontSize * textLength * fontWidthToHeightRatio : svgTextSelection.node().getComputedTextLength()\n } else {\n for (const tspan of tspanSelection.nodes()) {\n const tspanTextLength = (tspan as SVGTSpanElement).textContent.length\n const w = fastMode ? fontSize * tspanTextLength * fontWidthToHeightRatio : (tspan as SVGTSpanElement).getComputedTextLength()\n if (w > width) width = w\n }\n }\n\n return { width, height }\n}\n\n/**\n * Breaks a text block into lines based on the specified width.\n *\n * @param {UnovisText} textBlock - The text block to break into lines.\n * @param {number | undefined} [width=undefined] - The maximum width of a line in pixels.\n * @param {(number | undefined)} [height=undefined] - The height limit for the wrapped text in pixels.\n * @param {boolean} [fastMode=true] - Whether to use a fast estimation method or a more accurate one.\n * @param {string | string[]} [separator] - The word separators.\n * @returns {string[]} - The text split into lines.\n */\nfunction breakTextIntoLines (\n textBlock: UnovisText,\n width: number | undefined = undefined,\n fastMode = true,\n separator: string | string[] = UNOVIS_TEXT_SEPARATOR_DEFAULT,\n wordBreak = false\n): string[] {\n const text = `${textBlock.text}`\n if (!text) return []\n const separators = Array.isArray(separator) ? separator : [separator]\n\n const splitByNewLine = text.split('\\n')\n return splitByNewLine.map((str) => {\n const lines: string[] = []\n if (!width) return [str]\n\n const words = splitString(str, separators)\n let line = ''\n for (let i = 0; i < words.length; i += 1) {\n const textLengthPx = fastMode\n ? estimateStringPixelLength(line + words[i], textBlock.fontSize, textBlock.fontWidthToHeightRatio)\n : getPreciseStringLengthPx(line + words[i], textBlock.fontFamily, textBlock.fontSize)\n\n if (textLengthPx < width || i === 0) {\n line += words[i]\n } else {\n lines.push(line.trim())\n line = words[i]\n }\n\n // Word break functionality\n if (wordBreak) {\n while (line.length > 0) {\n const subLineLengthPx = fastMode\n ? estimateStringPixelLength(line, textBlock.fontSize, textBlock.fontWidthToHeightRatio)\n : getPreciseStringLengthPx(line, textBlock.fontFamily, textBlock.fontSize)\n\n if (subLineLengthPx > width) {\n let breakIndex = (line.trim()).length - 2 // Place at least 2 characters onto the next line\n while (breakIndex > 0) {\n const subLine = `${line.substring(0, breakIndex)}-` // Use hyphen when force breaking words\n const subLinePx = fastMode\n ? estimateStringPixelLength(subLine, textBlock.fontSize, textBlock.fontWidthToHeightRatio)\n : getPreciseStringLengthPx(subLine, textBlock.fontFamily, textBlock.fontSize)\n\n if (subLinePx <= width) {\n lines.push(subLine.trim())\n line = line.substring(breakIndex)\n break\n }\n breakIndex--\n }\n } else {\n break\n }\n }\n }\n\n if (i === words.length - 1) lines.push(line.trim())\n }\n\n return lines\n }).flat()\n}\n\n/**\n * Wraps a text or array of texts to fit within specified width and height, if provided.\n *\n * @export\n * @param {UnovisText | UnovisText[]} text - The text or array of texts to wrap.\n * @param {number | undefined} [width=undefined] - The maximum width of a line in pixels.\n * @param {boolean} [fastMode=true] - Whether to use a fast estimation method or a more accurate one.\n * @param {string | string[]} [separator] - The word separators.\n * @returns {UnovisWrappedText[]} - The wrapped texts.\n */\nexport function getWrappedText (\n text: UnovisText | UnovisText[],\n width: number | undefined = undefined,\n height: number | undefined = undefined,\n fastMode = true,\n separator: string | string[] = UNOVIS_TEXT_SEPARATOR_DEFAULT,\n wordBreak = false\n): UnovisWrappedText[] {\n // Merge input text with default values and convert it to an array if it's not already\n const textArrays = Array.isArray(text) ? text.map(t => merge(UNOVIS_TEXT_DEFAULT, t)) : [merge(UNOVIS_TEXT_DEFAULT, text)]\n\n // Break input text into lines based on width and separator\n const textWrapped: Array<string[]> = textArrays.map(block => breakTextIntoLines(block, width, fastMode, separator, wordBreak))\n\n const firstBlock = textArrays[0]\n let h = -firstBlock.fontSize * (firstBlock.lineHeight - 1)\n const blocks: UnovisWrappedText[] = []\n\n // Process each text block and its lines based on height limit\n textArrays.forEach((text, i) => {\n let lines = textWrapped[i]\n\n const prevBlock = i > 0 ? blocks[i - 1] : undefined\n const prevBlockMarginBottomPx = prevBlock ? prevBlock.marginBottom : 0\n const marginTopPx = text.marginTop\n const effectiveMarginPx = Math.max(prevBlockMarginBottomPx, marginTopPx)\n\n h += effectiveMarginPx\n const dh = text.fontSize * text.lineHeight\n // Iterate over lines and handle text overflow based on the height limit if provided\n for (let k = 0; k < lines.length; k += 1) {\n const line = lines[k]\n h += dh\n\n if (height && (h + dh) > height && (k !== lines.length - 1)) {\n const textLengthPx = fastMode\n ? estimateStringPixelLength(line, text.fontSize, text.fontWidthToHeightRatio)\n : getPreciseStringLengthPx(line, text.fontFamily, text.fontSize)\n\n if (textLengthPx < width) {\n lines[k] += ' …'\n } else {\n lines[k] = `${lines[k].substr(0, lines[k].length - 2)}…`\n }\n\n lines = lines.slice(0, k + 1)\n break\n }\n }\n\n // Create wrapped text block with its calculated properties\n blocks.push({ ...text, _lines: lines, _estimatedHeight: h - (prevBlock?._estimatedHeight || 0) })\n })\n\n return blocks\n}\n\n\n/**\n * Renders a text or array of texts to SVG tspan strings.\n *\n * @param {UnovisWrappedText[]} blocks - The wrapped text blocks.\n * @param {number} [x=0] - The x-coordinate for the tspan elements.\n * @param {number} [y] - The y-coordinate for the tspan elements.\n * @returns {string[]} - The SVG tspan strings.\n */\nfunction renderTextToTspanStrings (blocks: UnovisWrappedText[], x = 0, y?: number): string[] {\n return blocks.map((b, i) => {\n const prevBlock = i > 0 ? blocks[i - 1] : undefined\n const prevBlockMarginBottomEm = prevBlock ? prevBlock.marginBottom / prevBlock.fontSize : 0\n const marginTopEm = b.marginTop / b.fontSize\n const marginEm = Math.max(prevBlockMarginBottomEm, marginTopEm)\n const attributes = {\n fontSize: b.fontSize,\n fontFamily: b.fontFamily,\n fill: b.color,\n y: (i === 0) && y,\n }\n\n const attributesString = Object.entries(attributes)\n .filter(([_, value]) => value)\n .map(([key, value]) => `${kebabCase(key)}=\"${escape(value.toString())}\"`)\n .join(' ')\n\n return `<tspan xmlns=\"http://www.w3.org/2000/svg\" ${attributesString}>${b._lines.map((line, k) => {\n let dy: number\n if (i === 0 && k === 0) dy = 0.8 + marginEm\n else if (k === 0) dy = marginEm + b.lineHeight\n else dy = b.lineHeight\n\n return `<tspan x=\"${x}\" dy=\"${dy}em\">${line.length ? line : ' '}</tspan>`\n }).join('')}</tspan>`\n })\n}\n\n/**\n * Estimates the height of wrapped text blocks.\n *\n * @export\n * @param {UnovisWrappedText[]} blocks - The wrapped text blocks.\n * @returns {number} - The estimated height of the wrapped text blocks.\n */\nexport function estimateWrappedTextHeight (blocks: UnovisWrappedText[]): number {\n return sum(blocks, b => b._estimatedHeight)\n}\n\n/**\n * Renders a text or array of texts to an SVG text element.\n * Calling this function will replace the contents of the specified SVG text element.\n *\n * @export\n * @param {SVGTextElement} textElement - The SVG text element to render the text into.\n * @param {UnovisText | UnovisText[]} text - The text or array of texts to render.\n * @param {UnovisTextOptions} options - The text options.\n */\nexport function renderTextToSvgTextElement (\n textElement: SVGTextElement,\n text: UnovisText | UnovisText[],\n options: UnovisTextOptions\n): void {\n const wrappedText = getWrappedText(text, options.width, undefined, options.fastMode, options.separator, options.wordBreak)\n const textElementX = +textElement.getAttribute('x')\n const textElementY = +textElement.getAttribute('y')\n const x = textElementX ?? 0\n let y = textElementY ?? 0\n if (options.textAlign) textElement.setAttribute('text-anchor', getTextAnchorFromTextAlign(options.textAlign))\n if (options.verticalAlign && options.verticalAlign !== VerticalAlign.Top) {\n const height = estimateWrappedTextHeight(wrappedText)\n const dy = options.verticalAlign === VerticalAlign.Middle ? -height / 2\n : options.verticalAlign === VerticalAlign.Bottom ? -height : 0\n\n y += dy\n }\n\n const parser = new DOMParser()\n textElement.textContent = ''\n wrappedText.forEach(block => {\n const svgCode = renderTextToTspanStrings([block], x, y).join('')\n const parsedSvgCode = parser.parseFromString(svgCode, 'image/svg+xml').firstChild\n textElement.appendChild(parsedSvgCode)\n })\n}\n\n/**\n * Renders a text or array of texts into a frame.\n * Calling this function will replace the contents of the specified SVG group.\n *\n * @export\n * @param {SVGGElement} group - The SVG group element to render the text into.\n * @param {UnovisText | UnovisText[]} text - The text or array of texts to render.\n * @param {UnovisTextFrameOptions} frameOptions - The text frame options.\n */\nexport function renderTextIntoFrame (\n group: SVGGElement,\n text: UnovisText | UnovisText[],\n frameOptions: UnovisTextFrameOptions\n): void {\n const wrappedText = getWrappedText(text, frameOptions.width, frameOptions.height, frameOptions.fastMode, frameOptions.separator, frameOptions.wordBreak)\n\n const x = frameOptions.textAlign === TextAlign.Center ? frameOptions.width / 2\n : frameOptions.textAlign === TextAlign.Right ? frameOptions.width : 0\n\n let y = 0\n const height = estimateWrappedTextHeight(wrappedText)\n if (frameOptions.height && height < frameOptions.height) {\n const height = estimateWrappedTextHeight(wrappedText)\n const dh = frameOptions.height - height\n y = frameOptions.verticalAlign === VerticalAlign.Middle ? dh / 2\n : frameOptions.verticalAlign === VerticalAlign.Bottom ? dh : 0\n }\n\n const translate = (frameOptions.x || frameOptions.y)\n ? `transform=\"translate(${frameOptions.x ?? 0},${frameOptions.y ?? 0})\"`\n : ''\n\n const svgCode =\n `<text\n xmlns=\"http://www.w3.org/2000/svg\"\n text-anchor=\"${getTextAnchorFromTextAlign(frameOptions.textAlign)}\"\n ${translate}\n >\n ${renderTextToTspanStrings(wrappedText, x, y).join('')}\n </text>`\n\n const parser = new DOMParser()\n const parsedSvgCode = parser.parseFromString(svgCode, 'image/svg+xml').firstChild\n\n group.textContent = ''\n group.appendChild(parsedSvgCode)\n}\n"],"names":[],"mappings":";;;;;;AAaA;;;;;AAKG;AACG,SAAU,gBAAgB,CAAE,GAAW,EAAA;AAC3C,IAAA,OAAO,GAAG,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC,EAAE,MAAM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YAAY,CAAC,aAAa,KAAK,aAAa,CAAC,MAAM,GAAG,EAAE,GAAG,CAAC,CAAA;AACjE,KAAA;IAED,MAAM,SAAS,GAAG,CAAC,YAAY,CAAC,CAAC,IAAI,YAAY,CAAC,CAAC;AACjD,UAAE,CAAA,qBAAA,EAAwB,CAAA,EAAA,GAAA,YAAY,CAAC,CAAC,MAAA,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,EAAA,GAAI,CAAC,CAAA,CAAA,EAAI,MAAA,YAAY,CAAC,CAAC,MAAA,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,EAAA,GAAI,CAAC,CAAI,EAAA,CAAA;UACtE,EAAE,CAAA;AAEN,IAAA,MAAM,OAAO,GACb,CAAA;;AAEiB,iBAAA,EAAA,0BAA0B,CAAC,YAAY,CAAC,SAAS,CAAC,CAAA;MAC/D,SAAS,CAAA;;MAET,wBAAwB,CAAC,WAAW,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;UAChD,CAAA;AAER,IAAA,MAAM,MAAM,GAAG,IAAI,SAAS,EAAE,CAAA;AAC9B,IAAA,MAAM,aAAa,GAAG,MAAM,CAAC,eAAe,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC,UAAU,CAAA;AAEjF,IAAA,KAAK,CAAC,WAAW,GAAG,EAAE,CAAA;AACtB,IAAA,KAAK,CAAC,WAAW,CAAC,aAAa,CAAC,CAAA;AAClC;;;;"}
1
+ {"version":3,"file":"text.js","sources":["../../src/utils/text.ts"],"sourcesContent":["import { Selection } from 'd3-selection'\nimport { sum } from 'd3-array'\n\n// Types\nimport { TextAlign, TrimMode, UnovisText, UnovisTextFrameOptions, UnovisTextOptions, UnovisWrappedText, VerticalAlign } from 'types/text'\n\n// Utils\nimport { flatten, isArray, merge } from 'utils/data'\nimport { getTextAnchorFromTextAlign } from 'types/svg'\n\n// Styles\nimport { getFontWidthToHeightRatio, UNOVIS_TEXT_DEFAULT, UNOVIS_TEXT_SEPARATOR_DEFAULT, UNOVIS_TEXT_HYPHEN_CHARACTER_DEFAULT } from 'styles/index'\n\n/**\n * Converts a kebab-case string to camelCase.\n *\n * @param {string} str - The kebab-case string to be converted.\n * @returns {string} The resulting camelCase string.\n */\nexport function kebabCaseToCamel (str: string): string {\n return str.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase())\n}\n\n/**\n * Converts a given string to kebab-case.\n * @param {string} str - The input string to be converted to kebab-case.\n * @returns {string} - The kebab-cased string.\n */\nexport function kebabCase (str: string): string {\n return str.match(/[A-Z]{2,}(?=[A-Z][a-z0-9]*|\\b)|[A-Z]?[a-z0-9]*|[A-Z]|[0-9]+/g)\n ?.filter(Boolean)\n .map(x => x.toLowerCase())\n .join('-')\n}\n\n/**\n * Trims the input string from the start, leaving only the specified maximum length.\n * @param {string} [str=''] - The input string to be trimmed.\n * @param {number} [maxLength=15] - The maximum allowed length of the trimmed string.\n * @returns {string} - The trimmed string.\n */\nexport function trimStringStart (str = '', maxLength = 15): string {\n return str.length > maxLength ? `…${str.substr(str.length - maxLength, maxLength)}` : str\n}\n\n/**\n * Trims the input string from the middle, leaving only the specified maximum length.\n * @param {string} [str=''] - The input string to be trimmed.\n * @param {number} [maxLength=15] - The maximum allowed length of the trimmed string.\n * @returns {string} - The trimmed string.\n */\nexport function trimStringMiddle (str = '', maxLength = 15): string {\n const dist = Math.floor((maxLength - 3) / 2)\n return str.length > maxLength ? `${str.substr(0, dist)}…${str.substr(-dist, dist)}` : str\n}\n\n/**\n * Trims the input string from the end, leaving only the specified maximum length.\n * @param {string} [str=''] - The input string to be trimmed.\n * @param {number} [maxLength=15] - The maximum allowed length of the trimmed string.\n * @returns {string} - The trimmed string.\n */\nexport function trimStringEnd (str = '', maxLength = 15): string {\n return str.length > maxLength ? `${str.substr(0, maxLength)}…` : str\n}\n\n/**\n * Trims the input string according to the specified trim mode.\n * @param {string} [str=''] - The input string to be trimmed.\n * @param {number} [length=15] - The maximum allowed length of the trimmed string.\n * @param {TrimMode} [type=TrimMode.Middle] - The trim mode to be applied.\n * @returns {string} - The trimmed string.\n */\nexport function trimString (str = '', length = 15, type = TrimMode.Middle): string {\n let result = trimStringEnd(str, length)\n if (type === TrimMode.Start) result = trimStringStart(str, length)\n else if (type === TrimMode.Middle) result = trimStringMiddle(str, length)\n return result\n}\n\n/**\n * Splits the input string according to the specified separators.\n * @param {string} text - The input string to be split.\n * @param {string[]} [separators=[' ']] - The array of separators to be used for splitting.\n * @returns {string[]} - The array of split words.\n */\nexport function splitString (text: string, separators = [' ']): string[] {\n let result = [text] as any[]\n for (let i = 0; i < separators.length; i++) {\n const sep = separators[i]\n result.forEach((d, id) => {\n const separated = d.split(sep)\n const words = separated.map((word, j) => `${word}${j === separated.length - 1 ? '' : sep}`)\n result[id] = words\n })\n result = flatten(result)\n }\n\n return result\n}\n\n/**\n * Wraps an SVG text element to fit within the specified width.\n * @param {Selection<SVGTextElement, any, SVGElement, any>} textElement - The SVG text element to be wrapped.\n * @param {number} width - The maximum allowed width for the text element.\n * @param {(string | string[])} [separator=[' ', '-', '.', ',']] - The separator(s) to be used for wrapping.\n */\nexport function wrapSVGText (\n textElement: Selection<SVGTextElement, any, SVGElement, any>,\n width: number,\n separator: string | string[] = [' ', '-', '.', ',']\n): void {\n const text = textElement.text()\n if (!text) return\n\n // Wrap\n const separators = (isArray(separator) ? separator : [separator]) as string[]\n const words = splitString(text, separators)\n const x = parseFloat(textElement.attr('x')) || 0\n\n textElement.text('')\n let tspan = textElement.append('tspan').attr('x', x)\n let tspanContent = `${words[0]}`\n tspan.text(tspanContent)\n\n words.forEach((word, i) => {\n if (i === 0) return\n\n const tspanText = `${tspanContent}${word}`\n tspan.text(tspanText)\n const tspanWidth = tspan.node().getComputedTextLength()\n if (tspanWidth > width) {\n tspan.text(tspanContent.trim())\n\n tspan = textElement.append('tspan')\n .attr('x', x)\n .attr('dy', '1.2em')\n .text(word)\n\n tspanContent = word\n } else tspanContent += word\n })\n}\n\n/**\n * Trims an SVG text element based on the specified max width, trim type, and other options.\n * @param {Selection<SVGTextElement, any, SVGElement, any>} svgTextSelection - The D3 selection of the SVG text element to be trimmed.\n * @param {number} [maxWidth=50] - The maximum width of the text element.\n * @param {TrimMode} [trimType=TrimMode.Middle] - The type of trim (start, middle, or end).\n * @param {boolean} [fastMode=true] - Whether to use a fast estimation method for text length calculation.\n * @param {number} [fontSize=0] - The font size of the text.\n * @param {number} [fontWidthToHeightRatio=getFontWidthToHeightRatio()] - The font width to height ratio.\n * @returns {boolean} True if the text was trimmed, false otherwise.\n */\nexport function trimSVGText (\n svgTextSelection: Selection<SVGTextElement, any, SVGElement, any>,\n maxWidth = 50,\n trimType = TrimMode.Middle,\n fastMode = true,\n fontSize = +window.getComputedStyle(svgTextSelection.node())?.fontSize || 0,\n fontWidthToHeightRatio = getFontWidthToHeightRatio()\n): boolean {\n const text = svgTextSelection.text()\n const textLength = text.length\n\n const textWidth = fastMode ? fontSize * textLength * fontWidthToHeightRatio : svgTextSelection.node().getComputedTextLength()\n const tolerance = 1.1\n const maxCharacters = Math.ceil(textLength * maxWidth / (tolerance * textWidth))\n if (maxCharacters < textLength) {\n svgTextSelection.text(trimString(text, maxCharacters, trimType))\n return true\n }\n\n return false\n}\n\n/**\n * Estimates the length of a string in pixels.\n * @param {string} str - The string to be measured.\n * @param {number} fontSize - The font size of the string.\n * @param {number} [fontWidthToHeightRatio=getFontWidthToHeightRatio()] - The font width to height ratio.\n * @returns {number} The estimated length of the string in pixels.\n */\nexport function estimateStringPixelLength (\n str: string,\n fontSize: number,\n fontWidthToHeightRatio = getFontWidthToHeightRatio()\n): number {\n return str.length * fontSize * fontWidthToHeightRatio || 0\n}\n\n/**\n * Calculates the precise length of a string in pixels.\n * @param {string} str - The string to be measured.\n * @param {string} [fontFamily] - The font family of the string.\n * @param {(string | number)} [fontSize] - The font size of the string.\n * @returns {number} The precise length of the string in pixels.\n */\nexport function getPreciseStringLengthPx (str: string, fontFamily?: string, fontSize?: string | number): number {\n const svgNS = 'http://www.w3.org/2000/svg'\n const svg = document.createElementNS(svgNS, 'svg')\n const text = document.createElementNS(svgNS, 'text')\n\n text.textContent = str\n text.setAttribute('font-size', `${fontSize}`)\n text.setAttribute('font-family', fontFamily)\n\n svg.appendChild(text)\n document.body.appendChild(svg)\n const length = text.getComputedTextLength()\n document.body.removeChild(svg)\n\n return length\n}\n\n/**\n * Estimates the dimensions of an SVG text element.\n *\n * @export\n * @param {Selection<SVGTextElement, any, SVGElement, any>} svgTextSelection - The D3 selection of the SVG text element.\n * @param {number} fontSize - The font size.\n * @param {number} [dy=0.32] - The line height scaling factor.\n * @param {boolean} [fastMode=true] - Whether to use a fast estimation method or a more accurate one.\n * @param {number} [fontWidthToHeightRatio] - The font width-to-height ratio.\n * @returns {{width: number, height: number}} - The estimated dimensions of the text element.\n */\nexport function estimateTextSize (\n svgTextSelection: Selection<SVGTextElement, any, SVGElement, any>,\n fontSize: number,\n dy = 0.32,\n fastMode = true,\n fontWidthToHeightRatio?: number\n): { width: number; height: number } {\n fontWidthToHeightRatio = fontWidthToHeightRatio || getFontWidthToHeightRatio()\n const tspanSelection = svgTextSelection.selectAll('tspan')\n\n const lines = tspanSelection.size() || 1\n const height = svgTextSelection.text() ? 0.85 * fontSize * lines * (1 + dy) - dy : 0\n\n let width = 0\n if (tspanSelection.empty()) {\n const textLength = svgTextSelection.text().length\n width = fastMode ? fontSize * textLength * fontWidthToHeightRatio : svgTextSelection.node().getComputedTextLength()\n } else {\n for (const tspan of tspanSelection.nodes()) {\n const tspanTextLength = (tspan as SVGTSpanElement).textContent.length\n const w = fastMode ? fontSize * tspanTextLength * fontWidthToHeightRatio : (tspan as SVGTSpanElement).getComputedTextLength()\n if (w > width) width = w\n }\n }\n\n return { width, height }\n}\n\n/**\n * Breaks a text block into lines based on the specified width.\n *\n * @param {UnovisText} textBlock - The text block to break into lines.\n * @param {number | undefined} [width=undefined] - The maximum width of a line in pixels.\n * @param {(number | undefined)} [height=undefined] - The height limit for the wrapped text in pixels.\n * @param {boolean} [fastMode=true] - Whether to use a fast estimation method or a more accurate one.\n * @param {string | string[]} [separator] - The word separators.\n * @returns {string[]} - The text split into lines.\n */\nfunction breakTextIntoLines (\n textBlock: UnovisText,\n width: number | undefined = undefined,\n fastMode = true,\n separator: string | string[] = UNOVIS_TEXT_SEPARATOR_DEFAULT,\n wordBreak = false\n): string[] {\n const text = `${textBlock.text}`\n if (!text) return []\n const separators = Array.isArray(separator) ? separator : [separator]\n\n const splitByNewLine = text.split('\\n')\n return splitByNewLine.map((str) => {\n const lines: string[] = []\n if (!width) return [str]\n\n const words = splitString(str, separators)\n let line = ''\n for (let i = 0; i < words.length; i += 1) {\n const textLengthPx = fastMode\n ? estimateStringPixelLength(line + words[i], textBlock.fontSize, textBlock.fontWidthToHeightRatio)\n : getPreciseStringLengthPx(line + words[i], textBlock.fontFamily, textBlock.fontSize)\n\n if (textLengthPx < width || i === 0) {\n line += words[i]\n } else {\n lines.push(line.trim())\n line = words[i]\n }\n\n // Word break functionality\n if (wordBreak) {\n while (line.length > 0) {\n const subLineLengthPx = fastMode\n ? estimateStringPixelLength(line, textBlock.fontSize, textBlock.fontWidthToHeightRatio)\n : getPreciseStringLengthPx(line, textBlock.fontFamily, textBlock.fontSize)\n\n if (subLineLengthPx > width) {\n let breakIndex = (line.trim()).length - 2 // Place at least 2 characters onto the next line\n while (breakIndex > 0) {\n const subLine = `${line.substring(0, breakIndex)}${UNOVIS_TEXT_HYPHEN_CHARACTER_DEFAULT}` // Use hyphen when force breaking words\n const subLinePx = fastMode\n ? estimateStringPixelLength(subLine, textBlock.fontSize, textBlock.fontWidthToHeightRatio)\n : getPreciseStringLengthPx(subLine, textBlock.fontFamily, textBlock.fontSize)\n\n if (subLinePx <= width) {\n lines.push(subLine.trim())\n line = line.substring(breakIndex)\n break\n }\n breakIndex--\n }\n } else {\n break\n }\n }\n }\n\n if (i === words.length - 1) lines.push(line.trim())\n }\n\n return lines\n }).flat()\n}\n\n/**\n * Wraps a text or array of texts to fit within specified width and height, if provided.\n *\n * @export\n * @param {UnovisText | UnovisText[]} text - The text or array of texts to wrap.\n * @param {number | undefined} [width=undefined] - The maximum width of a line in pixels.\n * @param {boolean} [fastMode=true] - Whether to use a fast estimation method or a more accurate one.\n * @param {string | string[]} [separator] - The word separators.\n * @returns {UnovisWrappedText[]} - The wrapped texts.\n */\nexport function getWrappedText (\n text: UnovisText | UnovisText[],\n width: number | undefined = undefined,\n height: number | undefined = undefined,\n fastMode = true,\n separator: string | string[] = UNOVIS_TEXT_SEPARATOR_DEFAULT,\n wordBreak = false\n): UnovisWrappedText[] {\n // Merge input text with default values and convert it to an array if it's not already\n const textArrays = Array.isArray(text) ? text.map(t => merge(UNOVIS_TEXT_DEFAULT, t)) : [merge(UNOVIS_TEXT_DEFAULT, text)]\n\n // Break input text into lines based on width and separator\n const textWrapped: Array<string[]> = textArrays.map(block => breakTextIntoLines(block, width, fastMode, separator, wordBreak))\n\n const firstBlock = textArrays[0]\n let h = -firstBlock.fontSize * (firstBlock.lineHeight - 1)\n const blocks: UnovisWrappedText[] = []\n\n // Process each text block and its lines based on height limit\n textArrays.forEach((text, i) => {\n let lines = textWrapped[i]\n\n const prevBlock = i > 0 ? blocks[i - 1] : undefined\n const prevBlockMarginBottomPx = prevBlock ? prevBlock.marginBottom : 0\n const marginTopPx = text.marginTop\n const effectiveMarginPx = Math.max(prevBlockMarginBottomPx, marginTopPx)\n\n h += effectiveMarginPx\n const dh = text.fontSize * text.lineHeight\n // Iterate over lines and handle text overflow based on the height limit if provided\n for (let k = 0; k < lines.length; k += 1) {\n let line = lines[k]\n h += dh\n\n if (height && (h + dh) > height && (k !== lines.length - 1)) {\n // Remove hyphen character from the end of the line if it's there\n const lastCharacter = line.charAt(line.length - 1)\n if (lastCharacter === UNOVIS_TEXT_HYPHEN_CHARACTER_DEFAULT) {\n line = line.substr(0, lines[k].length - 1)\n }\n\n const lineWithEllipsis = `${line} …`\n const textLengthPx = fastMode\n ? estimateStringPixelLength(lineWithEllipsis, text.fontSize, text.fontWidthToHeightRatio)\n : getPreciseStringLengthPx(lineWithEllipsis, text.fontFamily, text.fontSize)\n\n if (textLengthPx < width) {\n lines[k] = lineWithEllipsis\n } else {\n lines[k] = `${lines[k].substr(0, lines[k].length - 2)}…`\n }\n\n lines = lines.slice(0, k + 1)\n break\n }\n }\n\n // Create wrapped text block with its calculated properties\n blocks.push({ ...text, _lines: lines, _estimatedHeight: h - (prevBlock?._estimatedHeight || 0) })\n })\n\n return blocks\n}\n\n\n/**\n * Renders a text or array of texts to SVG tspan strings.\n *\n * @param {UnovisWrappedText[]} blocks - The wrapped text blocks.\n * @param {number} [x=0] - The x-coordinate for the tspan elements.\n * @param {number} [y] - The y-coordinate for the tspan elements.\n * @returns {string[]} - The SVG tspan strings.\n */\nfunction renderTextToTspanStrings (blocks: UnovisWrappedText[], x = 0, y?: number): string[] {\n return blocks.map((b, i) => {\n const prevBlock = i > 0 ? blocks[i - 1] : undefined\n const prevBlockMarginBottomEm = prevBlock ? prevBlock.marginBottom / prevBlock.fontSize : 0\n const marginTopEm = b.marginTop / b.fontSize\n const marginEm = Math.max(prevBlockMarginBottomEm, marginTopEm)\n const attributes = {\n fontSize: b.fontSize,\n fontFamily: b.fontFamily,\n fill: b.color,\n y: (i === 0) && y,\n }\n\n const attributesString = Object.entries(attributes)\n .filter(([_, value]) => value)\n .map(([key, value]) => `${kebabCase(key)}=\"${escape(value.toString())}\"`)\n .join(' ')\n\n return `<tspan xmlns=\"http://www.w3.org/2000/svg\" ${attributesString}>${b._lines.map((line, k) => {\n let dy: number\n if (i === 0 && k === 0) dy = 0.8 + marginEm\n else if (k === 0) dy = marginEm + b.lineHeight\n else dy = b.lineHeight\n\n return `<tspan x=\"${x}\" dy=\"${dy}em\">${line.length ? line : ' '}</tspan>`\n }).join('')}</tspan>`\n })\n}\n\n/**\n * Estimates the height of wrapped text blocks.\n *\n * @export\n * @param {UnovisWrappedText[]} blocks - The wrapped text blocks.\n * @returns {number} - The estimated height of the wrapped text blocks.\n */\nexport function estimateWrappedTextHeight (blocks: UnovisWrappedText[]): number {\n return sum(blocks, b => b._estimatedHeight)\n}\n\n/**\n * Renders a text or array of texts to an SVG text element.\n * Calling this function will replace the contents of the specified SVG text element.\n *\n * @export\n * @param {SVGTextElement} textElement - The SVG text element to render the text into.\n * @param {UnovisText | UnovisText[]} text - The text or array of texts to render.\n * @param {UnovisTextOptions} options - The text options.\n */\nexport function renderTextToSvgTextElement (\n textElement: SVGTextElement,\n text: UnovisText | UnovisText[],\n options: UnovisTextOptions\n): void {\n const wrappedText = getWrappedText(text, options.width, undefined, options.fastMode, options.separator, options.wordBreak)\n const textElementX = +textElement.getAttribute('x')\n const textElementY = +textElement.getAttribute('y')\n const x = textElementX ?? 0\n let y = textElementY ?? 0\n if (options.textAlign) textElement.setAttribute('text-anchor', getTextAnchorFromTextAlign(options.textAlign))\n if (options.verticalAlign && options.verticalAlign !== VerticalAlign.Top) {\n const height = estimateWrappedTextHeight(wrappedText)\n const dy = options.verticalAlign === VerticalAlign.Middle ? -height / 2\n : options.verticalAlign === VerticalAlign.Bottom ? -height : 0\n\n y += dy\n }\n\n const parser = new DOMParser()\n textElement.textContent = ''\n wrappedText.forEach(block => {\n const svgCode = renderTextToTspanStrings([block], x, y).join('')\n const parsedSvgCode = parser.parseFromString(svgCode, 'image/svg+xml').firstChild\n textElement.appendChild(parsedSvgCode)\n })\n}\n\n/**\n * Renders a text or array of texts into a frame.\n * Calling this function will replace the contents of the specified SVG group.\n *\n * @export\n * @param {SVGGElement} group - The SVG group element to render the text into.\n * @param {UnovisText | UnovisText[]} text - The text or array of texts to render.\n * @param {UnovisTextFrameOptions} frameOptions - The text frame options.\n */\nexport function renderTextIntoFrame (\n group: SVGGElement,\n text: UnovisText | UnovisText[],\n frameOptions: UnovisTextFrameOptions\n): void {\n const wrappedText = getWrappedText(text, frameOptions.width, frameOptions.height, frameOptions.fastMode, frameOptions.separator, frameOptions.wordBreak)\n\n const x = frameOptions.textAlign === TextAlign.Center ? frameOptions.width / 2\n : frameOptions.textAlign === TextAlign.Right ? frameOptions.width : 0\n\n let y = 0\n const height = estimateWrappedTextHeight(wrappedText)\n if (frameOptions.height && height < frameOptions.height) {\n const height = estimateWrappedTextHeight(wrappedText)\n const dh = frameOptions.height - height\n y = frameOptions.verticalAlign === VerticalAlign.Middle ? dh / 2\n : frameOptions.verticalAlign === VerticalAlign.Bottom ? dh : 0\n }\n\n const translate = (frameOptions.x || frameOptions.y)\n ? `transform=\"translate(${frameOptions.x ?? 0},${frameOptions.y ?? 0})\"`\n : ''\n\n const svgCode =\n `<text\n xmlns=\"http://www.w3.org/2000/svg\"\n text-anchor=\"${getTextAnchorFromTextAlign(frameOptions.textAlign)}\"\n ${translate}\n >\n ${renderTextToTspanStrings(wrappedText, x, y).join('')}\n </text>`\n\n const parser = new DOMParser()\n const parsedSvgCode = parser.parseFromString(svgCode, 'image/svg+xml').firstChild\n\n group.textContent = ''\n group.appendChild(parsedSvgCode)\n}\n"],"names":[],"mappings":";;;;;;AAaA;;;;;AAKG;AACG,SAAU,gBAAgB,CAAE,GAAW,EAAA;AAC3C,IAAA,OAAO,GAAG,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC,WAAW,EAAE,CAAC,CAAA;AACtE,CAAC;AAED;;;;AAIG;AACG,SAAU,SAAS,CAAE,GAAW,EAAA;;IACpC,OAAO,CAAA,EAAA,GAAA,GAAG,CAAC,KAAK,CAAC,8DAA8D,CAAC,MAC5E,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,MAAM,CAAC,OAAO,CACf,CAAA,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,CAAA,CACxB,IAAI,CAAC,GAAG,CAAC,CAAA;AACd,CAAC;AAED;;;;;AAKG;AACG,SAAU,eAAe,CAAE,GAAG,GAAG,EAAE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