@unovis/ts 1.1.2-beta.8 → 1.2.0-pre.0
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.
- package/components/chord-diagram/index.d.ts +3 -2
- package/components/chord-diagram/index.js +44 -51
- package/components/chord-diagram/index.js.map +1 -1
- package/components/chord-diagram/modules/link.d.ts +3 -16
- package/components/chord-diagram/modules/link.js +32 -26
- package/components/chord-diagram/modules/link.js.map +1 -1
- package/components/chord-diagram/types.d.ts +0 -4
- package/components/chord-diagram/types.js.map +1 -1
- package/components/line/index.js +0 -1
- package/components/line/index.js.map +1 -1
- package/components/nested-donut/config.d.ts +3 -0
- package/components/nested-donut/config.js +1 -0
- package/components/nested-donut/config.js.map +1 -1
- package/components/nested-donut/index.d.ts +2 -1
- package/components/nested-donut/index.js +54 -31
- package/components/nested-donut/index.js.map +1 -1
- package/components/nested-donut/modules/label.js +10 -5
- package/components/nested-donut/modules/label.js.map +1 -1
- package/components/nested-donut/style.d.ts +2 -1
- package/components/nested-donut/style.js +9 -4
- package/components/nested-donut/style.js.map +1 -1
- package/components/nested-donut/types.d.ts +3 -3
- package/components/nested-donut/types.js +2 -6
- package/components/nested-donut/types.js.map +1 -1
- package/components/scatter/config.d.ts +6 -0
- package/components/scatter/config.js +2 -0
- package/components/scatter/config.js.map +1 -1
- package/components/scatter/index.js +2 -0
- package/components/scatter/index.js.map +1 -1
- package/components/scatter/modules/point.js +8 -5
- package/components/scatter/modules/point.js.map +1 -1
- package/components/scatter/style.js +2 -2
- package/components/scatter/style.js.map +1 -1
- package/components/scatter/types.d.ts +2 -0
- package/index.js +1 -1
- package/package.json +1 -1
- package/types/accessor.d.ts +3 -3
- package/types.js +1 -1
- package/utils/misc.d.ts +1 -0
- package/utils/misc.js +4 -1
- package/utils/misc.js.map +1 -1
- package/utils/path.d.ts +2 -0
- package/utils/path.js +10 -1
- package/utils/path.js.map +1 -1
- package/utils/text.js +4 -3
- package/utils/text.js.map +1 -1
|
@@ -1 +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 /** Angular size for empty segments in radians. Default: `Math.PI / 180` */\n emptySegmentAngle?: number;\n /** Hide segment labels when they don't fit. Default: `true` */\n hideOverflowingSegmentLabels?: boolean;\n /** Color accessor function for segments. Default: `undefined` */\n segmentColor?: ColorAccessor<NestedDonutSegment<Datum>>;\n /** Segment label accessor function. Default `undefined` */\n segmentLabel?: StringAccessor<NestedDonutSegment<Datum>>;\n /** Color accessor function for segment labels */\n segmentLabelColor?: ColorAccessor<NestedDonutSegment<Datum>>;\n /** When true, the component will display empty segments (the ones that have `0` values) as tiny slices.\n * Default: `false`\n */\n showEmptySegments?: boolean;\n}\n\nexport class NestedDonutConfig<Datum> extends ComponentConfig implements NestedDonutConfigInterface<Datum> {\n angleRange = [0, 2 * Math.PI] as [number, number]\n centralLabel = undefined\n centralSubLabel = undefined\n centralSubLabelWrap = true\n cornerRadius = 0\n direction = NestedDonutDirection.Inwards\n emptySegmentAngle = Math.PI / 180\n hideOverflowingSegmentLabels = true\n layers: StringAccessor<Datum>[]\n layerPadding = 0\n layerSettings = undefined\n segmentColor = undefined\n segmentLabel = undefined\n segmentLabelColor = undefined\n showBackground = false\n showEmptySegments = false\n value = undefined\n}\n"],"names":[],"mappings":";;;AAAA;
|
|
1
|
+
{"version":3,"file":"config.js","sources":["../../../src/components/nested-donut/config.ts"],"sourcesContent":["// Core\nimport { ComponentConfigInterface, ComponentConfig } from 'core/component/config'\n\n// Types\nimport { ColorAccessor, GenericAccessor, NumericAccessor, StringAccessor } from 'types/accessor'\nimport { NestedDonutDirection, NestedDonutLayerSettings, NestedDonutSegment } from './types'\n\nexport interface NestedDonutConfigInterface<Datum> extends ComponentConfigInterface {\n /** Diagram angle range. Default: `[0, 2 * Math.PI]` */\n angleRange?: [number, number];\n /** Direction of hierarchy flow from root to leaf.\n * `NestedDonutDirection.Inwards` starts from the outer most radius and works towards center\n * `NestedDonutDirection.Outwards` starts from the inner most radius the consecutive layers outward.\n * Default: `NestedDonutDirection.Inwards`\n */\n direction?: NestedDonutDirection | string;\n /* Numeric accessor for segment size value. Default: `undefined`. */\n value?: NumericAccessor<Datum>;\n\n /** Central label text. Default: `undefined` */\n centralLabel?: string;\n /** Central sub-label accessor function or text. Default: `undefined` */\n centralSubLabel?: string;\n /** Enables wrapping for the sub-label. Default: `true` */\n centralSubLabelWrap?: boolean;\n /**\n * Show donut background. The color is configurable via\n * the `--vis-nested-donut-background-color` and `--vis-dark-nested-donut-background-color` CSS variables.\n * Default: `false`\n */\n showBackground?: boolean;\n /** Sort function for segments. Default `undefined` */\n sort?: (a: NestedDonutSegment<Datum>, b: NestedDonutSegment<Datum>) => number;\n\n // Layers\n /** Array of accessor functions to defined the nested groups */\n layers: StringAccessor<Datum>[];\n /* Layer settings */\n layerSettings?: GenericAccessor<NestedDonutLayerSettings, number>;\n /* Space between layers */\n layerPadding?: number;\n\n // Segments\n /** Corner Radius. Default: `0` */\n cornerRadius?: number;\n /** Angular size for empty segments in radians. Default: `Math.PI / 180` */\n emptySegmentAngle?: number;\n /** Hide segment labels when they don't fit. Default: `true` */\n hideOverflowingSegmentLabels?: boolean;\n /** Color accessor function for segments. Default: `undefined` */\n segmentColor?: ColorAccessor<NestedDonutSegment<Datum>>;\n /** Segment label accessor function. Default `undefined` */\n segmentLabel?: StringAccessor<NestedDonutSegment<Datum>>;\n /** Color accessor function for segment labels */\n segmentLabelColor?: ColorAccessor<NestedDonutSegment<Datum>>;\n /** When true, the component will display empty segments (the ones that have `0` values) as tiny slices.\n * Default: `false`\n */\n showEmptySegments?: boolean;\n}\n\nexport class NestedDonutConfig<Datum> extends ComponentConfig implements NestedDonutConfigInterface<Datum> {\n angleRange = [0, 2 * Math.PI] as [number, number]\n centralLabel = undefined\n centralSubLabel = undefined\n centralSubLabelWrap = true\n cornerRadius = 0\n direction = NestedDonutDirection.Inwards\n emptySegmentAngle = Math.PI / 180\n hideOverflowingSegmentLabels = true\n layers: StringAccessor<Datum>[]\n layerPadding = 0\n layerSettings = undefined\n segmentColor = undefined\n segmentLabel = undefined\n segmentLabelColor = undefined\n showBackground = false\n showEmptySegments = false\n sort = undefined\n value = undefined\n}\n"],"names":[],"mappings":";;;AAAA;AA6DM,MAAO,iBAAyB,SAAQ,eAAe,CAAA;AAA7D,IAAA,WAAA,GAAA;;QACE,IAAU,CAAA,UAAA,GAAG,CAAC,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,EAAE,CAAqB,CAAA;QACjD,IAAY,CAAA,YAAA,GAAG,SAAS,CAAA;QACxB,IAAe,CAAA,eAAA,GAAG,SAAS,CAAA;QAC3B,IAAmB,CAAA,mBAAA,GAAG,IAAI,CAAA;QAC1B,IAAY,CAAA,YAAA,GAAG,CAAC,CAAA;AAChB,QAAA,IAAA,CAAA,SAAS,GAAG,oBAAoB,CAAC,OAAO,CAAA;AACxC,QAAA,IAAA,CAAA,iBAAiB,GAAG,IAAI,CAAC,EAAE,GAAG,GAAG,CAAA;QACjC,IAA4B,CAAA,4BAAA,GAAG,IAAI,CAAA;QAEnC,IAAY,CAAA,YAAA,GAAG,CAAC,CAAA;QAChB,IAAa,CAAA,aAAA,GAAG,SAAS,CAAA;QACzB,IAAY,CAAA,YAAA,GAAG,SAAS,CAAA;QACxB,IAAY,CAAA,YAAA,GAAG,SAAS,CAAA;QACxB,IAAiB,CAAA,iBAAA,GAAG,SAAS,CAAA;QAC7B,IAAc,CAAA,cAAA,GAAG,KAAK,CAAA;QACtB,IAAiB,CAAA,iBAAA,GAAG,KAAK,CAAA;QACzB,IAAI,CAAA,IAAA,GAAG,SAAS,CAAA;QAChB,IAAK,CAAA,KAAA,GAAG,SAAS,CAAA;KAClB;AAAA;;;;"}
|
|
@@ -8,8 +8,8 @@ import * as s from './style';
|
|
|
8
8
|
export declare class NestedDonut<Datum> extends ComponentCore<Datum[], NestedDonutConfig<Datum>, NestedDonutConfigInterface<Datum>> {
|
|
9
9
|
static selectors: typeof s;
|
|
10
10
|
static cssVariables: {
|
|
11
|
-
nestedDonutBackgroundColor: "--vis-nested-donut-background-color";
|
|
12
11
|
nestedDonutFontFamily: "--vis-nested-donut-font-family";
|
|
12
|
+
nestedDonutBackgroundColor: "--vis-nested-donut-background-color";
|
|
13
13
|
nestedDonutCentralLabelFontSize: "--vis-nested-donut-central-label-font-size";
|
|
14
14
|
nestedDonutCentralLabelFontWeight: "--vis-nested-donut-central-label-font-weight";
|
|
15
15
|
nestedDonutCentralLabelTextColor: "--vis-nested-donut-central-label-text-color";
|
|
@@ -20,6 +20,7 @@ export declare class NestedDonut<Datum> extends ComponentCore<Datum[], NestedDon
|
|
|
20
20
|
nestedDonutSegmentStrokeColor: "--vis-nested-donut-segment-stroke-color";
|
|
21
21
|
nestedDonutSegmentLabelTextColorLight: "--vis-nested-donut-segment-label-text-color-light";
|
|
22
22
|
nestedDonutSegmentLabelTextColorDark: "--vis-nested-donut-segment-label-text-color-dark";
|
|
23
|
+
nestedDonutSegmentLabelFontSize: "--vis-nested-donut-segment-label-font-size";
|
|
23
24
|
darkNestedDonutBackgroundColor: "--vis-dark-nested-donut-background-color";
|
|
24
25
|
darkNestedDonutCentralLabelTextColor: "--vis-dark-nested-donut-central-label-text-color";
|
|
25
26
|
darkNestedDonutCentralSublabelTextColor: "--vis-dark-nested-donut-central-sublabel-text-color";
|
|
@@ -6,10 +6,12 @@ import { ComponentCore } from '../../core/component/index.js';
|
|
|
6
6
|
import { SeriesDataModel } from '../../data-models/series.js';
|
|
7
7
|
import { VerticalAlign } from '../../types/text.js';
|
|
8
8
|
import { getHexValue, getColor } from '../../utils/color.js';
|
|
9
|
-
import { isNumber, getString, getNumber, isNumberWithinRange, merge, getValue } from '../../utils/data.js';
|
|
10
9
|
import { smartTransition } from '../../utils/d3.js';
|
|
10
|
+
import { isNumber, getString, getNumber, isNumberWithinRange, merge, getValue } from '../../utils/data.js';
|
|
11
|
+
import { getPixelValue } from '../../utils/misc.js';
|
|
12
|
+
import { cssvar } from '../../utils/style.js';
|
|
11
13
|
import { wrapSVGText } from '../../utils/text.js';
|
|
12
|
-
import {
|
|
14
|
+
import { NestedDonutSegmentLabelAlignment, NestedDonutDirection } from './types.js';
|
|
13
15
|
import { NestedDonutConfig } from './config.js';
|
|
14
16
|
import { createArc, updateArc, removeArc } from './modules/arc.js';
|
|
15
17
|
import { createLabel, updateLabel, removeLabel } from './modules/label.js';
|
|
@@ -54,13 +56,15 @@ class NestedDonut extends ComponentCore {
|
|
|
54
56
|
const backgroundsEnter = backgrounds.enter().append('path')
|
|
55
57
|
.attr('class', background)
|
|
56
58
|
.attr('visibility', config.showBackground ? null : 'hidden');
|
|
57
|
-
const backgroundsMerged = backgrounds.merge(backgroundsEnter)
|
|
59
|
+
const backgroundsMerged = backgrounds.merge(backgroundsEnter)
|
|
60
|
+
.style('transition', `fill ${duration}ms`)
|
|
61
|
+
.style('fill', d => d.backgroundColor);
|
|
58
62
|
smartTransition(backgroundsMerged, duration)
|
|
59
63
|
.attr('d', d => {
|
|
60
|
-
var _a, _b, _c, _d
|
|
64
|
+
var _a, _b, _c, _d;
|
|
61
65
|
return this.arcGen({
|
|
62
|
-
x0: (
|
|
63
|
-
x1: (
|
|
66
|
+
x0: (_b = (_a = config.angleRange) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : 0,
|
|
67
|
+
x1: (_d = (_c = config.angleRange) === null || _c === void 0 ? void 0 : _c[1]) !== null && _d !== void 0 ? _d : 2 * Math.PI,
|
|
64
68
|
y0: d._innerRadius,
|
|
65
69
|
y1: d._outerRadius,
|
|
66
70
|
});
|
|
@@ -121,35 +125,45 @@ class NestedDonut extends ComponentCore {
|
|
|
121
125
|
? hierarchy(nestedData).sum(index => typeof index === 'number' && getNumber(data[index], config.value, index))
|
|
122
126
|
: hierarchy(nestedData).count();
|
|
123
127
|
const partitionData = partition().size([config.angleRange[1], 1])(rootNode);
|
|
124
|
-
partitionData
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
node.data = {
|
|
128
|
+
partitionData
|
|
129
|
+
.each(node => {
|
|
130
|
+
var _a, _b, _c;
|
|
131
|
+
node.data = {
|
|
132
|
+
key: node.data[0],
|
|
133
|
+
values: ((_a = (node.data[1])) === null || _a === void 0 ? void 0 : _a.length) ? node.data[1].map((index) => data[index]) : [],
|
|
134
|
+
root: (_c = (_b = node.parent) === null || _b === void 0 ? void 0 : _b.data.root) !== null && _c !== void 0 ? _c : node.data[0],
|
|
135
|
+
};
|
|
136
|
+
node._id = `root${partitionData.path(node).map(d => d.data.key).join('->')}`;
|
|
128
137
|
if (isNumberWithinRange(node.depth - 1, [0, layers.length - 1])) {
|
|
129
|
-
node._id = this.uid.replace(/-.*/gm, `-${key}`);
|
|
130
138
|
node._layer = layers[node.depth - 1];
|
|
131
139
|
node.y0 = node._layer._innerRadius;
|
|
132
140
|
node.y1 = node._layer._outerRadius;
|
|
133
141
|
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
142
|
+
})
|
|
143
|
+
.eachAfter(node => { var _a; return (_a = node.children) === null || _a === void 0 ? void 0 : _a.forEach(ch => node.data.values.push(...ch.data.values)); })
|
|
144
|
+
.eachBefore(node => {
|
|
145
|
+
var _a, _b, _c;
|
|
146
|
+
if (!node.children || node.depth === rootNode.height - 1)
|
|
147
|
+
return;
|
|
148
|
+
const colors = this.colorScale
|
|
149
|
+
.domain([-1, node.children.length])
|
|
150
|
+
.range([getHexValue((_a = node._state) === null || _a === void 0 ? void 0 : _a.fill, this.element), '#fff']);
|
|
151
|
+
const positions = pie()
|
|
152
|
+
.startAngle(node.parent ? node.x0 : (_b = config.angleRange) === null || _b === void 0 ? void 0 : _b[0])
|
|
153
|
+
.endAngle(node.parent ? node.x1 : (_c = config.angleRange) === null || _c === void 0 ? void 0 : _c[1])
|
|
154
|
+
.value(d => config.showEmptySegments && d.value === 0
|
|
155
|
+
? config.emptySegmentAngle
|
|
156
|
+
: (d.x1 - d.x0))
|
|
157
|
+
.sort(config.sort)(node.children);
|
|
158
|
+
node.children.forEach((child, i) => {
|
|
159
|
+
var _a;
|
|
160
|
+
child._index = i;
|
|
161
|
+
child.x0 = positions[i].startAngle;
|
|
162
|
+
child.x1 = positions[i].endAngle;
|
|
163
|
+
child._state = {
|
|
164
|
+
fill: (_a = getColor(child, config.segmentColor, positions[i].index, child.depth !== 1)) !== null && _a !== void 0 ? _a : colors(positions[i].index),
|
|
165
|
+
};
|
|
166
|
+
});
|
|
153
167
|
});
|
|
154
168
|
const segments = partitionData.descendants().filter(d => { var _a; return ((_a = d.parent) === null || _a === void 0 ? void 0 : _a.value) && d.data.key; });
|
|
155
169
|
return segments;
|
|
@@ -157,11 +171,20 @@ class NestedDonut extends ComponentCore {
|
|
|
157
171
|
_getLayerSettings() {
|
|
158
172
|
const { direction, layers, layerPadding, layerSettings } = this.config;
|
|
159
173
|
const outerRadius = Math.min(this._width, this._height) / 2;
|
|
174
|
+
const defaultLayerSettings = {
|
|
175
|
+
backgroundColor: cssvar(variables.nestedDonutBackgroundColor),
|
|
176
|
+
labelAlignment: NestedDonutSegmentLabelAlignment.Perpendicular,
|
|
177
|
+
width: outerRadius * 0.75 / layers.length,
|
|
178
|
+
};
|
|
160
179
|
const layerItems = layers.reduceRight((arr, _, i) => {
|
|
161
180
|
const layerId = direction === NestedDonutDirection.Outwards ? i : arr.length;
|
|
162
181
|
const layerConfig = merge(defaultLayerSettings, getValue(layerId, layerSettings));
|
|
163
182
|
const radius = arr.length ? arr[0]._innerRadius - layerPadding : outerRadius;
|
|
164
|
-
|
|
183
|
+
const layerWidth = getPixelValue(layerConfig.width);
|
|
184
|
+
if (layerWidth === null) {
|
|
185
|
+
console.warn(`Unovis | Nested Donut: Could not parse width ${layerConfig.width}. Setting to default.`);
|
|
186
|
+
}
|
|
187
|
+
arr.unshift(Object.assign(Object.assign({}, layerConfig), { _id: layerId, _outerRadius: radius, _innerRadius: radius - (layerWidth !== null && layerWidth !== void 0 ? layerWidth : defaultLayerSettings.width) }));
|
|
165
188
|
return arr;
|
|
166
189
|
}, new Array());
|
|
167
190
|
return direction === NestedDonutDirection.Inwards ? layerItems.reverse() : layerItems;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/components/nested-donut/index.ts"],"sourcesContent":["import { Selection } from 'd3-selection'\nimport { arc, pie } from 'd3-shape'\nimport { hierarchy, partition } from 'd3-hierarchy'\nimport { scaleLinear, ScaleLinear } from 'd3-scale'\nimport { group } from 'd3-array'\n\n// Core\nimport { ComponentCore } from 'core/component'\nimport { SeriesDataModel } from 'data-models/series'\n\n// Types\nimport { VerticalAlign } from 'types/text'\n\n// Utils\nimport { getColor, 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 smartTransition(backgrounds.exit(), duration)\n .style('opacity', 0)\n .remove()\n\n // Segments\n const segments = this.arcGroup.selectAll<SVGGElement, NestedDonutSegment<Datum>>(`${s.segment}`)\n .data(data, d => d._id)\n\n const segmentsEnter = segments.enter()\n .append('g')\n .attr('class', s.segment)\n\n segments.merge(segmentsEnter)\n smartTransition(segments.exit(), duration)\n .attr('class', s.segmentExit)\n .style('opacity', 0)\n .remove()\n\n // Segment arcs\n const arcs = this.arcGroup\n .selectAll<SVGPathElement, NestedDonutSegment<Datum>>(`.${s.segmentArc}`)\n .data(data, d => d._id)\n\n const arcsEnter = segmentsEnter.append('path')\n .attr('class', s.segmentArc)\n .call(createArc, config)\n\n arcs.merge(arcsEnter)\n .call(updateArc, config, this.arcGen, duration)\n\n arcs.exit<NestedDonutSegment<Datum>>()\n .attr('class', s.segmentExit)\n .call(removeArc, duration)\n\n // Segment labels\n const labels = this.arcGroup\n .selectAll<SVGTextElement, NestedDonutSegment<Datum>>(`.${s.segmentLabel}`)\n .data(data, d => d._id)\n\n const labelsEnter = segmentsEnter.append('text')\n .attr('class', s.segmentLabel)\n .call(createLabel, this.arcGen)\n\n labels.merge(labelsEnter)\n .call(updateLabel, config, this.arcGen, duration)\n\n labels.exit<NestedDonutSegment<Datum>>()\n .call(removeLabel, duration)\n\n // Chart labels\n this.centralLabel\n .attr('dy', config.centralSubLabel ? '-0.55em' : null)\n .text(config.centralLabel ?? null)\n\n this.centralSubLabel\n .attr('dy', config.centralLabel ? '0.55em' : null)\n .text(config.centralSubLabel ?? null)\n\n if (config.centralSubLabelWrap) wrapSVGText(this.centralSubLabel, layers[0]._innerRadius * 1.9, VerticalAlign.Top)\n }\n\n private _getHierarchyData (layers: NestedDonutLayer[]): NestedDonutSegment<Datum>[] {\n const { config, datamodel: { data } } = this\n\n const layerAccessors = config.layers?.map(layerAccessor => (i: number) => getString(data[i], layerAccessor, i))\n const nestedData = group(data.keys(), ...layerAccessors as [(i: number) => string])\n const rootNode = config.value !== undefined\n ? hierarchy(nestedData).sum(index => typeof index === 'number' && getNumber(data[index], config.value, index))\n : hierarchy(nestedData).count()\n\n const partitionData = partition().size([config.angleRange[1], 1])(rootNode) as NestedDonutSegment<Datum>\n\n partitionData.eachBefore(node => {\n const key = node.data[0] as string\n node.data = { key, root: node.parent?.data.root ?? key }\n\n if (isNumberWithinRange(node.depth - 1, [0, layers.length - 1])) {\n node._id = this.uid.replace(/-.*/gm, `-${key}`)\n node._layer = layers[node.depth - 1]\n node.y0 = node._layer._innerRadius\n node.y1 = node._layer._outerRadius\n }\n\n if (node.children) {\n const colors = this.colorScale\n .domain([-1, node.children.length])\n .range(['#fff', getHexValue(node._state?.fill, this.element)])\n\n const positions = pie<NestedDonutSegment<Datum>>()\n .startAngle(node.parent ? node.x0 : config.angleRange?.[0])\n .endAngle(node.parent ? node.x1 : config.angleRange?.[1])\n .value(d => config.showEmptySegments && d.value === 0 ? config.emptySegmentAngle : (d.x1 - d.x0))\n .sort(d => d._index)(node.children)\n\n node.children.forEach((child, i) => {\n child._index = i\n child.x0 = positions[i].startAngle\n child.x1 = positions[i].endAngle\n child._state = {\n fill: getColor(child, config.segmentColor, i, child.depth !== 1) ?? colors(i),\n }\n })\n }\n })\n const segments = partitionData.descendants().filter(d => d.parent?.value && d.data.key)\n return segments\n }\n\n private _getLayerSettings (): NestedDonutLayer[] {\n const { direction, layers, layerPadding, layerSettings } = this.config\n\n const outerRadius = Math.min(this._width, this._height) / 2\n\n const layerItems = layers.reduceRight((arr, _, i) => {\n const layerId = direction === NestedDonutDirection.Outwards ? i : arr.length\n const layerConfig = merge(defaultLayerSettings, getValue(layerId, layerSettings))\n const radius = arr.length ? arr[0]._innerRadius - layerPadding : outerRadius\n arr.unshift({\n ...layerConfig,\n _id: layerId,\n _outerRadius: radius,\n _innerRadius: radius - layerConfig.width,\n })\n return arr\n }, new Array<NestedDonutLayer>())\n\n return direction === NestedDonutDirection.Inwards ? layerItems.reverse() : layerItems\n }\n}\n"],"names":["s.segmentsGroup","s.centralLabel","s.centralSubLabel","s.background","s.segment","s.segmentExit","s.segmentArc","s.segmentLabel","s","s.variables"],"mappings":";;;;;;;;;;;;;;;;;;AAgCM,MAAO,WAAmB,SAAQ,aAIvC,CAAA;AAgBC,IAAA,WAAA,CAAa,MAA0C,EAAA;AACrD,QAAA,KAAK,EAAE,CAAA;AAdT,QAAA,IAAA,CAAA,MAAM,GAA6B,IAAI,iBAAiB,EAAE,CAAA;AAC1D,QAAA,IAAA,CAAA,SAAS,GAA2B,IAAI,eAAe,EAAE,CAAA;QAOzD,IAAM,CAAA,MAAA,GAAG,GAAG,EAAsC,CAAA;QAClD,IAAU,CAAA,UAAA,GAAgC,WAAW,EAAE,CAAA;QAEvD,IAAM,CAAA,MAAA,GAAG,EAAG,CAAA;AAIV,QAAA,IAAI,MAAM;AAAE,YAAA,IAAI,CAAC,M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,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;;AA5LM,WAAS,CAAA,SAAA,GAAGC,KAAC,CAAA;AACb,WAAA,CAAA,YAAY,GAAGC,SAAW;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/components/nested-donut/index.ts"],"sourcesContent":["import { Selection } from 'd3-selection'\nimport { arc, pie } from 'd3-shape'\nimport { hierarchy, partition } from 'd3-hierarchy'\nimport { scaleLinear, ScaleLinear } from 'd3-scale'\nimport { group } from 'd3-array'\n\n// Core\nimport { ComponentCore } from 'core/component'\nimport { SeriesDataModel } from 'data-models/series'\n\n// Types\nimport { VerticalAlign } from 'types/text'\n\n// Utils\nimport { getColor, getHexValue } from 'utils/color'\nimport { smartTransition } from 'utils/d3'\nimport { getNumber, getString, getValue, isNumber, isNumberWithinRange, merge } from 'utils/data'\nimport { getPixelValue } from 'utils/misc'\nimport { cssvar } from 'utils/style'\nimport { wrapSVGText } from 'utils/text'\n\n// Local Types\nimport { NestedDonutDirection, NestedDonutSegment, NestedDonutLayer, NestedDonutSegmentLabelAlignment } from './types'\n\n// Config\nimport { NestedDonutConfig, NestedDonutConfigInterface } from './config'\n\n// Modules\nimport { createArc, updateArc, removeArc } from './modules/arc'\nimport { createLabel, updateLabel, removeLabel } from './modules/label'\n\n// Styles\nimport * as s from './style'\n\nexport class NestedDonut<Datum> extends ComponentCore<\nDatum[],\nNestedDonutConfig<Datum>,\nNestedDonutConfigInterface<Datum>\n> {\n static selectors = s\n static cssVariables = s.variables\n config: NestedDonutConfig<Datum> = new NestedDonutConfig()\n datamodel: SeriesDataModel<Datum> = new SeriesDataModel()\n\n arcBackground: Selection<SVGGElement, unknown, SVGGElement, unknown>\n arcGroup: Selection<SVGGElement, unknown, SVGGElement, unknown>\n centralLabel: Selection<SVGTextElement, unknown, SVGGElement, unknown>\n centralSubLabel: Selection<SVGTextElement, unknown, SVGGElement, unknown>\n\n arcGen = arc<Partial<NestedDonutSegment<Datum>>>()\n colorScale: ScaleLinear<string, string> = scaleLinear()\n\n events = { }\n\n constructor (config?: NestedDonutConfigInterface<Datum>) {\n super()\n if (config) this.config.init(config)\n this.arcBackground = this.g.append('g')\n this.arcGroup = this.g.append('g')\n .attr('class', s.segmentsGroup)\n this.centralLabel = this.g.append('text')\n .attr('class', s.centralLabel)\n this.centralSubLabel = this.g.append('text')\n .attr('class', s.centralSubLabel)\n }\n\n _render (customDuration?: number): void {\n const { config } = this\n const duration = isNumber(customDuration) ? customDuration : config.duration\n\n const layers = this._getLayerSettings()\n const data = this._getHierarchyData(layers)\n\n this.arcGen\n .startAngle(d => d.x0)\n .endAngle(d => d.x1)\n .innerRadius(d => d.y0)\n .outerRadius(d => d.y1)\n .cornerRadius(config.cornerRadius)\n\n this.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 .style('transition', `fill ${duration}ms`)\n .style('fill', d => d.backgroundColor)\n\n smartTransition(backgroundsMerged, duration)\n .attr('d', d => this.arcGen({\n x0: config.angleRange?.[0] ?? 0,\n x1: config.angleRange?.[1] ?? 2 * Math.PI,\n y0: d._innerRadius,\n y1: d._outerRadius,\n }))\n\n smartTransition(backgrounds.exit(), duration)\n .style('opacity', 0)\n .remove()\n\n // Segments\n const segments = this.arcGroup.selectAll<SVGGElement, NestedDonutSegment<Datum>>(`${s.segment}`)\n .data(data, d => d._id)\n\n const segmentsEnter = segments.enter()\n .append('g')\n .attr('class', s.segment)\n\n segments.merge(segmentsEnter)\n smartTransition(segments.exit(), duration)\n .attr('class', s.segmentExit)\n .style('opacity', 0)\n .remove()\n\n // Segment arcs\n const arcs = this.arcGroup\n .selectAll<SVGPathElement, NestedDonutSegment<Datum>>(`.${s.segmentArc}`)\n .data(data, d => d._id)\n\n const arcsEnter = segmentsEnter.append('path')\n .attr('class', s.segmentArc)\n .call(createArc, config)\n\n arcs.merge(arcsEnter)\n .call(updateArc, config, this.arcGen, duration)\n\n arcs.exit<NestedDonutSegment<Datum>>()\n .attr('class', s.segmentExit)\n .call(removeArc, duration)\n\n // Segment labels\n const labels = this.arcGroup\n .selectAll<SVGTextElement, NestedDonutSegment<Datum>>(`.${s.segmentLabel}`)\n .data(data, d => d._id)\n\n const labelsEnter = segmentsEnter.append('text')\n .attr('class', s.segmentLabel)\n .call(createLabel, this.arcGen)\n\n labels.merge(labelsEnter)\n .call(updateLabel, config, this.arcGen, duration)\n\n labels.exit<NestedDonutSegment<Datum>>()\n .call(removeLabel, duration)\n\n // Chart labels\n this.centralLabel\n .attr('dy', config.centralSubLabel ? '-0.55em' : null)\n .text(config.centralLabel ?? null)\n\n this.centralSubLabel\n .attr('dy', config.centralLabel ? '0.55em' : null)\n .text(config.centralSubLabel ?? null)\n\n if (config.centralSubLabelWrap) wrapSVGText(this.centralSubLabel, layers[0]._innerRadius * 1.9, VerticalAlign.Top)\n }\n\n private _getHierarchyData (layers: NestedDonutLayer[]): NestedDonutSegment<Datum>[] {\n const { config, datamodel: { data } } = this\n\n const layerAccessors = config.layers?.map(layerAccessor => (i: number) => getString(data[i], layerAccessor, i))\n const nestedData = group(data.keys(), ...layerAccessors as [(i: number) => string])\n\n const rootNode = config.value !== undefined\n ? hierarchy(nestedData).sum(index => typeof index === 'number' && getNumber(data[index], config.value, index))\n : hierarchy(nestedData).count()\n\n const partitionData = partition().size([config.angleRange[1], 1])(rootNode) as NestedDonutSegment<Datum>\n\n partitionData\n .each(node => {\n node.data = {\n key: node.data[0] as string,\n values: (node.data[1])?.length ? node.data[1].map((index: number) => data[index]) : [],\n root: node.parent?.data.root ?? node.data[0],\n }\n node._id = `root${partitionData.path(node).map(d => d.data.key).join('->')}`\n if (isNumberWithinRange(node.depth - 1, [0, layers.length - 1])) {\n node._layer = layers[node.depth - 1]\n node.y0 = node._layer._innerRadius\n node.y1 = node._layer._outerRadius\n }\n })\n .eachAfter(node => node.children?.forEach(ch => node.data.values.push(...ch.data.values)))\n .eachBefore(node => {\n if (!node.children || node.depth === rootNode.height - 1) return\n\n const colors = this.colorScale\n .domain([-1, node.children.length])\n .range([getHexValue(node._state?.fill, this.element), '#fff'])\n\n const positions = pie<NestedDonutSegment<Datum>>()\n .startAngle(node.parent ? node.x0 : config.angleRange?.[0])\n .endAngle(node.parent ? node.x1 : config.angleRange?.[1])\n .value(d => config.showEmptySegments && d.value === 0\n ? config.emptySegmentAngle\n : (d.x1 - d.x0))\n .sort(config.sort)(node.children)\n\n node.children.forEach((child, i) => {\n child._index = i\n child.x0 = positions[i].startAngle\n child.x1 = positions[i].endAngle\n child._state = {\n fill:\n getColor(child, config.segmentColor, positions[i].index, child.depth !== 1) ??\n colors(positions[i].index),\n }\n })\n })\n\n const segments = partitionData.descendants().filter(d => d.parent?.value && d.data.key)\n return segments\n }\n\n private _getLayerSettings (): NestedDonutLayer[] {\n const { direction, layers, layerPadding, layerSettings } = this.config\n\n const outerRadius = Math.min(this._width, this._height) / 2\n\n const defaultLayerSettings = {\n backgroundColor: cssvar(s.variables.nestedDonutBackgroundColor),\n labelAlignment: NestedDonutSegmentLabelAlignment.Perpendicular,\n width: outerRadius * 0.75 / layers.length,\n }\n const layerItems = layers.reduceRight((arr, _, i) => {\n const layerId = direction === NestedDonutDirection.Outwards ? i : arr.length\n const layerConfig = merge(defaultLayerSettings, getValue(layerId, layerSettings))\n const radius = arr.length ? arr[0]._innerRadius - layerPadding : outerRadius\n const layerWidth = getPixelValue(layerConfig.width)\n if (layerWidth === null) {\n console.warn(`Unovis | Nested Donut: Could not parse width ${layerConfig.width}. Setting to default.`)\n }\n arr.unshift({\n ...layerConfig,\n _id: layerId,\n _outerRadius: radius,\n _innerRadius: radius - (layerWidth ?? defaultLayerSettings.width),\n })\n return arr\n }, new Array<NestedDonutLayer>())\n\n return direction === NestedDonutDirection.Inwards ? layerItems.reverse() : layerItems\n }\n}\n"],"names":["s.segmentsGroup","s.centralLabel","s.centralSubLabel","s.background","s.segment","s.segmentExit","s.segmentArc","s.segmentLabel","s.variables","s"],"mappings":";;;;;;;;;;;;;;;;;;;;AAkCM,MAAO,WAAmB,SAAQ,aAIvC,CAAA;AAgBC,IAAA,WAAA,CAAa,MAA0C,EAAA;AACrD,QAAA,KAAK,EAAE,CAAA;AAdT,QAAA,IAAA,CAAA,MAAM,GAA6B,IAAI,iBAAiB,EAAE,CAAA;AAC1D,QAAA,IAAA,CAAA,SAAS,GAA2B,IAAI,eAAe,EAAE,CAAA;QAOzD,IAAM,CAAA,MAAA,GAAG,GAAG,EAAsC,CAAA;QAClD,IAAU,CAAA,UAAA,GAAgC,WAAW,EAAE,CAAA;QAEvD,IAAM,CAAA,MAAA,GAAG,EAAG,CAAA;AAIV,QAAA,IAAI,MAAM;AAAE,YAAA,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;QACpC,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;QACvC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;AAC/B,aAAA,IAAI,CAAC,OAAO,EAAEA,aAAe,CAAC,CAAA;QACjC,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC;AACtC,aA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C,OAAO,GAAG,UAAU,CAAC,OAAO,EAAE,GAAG,UAAU,CAAA;KACtF;;AAnNM,WAAS,CAAA,SAAA,GAAGC,KAAC,CAAA;AACb,WAAA,CAAA,YAAY,GAAGD,SAAW;;;;"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { select } from 'd3-selection';
|
|
2
2
|
import { color } from 'd3-color';
|
|
3
|
-
import { UNOVIS_TEXT_DEFAULT } from '../../../styles/index.js';
|
|
4
3
|
import { getColor, hexToBrightness } from '../../../utils/color.js';
|
|
5
4
|
import { smartTransition } from '../../../utils/d3.js';
|
|
6
5
|
import { getString } from '../../../utils/data.js';
|
|
6
|
+
import { getCSSVariableValueInPixels } from '../../../utils/misc.js';
|
|
7
7
|
import { cssvar } from '../../../utils/style.js';
|
|
8
8
|
import { wrapSVGText } from '../../../utils/text.js';
|
|
9
9
|
import { NestedDonutSegmentLabelAlignment } from '../types.js';
|
|
@@ -31,7 +31,7 @@ function getLabelTransform(d, arcGen) {
|
|
|
31
31
|
function getLabelBounds(d) {
|
|
32
32
|
const arcWidth = d.y1 - d.y0;
|
|
33
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) *
|
|
34
|
+
const bandwidth = Math.max(Math.abs(Math.cos(d.x0 + (d.x1 - d.x0) / 2 - Math.PI / 2) * arcWidth), arcWidth);
|
|
35
35
|
switch (d._layer.labelAlignment) {
|
|
36
36
|
case NestedDonutSegmentLabelAlignment.Perpendicular:
|
|
37
37
|
return { width: arcWidth, height: arcLength };
|
|
@@ -55,10 +55,15 @@ function updateLabel(selection, config, arcGen, duration) {
|
|
|
55
55
|
.each((d, i, els) => {
|
|
56
56
|
const bounds = getLabelBounds(d);
|
|
57
57
|
const label = select(els[i]).call(wrapSVGText, bounds.width);
|
|
58
|
-
const offset = label.selectChildren().size() - 1;
|
|
59
58
|
const { width, height } = label.node().getBBox();
|
|
60
|
-
|
|
61
|
-
.attr('visibility',
|
|
59
|
+
if (config.hideOverflowingSegmentLabels && (width > bounds.width || height > bounds.height) && 'hidden') {
|
|
60
|
+
label.attr('visibility', 'hidden');
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
const fontSize = getCSSVariableValueInPixels(cssvar(variables.nestedDonutSegmentLabelFontSize), els[i]);
|
|
64
|
+
const len = label.selectChildren().size() - 1;
|
|
65
|
+
label.attr('dy', -fontSize / 2 * len);
|
|
66
|
+
}
|
|
62
67
|
});
|
|
63
68
|
smartTransition(selection, duration)
|
|
64
69
|
.attr('transform', d => getLabelTransform(d, arcGen))
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"label.js","sources":["../../../../src/components/nested-donut/modules/label.ts"],"sourcesContent":["import { Selection, select } from 'd3-selection'\nimport { color } from 'd3-color'\nimport { Arc } from 'd3-shape'\n\n// Utils\nimport {
|
|
1
|
+
{"version":3,"file":"label.js","sources":["../../../../src/components/nested-donut/modules/label.ts"],"sourcesContent":["import { Selection, select } from 'd3-selection'\nimport { color } from 'd3-color'\nimport { Arc } from 'd3-shape'\n\n// Utils\nimport { getColor, hexToBrightness } from 'utils/color'\nimport { smartTransition } from 'utils/d3'\nimport { getString } from 'utils/data'\nimport { getCSSVariableValueInPixels } from 'utils/misc'\nimport { cssvar } from 'utils/style'\nimport { wrapSVGText } from 'utils/text'\n\n// Config\nimport { NestedDonutConfig } from '../config'\n\n// Local Types\nimport { NestedDonutSegment, NestedDonutSegmentLabelAlignment } from '../types'\n\n// Styles\nimport { variables } from '../style'\n\nfunction getLabelFillColor<Datum> (\n d: NestedDonutSegment<Datum>,\n 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) * arcWidth), arcWidth)\n switch (d._layer.labelAlignment) {\n case NestedDonutSegmentLabelAlignment.Perpendicular:\n return { width: arcWidth, height: arcLength }\n case NestedDonutSegmentLabelAlignment.Along:\n return { width: arcLength, height: arcWidth }\n case NestedDonutSegmentLabelAlignment.Straight:\n return { width: bandwidth, height: bandwidth }\n }\n}\n\nexport function createLabel<Datum> (\n selection: Selection<SVGTextElement, NestedDonutSegment<Datum>, SVGGElement, unknown>,\n arcGen: Arc<unknown, NestedDonutSegment<Datum>>\n): void {\n selection\n .attr('transform', d => getLabelTransform(d, arcGen))\n .style('visibility', null)\n .style('opacity', 0)\n}\n\n\nexport function updateLabel<Datum> (\n selection: Selection<SVGTextElement, NestedDonutSegment<Datum>, SVGGElement, unknown>,\n config: NestedDonutConfig<Datum>,\n arcGen: Arc<unknown, NestedDonutSegment<Datum>>,\n duration: number\n): void {\n selection\n .text(d => getString(d, config.segmentLabel) ?? d.data.key)\n .style('transition', `fill ${duration}ms`)\n .style('fill', d => 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\n const { width, height } = label.node().getBBox()\n\n if (config.hideOverflowingSegmentLabels && (width > bounds.width || height > bounds.height) && 'hidden') {\n label.attr('visibility', 'hidden')\n } else {\n const fontSize = getCSSVariableValueInPixels(cssvar(variables.nestedDonutSegmentLabelFontSize), els[i])\n const len = label.selectChildren().size() - 1\n label.attr('dy', -fontSize / 2 * len)\n }\n })\n\n smartTransition(selection, duration)\n .attr('transform', d => getLabelTransform(d, arcGen))\n .style('opacity', 1)\n}\n\nexport function removeLabel<Datum> (\n selection: Selection<SVGTextElement, NestedDonutSegment<Datum>, SVGGElement, unknown>,\n duration: number\n): void {\n smartTransition(selection, duration)\n .style('opacity', 0)\n .remove()\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAqBA,SAAS,iBAAiB,CACxB,CAA4B,EAC5B,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,G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"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export declare const root: string;
|
|
2
2
|
export declare const segmentsGroup: string;
|
|
3
3
|
export declare const variables: {
|
|
4
|
-
nestedDonutBackgroundColor: "--vis-nested-donut-background-color";
|
|
5
4
|
nestedDonutFontFamily: "--vis-nested-donut-font-family";
|
|
5
|
+
nestedDonutBackgroundColor: "--vis-nested-donut-background-color";
|
|
6
6
|
nestedDonutCentralLabelFontSize: "--vis-nested-donut-central-label-font-size";
|
|
7
7
|
nestedDonutCentralLabelFontWeight: "--vis-nested-donut-central-label-font-weight";
|
|
8
8
|
nestedDonutCentralLabelTextColor: "--vis-nested-donut-central-label-text-color";
|
|
@@ -13,6 +13,7 @@ export declare const variables: {
|
|
|
13
13
|
nestedDonutSegmentStrokeColor: "--vis-nested-donut-segment-stroke-color";
|
|
14
14
|
nestedDonutSegmentLabelTextColorLight: "--vis-nested-donut-segment-label-text-color-light";
|
|
15
15
|
nestedDonutSegmentLabelTextColorDark: "--vis-nested-donut-segment-label-text-color-dark";
|
|
16
|
+
nestedDonutSegmentLabelFontSize: "--vis-nested-donut-segment-label-font-size";
|
|
16
17
|
darkNestedDonutBackgroundColor: "--vis-dark-nested-donut-background-color";
|
|
17
18
|
darkNestedDonutCentralLabelTextColor: "--vis-dark-nested-donut-central-label-text-color";
|
|
18
19
|
darkNestedDonutCentralSublabelTextColor: "--vis-dark-nested-donut-central-sublabel-text-color";
|
|
@@ -2,9 +2,10 @@ import { css } from '@emotion/css';
|
|
|
2
2
|
import { getCssVarNames, injectGlobalCssVariables } from '../../utils/style.js';
|
|
3
3
|
|
|
4
4
|
const cssVarDefaults = {
|
|
5
|
-
'--vis-nested-donut-background-color': '#E7E9F3',
|
|
6
5
|
// Undefined by default to allow proper fallback to var(--vis-font-family)
|
|
7
6
|
'--vis-nested-donut-font-family': undefined,
|
|
7
|
+
// Background
|
|
8
|
+
'--vis-nested-donut-background-color': '#E7E9F3',
|
|
8
9
|
// Central label
|
|
9
10
|
'--vis-nested-donut-central-label-font-size': '16px',
|
|
10
11
|
'--vis-nested-donut-central-label-font-weight': 600,
|
|
@@ -15,9 +16,10 @@ const cssVarDefaults = {
|
|
|
15
16
|
'--vis-nested-donut-central-sublabel-text-color': '#5b5f6d',
|
|
16
17
|
// Segments
|
|
17
18
|
'--vis-nested-donut-segment-stroke-width': '1px',
|
|
18
|
-
'--vis-nested-donut-segment-stroke-color':
|
|
19
|
+
'--vis-nested-donut-segment-stroke-color': 'var(--vis-nested-donut-background-color)',
|
|
19
20
|
'--vis-nested-donut-segment-label-text-color-light': '#5b5f6d',
|
|
20
21
|
'--vis-nested-donut-segment-label-text-color-dark': '#fff',
|
|
22
|
+
'--vis-nested-donut-segment-label-font-size': '1em',
|
|
21
23
|
/* Dark theme */
|
|
22
24
|
'--vis-dark-nested-donut-background-color': '#18160C',
|
|
23
25
|
'--vis-dark-nested-donut-central-label-text-color': '#fff',
|
|
@@ -33,7 +35,9 @@ const variables = getCssVarNames(cssVarDefaults);
|
|
|
33
35
|
injectGlobalCssVariables(cssVarDefaults, root);
|
|
34
36
|
const background = css `
|
|
35
37
|
label: background;
|
|
36
|
-
fill: var(--vis-donut-background-color);
|
|
38
|
+
fill: var(--vis-nested-donut-background-color);
|
|
39
|
+
stroke-width: var(--vis-nested-donut-segment-stroke-width);
|
|
40
|
+
stroke: var(--vis-nested-donut-segment-stroke-color);
|
|
37
41
|
`;
|
|
38
42
|
const segment = css `
|
|
39
43
|
label: segment;
|
|
@@ -44,13 +48,14 @@ const segmentExit = css `
|
|
|
44
48
|
const segmentArc = css `
|
|
45
49
|
label: segment-arc;
|
|
46
50
|
stroke-width: var(--vis-nested-donut-segment-stroke-width);
|
|
47
|
-
stroke: var(--vis-nested-donut-segment-stroke-color
|
|
51
|
+
stroke: var(--vis-nested-donut-segment-stroke-color);
|
|
48
52
|
`;
|
|
49
53
|
const segmentLabel = css `
|
|
50
54
|
label: segment-label;
|
|
51
55
|
text-anchor: middle;
|
|
52
56
|
dominant-baseline: middle;
|
|
53
57
|
user-select: none;
|
|
58
|
+
font-size: var(--vis-nested-donut-segment-label-font-size);
|
|
54
59
|
`;
|
|
55
60
|
const centralLabel = css `
|
|
56
61
|
label: central-label;
|
|
@@ -1 +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
|
|
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 // Undefined by default to allow proper fallback to var(--vis-font-family)\n '--vis-nested-donut-font-family': undefined,\n\n // Background\n '--vis-nested-donut-background-color': '#E7E9F3',\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': 'var(--vis-nested-donut-background-color)',\n '--vis-nested-donut-segment-label-text-color-light': '#5b5f6d',\n '--vis-nested-donut-segment-label-text-color-dark': '#fff',\n '--vis-nested-donut-segment-label-font-size': '1em',\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-nested-donut-background-color);\n stroke-width: var(--vis-nested-donut-segment-stroke-width);\n stroke: var(--vis-nested-donut-segment-stroke-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);\n`\n\nexport const segmentLabel = css`\n label: segment-label;\n text-anchor: middle;\n dominant-baseline: middle;\n user-select: none;\n font-size: var(--vis-nested-donut-segment-label-font-size);\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;;AAErB,IAAA,gCAAgC,EAAE,SAAS;;AAG3C,IAAA,qCAAqC,EAAE,SAAS;;AAGhD,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,0CAA0C;AACrF,IAAA,mDAAmD,EAAE,SAAS;AAC9D,IAAA,kDAAkD,EAAE,MAAM;AAC1D,IAAA,4CAA4C,EAAE,KAAK;;AAGnD,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;;;;;EAK5B;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;;;;;;EAM9B;AAEM,MAAM,YAAY,GAAG,GAAG,CAAA,CAAA;;;;;;;;EAQ9B;AAEM,MAAM,eAAe,GAAG,GAAG,CAAA,CAAA;;;;;;;;;;;;"}
|
|
@@ -2,7 +2,7 @@ import { HierarchyRectangularNode } from 'd3-hierarchy';
|
|
|
2
2
|
export declare type NestedDonutSegmentDatum<Datum> = {
|
|
3
3
|
key: string;
|
|
4
4
|
root: string;
|
|
5
|
-
values
|
|
5
|
+
values: Datum[];
|
|
6
6
|
};
|
|
7
7
|
export declare type NestedDonutSegment<Datum> = HierarchyRectangularNode<NestedDonutSegmentDatum<Datum>> & {
|
|
8
8
|
_id: string;
|
|
@@ -22,12 +22,12 @@ export declare enum NestedDonutSegmentLabelAlignment {
|
|
|
22
22
|
Straight = "straight"
|
|
23
23
|
}
|
|
24
24
|
export declare type NestedDonutLayerSettings = {
|
|
25
|
+
backgroundColor?: string;
|
|
25
26
|
labelAlignment?: NestedDonutSegmentLabelAlignment;
|
|
26
|
-
width?: number;
|
|
27
|
+
width?: number | string;
|
|
27
28
|
};
|
|
28
29
|
export declare type NestedDonutLayer = NestedDonutLayerSettings & {
|
|
29
30
|
_id: number;
|
|
30
31
|
_innerRadius: number;
|
|
31
32
|
_outerRadius: number;
|
|
32
33
|
};
|
|
33
|
-
export declare const defaultLayerSettings: NestedDonutLayerSettings;
|
|
@@ -8,11 +8,7 @@ var NestedDonutSegmentLabelAlignment;
|
|
|
8
8
|
NestedDonutSegmentLabelAlignment["Along"] = "along";
|
|
9
9
|
NestedDonutSegmentLabelAlignment["Perpendicular"] = "perpendicular";
|
|
10
10
|
NestedDonutSegmentLabelAlignment["Straight"] = "straight";
|
|
11
|
-
})(NestedDonutSegmentLabelAlignment || (NestedDonutSegmentLabelAlignment = {}));
|
|
12
|
-
const defaultLayerSettings = {
|
|
13
|
-
labelAlignment: NestedDonutSegmentLabelAlignment.Perpendicular,
|
|
14
|
-
width: 50,
|
|
15
|
-
};
|
|
11
|
+
})(NestedDonutSegmentLabelAlignment || (NestedDonutSegmentLabelAlignment = {}));
|
|
16
12
|
|
|
17
|
-
export { NestedDonutDirection, NestedDonutSegmentLabelAlignment
|
|
13
|
+
export { NestedDonutDirection, NestedDonutSegmentLabelAlignment };
|
|
18
14
|
//# sourceMappingURL=types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sources":["../../../src/components/nested-donut/types.ts"],"sourcesContent":["import { HierarchyRectangularNode } from 'd3-hierarchy'\n\nexport type NestedDonutSegmentDatum<Datum> = {\n key: string;\n root: string;\n values
|
|
1
|
+
{"version":3,"file":"types.js","sources":["../../../src/components/nested-donut/types.ts"],"sourcesContent":["import { HierarchyRectangularNode } from 'd3-hierarchy'\n\nexport type NestedDonutSegmentDatum<Datum> = {\n key: string;\n root: string;\n values: Datum[];\n}\n\nexport type NestedDonutSegment<Datum> = HierarchyRectangularNode<NestedDonutSegmentDatum<Datum>> & {\n _id: string;\n _layer: NestedDonutLayer;\n _index?: number;\n _state?: {\n fill?: string;\n };\n}\n\nexport enum NestedDonutDirection {\n Inwards = 'inwards',\n Outwards = 'outwards',\n}\n\nexport enum NestedDonutSegmentLabelAlignment {\n Along = 'along',\n Perpendicular = 'perpendicular',\n Straight = 'straight',\n}\n\nexport type NestedDonutLayerSettings = {\n backgroundColor?: string;\n labelAlignment?: NestedDonutSegmentLabelAlignment;\n width?: number | string;\n}\n\nexport type NestedDonutLayer = NestedDonutLayerSettings & {\n _id: number;\n _innerRadius: number;\n _outerRadius: number;\n}\n\n"],"names":[],"mappings":"IAiBY,qBAGX;AAHD,CAAA,UAAY,oBAAoB,EAAA;AAC9B,IAAA,oBAAA,CAAA,SAAA,CAAA,GAAA,SAAmB,CAAA;AACnB,IAAA,oBAAA,CAAA,UAAA,CAAA,GAAA,UAAqB,CAAA;AACvB,CAAC,EAHW,oBAAoB,KAApB,oBAAoB,GAG/B,EAAA,CAAA,CAAA,CAAA;IAEW,iCAIX;AAJD,CAAA,UAAY,gCAAgC,EAAA;AAC1C,IAAA,gCAAA,CAAA,OAAA,CAAA,GAAA,OAAe,CAAA;AACf,IAAA,gCAAA,CAAA,eAAA,CAAA,GAAA,eAA+B,CAAA;AAC/B,IAAA,gCAAA,CAAA,UAAA,CAAA,GAAA,UAAqB,CAAA;AACvB,CAAC,EAJW,gCAAgC,KAAhC,gCAAgC,GAI3C,EAAA,CAAA,CAAA;;;;"}
|
|
@@ -30,6 +30,10 @@ export interface ScatterConfigInterface<Datum> extends XYComponentConfigInterfac
|
|
|
30
30
|
labelTextBrightnessRatio?: number;
|
|
31
31
|
/** Label position. Default: `Position.Bottom` */
|
|
32
32
|
labelPosition?: GenericAccessor<Position | string, Datum>;
|
|
33
|
+
/** Point stroke color. Default: `undefined` */
|
|
34
|
+
strokeColor?: ColorAccessor<Datum>;
|
|
35
|
+
/** Point stroke width. Default: `undefined` */
|
|
36
|
+
strokeWidth?: NumericAccessor<Datum>;
|
|
33
37
|
}
|
|
34
38
|
export declare class ScatterConfig<Datum> extends XYComponentConfig<Datum> implements ScatterConfigInterface<Datum> {
|
|
35
39
|
size: number;
|
|
@@ -41,4 +45,6 @@ export declare class ScatterConfig<Datum> extends XYComponentConfig<Datum> imple
|
|
|
41
45
|
labelPosition: Position;
|
|
42
46
|
cursor: any;
|
|
43
47
|
labelTextBrightnessRatio: number;
|
|
48
|
+
strokeColor: ScatterConfigInterface<Datum>['strokeColor'];
|
|
49
|
+
strokeWidth: ScatterConfigInterface<Datum>['strokeWidth'];
|
|
44
50
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sources":["../../../src/components/scatter/config.ts"],"sourcesContent":["import { ScalePower } from 'd3-scale'\n// Core\nimport { XYComponentConfigInterface, XYComponentConfig } from 'core/xy-component/config'\n\n// Types\nimport { Scale, ContinuousScale } from 'types/scale'\nimport { SymbolType } from 'types/symbol'\nimport { ColorAccessor, GenericAccessor, NumericAccessor, StringAccessor } from 'types/accessor'\nimport { Position } from 'types/position'\n\nexport interface ScatterConfigInterface<Datum> extends XYComponentConfigInterface<Datum> {\n /**\n * Size of the scatter plot marker (e.g. diameter if `SymbolType.Circle` is used for `shape`) in pixels.\n * Can be a constant value or an accessor function. But if `sizeRange` is set, then the values will be treated\n * as an input to `sizeScale`, and the resulting size will be different.\n * Default: `10`\n */\n size?: NumericAccessor<Datum>;\n /** Size scale to be used if the `sizeRange` was set. Default: `Scale.scaleSqrt()` */\n sizeScale?: ContinuousScale;\n /** Size range in the format of `[number, number]` to rescale the input values. Default: `undefined` */\n sizeRange?: [number, number];\n /** Shape of the scatter point. Accessor function or constant value: `SymbolType.Circle`, `SymbolType.Cross`, `SymbolType.Diamond`, `SymbolType.Square`,\n * `SymbolType.Star`, `SymbolType.Triangle` or `SymbolType.Wye`.\n * Default: `SymbolType.Circle` */\n shape?: ((d: Datum, i?: number, ...any) => (SymbolType | string)) | SymbolType | string;\n /** Label accessor function or string. Default: `undefined` */\n label?: StringAccessor<Datum>;\n /** Label color. Default: `undefined` */\n labelColor?: ColorAccessor<Datum>;\n /** Optional point cursor. Default: `null` */\n cursor?: StringAccessor<Datum>;\n /** Point color brightness ratio for switching between dark and light text label color. Default: `0.65` */\n labelTextBrightnessRatio?: number;\n /** Label position. Default: `Position.Bottom` */\n labelPosition?: GenericAccessor<Position | string, Datum>;\n}\n\nexport class ScatterConfig<Datum> extends XYComponentConfig<Datum> implements ScatterConfigInterface<Datum> {\n size = 10\n sizeScale: ScalePower<number, number> = Scale.scaleSqrt()\n sizeRange = undefined\n shape = SymbolType.Circle\n label = undefined\n labelColor = undefined\n labelPosition = Position.Bottom\n cursor = null\n labelTextBrightnessRatio = 0.65\n}\n"],"names":[],"mappings":";;;;;AACA;
|
|
1
|
+
{"version":3,"file":"config.js","sources":["../../../src/components/scatter/config.ts"],"sourcesContent":["import { ScalePower } from 'd3-scale'\n// Core\nimport { XYComponentConfigInterface, XYComponentConfig } from 'core/xy-component/config'\n\n// Types\nimport { Scale, ContinuousScale } from 'types/scale'\nimport { SymbolType } from 'types/symbol'\nimport { ColorAccessor, GenericAccessor, NumericAccessor, StringAccessor } from 'types/accessor'\nimport { Position } from 'types/position'\n\nexport interface ScatterConfigInterface<Datum> extends XYComponentConfigInterface<Datum> {\n /**\n * Size of the scatter plot marker (e.g. diameter if `SymbolType.Circle` is used for `shape`) in pixels.\n * Can be a constant value or an accessor function. But if `sizeRange` is set, then the values will be treated\n * as an input to `sizeScale`, and the resulting size will be different.\n * Default: `10`\n */\n size?: NumericAccessor<Datum>;\n /** Size scale to be used if the `sizeRange` was set. Default: `Scale.scaleSqrt()` */\n sizeScale?: ContinuousScale;\n /** Size range in the format of `[number, number]` to rescale the input values. Default: `undefined` */\n sizeRange?: [number, number];\n /** Shape of the scatter point. Accessor function or constant value: `SymbolType.Circle`, `SymbolType.Cross`, `SymbolType.Diamond`, `SymbolType.Square`,\n * `SymbolType.Star`, `SymbolType.Triangle` or `SymbolType.Wye`.\n * Default: `SymbolType.Circle` */\n shape?: ((d: Datum, i?: number, ...any) => (SymbolType | string)) | SymbolType | string;\n /** Label accessor function or string. Default: `undefined` */\n label?: StringAccessor<Datum>;\n /** Label color. Default: `undefined` */\n labelColor?: ColorAccessor<Datum>;\n /** Optional point cursor. Default: `null` */\n cursor?: StringAccessor<Datum>;\n /** Point color brightness ratio for switching between dark and light text label color. Default: `0.65` */\n labelTextBrightnessRatio?: number;\n /** Label position. Default: `Position.Bottom` */\n labelPosition?: GenericAccessor<Position | string, Datum>;\n /** Point stroke color. Default: `undefined` */\n strokeColor?: ColorAccessor<Datum>;\n /** Point stroke width. Default: `undefined` */\n strokeWidth?: NumericAccessor<Datum>;\n}\n\nexport class ScatterConfig<Datum> extends XYComponentConfig<Datum> implements ScatterConfigInterface<Datum> {\n size = 10\n sizeScale: ScalePower<number, number> = Scale.scaleSqrt()\n sizeRange = undefined\n shape = SymbolType.Circle\n label = undefined\n labelColor = undefined\n labelPosition = Position.Bottom\n cursor = null\n labelTextBrightnessRatio = 0.65\n strokeColor: ScatterConfigInterface<Datum>['strokeColor'] = undefined\n strokeWidth: ScatterConfigInterface<Datum>['strokeWidth'] = undefined\n}\n"],"names":[],"mappings":";;;;;AACA;AAyCM,MAAO,aAAqB,SAAQ,iBAAwB,CAAA;AAAlE,IAAA,WAAA,GAAA;;QACE,IAAI,CAAA,IAAA,GAAG,EAAE,CAAA;AACT,QAAA,IAAA,CAAA,SAAS,GAA+B,KAAK,CAAC,SAAS,EAAE,CAAA;QACzD,IAAS,CAAA,SAAA,GAAG,SAAS,CAAA;AACrB,QAAA,IAAA,CAAA,KAAK,GAAG,UAAU,CAAC,MAAM,CAAA;QACzB,IAAK,CAAA,KAAA,GAAG,SAAS,CAAA;QACjB,IAAU,CAAA,UAAA,GAAG,SAAS,CAAA;AACtB,QAAA,IAAA,CAAA,aAAa,GAAG,QAAQ,CAAC,MAAM,CAAA;QAC/B,IAAM,CAAA,MAAA,GAAG,IAAI,CAAA;QACb,IAAwB,CAAA,wBAAA,GAAG,IAAI,CAAA;QAC/B,IAAW,CAAA,WAAA,GAAiD,SAAS,CAAA;QACrE,IAAW,CAAA,WAAA,GAAiD,SAAS,CAAA;KACtE;AAAA;;;;"}
|
|
@@ -134,6 +134,8 @@ class Scatter extends XYComponentCore {
|
|
|
134
134
|
yValue: yValue,
|
|
135
135
|
sizePx: pointSizeScaled,
|
|
136
136
|
color: getColor(d, config.color, j),
|
|
137
|
+
strokeColor: getColor(d, config.strokeColor, j, true),
|
|
138
|
+
strokeWidthPx: getNumber(d, config.strokeWidth, j),
|
|
137
139
|
shape: getString(d, config.shape, j),
|
|
138
140
|
label: getString(d, config.label, j),
|
|
139
141
|
labelColor: getValue(d, config.labelColor, j),
|