@unovis/ts 1.1.1-beta.0 → 1.1.1-beta.10

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 (97) hide show
  1. package/components/axis/config.d.ts +0 -3
  2. package/components/axis/config.js +0 -1
  3. package/components/axis/config.js.map +1 -1
  4. package/components/axis/index.d.ts +1 -8
  5. package/components/axis/index.js +29 -24
  6. package/components/axis/index.js.map +1 -1
  7. package/components/chord-diagram/modules/label.js +4 -2
  8. package/components/chord-diagram/modules/label.js.map +1 -1
  9. package/components/donut/index.js +1 -2
  10. package/components/donut/index.js.map +1 -1
  11. package/components/flow-legend/style.js +2 -2
  12. package/components/flow-legend/style.js.map +1 -1
  13. package/components/graph/modules/node/index.js +3 -3
  14. package/components/graph/modules/node/index.js.map +1 -1
  15. package/components/graph/modules/panel/index.js +3 -3
  16. package/components/graph/modules/panel/index.js.map +1 -1
  17. package/components/graph/style.js +2 -2
  18. package/components/graph/style.js.map +1 -1
  19. package/components/leaflet-map/index.d.ts +33 -0
  20. package/components/leaflet-map/index.js +30 -7
  21. package/components/leaflet-map/index.js.map +1 -1
  22. package/components/leaflet-map/modules/node.js +8 -7
  23. package/components/leaflet-map/modules/node.js.map +1 -1
  24. package/components/leaflet-map/modules/utils.d.ts +1 -1
  25. package/components/leaflet-map/modules/utils.js +4 -5
  26. package/components/leaflet-map/modules/utils.js.map +1 -1
  27. package/components/leaflet-map/style.d.ts +33 -1
  28. package/components/leaflet-map/style.js +54 -86
  29. package/components/leaflet-map/style.js.map +1 -1
  30. package/components/nested-donut/config.d.ts +59 -0
  31. package/components/nested-donut/config.js +19 -0
  32. package/components/nested-donut/config.js.map +1 -0
  33. package/components/nested-donut/index.d.ts +38 -0
  34. package/components/nested-donut/index.js +133 -0
  35. package/components/nested-donut/index.js.map +1 -0
  36. package/components/nested-donut/modules/arc.d.ts +17 -0
  37. package/components/nested-donut/modules/arc.js +50 -0
  38. package/components/nested-donut/modules/arc.js.map +1 -0
  39. package/components/nested-donut/modules/label.d.ts +7 -0
  40. package/components/nested-donut/modules/label.js +34 -0
  41. package/components/nested-donut/modules/label.js.map +1 -0
  42. package/components/nested-donut/style.d.ts +26 -0
  43. package/components/nested-donut/style.js +70 -0
  44. package/components/nested-donut/style.js.map +1 -0
  45. package/components/nested-donut/types.d.ts +24 -0
  46. package/components/nested-donut/types.js +11 -0
  47. package/components/nested-donut/types.js.map +1 -0
  48. package/components/sankey/modules/label.js +2 -2
  49. package/components/sankey/modules/label.js.map +1 -1
  50. package/components/sankey/style.js +2 -2
  51. package/components/sankey/style.js.map +1 -1
  52. package/components/vis-controls/style.js +2 -2
  53. package/components/vis-controls/style.js.map +1 -1
  54. package/components/xy-labels/config.d.ts +2 -2
  55. package/components/xy-labels/config.js.map +1 -1
  56. package/components.d.ts +2 -0
  57. package/components.js +1 -0
  58. package/components.js.map +1 -1
  59. package/containers/single-container/index.js +4 -1
  60. package/containers/single-container/index.js.map +1 -1
  61. package/containers/xy-container/index.js +1 -1
  62. package/containers/xy-container/index.js.map +1 -1
  63. package/core/component/index.d.ts +5 -1
  64. package/core/component/index.js +9 -1
  65. package/core/component/index.js.map +1 -1
  66. package/core/container/index.d.ts +3 -2
  67. package/core/container/index.js +12 -7
  68. package/core/container/index.js.map +1 -1
  69. package/index.d.ts +1 -0
  70. package/index.js +4 -1
  71. package/index.js.map +1 -1
  72. package/package.json +1 -1
  73. package/styles/index.d.ts +6 -1
  74. package/styles/index.js +18 -3
  75. package/styles/index.js.map +1 -1
  76. package/types/svg.d.ts +18 -0
  77. package/types/svg.js +22 -0
  78. package/types/svg.js.map +1 -0
  79. package/types/text.d.ts +27 -18
  80. package/types/text.js +1 -6
  81. package/types/text.js.map +1 -1
  82. package/types.d.ts +1 -0
  83. package/types.js +2 -1
  84. package/types.js.map +1 -1
  85. package/utils/data.js +1 -1
  86. package/utils/data.js.map +1 -1
  87. package/utils/style.d.ts +6 -0
  88. package/utils/style.js +24 -0
  89. package/utils/style.js.map +1 -0
  90. package/utils/svg.d.ts +3 -0
  91. package/utils/text.d.ts +134 -13
  92. package/utils/text.js +361 -126
  93. package/utils/text.js.map +1 -1
  94. package/utils/type.d.ts +5 -0
  95. package/components/axis/modules/tick.d.ts +0 -5
  96. package/components/axis/modules/tick.js +0 -48
  97. package/components/axis/modules/tick.js.map +0 -1
@@ -1,7 +1,43 @@
1
1
  import { injectGlobal, css } from '@emotion/css';
2
+ import { getCssVarNames, injectGlobalCssVariables } from '../../utils/style.js';
2
3
  import css_248z from './leaflet.css.js';
3
4
 
4
5
  injectGlobal(css_248z);
6
+ const cssVarDefaults = {
7
+ '--vis-map-container-background-color': '#dfe5eb',
8
+ /* Undefined by default to allow proper fallback to var(--vis-font-family) */
9
+ '--vis-map-label-font-family': undefined,
10
+ '--vis-map-point-default-fill-color': '#B9BEC3',
11
+ '--vis-map-point-ring-fill-color': '#ffffff',
12
+ '--vis-map-point-default-stroke-color': '#959da3',
13
+ '--vis-map-point-default-stroke-width': '0px',
14
+ '--vis-map-point-default-cursor': 'default',
15
+ '--vis-map-cluster-default-fill-color': '#fff',
16
+ '--vis-map-cluster-default-stroke-color': '#B9BEC3',
17
+ '--vis-map-cluster-default-stroke-width': '1.5px',
18
+ '--vis-map-cluster-donut-fill-color': '#959da3',
19
+ '--vis-map-cluster-inner-label-text-color-dark': '#5b5f6d',
20
+ '--vis-map-cluster-inner-label-text-color-light': '#fff',
21
+ '--vis-map-point-inner-label-text-color-dark': '#5b5f6d',
22
+ '--vis-map-point-inner-label-text-color-light': '#fff',
23
+ '--vis-map-point-bottom-label-text-color': '#5b5f6d',
24
+ '--vis-map-point-bottom-label-font-size': '10px',
25
+ '--vis-map-cluster-expanded-background-fill-color': '#fff',
26
+ /* Dark Theme */
27
+ '--vis-dark-map-container-background-color': '#dfe5eb',
28
+ '--vis-dark-map-point-default-fill-color': '#B9BEC3',
29
+ '--vis-dark-map-point-default-stroke-color': '#959da3',
30
+ '--vis-dark-map-point-ring-fill-color': '#5b5f6d',
31
+ '--vis-dark-map-cluster-default-fill-color': '#5b5f6d',
32
+ '--vis-dark-map-cluster-default-stroke-color': '#B9BEC3',
33
+ '--vis-dark-map-cluster-donut-fill-color': '#959da3',
34
+ '--vis-dark-map-cluster-inner-label-text-color-dark': '#5b5f6d',
35
+ '--vis-dark-map-cluster-inner-label-text-color-light': '#fff',
36
+ '--vis-dark-map-point-inner-label-text-color-dark': '#5b5f6d',
37
+ '--vis-dark-map-point-inner-label-text-color-light': '#fff',
38
+ '--vis-dark-map-point-bottom-label-text-color': '#5b5f6d',
39
+ '--vis-dark-map-cluster-expanded-background-fill-color': '#fff',
40
+ };
5
41
  const root = css `
6
42
  label: leaflet-map-component;
7
43
 
@@ -14,76 +50,8 @@ const root = css `
14
50
  pointer-events: all;
15
51
  }
16
52
  `;
17
- const variables = injectGlobal `
18
- :root {
19
- --vis-map-container-background-color: #dfe5eb;
20
- // Undefined by default to allow proper fallback to var(--vis-font-family)
21
- /* --vis-map-label-font-family, var(--vis-font-family): */
22
-
23
- --vis-map-point-default-fill-color: #B9BEC3;
24
- --vis-map-point-ring-fill-color: #ffffff;
25
- --vis-map-point-default-stroke-color: #959da3;
26
- --vis-map-point-default-stroke-width: 0px;
27
- --vis-map-point-default-cursor: default;
28
-
29
- --vis-map-cluster-default-fill-color: #fff;
30
- --vis-map-cluster-default-stroke-color: #B9BEC3;
31
- --vis-map-cluster-default-stroke-width: 1.5px;
32
- --vis-map-cluster-donut-fill-color: #959da3;
33
-
34
- --vis-map-cluster-inner-label-text-color-dark: #5b5f6d;
35
- --vis-map-cluster-inner-label-text-color-light: #fff;
36
-
37
- --vis-map-point-inner-label-text-color-dark: #5b5f6d;
38
- --vis-map-point-inner-label-text-color-light: #fff;
39
-
40
- --vis-map-point-bottom-label-text-color: #5b5f6d;
41
- --vis-map-point-bottom-label-font-size: 10px;
42
-
43
- --vis-map-cluster-expanded-background-fill-color: #fff;
44
-
45
- /* Dark Theme */
46
- --vis-dark-map-container-background-color: #dfe5eb;
47
- --vis-dark-map-point-default-fill-color: #B9BEC3;
48
- --vis-dark-map-point-default-stroke-color: #959da3;
49
- --vis-dark-map-point-ring-fill-color: #5b5f6d;
50
-
51
- --vis-dark-map-cluster-default-fill-color: #5b5f6d;
52
- --vis-dark-map-cluster-default-stroke-color: #B9BEC3;
53
- --vis-dark-map-cluster-donut-fill-color: #959da3;
54
-
55
- --vis-dark-map-cluster-inner-label-text-color-dark: #5b5f6d;
56
- --vis-dark-map-cluster-inner-label-text-color-light: #fff;
57
-
58
- --vis-dark-map-point-inner-label-text-color-dark: #5b5f6d;
59
- --vis-dark-map-point-inner-label-text-color-light: #fff;
60
-
61
- --vis-dark-map-point-bottom-label-text-color: #eee;
62
-
63
- --vis-dark-map-cluster-expanded-background-fill-color: #fff;
64
- }
65
-
66
- body.theme-dark ${`.${root}`} {
67
- --vis-map-container-background-color: var(--vis-dark-map-container-background-color);
68
- --vis-map-point-default-fill-color: var(--vis-dark-map-point-default-fill-color);
69
- --vis-map-point-default-stroke-color: var(--vis-dark-map-point-default-stroke-color);
70
- --vis-map-point-ring-fill-color: var(--vis-dark-map-point-ring-fill-color);
71
-
72
- --vis-map-cluster-default-fill-color: var(--vis-dark-map-cluster-default-fill-color);
73
- --vis-map-cluster-default-stroke-color: var(--vis-dark-map-cluster-default-stroke-color);
74
- --vis-map-cluster-donut-fill-color: var(--vis-dark-map-cluster-donut-fill-color);
75
-
76
- --vis-map-cluster-inner-label-text-color-dark: var(--vis-dark-map-cluster-inner-label-text-color-dark);
77
- --vis-map-cluster-inner-label-text-color-light: var(--vis-dark-map-cluster-inner-label-text-color-light);
78
-
79
- --vis-map-point-inner-label-text-color-dark: var(--vis-dark-map-point-inner-label-text-color-dark);
80
- --vis-map-point-inner-label-text-color-light: var(--vis-dark-map-point-inner-label-text-color-light);
81
-
82
- --vis-map-point-bottom-label-text-color: var(--vis-dark-map-point-bottom-label-text-color);
83
-
84
- --vis-map-cluster-expanded-background-fill-color: var(--vis-dark-map-cluster-expanded-background-fill-color);
85
- }
86
- `;
53
+ const variables = getCssVarNames(cssVarDefaults);
54
+ injectGlobalCssVariables(cssVarDefaults, root);
87
55
  const background = `${root} canvas`;
88
56
  const points = css `
89
57
  label: g-points;
@@ -96,12 +64,12 @@ const pointPath = css `
96
64
 
97
65
  stroke-opacity: 1;
98
66
  fill-opacity: 1.0;
99
- fill: var(--vis-map-point-default-fill-color);
100
- stroke: var(--vis-map-point-default-stroke-color);
101
- stroke-width: var(--vis-map-point-default-stroke-width);
67
+ fill: var(${variables.mapPointDefaultFillColor});
68
+ stroke: var(${variables.mapPointDefaultStrokeColor});
69
+ stroke-width: var(${variables.mapPointDefaultStrokeWidth});
102
70
  pointer-events: fill !important;
103
71
  transition: .2s stroke-width, .3s transform;
104
- cursor: var(--vis-map-point-default-cursor);
72
+ cursor: var(${variables.mapPointDefaultCursor});
105
73
 
106
74
  &:hover {
107
75
  stroke-width: 2;
@@ -112,20 +80,20 @@ const pointPath = css `
112
80
  `;
113
81
  const pointPathRing = css `
114
82
  label: point-path-ring;
115
- fill: var(--vis-map-point-ring-fill-color);
83
+ fill: var(${variables.mapPointRingFillColor});
116
84
  `;
117
85
  const pointPathCluster = css `
118
86
  label: point-path-cluster;
119
87
  fill-opacity: 0.9;
120
88
  stroke: none;
121
89
  animation: none;
122
- fill: var(--vis-map-cluster-default-fill-color);
123
- stroke: var(--vis-map-cluster-default-stroke-color);
124
- stroke-width: var(--vis-map-cluster-default-stroke-width);
90
+ fill: var(${variables.mapClusterDefaultFillColor});
91
+ stroke: var(${variables.mapClusterDefaultStrokeColor});
92
+ stroke-width: var(${variables.mapClusterDefaultStrokeWidth});
125
93
  `;
126
94
  const pointSelectionRing = css `
127
95
  label: point-selection-ring;
128
- stroke: var(--vis-map-point-default-fill-color);
96
+ stroke: var(${variables.mapPointDefaultFillColor});
129
97
  `;
130
98
  const pointSelection = css `
131
99
  label: point-selection;
@@ -143,21 +111,21 @@ const innerLabel = css `
143
111
  label: inner-label;
144
112
 
145
113
  text-anchor: middle;
146
- fill: var(--vis-map-point-inner-label-text-color-dark);
147
- font-family: var(--vis-map-label-font-family, var(--vis-font-family));
114
+ fill: var(${variables.mapPointInnerLabelTextColorDark});
115
+ font-family: var(${variables.mapLabelFontFamily}, var(--vis-font-family));
148
116
  pointer-events: none;
149
117
  font-weight: 600;
150
118
  `;
151
119
  const innerLabelCluster = css `
152
120
  label: inner-label-cluster;
153
- fill: var(--vis-map-point-inner-label-text-color-dark);
121
+ fill: var(${variables.mapPointInnerLabelTextColorDark});
154
122
  `;
155
123
  const bottomLabel = css `
156
124
  label: bottom-label;
157
125
 
158
126
  text-anchor: middle;
159
- fill: var(--vis-map-point-bottom-label-text-color);
160
- font-family: var(--vis-map-label-font-family, var(--vis-font-family));
127
+ fill: var(${variables.mapPointBottomLabelTextColor});
128
+ font-family: var(${variables.mapLabelFontFamily}, var(--vis-font-family));
161
129
  pointer-events: none;
162
130
  font-weight: 600;
163
131
  `;
@@ -167,7 +135,7 @@ const donutCluster = css `
167
135
  transform: scale(1);
168
136
  transition: .3s transform;
169
137
  path {
170
- fill: var(--vis-map-cluster-donut-fill-color);
138
+ fill: var(${variables.mapClusterDonutFillColor});
171
139
  stroke-width: 0.5;
172
140
  }
173
141
 
@@ -188,7 +156,7 @@ const backgroundRect = css `
188
156
  const clusterBackground = css `
189
157
  label: cluster-background;
190
158
 
191
- fill: var(--vis-map-cluster-expanded-background-fill-color);
159
+ fill: var(${variables.mapClusterExpandedBackgroundFillColor});
192
160
  opacity: 0.6;
193
161
  visibility: hidden;
194
162
 
@@ -1 +1 @@
1
- {"version":3,"file":"style.js","sources":["../../../src/components/leaflet-map/style.ts"],"sourcesContent":["import { css, injectGlobal } from '@emotion/css'\n\n// Inject Leaflet global style\n// eslint-disable-next-line\nimport leafletCSS from './leaflet.css'\ninjectGlobal(leafletCSS)\n\nexport const root = css`\n label: leaflet-map-component;\n\n width: 100%;\n height: 100%;\n position: absolute;\n background-color: var(--vis-map-container-background-color);\n\n canvas {\n pointer-events: all;\n }\n`\n\nexport const variables = injectGlobal`\n :root {\n --vis-map-container-background-color: #dfe5eb;\n // Undefined by default to allow proper fallback to var(--vis-font-family)\n /* --vis-map-label-font-family, var(--vis-font-family): */\n\n --vis-map-point-default-fill-color: #B9BEC3;\n --vis-map-point-ring-fill-color: #ffffff;\n --vis-map-point-default-stroke-color: #959da3;\n --vis-map-point-default-stroke-width: 0px;\n --vis-map-point-default-cursor: default;\n\n --vis-map-cluster-default-fill-color: #fff;\n --vis-map-cluster-default-stroke-color: #B9BEC3;\n --vis-map-cluster-default-stroke-width: 1.5px;\n --vis-map-cluster-donut-fill-color: #959da3;\n\n --vis-map-cluster-inner-label-text-color-dark: #5b5f6d;\n --vis-map-cluster-inner-label-text-color-light: #fff;\n\n --vis-map-point-inner-label-text-color-dark: #5b5f6d;\n --vis-map-point-inner-label-text-color-light: #fff;\n\n --vis-map-point-bottom-label-text-color: #5b5f6d;\n --vis-map-point-bottom-label-font-size: 10px;\n\n --vis-map-cluster-expanded-background-fill-color: #fff;\n\n /* Dark Theme */\n --vis-dark-map-container-background-color: #dfe5eb;\n --vis-dark-map-point-default-fill-color: #B9BEC3;\n --vis-dark-map-point-default-stroke-color: #959da3;\n --vis-dark-map-point-ring-fill-color: #5b5f6d;\n\n --vis-dark-map-cluster-default-fill-color: #5b5f6d;\n --vis-dark-map-cluster-default-stroke-color: #B9BEC3;\n --vis-dark-map-cluster-donut-fill-color: #959da3;\n\n --vis-dark-map-cluster-inner-label-text-color-dark: #5b5f6d;\n --vis-dark-map-cluster-inner-label-text-color-light: #fff;\n\n --vis-dark-map-point-inner-label-text-color-dark: #5b5f6d;\n --vis-dark-map-point-inner-label-text-color-light: #fff;\n\n --vis-dark-map-point-bottom-label-text-color: #eee;\n\n --vis-dark-map-cluster-expanded-background-fill-color: #fff;\n }\n\n body.theme-dark ${`.${root}`} {\n --vis-map-container-background-color: var(--vis-dark-map-container-background-color);\n --vis-map-point-default-fill-color: var(--vis-dark-map-point-default-fill-color);\n --vis-map-point-default-stroke-color: var(--vis-dark-map-point-default-stroke-color);\n --vis-map-point-ring-fill-color: var(--vis-dark-map-point-ring-fill-color);\n\n --vis-map-cluster-default-fill-color: var(--vis-dark-map-cluster-default-fill-color);\n --vis-map-cluster-default-stroke-color: var(--vis-dark-map-cluster-default-stroke-color);\n --vis-map-cluster-donut-fill-color: var(--vis-dark-map-cluster-donut-fill-color);\n\n --vis-map-cluster-inner-label-text-color-dark: var(--vis-dark-map-cluster-inner-label-text-color-dark);\n --vis-map-cluster-inner-label-text-color-light: var(--vis-dark-map-cluster-inner-label-text-color-light);\n\n --vis-map-point-inner-label-text-color-dark: var(--vis-dark-map-point-inner-label-text-color-dark);\n --vis-map-point-inner-label-text-color-light: var(--vis-dark-map-point-inner-label-text-color-light);\n\n --vis-map-point-bottom-label-text-color: var(--vis-dark-map-point-bottom-label-text-color);\n\n --vis-map-cluster-expanded-background-fill-color: var(--vis-dark-map-cluster-expanded-background-fill-color);\n }\n`\n\nexport const background = `${root} canvas`\n\nexport const points = css`\n label: g-points;\n`\n\nexport const point = css`\n label: g-point;\n`\n\nexport const pointPath = css`\n label: point-path;\n\n stroke-opacity: 1;\n fill-opacity: 1.0;\n fill: var(--vis-map-point-default-fill-color);\n stroke: var(--vis-map-point-default-stroke-color);\n stroke-width: var(--vis-map-point-default-stroke-width);\n pointer-events: fill !important;\n transition: .2s stroke-width, .3s transform;\n cursor: var(--vis-map-point-default-cursor);\n\n &:hover {\n stroke-width: 2;\n fill-opacity: 1;\n animation: none;\n transform: scale(1.1);\n }\n`\n\nexport const pointPathRing = css`\n label: point-path-ring;\n fill: var(--vis-map-point-ring-fill-color);\n`\n\nexport const pointPathCluster = css`\n label: point-path-cluster;\n fill-opacity: 0.9;\n stroke: none;\n animation: none;\n fill: var(--vis-map-cluster-default-fill-color);\n stroke: var(--vis-map-cluster-default-stroke-color);\n stroke-width: var(--vis-map-cluster-default-stroke-width);\n`\n\nexport const pointSelectionRing = css`\n label: point-selection-ring;\n stroke: var(--vis-map-point-default-fill-color);\n`\n\nexport const pointSelection = css`\n label: point-selection;\n\n opacity: 0;\n transform: scale(1);\n\n &.active {\n transition: all 400ms cubic-bezier(0.230, 1.000, 0.320, 1.000);\n opacity: 1;\n transform: scale(1.25);\n }\n`\n\nexport const innerLabel = css`\n label: inner-label;\n\n text-anchor: middle;\n fill: var(--vis-map-point-inner-label-text-color-dark);\n font-family: var(--vis-map-label-font-family, var(--vis-font-family));\n pointer-events: none;\n font-weight: 600;\n`\n\nexport const innerLabelCluster = css`\n label: inner-label-cluster;\n fill: var(--vis-map-point-inner-label-text-color-dark);\n`\n\nexport const bottomLabel = css`\n label: bottom-label;\n\n text-anchor: middle;\n fill: var(--vis-map-point-bottom-label-text-color);\n font-family: var(--vis-map-label-font-family, var(--vis-font-family));\n pointer-events: none;\n font-weight: 600;\n`\n\nexport const donutCluster = css`\n label: donut-cluster;\n\n transform: scale(1);\n transition: .3s transform;\n path {\n fill: var(--vis-map-cluster-donut-fill-color);\n stroke-width: 0.5;\n }\n\n &:hover {\n transform: scale(1.1);\n }\n`\n\nexport const svgOverlay = css`\n label: svg-overlay;\n position: absolute;\n pointer-events: none;\n`\n\nexport const backgroundRect = css`\n label: background-rect;\n\n opacity: 0;\n`\n\nexport const clusterBackground = css`\n label: cluster-background;\n\n fill: var(--vis-map-cluster-expanded-background-fill-color);\n opacity: 0.6;\n visibility: hidden;\n\n &.active {\n visibility: visible;\n }\n`\n\nexport const onFeatureHover = css`\n label: feature-hovered;\n`\n\nexport const mapboxglCanvas = css`\n pointer-events: all;\n cursor: grab;\n\n &${`.${onFeatureHover}`} {\n cursor: default;\n }\n`\n\nexport const map = css`\n label: map;\n`\n"],"names":["leafletCSS"],"mappings":";;;AAKA,YAAY,CAACA,QAAU,CAAC,CAAA;AAEjB,MAAM,IAAI,GAAG,GAAG,CAAA,CAAA;;;;;;;;;;;EAWtB;AAEM,MAAM,SAAS,GAAG,YAAY,CAAA,CAAA;;;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,"file":"style.js","sources":["../../../src/components/leaflet-map/style.ts"],"sourcesContent":["import { css, injectGlobal } from '@emotion/css'\n\n// Utils\nimport { getCssVarNames, injectGlobalCssVariables } from 'utils/style'\n\n// Inject Leaflet global style\n// eslint-disable-next-line\nimport leafletCSS from './leaflet.css'\ninjectGlobal(leafletCSS)\n\nconst cssVarDefaults = {\n '--vis-map-container-background-color': '#dfe5eb',\n /* Undefined by default to allow proper fallback to var(--vis-font-family) */\n '--vis-map-label-font-family': undefined,\n\n '--vis-map-point-default-fill-color': '#B9BEC3',\n '--vis-map-point-ring-fill-color': '#ffffff',\n '--vis-map-point-default-stroke-color': '#959da3',\n '--vis-map-point-default-stroke-width': '0px',\n '--vis-map-point-default-cursor': 'default',\n\n '--vis-map-cluster-default-fill-color': '#fff',\n '--vis-map-cluster-default-stroke-color': '#B9BEC3',\n '--vis-map-cluster-default-stroke-width': '1.5px',\n '--vis-map-cluster-donut-fill-color': '#959da3',\n\n '--vis-map-cluster-inner-label-text-color-dark': '#5b5f6d',\n '--vis-map-cluster-inner-label-text-color-light': '#fff',\n\n '--vis-map-point-inner-label-text-color-dark': '#5b5f6d',\n '--vis-map-point-inner-label-text-color-light': '#fff',\n\n '--vis-map-point-bottom-label-text-color': '#5b5f6d',\n '--vis-map-point-bottom-label-font-size': '10px',\n\n '--vis-map-cluster-expanded-background-fill-color': '#fff',\n\n /* Dark Theme */\n '--vis-dark-map-container-background-color': '#dfe5eb',\n '--vis-dark-map-point-default-fill-color': '#B9BEC3',\n '--vis-dark-map-point-default-stroke-color': '#959da3',\n '--vis-dark-map-point-ring-fill-color': '#5b5f6d',\n\n '--vis-dark-map-cluster-default-fill-color': '#5b5f6d',\n '--vis-dark-map-cluster-default-stroke-color': '#B9BEC3',\n '--vis-dark-map-cluster-donut-fill-color': '#959da3',\n\n '--vis-dark-map-cluster-inner-label-text-color-dark': '#5b5f6d',\n '--vis-dark-map-cluster-inner-label-text-color-light': '#fff',\n\n '--vis-dark-map-point-inner-label-text-color-dark': '#5b5f6d',\n '--vis-dark-map-point-inner-label-text-color-light': '#fff',\n\n '--vis-dark-map-point-bottom-label-text-color': '#5b5f6d',\n\n '--vis-dark-map-cluster-expanded-background-fill-color': '#fff',\n}\n\nexport const root = css`\n label: leaflet-map-component;\n\n width: 100%;\n height: 100%;\n position: absolute;\n background-color: var(--vis-map-container-background-color);\n\n canvas {\n pointer-events: all;\n }\n`\n\nexport const variables = getCssVarNames(cssVarDefaults)\ninjectGlobalCssVariables(cssVarDefaults, root)\n\nexport const background = `${root} canvas`\n\nexport const points = css`\n label: g-points;\n`\n\nexport const point = css`\n label: g-point;\n`\n\nexport const pointPath = css`\n label: point-path;\n\n stroke-opacity: 1;\n fill-opacity: 1.0;\n fill: var(${variables.mapPointDefaultFillColor});\n stroke: var(${variables.mapPointDefaultStrokeColor});\n stroke-width: var(${variables.mapPointDefaultStrokeWidth});\n pointer-events: fill !important;\n transition: .2s stroke-width, .3s transform;\n cursor: var(${variables.mapPointDefaultCursor});\n\n &:hover {\n stroke-width: 2;\n fill-opacity: 1;\n animation: none;\n transform: scale(1.1);\n }\n`\n\nexport const pointPathRing = css`\n label: point-path-ring;\n fill: var(${variables.mapPointRingFillColor});\n`\n\nexport const pointPathCluster = css`\n label: point-path-cluster;\n fill-opacity: 0.9;\n stroke: none;\n animation: none;\n fill: var(${variables.mapClusterDefaultFillColor});\n stroke: var(${variables.mapClusterDefaultStrokeColor});\n stroke-width: var(${variables.mapClusterDefaultStrokeWidth});\n`\n\nexport const pointSelectionRing = css`\n label: point-selection-ring;\n stroke: var(${variables.mapPointDefaultFillColor});\n`\n\nexport const pointSelection = css`\n label: point-selection;\n\n opacity: 0;\n transform: scale(1);\n\n &.active {\n transition: all 400ms cubic-bezier(0.230, 1.000, 0.320, 1.000);\n opacity: 1;\n transform: scale(1.25);\n }\n`\n\nexport const innerLabel = css`\n label: inner-label;\n\n text-anchor: middle;\n fill: var(${variables.mapPointInnerLabelTextColorDark});\n font-family: var(${variables.mapLabelFontFamily}, var(--vis-font-family));\n pointer-events: none;\n font-weight: 600;\n`\n\nexport const innerLabelCluster = css`\n label: inner-label-cluster;\n fill: var(${variables.mapPointInnerLabelTextColorDark});\n`\n\nexport const bottomLabel = css`\n label: bottom-label;\n\n text-anchor: middle;\n fill: var(${variables.mapPointBottomLabelTextColor});\n font-family: var(${variables.mapLabelFontFamily}, var(--vis-font-family));\n pointer-events: none;\n font-weight: 600;\n`\n\nexport const donutCluster = css`\n label: donut-cluster;\n\n transform: scale(1);\n transition: .3s transform;\n path {\n fill: var(${variables.mapClusterDonutFillColor});\n stroke-width: 0.5;\n }\n\n &:hover {\n transform: scale(1.1);\n }\n`\n\nexport const svgOverlay = css`\n label: svg-overlay;\n position: absolute;\n pointer-events: none;\n`\n\nexport const backgroundRect = css`\n label: background-rect;\n\n opacity: 0;\n`\n\nexport const clusterBackground = css`\n label: cluster-background;\n\n fill: var(${variables.mapClusterExpandedBackgroundFillColor});\n opacity: 0.6;\n visibility: hidden;\n\n &.active {\n visibility: visible;\n }\n`\n\nexport const onFeatureHover = css`\n label: feature-hovered;\n`\n\nexport const mapboxglCanvas = css`\n pointer-events: all;\n cursor: grab;\n\n &${`.${onFeatureHover}`} {\n cursor: default;\n }\n`\n\nexport const map = css`\n label: map;\n`\n"],"names":["leafletCSS"],"mappings":";;;;AAQA,YAAY,CAACA,QAAU,CAAC,CAAA;AAExB,MAAM,cAAc,GAAG;AACrB,IAAA,sCAAsC,EAAE,SAAS;;AAEjD,IAAA,6BAA6B,EAAE,SAAS;AAExC,IAAA,oCAAoC,EAAE,SAAS;AAC/C,IAAA,iCAAiC,EAAE,SAAS;AAC5C,IAAA,sCAAsC,EAAE,SAAS;AACjD,IAAA,sCAAsC,EAAE,KAAK;AAC7C,IAAA,gCAAgC,EAAE,SAAS;AAE3C,IAAA,sCAAsC,EAAE,MAAM;AAC9C,IAAA,wCAAwC,EAAE,SAAS;AACnD,IAAA,wCAAwC,EAAE,OAAO;AACjD,IAAA,oCAAo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AAc,GAAG,GAAG,CAAA,CAAA;;;;AAI5B,GAAA,EAAA,CAAA,CAAA,EAAI,cAAc,CAAE,CAAA,CAAA;;;EAGxB;AAEM,MAAM,GAAG,GAAG,GAAG,CAAA,CAAA;;;;;;"}
@@ -0,0 +1,59 @@
1
+ import { ComponentConfigInterface, ComponentConfig } from "../../core/component/config";
2
+ import { ColorAccessor, GenericAccessor, 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
+ /** Central label text. Default: `undefined` */
14
+ centralLabel?: string;
15
+ /** Central sub-label accessor function or text. Default: `undefined` */
16
+ centralSubLabel?: string;
17
+ /** Enables wrapping for the sub-label. Default: `true` */
18
+ centralSubLabelWrap?: boolean;
19
+ /**
20
+ * Show donut background. The color is configurable via
21
+ * the `--vis-nested-donut-background-color` and `--vis-dark-nested-donut-background-color` CSS variables.
22
+ * Default: `true`
23
+ */
24
+ showBackground?: boolean;
25
+ /** Array of accessor functions to defined the nested groups */
26
+ layers: StringAccessor<Datum>[];
27
+ layerConfig?: GenericAccessor<NestedDonutLayerSettings, string>;
28
+ layerPadding?: number;
29
+ /** Color accessor function. Default: `undefined` */
30
+ color?: ColorAccessor<NestedDonutSegment<Datum>>;
31
+ /** Corner Radius. Default: `0` */
32
+ cornerRadius?: number;
33
+ /** Label accessor function. */
34
+ label?: StringAccessor<NestedDonutSegment<Datum>>;
35
+ /**
36
+ * When true, the component will display empty segments (the ones that have `0` values) as tiny slices.
37
+ * Default: `false`
38
+ * */
39
+ showEmptySegments?: boolean;
40
+ /** Angular size for empty segments in radians. Default: `0.5 * Math.PI / 180` */
41
+ emptySegmentAngle?: number;
42
+ }
43
+ export declare class NestedDonutConfig<Datum> extends ComponentConfig implements NestedDonutConfigInterface<Datum> {
44
+ centralLabel?: string;
45
+ centralSubLabel?: string;
46
+ centralSubLabelWrap?: boolean;
47
+ showEmptySegments?: boolean;
48
+ emptySegmentAngle?: number;
49
+ color?: ColorAccessor<NestedDonutSegment<Datum>>;
50
+ label?: StringAccessor<NestedDonutSegment<Datum>>;
51
+ direction: NestedDonutDirection;
52
+ layers: StringAccessor<Datum>[];
53
+ layerSettings: any;
54
+ layerPadding: number;
55
+ angleRange: [number, number];
56
+ padAngle: number;
57
+ cornerRadius: number;
58
+ showBackground: boolean;
59
+ }
@@ -0,0 +1,19 @@
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.direction = NestedDonutDirection.INWARDS;
9
+ this.layerSettings = undefined;
10
+ this.layerPadding = 0;
11
+ this.angleRange = [0, 2 * Math.PI];
12
+ this.padAngle = 0;
13
+ this.cornerRadius = 0;
14
+ this.showBackground = true;
15
+ }
16
+ }
17
+
18
+ export { NestedDonutConfig };
19
+ //# 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, StringAccessor } from 'types/accessor'\nimport { NestedDonutDirection, NestedDonutLayerSettings, NestedDonutSegment } from './types'\n\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\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: `true`\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 layerConfig?: GenericAccessor<NestedDonutLayerSettings, string>;\n /* Space between layers */\n layerPadding?: number;\n\n // Segments\n /** Color accessor function. Default: `undefined` */\n color?: ColorAccessor<NestedDonutSegment<Datum>>;\n /** Corner Radius. Default: `0` */\n cornerRadius?: number;\n /** Label accessor function. */\n label?: StringAccessor<NestedDonutSegment<Datum>>;\n /**\n * When true, the component will display empty segments (the ones that have `0` values) as tiny slices.\n * Default: `false`\n * */\n showEmptySegments?: boolean;\n /** Angular size for empty segments in radians. Default: `0.5 * Math.PI / 180` */\n emptySegmentAngle?: number;\n}\n\nexport class NestedDonutConfig<Datum> extends ComponentConfig implements NestedDonutConfigInterface<Datum> {\n centralLabel?: string\n centralSubLabel?: string\n centralSubLabelWrap?: boolean\n showEmptySegments?: boolean\n emptySegmentAngle?: number\n\n color?: ColorAccessor<NestedDonutSegment<Datum>>\n label?: StringAccessor<NestedDonutSegment<Datum>>\n direction = NestedDonutDirection.INWARDS\n layers: StringAccessor<Datum>[]\n layerSettings = undefined\n layerPadding = 0\n angleRange = [0, 2 * Math.PI] as [number, number]\n padAngle = 0\n cornerRadius = 0\n showBackground = true\n}\n\n\n"],"names":[],"mappings":";;;AAAA;AAuDM,MAAO,iBAAyB,SAAQ,eAAe,CAAA;AAA7D,IAAA,WAAA,GAAA;;AASE,QAAA,IAAA,CAAA,SAAS,GAAG,oBAAoB,CAAC,OAAO,CAAA;QAExC,IAAa,CAAA,aAAA,GAAG,SAAS,CAAA;QACzB,IAAY,CAAA,YAAA,GAAG,CAAC,CAAA;QAChB,IAAU,CAAA,UAAA,GAAG,CAAC,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,EAAE,CAAqB,CAAA;QACjD,IAAQ,CAAA,QAAA,GAAG,CAAC,CAAA;QACZ,IAAY,CAAA,YAAA,GAAG,CAAC,CAAA;QAChB,IAAc,CAAA,cAAA,GAAG,IAAI,CAAA;KACtB;AAAA;;;;"}
@@ -0,0 +1,38 @@
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
+ darkNestedDonutBackgroundColor: "--vis-dark-nested-donut-background-color";
22
+ darkNestedDonutCentralLabelTextColor: "--vis-dark-nested-donut-central-label-text-color";
23
+ darkNestedDonutCentralSublabelTextColor: "--vis-dark-nested-donut-central-sublabel-text-color";
24
+ };
25
+ config: NestedDonutConfig<Datum>;
26
+ datamodel: SeriesDataModel<Datum>;
27
+ arcBackground: Selection<SVGPathElement, unknown, SVGGElement, unknown>;
28
+ arcGroup: Selection<SVGGElement, unknown, SVGGElement, unknown>;
29
+ centralLabel: Selection<SVGTextElement, unknown, SVGGElement, unknown>;
30
+ centralSubLabel: Selection<SVGTextElement, unknown, SVGGElement, unknown>;
31
+ arcGen: import("d3-shape").Arc<any, Partial<NestedDonutSegment<Datum>>>;
32
+ radiusScale: ScaleLinear<number, number>;
33
+ colorScale: ScaleLinear<string, string>;
34
+ events: {};
35
+ constructor(config?: NestedDonutConfigInterface<Datum>);
36
+ private getHierarchyData;
37
+ _render(customDuration?: number): void;
38
+ }
@@ -0,0 +1,133 @@
1
+ import { arc } from 'd3-shape';
2
+ import { hierarchy, partition } from 'd3-hierarchy';
3
+ import { scaleLinear } from 'd3-scale';
4
+ import { group, sum, min, max } 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 { getString, isNumber, getValue } from '../../utils/data.js';
10
+ import { smartTransition } from '../../utils/d3.js';
11
+ import { wrapSVGText } from '../../utils/text.js';
12
+ import { defaultLayerSettings, NestedDonutDirection } 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 { centralLabel, centralSubLabel, segment, segmentExit, segmentLabel, background, 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.radiusScale = scaleLinear();
26
+ this.colorScale = scaleLinear();
27
+ this.events = {};
28
+ if (config)
29
+ this.config.init(config);
30
+ this.arcBackground = this.g.append('path');
31
+ this.arcGroup = this.g.append('g');
32
+ this.centralLabel = this.g.append('text')
33
+ .attr('class', centralLabel);
34
+ this.centralSubLabel = this.g.append('text')
35
+ .attr('class', centralSubLabel);
36
+ }
37
+ getHierarchyData() {
38
+ var _a;
39
+ const { config, datamodel } = this;
40
+ const layerAccessors = (_a = config.layers) === null || _a === void 0 ? void 0 : _a.map(layerAccessor => (d, i) => getString(d, layerAccessor, i));
41
+ const nestedData = group(datamodel.data, ...layerAccessors);
42
+ const rootNode = hierarchy(nestedData).count();
43
+ const partitionData = partition().size([config.angleRange[1], 1])(rootNode);
44
+ partitionData.eachBefore((node, index) => {
45
+ var _a, _b, _c, _d;
46
+ const scale = this.colorScale.domain([-1, (_a = node.children) === null || _a === void 0 ? void 0 : _a.length]);
47
+ node._id = this.uid + index;
48
+ node._layer = node.depth - 1;
49
+ node.data = { key: node.data[0], root: (_c = (_b = node.parent) === null || _b === void 0 ? void 0 : _b.data.root) !== null && _c !== void 0 ? _c : node.data[0] };
50
+ (_d = node.children) === null || _d === void 0 ? void 0 : _d.forEach((child, i) => {
51
+ var _a;
52
+ child._index = i;
53
+ child._state = {
54
+ fill: (_a = getColor(child, config.color, i, child.depth !== 1)) !== null && _a !== void 0 ? _a : scale.range(['#fff', getHexValue(node._state.fill, this.element)])(i),
55
+ };
56
+ });
57
+ });
58
+ const segments = partitionData.descendants().filter(d => d.parent && d.children && d.data.key);
59
+ return segments;
60
+ }
61
+ _render(customDuration) {
62
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
63
+ const { config } = this;
64
+ const duration = isNumber(customDuration) ? customDuration : config.duration;
65
+ const layers = (_a = config.layers) === null || _a === void 0 ? void 0 : _a.map((_, i) => { var _a; return (_a = getValue(i, config.layerSettings)) !== null && _a !== void 0 ? _a : defaultLayerSettings; });
66
+ const data = this.getHierarchyData();
67
+ const outerRadius = Math.min(this._width, this._height) / 2;
68
+ const innerRadius = Math.max(0, outerRadius - sum(layers, d => d.width + config.layerPadding));
69
+ const yMin = min(data, d => d.y0);
70
+ const yMax = max(data, d => d.y1);
71
+ this.radiusScale
72
+ .domain(config.direction === NestedDonutDirection.OUTWARDS ? [yMin, yMax] : [yMax, yMin])
73
+ .range([innerRadius, outerRadius]);
74
+ this.arcGen
75
+ .startAngle(d => d.x0)
76
+ .endAngle(d => d.x1)
77
+ .innerRadius(d => this.radiusScale(d.y0))
78
+ .outerRadius(d => this.radiusScale(d.y1))
79
+ .padAngle(config.padAngle)
80
+ .cornerRadius(config.cornerRadius);
81
+ this.arcGroup.attr('transform', `translate(${this._width / 2},${this._height / 2})`);
82
+ // Arcs
83
+ const arcs = this.arcGroup
84
+ .selectAll(`.${segment}`)
85
+ .data(data, d => d._id);
86
+ const arcsEnter = arcs.enter().append('path')
87
+ .attr('class', segment)
88
+ .call(createArc, config);
89
+ arcs.merge(arcsEnter)
90
+ .call(updateArc, config, this.arcGen, duration);
91
+ arcs.exit()
92
+ .attr('class', segmentExit)
93
+ .call(removeArc, duration);
94
+ // Segment labels
95
+ const arcLabels = this.arcGroup
96
+ .selectAll(`.${segmentLabel}`)
97
+ .data(data, d => d._id);
98
+ const arcLabelsEnter = arcLabels.enter().append('text')
99
+ .attr('class', segmentLabel)
100
+ .call(createLabel, config);
101
+ arcLabels.merge(arcLabelsEnter)
102
+ .call(updateLabel, config, this.arcGen, duration);
103
+ arcLabels.exit()
104
+ .call(removeLabel, duration);
105
+ // Chart labels
106
+ this.centralLabel
107
+ .attr('transform', `translate(${this._width / 2},${this._height / 2})`)
108
+ .attr('dy', config.centralSubLabel ? '-0.55em' : null)
109
+ .text((_b = config.centralLabel) !== null && _b !== void 0 ? _b : null);
110
+ this.centralSubLabel
111
+ .attr('transform', `translate(${this._width / 2},${this._height / 2})`)
112
+ .attr('dy', config.centralLabel ? '0.55em' : null)
113
+ .text((_c = config.centralSubLabel) !== null && _c !== void 0 ? _c : null);
114
+ if (config.centralSubLabelWrap)
115
+ wrapSVGText(this.centralSubLabel, innerRadius * 1.9, VerticalAlign.Top);
116
+ // Background
117
+ this.arcBackground.attr('class', background)
118
+ .attr('visibility', config.showBackground ? null : 'hidden')
119
+ .attr('transform', `translate(${this._width / 2},${this._height / 2})`);
120
+ smartTransition(this.arcBackground, duration)
121
+ .attr('d', arc()({
122
+ startAngle: (_g = (_e = (_d = config.angleRange) === null || _d === void 0 ? void 0 : _d[0]) !== null && _e !== void 0 ? _e : (_f = config.angleRange) === null || _f === void 0 ? void 0 : _f[0]) !== null && _g !== void 0 ? _g : 0,
123
+ endAngle: (_l = (_j = (_h = config.angleRange) === null || _h === void 0 ? void 0 : _h[1]) !== null && _j !== void 0 ? _j : (_k = config.angleRange) === null || _k === void 0 ? void 0 : _k[1]) !== null && _l !== void 0 ? _l : 2 * Math.PI,
124
+ innerRadius,
125
+ outerRadius,
126
+ }));
127
+ }
128
+ }
129
+ NestedDonut.selectors = style;
130
+ NestedDonut.cssVariables = variables;
131
+
132
+ export { NestedDonut };
133
+ //# 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, max, min, sum } 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 { getString, getValue, isNumber } from 'utils/data'\nimport { smartTransition } from 'utils/d3'\nimport { wrapSVGText } from 'utils/text'\n\n// Local Types\nimport { NestedDonutDirection, NestedDonutLayerSettings, NestedDonutSegment, defaultLayerSettings } 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<SVGPathElement, 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 radiusScale: ScaleLinear<number, number> = scaleLinear()\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('path')\n this.arcGroup = this.g.append('g')\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 private getHierarchyData (): NestedDonutSegment<Datum>[] {\n const { config, datamodel } = this\n\n const layerAccessors = config.layers?.map(layerAccessor => (d: Datum, i: number) => getString(d, layerAccessor, i))\n const nestedData = group(datamodel.data, ...layerAccessors as [(d: Datum) => string])\n const rootNode = hierarchy(nestedData).count()\n const partitionData = partition().size([config.angleRange[1], 1])(rootNode) as NestedDonutSegment<Datum>\n\n partitionData.eachBefore((node, index) => {\n const scale = this.colorScale.domain([-1, node.children?.length])\n node._id = this.uid + index\n node._layer = node.depth - 1\n\n node.data = { key: node.data[0], root: node.parent?.data.root ?? node.data[0] }\n node.children?.forEach((child, i) => {\n child._index = i\n child._state = {\n fill:\n getColor(child, config.color, 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 _render (customDuration?: number): void {\n const { config } = this\n const duration = isNumber(customDuration) ? customDuration : config.duration\n\n const layers: NestedDonutLayerSettings[] = config.layers?.map((_, i) => getValue(i, config.layerSettings) ?? defaultLayerSettings)\n const data = this.getHierarchyData()\n\n const outerRadius = Math.min(this._width, this._height) / 2\n const innerRadius = Math.max(0, outerRadius - sum(layers, d => d.width + config.layerPadding))\n\n const yMin = min(data, d => d.y0)\n const yMax = max(data, d => d.y1)\n\n this.radiusScale\n .domain(config.direction === NestedDonutDirection.OUTWARDS ? [yMin, yMax] : [yMax, yMin])\n .range([innerRadius, outerRadius])\n\n this.arcGen\n .startAngle(d => d.x0)\n .endAngle(d => d.x1)\n .innerRadius(d => this.radiusScale(d.y0))\n .outerRadius(d => this.radiusScale(d.y1))\n .padAngle(config.padAngle)\n .cornerRadius(config.cornerRadius)\n\n this.arcGroup.attr('transform', `translate(${this._width / 2},${this._height / 2})`)\n\n // Arcs\n const arcs = this.arcGroup\n .selectAll<SVGPathElement, NestedDonutSegment<Datum>>(`.${s.segment}`)\n .data(data, d => d._id)\n\n const arcsEnter = arcs.enter().append('path')\n .attr('class', s.segment)\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 arcLabels = this.arcGroup\n .selectAll<SVGTextElement, NestedDonutSegment<Datum>>(`.${s.segmentLabel}`)\n .data(data, d => d._id)\n\n const arcLabelsEnter = arcLabels.enter().append('text')\n .attr('class', s.segmentLabel)\n .call(createLabel, config)\n\n arcLabels.merge(arcLabelsEnter)\n .call(updateLabel, config, this.arcGen, duration)\n\n arcLabels.exit<NestedDonutSegment<Datum>>()\n .call(removeLabel, duration)\n\n // Chart labels\n this.centralLabel\n .attr('transform', `translate(${this._width / 2},${this._height / 2})`)\n .attr('dy', config.centralSubLabel ? '-0.55em' : null)\n .text(config.centralLabel ?? null)\n\n this.centralSubLabel\n .attr('transform', `translate(${this._width / 2},${this._height / 2})`)\n .attr('dy', config.centralLabel ? '0.55em' : null)\n .text(config.centralSubLabel ?? null)\n\n if (config.centralSubLabelWrap) wrapSVGText(this.centralSubLabel, innerRadius * 1.9, VerticalAlign.Top)\n\n // Background\n this.arcBackground.attr('class', s.background)\n .attr('visibility', config.showBackground ? null : 'hidden')\n .attr('transform', `translate(${this._width / 2},${this._height / 2})`)\n\n smartTransition(this.arcBackground, duration)\n .attr('d', arc()({\n startAngle: config.angleRange?.[0] ?? config.angleRange?.[0] ?? 0,\n endAngle: config.angleRange?.[1] ?? config.angleRange?.[1] ?? 2 * Math.PI,\n innerRadius,\n outerRadius,\n }))\n }\n}\n"],"names":["s.centralLabel","s.centralSubLabel","s.segment","s.segmentExit","s.segmentLabel","s.background","s","s.variables"],"mappings":";;;;;;;;;;;;;;;;;;AAgCM,MAAO,WAAmB,SAAQ,aAIvC,CAAA;AAiBC,IAAA,WAAA,CAAa,MAA0C,EAAA;AACrD,QAAA,KAAK,EAAE,CAAA;AAfT,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,IAAW,CAAA,WAAA,GAAgC,WAAW,EAAE,CAAA;QACxD,IAAU,CAAA,UAAA,GAAgC,WAAW,EAAE,CAAA;QAEvD,IAAM,CAAA,MAAA,GAAG,EAAG,CAAA;AAIV,QAAA,IAAI,MAAM;AAAE,YAAA,IAAI,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A,KAAA,CAAA,GAAA,EAAA,GAAA,CAAA,EAAA,GAAA,MAAM,CAAC,UAAU,0CAAG,CAAC,CAAC,mCAAI,CAAC;YACjE,QAAQ,EAAE,MAAA,CAAA,EAAA,GAAA,CAAA,EAAA,GAAA,MAAM,CAAC,UAAU,MAAG,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,CAAC,CAAC,MAAA,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,EAAA,GAAI,MAAA,MAAM,CAAC,UAAU,MAAA,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAG,CAAC,CAAC,mCAAI,CAAC,GAAG,IAAI,CAAC,EAAE;YACzE,WAAW;YACX,WAAW;AACZ,SAAA,CAAC,CAAC,CAAA;KACN;;AAzIM,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.color)) !== 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.color)) !== 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.color) ?? 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.color) ?? 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\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":[],"mapp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