@unovis/ts 1.1.1 → 1.1.2-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/components/axis/style.js +11 -2
  2. package/components/axis/style.js.map +1 -1
  3. package/components/leaflet-map/index.d.ts +5 -0
  4. package/components/leaflet-map/index.js +9 -0
  5. package/components/leaflet-map/index.js.map +1 -1
  6. package/components/leaflet-map/modules/utils.d.ts +1 -1
  7. package/components/leaflet-map/modules/utils.js +3 -3
  8. package/components/leaflet-map/modules/utils.js.map +1 -1
  9. package/components/leaflet-map/types.d.ts +1 -0
  10. package/components/leaflet-map/types.js.map +1 -1
  11. package/components/nested-donut/config.d.ts +57 -0
  12. package/components/nested-donut/config.js +26 -0
  13. package/components/nested-donut/config.js.map +1 -0
  14. package/components/nested-donut/index.d.ts +40 -0
  15. package/components/nested-donut/index.js +160 -0
  16. package/components/nested-donut/index.js.map +1 -0
  17. package/components/nested-donut/modules/arc.d.ts +17 -0
  18. package/components/nested-donut/modules/arc.js +50 -0
  19. package/components/nested-donut/modules/arc.js.map +1 -0
  20. package/components/nested-donut/modules/label.d.ts +7 -0
  21. package/components/nested-donut/modules/label.js +74 -0
  22. package/components/nested-donut/modules/label.js.map +1 -0
  23. package/components/nested-donut/style.d.ts +26 -0
  24. package/components/nested-donut/style.js +75 -0
  25. package/components/nested-donut/style.js.map +1 -0
  26. package/components/nested-donut/types.d.ts +33 -0
  27. package/components/nested-donut/types.js +18 -0
  28. package/components/nested-donut/types.js.map +1 -0
  29. package/components.d.ts +2 -0
  30. package/components.js +1 -0
  31. package/components.js.map +1 -1
  32. package/index.js +2 -0
  33. package/index.js.map +1 -1
  34. package/package.json +1 -1
  35. package/types.d.ts +1 -0
  36. package/types.js +1 -0
  37. package/types.js.map +1 -1
  38. package/utils/style.d.ts +1 -1
  39. package/utils/style.js.map +1 -1
@@ -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,IAA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,GAAG,CAAC,GAAG,GAAG,CAAC,MAAM,CAAA;AAC5E,YAAA,MAAM,WAAW,GAAG,KAAK,CAAC,oBAAoB,EAAE,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC,CAAA;YACjF,MAAM,MAAM,GAAG,GAAG,CAAC,MAAM,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,YAAY,GAAG,YAAY,GAAG,WAAW,CAAA;YAC5E,GAAG,CAAC,OAAO,CACN,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,EAAA,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,YAAY,CAAC,MAAI,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,EAAA,GAAA,CAAC,CAAC,MAAM,CAAC,IAAI,CAAA,EAAA,CAAC;AACrE,SAAA,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC;SACnB,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,KAAI;AAClB,QAAA,MAAM,OAAO,GAAY,GAAG,CAAC,CAAC,CAAC,CAAA;AAC/B,QAAA,MAAM,WAAW,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,CAAA;AACrC,QAAA,MAAM,cAAc,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,CAAA;QACxC,OAAO,CAAC,UAAU,GAAG;YACnB,EAAE,EAAE,WAAW,GAAG,cAAc;YAChC,EAAE,EAAE,WAAW,GAAG,cAAc;YAChC,EAAE,EAAE,CAAC,CAAC,EAAE;YACR,EAAE,EAAE,CAAC,CAAC,EAAE;SACT,CAAA;AACH,KAAC,CAAC,CAAA;AACN,CAAC;AAEK,SAAU,SAAS,CACvB,SAAqF,EACrF,MAAgC,EAChC,MAA2B,EAC3B,QAAgB,EAAA;IAEhB,SAAS;SACN,KAAK,CAAC,YAAY,EAAE,CAAA,KAAA,EAAQ,QAAQ,CAAI,EAAA,CAAA,CAAC;SACzC,KAAK,C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AAA,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,CAAC,MAAM,CAAC,IAAI,CAAA;AAC3D,IAAA,MAAM,WAAW,GAAG,KAAK,CAAC,CAAC,CAAC,CAAA;AAC5B,IAAA,MAAM,UAAU,GAAG,WAAW,GAAG,eAAe,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAA;AACvE,IAAA,OAAO,MAAM,CAAC,UAAU,GAAG,IAAI,GAAG,SAAS,CAAC,qCAAqC,GAAG,SAAS,CAAC,oCAAoC,CAAC,CAAA;AACrI,CAAC;AAED,SAAS,iBAAiB,CACxB,CAA4B,EAC5B,MAA+C,EAAA;IAE/C,MAAM,SAAS,GAAG,CAAA,UAAA,EAAa,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAA,CAAA,CAAG,CAAA;AACpD,IAAA,MAAM,MAAM,GAAG,GAAG,GAAG,IAAI,CAAC,EAAE,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,EAAE,CAAA;AACvF,IAAA,QAAQ,CAAC,CAAC,MAAM,CAAC,cAAc;QAC7B,KAAK,gCAAgC,CAAC,KAAK;AACzC,YAAA,OAAO,GAAG,SAAS,CAAA,QAAA,EAAW,MAAM,GAAG,EAAE,GAAG,CAAA;QAC9C,KAAK,gCAAgC,CAAC,aAAa;AACjD,YAAA,OAAO,GA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AAC,IAAI,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,mBAAmB,CAAC,QAAQ,IAAI,CAAC,GAAG,MAAM,CAAC,CAAC;aACpE,IAAI,CAAC,YAAY,EAAE,MAAM,CAAC,4BAA4B,KAAK,KAAK,GAAG,MAAM,CAAC,KAAK,IAAI,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,QAAQ,CAAC,CAAA;AAC5H,KAAC,CAAC,CAAA;AAEJ,IAAA,eAAe,CAAC,SAAS,EAAE,QAAQ,CAAC;AACjC,SAAA,IAAI,CAAC,WAAW,EAAE,CAAC,IAAI,iBAAiB,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;AACpD,SAAA,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC,CAAA;AACxB,CAAC;AAEe,SAAA,WAAW,CACzB,SAAqF,EACrF,QAAgB,EAAA;AAEhB,IAAA,eAAe,CAAC,SAAS,EAAE,QAAQ,CAAC;AACjC,SAAA,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC;AACnB,SAAA,MAAM,EAAE,CAAA;AACb;;;;"}
@@ -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;;;;;;;;;;;;"}