@unovis/ts 1.5.1-xplg.5 → 1.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/components/annotations/style.js.map +1 -1
- package/components/area/config.d.ts +0 -2
- package/components/area/config.js +1 -1
- package/components/area/config.js.map +1 -1
- package/components/area/index.js +3 -6
- package/components/area/index.js.map +1 -1
- package/components/area/style.js.map +1 -1
- package/components/axis/config.d.ts +1 -1
- package/components/axis/config.js.map +1 -1
- package/components/axis/index.d.ts +1 -0
- package/components/axis/index.js +10 -2
- package/components/axis/index.js.map +1 -1
- package/components/axis/style.js.map +1 -1
- package/components/brush/config.d.ts +1 -1
- package/components/brush/config.js.map +1 -1
- package/components/brush/style.js.map +1 -1
- package/components/bullet-legend/style.js.map +1 -1
- package/components/chord-diagram/index.js +3 -1
- package/components/chord-diagram/index.js.map +1 -1
- package/components/chord-diagram/style.js.map +1 -1
- package/components/crosshair/style.js.map +1 -1
- package/components/donut/style.js.map +1 -1
- package/components/flow-legend/style.js.map +1 -1
- package/components/free-brush/style.js.map +1 -1
- package/components/graph/index.js +3 -4
- package/components/graph/index.js.map +1 -1
- package/components/graph/modules/link/index.js +1 -2
- package/components/graph/modules/link/index.js.map +1 -1
- package/components/graph/modules/link/style.js.map +1 -1
- package/components/graph/modules/node/style.js.map +1 -1
- package/components/graph/modules/panel/style.js.map +1 -1
- package/components/graph/style.js.map +1 -1
- package/components/grouped-bar/style.js.map +1 -1
- package/components/leaflet-flow-map/config.js +0 -1
- package/components/leaflet-flow-map/config.js.map +1 -1
- package/components/leaflet-flow-map/shaders.js.map +1 -1
- package/components/leaflet-map/config.js +0 -1
- package/components/leaflet-map/config.js.map +1 -1
- package/components/leaflet-map/modules/map.js +3 -3
- package/components/leaflet-map/modules/map.js.map +1 -1
- package/components/leaflet-map/renderer/leaflet-maplibre-gl.js.map +1 -1
- package/components/leaflet-map/style.js.map +1 -1
- package/components/line/config.d.ts +5 -0
- package/components/line/config.js +1 -1
- package/components/line/config.js.map +1 -1
- package/components/line/index.js +41 -2
- package/components/line/index.js.map +1 -1
- package/components/line/style.d.ts +1 -0
- package/components/line/style.js +12 -1
- package/components/line/style.js.map +1 -1
- package/components/line/types.d.ts +1 -0
- package/components/nested-donut/config.d.ts +1 -1
- package/components/nested-donut/config.js.map +1 -1
- package/components/nested-donut/style.js.map +1 -1
- package/components/sankey/modules/label.js.map +1 -1
- package/components/sankey/modules/link.js.map +1 -1
- package/components/sankey/style.js.map +1 -1
- package/components/scatter/index.d.ts +1 -0
- package/components/scatter/index.js +11 -1
- package/components/scatter/index.js.map +1 -1
- package/components/scatter/style.js.map +1 -1
- package/components/stacked-bar/style.js.map +1 -1
- package/components/timeline/config.d.ts +14 -65
- package/components/timeline/config.js +1 -15
- package/components/timeline/config.js.map +1 -1
- package/components/timeline/index.d.ts +10 -21
- package/components/timeline/index.js +93 -379
- package/components/timeline/index.js.map +1 -1
- package/components/timeline/style.d.ts +0 -7
- package/components/timeline/style.js +1 -40
- package/components/timeline/style.js.map +1 -1
- package/components/tooltip/config.d.ts +6 -4
- package/components/tooltip/config.js +3 -1
- package/components/tooltip/config.js.map +1 -1
- package/components/tooltip/index.d.ts +7 -3
- package/components/tooltip/index.js +39 -9
- package/components/tooltip/index.js.map +1 -1
- package/components/tooltip/style.js.map +1 -1
- package/components/topojson-map/index.js.map +1 -1
- package/components/topojson-map/style.js.map +1 -1
- package/components/vis-controls/style.js.map +1 -1
- package/components/xy-labels/index.js +1 -1
- package/components/xy-labels/index.js.map +1 -1
- package/components/xy-labels/style.js.map +1 -1
- package/components.d.ts +0 -4
- package/components.js +0 -2
- package/components.js.map +1 -1
- package/containers/single-container/config.d.ts +0 -3
- package/containers/single-container/config.js.map +1 -1
- package/containers/single-container/index.js +1 -2
- package/containers/single-container/index.js.map +1 -1
- package/containers/xy-container/config.d.ts +0 -5
- package/containers/xy-container/config.js +1 -1
- package/containers/xy-container/config.js.map +1 -1
- package/containers/xy-container/index.d.ts +0 -1
- package/containers/xy-container/index.js +11 -15
- package/containers/xy-container/index.js.map +1 -1
- package/core/container/config.js +0 -1
- package/core/container/config.js.map +1 -1
- package/index.js +3 -5
- package/index.js.map +1 -1
- package/maps/ind-regions.json.js +1 -1
- package/maps/us-counties.json.js +8 -8
- package/package.json +9 -7
- package/styles/index.js.map +1 -1
- package/styles/patterns.js.map +1 -1
- package/styles/sizes.js.map +1 -1
- package/types/position.d.ts +1 -2
- package/types/position.js +0 -1
- package/types/position.js.map +1 -1
- package/types.d.ts +0 -2
- package/types.js +1 -4
- package/types.js.map +1 -1
- package/utils/color.d.ts +0 -14
- package/utils/color.js +2 -26
- package/utils/color.js.map +1 -1
- package/utils/data.d.ts +1 -1
- package/utils/data.js +2 -2
- package/utils/data.js.map +1 -1
- package/utils/index.js +3 -3
- package/utils/path.d.ts +0 -8
- package/utils/path.js +1 -109
- package/utils/path.js.map +1 -1
- package/utils/text.d.ts +1 -2
- package/utils/text.js +2 -10
- package/utils/text.js.map +1 -1
- package/components/rolling-pin-legend/config.d.ts +0 -19
- package/components/rolling-pin-legend/config.js +0 -9
- package/components/rolling-pin-legend/config.js.map +0 -1
- package/components/rolling-pin-legend/index.d.ts +0 -16
- package/components/rolling-pin-legend/index.js +0 -63
- package/components/rolling-pin-legend/index.js.map +0 -1
- package/components/rolling-pin-legend/style.d.ts +0 -5
- package/components/rolling-pin-legend/style.js +0 -40
- package/components/rolling-pin-legend/style.js.map +0 -1
- package/components/rolling-pin-legend/types.d.ts +0 -1
- package/components/timeline/constants.d.ts +0 -3
- package/components/timeline/constants.js +0 -6
- package/components/timeline/constants.js.map +0 -1
- package/components/timeline/types.d.ts +0 -62
- package/components/timeline/types.js +0 -2
- package/components/timeline/types.js.map +0 -1
- package/components/timeline/utils.d.ts +0 -2
- package/components/timeline/utils.js +0 -16
- package/components/timeline/utils.js.map +0 -1
- package/components/treemap/config.d.ts +0 -44
- package/components/treemap/config.js +0 -6
- package/components/treemap/config.js.map +0 -1
- package/components/treemap/index.d.ts +0 -16
- package/components/treemap/index.js +0 -263
- package/components/treemap/index.js.map +0 -1
- package/components/treemap/style.d.ts +0 -22
- package/components/treemap/style.js +0 -62
- package/components/treemap/style.js.map +0 -1
- package/components/treemap/types.d.ts +0 -11
- package/components/treemap/types.js +0 -2
- package/components/treemap/types.js.map +0 -1
package/components/line/index.js
CHANGED
|
@@ -9,7 +9,7 @@ import { Curve, CurveType } from '../../types/curve.js';
|
|
|
9
9
|
import { Direction } from '../../types/direction.js';
|
|
10
10
|
import { LineDefaultConfig } from './config.js';
|
|
11
11
|
import * as style from './style.js';
|
|
12
|
-
import { line as line$1, linePath, lineSelectionHelper, dim } from './style.js';
|
|
12
|
+
import { line as line$1, linePath, lineSelectionHelper, interpolatedPath, dim } from './style.js';
|
|
13
13
|
|
|
14
14
|
class Line extends XYComponentCore {
|
|
15
15
|
constructor(config) {
|
|
@@ -59,20 +59,42 @@ class Line extends XYComponentCore {
|
|
|
59
59
|
const rawValue = getNumber(d, a, i);
|
|
60
60
|
// If `rawValue` is not numerical or if it's not finite (`NaN`, `undefined`, ...), we replace it with `config.fallbackValue`
|
|
61
61
|
const value = (isNumber(rawValue) || (rawValue === null)) && isFinite(rawValue) ? rawValue : config.fallbackValue;
|
|
62
|
+
const defined = config.interpolateMissingData
|
|
63
|
+
? (isNumber(rawValue) || (rawValue === null)) && isFinite(rawValue)
|
|
64
|
+
: isFinite(value);
|
|
62
65
|
return {
|
|
63
66
|
x: lineDataX[i],
|
|
64
67
|
y: this.yScale(value !== null && value !== void 0 ? value : 0),
|
|
65
|
-
defined
|
|
68
|
+
defined,
|
|
66
69
|
value,
|
|
67
70
|
};
|
|
68
71
|
});
|
|
69
72
|
const defined = ld.reduce((def, d) => (d.defined || def), false);
|
|
73
|
+
let validGap = false;
|
|
74
|
+
const gaps = ld.reduce((acc, d, i) => {
|
|
75
|
+
// Gaps include fallback values if configured.
|
|
76
|
+
if (!d.defined && isFinite(config.fallbackValue)) {
|
|
77
|
+
acc.push(Object.assign(Object.assign({}, d), { defined: true }));
|
|
78
|
+
}
|
|
79
|
+
if (!d.defined && !validGap)
|
|
80
|
+
validGap = true;
|
|
81
|
+
const isEndpoint = (i > 0 && !ld[i - 1].defined) || (i < ld.length - 1 && !ld[i + 1].defined);
|
|
82
|
+
if (d.defined && isEndpoint) {
|
|
83
|
+
// If no undefined points have been found since the last endpoint, we insert one to enforce breaks between adjacent gaps.
|
|
84
|
+
if (!validGap)
|
|
85
|
+
acc.push(Object.assign(Object.assign({}, d), { defined: false }));
|
|
86
|
+
acc.push(d);
|
|
87
|
+
validGap = false;
|
|
88
|
+
}
|
|
89
|
+
return acc;
|
|
90
|
+
}, []);
|
|
70
91
|
// If the line consists only of `null` values, we'll still render it but it'll be invisible.
|
|
71
92
|
// Such trick allows us to have better animated transitions.
|
|
72
93
|
const visible = defined && ld.some(d => d.value !== null);
|
|
73
94
|
return {
|
|
74
95
|
values: ld,
|
|
75
96
|
defined,
|
|
97
|
+
gaps,
|
|
76
98
|
visible,
|
|
77
99
|
};
|
|
78
100
|
});
|
|
@@ -91,6 +113,10 @@ class Line extends XYComponentCore {
|
|
|
91
113
|
.append('path')
|
|
92
114
|
.attr('class', lineSelectionHelper)
|
|
93
115
|
.attr('d', this._emptyPath());
|
|
116
|
+
linesEnter.append('path')
|
|
117
|
+
.attr('class', interpolatedPath)
|
|
118
|
+
.attr('d', this._emptyPath())
|
|
119
|
+
.style('opacity', 0);
|
|
94
120
|
const linesMerged = linesEnter.merge(lines);
|
|
95
121
|
linesMerged.style('cursor', (d, i) => getString(data, config.cursor, i));
|
|
96
122
|
linesMerged.each((d, i, elements) => {
|
|
@@ -98,6 +124,7 @@ class Line extends XYComponentCore {
|
|
|
98
124
|
const group = select(elements[i]);
|
|
99
125
|
const linePath$1 = group.select(`.${linePath}`);
|
|
100
126
|
const lineSelectionHelper$1 = group.select(`.${lineSelectionHelper}`);
|
|
127
|
+
const lineGaps = group.select(`.${interpolatedPath}`);
|
|
101
128
|
const isLineVisible = d.visible;
|
|
102
129
|
const dashArray = getValue(data, config.lineDashArray, i);
|
|
103
130
|
const transition = smartTransition(linePath$1, duration)
|
|
@@ -119,6 +146,18 @@ class Line extends XYComponentCore {
|
|
|
119
146
|
lineSelectionHelper$1
|
|
120
147
|
.attr('d', svgPathD)
|
|
121
148
|
.attr('visibility', isLineVisible ? null : 'hidden');
|
|
149
|
+
if (hasUndefinedSegments && config.interpolateMissingData) {
|
|
150
|
+
smartTransition(lineGaps, duration)
|
|
151
|
+
.attr('d', this.lineGen(d.gaps))
|
|
152
|
+
.attr('stroke', getColor(data, config.color, i))
|
|
153
|
+
.attr('stroke-width', config.lineWidth - 1)
|
|
154
|
+
.style('opacity', 1);
|
|
155
|
+
}
|
|
156
|
+
else {
|
|
157
|
+
lineGaps.transition()
|
|
158
|
+
.duration(duration)
|
|
159
|
+
.style('opacity', 0);
|
|
160
|
+
}
|
|
122
161
|
});
|
|
123
162
|
smartTransition(lines.exit(), duration)
|
|
124
163
|
.style('opacity', 0)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/components/line/index.ts"],"sourcesContent":["import { select } from 'd3-selection'\nimport { Transition } from 'd3-transition'\nimport { CurveFactoryLineOnly, Line as LineGenInterface, line } from 'd3-shape'\nimport { interpolatePath } from 'd3-interpolate-path'\n\n// Core\nimport { XYComponentCore } from 'core/xy-component'\n\n// Utils\nimport { getNumber, getString, getValue, isArray, isNumber } from 'utils/data'\nimport { smartTransition } from 'utils/d3'\nimport { getColor } from 'utils/color'\n\n// Types\nimport { NumericAccessor } from 'types/accessor'\nimport { Spacing } from 'types/spacing'\nimport { Curve, CurveType } from 'types/curve'\nimport { Direction } from 'types/direction'\n\n// Local Types\nimport { LineData, LineDatum } from './types'\n\n// Config\nimport { LineDefaultConfig, LineConfigInterface } from './config'\n\n// Styles\nimport * as s from './style'\n\nexport class Line<Datum> extends XYComponentCore<Datum, LineConfigInterface<Datum>> {\n static selectors = s\n protected _defaultConfig = LineDefaultConfig as LineConfigInterface<Datum>\n public config: LineConfigInterface<Datum> = this._defaultConfig\n lineGen: LineGenInterface<{ x: number; y: number; defined: boolean }>\n curve: CurveFactoryLineOnly = Curve[CurveType.MonotoneX]\n events = {\n [Line.selectors.line]: {\n mouseover: this._highlight.bind(this),\n mouseleave: this._resetHighlight.bind(this),\n },\n }\n\n constructor (config?: LineConfigInterface<Datum>) {\n super()\n if (config) this.setConfig(config)\n }\n\n get bleed (): Spacing {\n const { config: { lineWidth } } = this\n const yDomain = this.yScale.domain() as [number, number]\n const yDirection = this.yScale.range()[0] > this.yScale.range()[1]\n ? Direction.North\n : Direction.South\n const isYDirectionSouth = yDirection === Direction.South\n\n const isLineThick = lineWidth > 3\n const isLineVeryThick = lineWidth >= 10\n return {\n top: !isLineVeryThick && (\n (!isYDirectionSouth && (yDomain[1] === 0)) || (isYDirectionSouth && (yDomain[0] === 0))\n ) ? 0 : lineWidth / 2,\n bottom: !isLineVeryThick && (\n (!isYDirectionSouth && (yDomain[0] === 0)) || (isYDirectionSouth && (yDomain[1] === 0))\n ) ? 0 : lineWidth / 2,\n left: isLineThick ? lineWidth / 2 : 0,\n right: isLineThick ? lineWidth / 2 : 0,\n }\n }\n\n _render (customDuration?: number): void {\n super._render(customDuration)\n const { config, datamodel: { data } } = this\n const duration = isNumber(customDuration) ? customDuration : config.duration\n\n this.curve = Curve[config.curveType]\n this.lineGen = line<{ x: number; y: number; defined: boolean }>()\n .x(d => d.x)\n .y(d => d.y)\n .defined(d => d.defined)\n .curve(this.curve)\n\n const yAccessors = (isArray(config.y) ? config.y : [config.y]) as NumericAccessor<Datum>[]\n const lineDataX = data.map((d, i) => this.xScale(getNumber(d, config.x, i)))\n const lineData: LineData[] = yAccessors.map(a => {\n const ld: LineDatum[] = data.map((d, i) => {\n const rawValue = getNumber(d, a, i)\n // If `rawValue` is not numerical or if it's not finite (`NaN`, `undefined`, ...), we replace it with `config.fallbackValue`\n const value = (isNumber(rawValue) || (rawValue === null)) && isFinite(rawValue) ? rawValue : config.fallbackValue\n return {\n x: lineDataX[i],\n y: this.yScale(value ?? 0),\n defined: isFinite(value),\n value,\n }\n })\n\n const defined = ld.reduce((def, d) => (d.defined || def), false)\n // If the line consists only of `null` values, we'll still render it but it'll be invisible.\n // Such trick allows us to have better animated transitions.\n const visible = defined && ld.some(d => d.value !== null)\n return {\n values: ld,\n defined,\n visible,\n }\n })\n\n const lines = this.g\n .selectAll<SVGGElement, LineData>(`.${s.line}`)\n .data(lineData)\n\n const linesEnter = lines.enter().append('g')\n .attr('class', s.line)\n\n linesEnter\n .append('path')\n .attr('class', s.linePath)\n .attr('stroke', (d, i) => getColor(data, config.color, i))\n .attr('stroke-opacity', 0)\n .attr('stroke-width', config.lineWidth)\n\n linesEnter\n .append('path')\n .attr('class', s.lineSelectionHelper)\n .attr('d', this._emptyPath())\n\n const linesMerged = linesEnter.merge(lines)\n linesMerged.style('cursor', (d, i) => getString(data, config.cursor, i))\n linesMerged.each((d, i, elements) => {\n const group = select(elements[i])\n const linePath = group.select<SVGPathElement>(`.${s.linePath}`)\n const lineSelectionHelper = group.select(`.${s.lineSelectionHelper}`)\n\n const isLineVisible = d.visible\n const dashArray = getValue<Datum[], number[]>(data, config.lineDashArray, i)\n const transition = smartTransition(linePath, duration)\n .attr('stroke', getColor(data, config.color, i))\n .attr('stroke-width', config.lineWidth)\n .attr('stroke-opacity', isLineVisible ? 1 : 0)\n .style('stroke-dasharray', dashArray?.join(' ') ?? null) // We use `.style` because there's also a default CSS-variable for stroke-dasharray\n\n const hasUndefinedSegments = d.values.some(d => !d.defined)\n const svgPathD = this.lineGen(d.values)\n\n if (duration && !hasUndefinedSegments) {\n const previous = linePath.attr('d') || this._emptyPath()\n const next = svgPathD || this._emptyPath()\n const t = transition as Transition<SVGPathElement, LineData, SVGGElement, LineData>\n t.attrTween('d', () => interpolatePath(previous, next))\n } else if (d.visible) {\n transition.attr('d', svgPathD)\n }\n\n lineSelectionHelper\n .attr('d', svgPathD)\n .attr('visibility', isLineVisible ? null : 'hidden')\n })\n\n smartTransition(lines.exit(), duration)\n .style('opacity', 0)\n .remove()\n }\n\n private _emptyPath (): string {\n const xRange = this.xScale.range()\n const yRange = this.yScale.range()\n return `M${xRange[0]},${yRange[0]} L${xRange[1]},${yRange[0]}`\n }\n\n private _highlight (datum: Datum): void {\n const { config } = this\n\n if (config.highlightOnHover) {\n this.g\n .selectAll(`.${s.line}`)\n .classed(s.dim, d => d !== datum)\n }\n }\n\n private _resetHighlight (): void {\n const { config } = this\n\n if (config.highlightOnHover) {\n this.g\n .selectAll(`.${s.line}`)\n .classed(s.dim, false)\n }\n }\n}\n"],"names":["s.line","s.linePath","s.lineSelectionHelper","linePath","lineSelectionHelper","s.dim","s"],"mappings":";;;;;;;;;;;;;AA4BM,MAAO,IAAY,SAAQ,eAAkD,CAAA;AAajF,IAAA,WAAA,CAAa,MAAmC,EAAA;AAC9C,QAAA,KAAK,EAAE,CAAA;QAZC,IAAc,CAAA,cAAA,GAAG,iBAA+C,CAAA;AACnE,QAAA,IAAA,CAAA,MAAM,GAA+B,IAAI,CAAC,cAAc,CAAA;AAE/D,QAAA,IAAA,CAAA,KAAK,GAAyB,KAAK,CAAC,SAAS,CAAC,SAAS,CAAC,CAAA;AACxD,QAAA,IAAA,CAAA,MAAM,GAAG;AACP,YAAA,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,GAAG;gBACrB,SAAS,EAAE,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC;gBACrC,UAAU,EAAE,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC;AAC5C,aAAA;SACF,CAAA;AAIC,QAAA,IAAI,MAAM;AAAE,YAAA,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAA;KACnC;AAED,IAAA,IAAI,KAAK,GAAA;QACP,MAAM,EAAE,MAAM,EAAE,EAAE,SAAS,EAAE,EAAE,GAAG,IAAI,CAAA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AAM,CAAC,KAAK,EAAE,CAAA;QAClC,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAA;QAClC,OAAO,CAAA,CAAA,EAAI,MAAM,CAAC,CAAC,CAAC,CAAI,CAAA,EAAA,MAAM,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC,CAAC,CAAC,CAAA,CAAA,EAAI,MAAM,CAAC,CAAC,CAAC,CAAA,CAAE,CAAA;KAC/D;AAEO,IAAA,UAAU,CAAE,KAAY,EAAA;AAC9B,QAAA,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAA;QAEvB,IAAI,MAAM,CAAC,gBAAgB,EAAE;AAC3B,YAAA,IAAI,CAAC,CAAC;AACH,iBAAA,SAAS,CAAC,CAAI,CAAA,EAAAJ,MAAM,EAAE,CAAC;AACvB,iBAAA,OAAO,CAACK,GAAK,EAAE,CAAC,IAAI,CAAC,KAAK,KAAK,CAAC,CAAA;AACpC,SAAA;KACF;IAEO,eAAe,GAAA;AACrB,QAAA,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAA;QAEvB,IAAI,MAAM,CAAC,gBAAgB,EAAE;AAC3B,YAAA,IAAI,CAAC,CAAC;AACH,iBAAA,SAAS,CAAC,CAAI,CAAA,EAAAL,MAAM,EAAE,CAAC;AACvB,iBAAA,OAAO,CAACK,GAAK,EAAE,KAAK,CAAC,CAAA;AACzB,SAAA;KACF;;AA7JM,IAAS,CAAA,SAAA,GAAGC,KAAC;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/components/line/index.ts"],"sourcesContent":["import { select } from 'd3-selection'\nimport { Transition } from 'd3-transition'\nimport { CurveFactoryLineOnly, Line as LineGenInterface, line } from 'd3-shape'\nimport { interpolatePath } from 'd3-interpolate-path'\n\n// Core\nimport { XYComponentCore } from 'core/xy-component'\n\n// Utils\nimport { getNumber, getString, getValue, isArray, isNumber } from 'utils/data'\nimport { smartTransition } from 'utils/d3'\nimport { getColor } from 'utils/color'\n\n// Types\nimport { NumericAccessor } from 'types/accessor'\nimport { Spacing } from 'types/spacing'\nimport { Curve, CurveType } from 'types/curve'\nimport { Direction } from 'types/direction'\n\n// Local Types\nimport { LineData, LineDatum } from './types'\n\n// Config\nimport { LineDefaultConfig, LineConfigInterface } from './config'\n\n// Styles\nimport * as s from './style'\n\nexport class Line<Datum> extends XYComponentCore<Datum, LineConfigInterface<Datum>> {\n static selectors = s\n protected _defaultConfig = LineDefaultConfig as LineConfigInterface<Datum>\n public config: LineConfigInterface<Datum> = this._defaultConfig\n lineGen: LineGenInterface<{ x: number; y: number; defined: boolean }>\n curve: CurveFactoryLineOnly = Curve[CurveType.MonotoneX]\n events = {\n [Line.selectors.line]: {\n mouseover: this._highlight.bind(this),\n mouseleave: this._resetHighlight.bind(this),\n },\n }\n\n constructor (config?: LineConfigInterface<Datum>) {\n super()\n if (config) this.setConfig(config)\n }\n\n get bleed (): Spacing {\n const { config: { lineWidth } } = this\n const yDomain = this.yScale.domain() as [number, number]\n const yDirection = this.yScale.range()[0] > this.yScale.range()[1]\n ? Direction.North\n : Direction.South\n const isYDirectionSouth = yDirection === Direction.South\n\n const isLineThick = lineWidth > 3\n const isLineVeryThick = lineWidth >= 10\n return {\n top: !isLineVeryThick && (\n (!isYDirectionSouth && (yDomain[1] === 0)) || (isYDirectionSouth && (yDomain[0] === 0))\n ) ? 0 : lineWidth / 2,\n bottom: !isLineVeryThick && (\n (!isYDirectionSouth && (yDomain[0] === 0)) || (isYDirectionSouth && (yDomain[1] === 0))\n ) ? 0 : lineWidth / 2,\n left: isLineThick ? lineWidth / 2 : 0,\n right: isLineThick ? lineWidth / 2 : 0,\n }\n }\n\n _render (customDuration?: number): void {\n super._render(customDuration)\n const { config, datamodel: { data } } = this\n const duration = isNumber(customDuration) ? customDuration : config.duration\n\n this.curve = Curve[config.curveType]\n this.lineGen = line<{ x: number; y: number; defined: boolean }>()\n .x(d => d.x)\n .y(d => d.y)\n .defined(d => d.defined)\n .curve(this.curve)\n\n const yAccessors = (isArray(config.y) ? config.y : [config.y]) as NumericAccessor<Datum>[]\n const lineDataX = data.map((d, i) => this.xScale(getNumber(d, config.x, i)))\n const lineData: LineData[] = yAccessors.map(a => {\n const ld: LineDatum[] = data.map((d, i) => {\n const rawValue = getNumber(d, a, i)\n\n // If `rawValue` is not numerical or if it's not finite (`NaN`, `undefined`, ...), we replace it with `config.fallbackValue`\n const value = (isNumber(rawValue) || (rawValue === null)) && isFinite(rawValue) ? rawValue : config.fallbackValue\n const defined = config.interpolateMissingData\n ? (isNumber(rawValue) || (rawValue === null)) && isFinite(rawValue)\n : isFinite(value)\n\n return {\n x: lineDataX[i],\n y: this.yScale(value ?? 0),\n defined,\n value,\n }\n })\n const defined = ld.reduce((def, d) => (d.defined || def), false)\n\n let validGap = false\n const gaps = ld.reduce((acc, d, i) => {\n // Gaps include fallback values if configured.\n if (!d.defined && isFinite(config.fallbackValue)) {\n acc.push({ ...d, defined: true })\n }\n\n if (!d.defined && !validGap) validGap = true\n\n const isEndpoint = (i > 0 && !ld[i - 1].defined) || (i < ld.length - 1 && !ld[i + 1].defined)\n if (d.defined && isEndpoint) {\n // If no undefined points have been found since the last endpoint, we insert one to enforce breaks between adjacent gaps.\n if (!validGap) acc.push({ ...d, defined: false })\n acc.push(d)\n validGap = false\n }\n return acc\n }, [])\n\n // If the line consists only of `null` values, we'll still render it but it'll be invisible.\n // Such trick allows us to have better animated transitions.\n const visible = defined && ld.some(d => d.value !== null)\n return {\n values: ld,\n defined,\n gaps,\n visible,\n }\n })\n\n const lines = this.g\n .selectAll<SVGGElement, LineData>(`.${s.line}`)\n .data(lineData)\n\n const linesEnter = lines.enter().append('g')\n .attr('class', s.line)\n\n linesEnter\n .append('path')\n .attr('class', s.linePath)\n .attr('stroke', (d, i) => getColor(data, config.color, i))\n .attr('stroke-opacity', 0)\n .attr('stroke-width', config.lineWidth)\n\n linesEnter\n .append('path')\n .attr('class', s.lineSelectionHelper)\n .attr('d', this._emptyPath())\n\n linesEnter.append('path')\n .attr('class', s.interpolatedPath)\n .attr('d', this._emptyPath())\n .style('opacity', 0)\n\n const linesMerged = linesEnter.merge(lines)\n linesMerged.style('cursor', (d, i) => getString(data, config.cursor, i))\n linesMerged.each((d, i, elements) => {\n const group = select(elements[i])\n const linePath = group.select<SVGPathElement>(`.${s.linePath}`)\n const lineSelectionHelper = group.select(`.${s.lineSelectionHelper}`)\n const lineGaps = group.select(`.${s.interpolatedPath}`)\n\n const isLineVisible = d.visible\n const dashArray = getValue<Datum[], number[]>(data, config.lineDashArray, i)\n const transition = smartTransition(linePath, duration)\n .attr('stroke', getColor(data, config.color, i))\n .attr('stroke-width', config.lineWidth)\n .attr('stroke-opacity', isLineVisible ? 1 : 0)\n .style('stroke-dasharray', dashArray?.join(' ') ?? null) // We use `.style` because there's also a default CSS-variable for stroke-dasharray\n\n const hasUndefinedSegments = d.values.some(d => !d.defined)\n const svgPathD = this.lineGen(d.values)\n\n if (duration && !hasUndefinedSegments) {\n const previous = linePath.attr('d') || this._emptyPath()\n const next = svgPathD || this._emptyPath()\n const t = transition as Transition<SVGPathElement, LineData, SVGGElement, LineData>\n t.attrTween('d', () => interpolatePath(previous, next))\n } else if (d.visible) {\n transition.attr('d', svgPathD)\n }\n\n lineSelectionHelper\n .attr('d', svgPathD)\n .attr('visibility', isLineVisible ? null : 'hidden')\n\n if (hasUndefinedSegments && config.interpolateMissingData) {\n smartTransition(lineGaps, duration)\n .attr('d', this.lineGen(d.gaps))\n .attr('stroke', getColor(data, config.color, i))\n .attr('stroke-width', config.lineWidth - 1)\n .style('opacity', 1)\n } else {\n lineGaps.transition()\n .duration(duration)\n .style('opacity', 0)\n }\n })\n\n smartTransition(lines.exit(), duration)\n .style('opacity', 0)\n .remove()\n }\n\n private _emptyPath (): string {\n const xRange = this.xScale.range()\n const yRange = this.yScale.range()\n return `M${xRange[0]},${yRange[0]} L${xRange[1]},${yRange[0]}`\n }\n\n private _highlight (datum: Datum): void {\n const { config } = this\n\n if (config.highlightOnHover) {\n this.g\n .selectAll(`.${s.line}`)\n .classed(s.dim, d => d !== datum)\n }\n }\n\n private _resetHighlight (): void {\n const { config } = this\n\n if (config.highlightOnHover) {\n this.g\n .selectAll(`.${s.line}`)\n .classed(s.dim, false)\n }\n }\n}\n"],"names":["s.line","s.linePath","s.lineSelectionHelper","s.interpolatedPath","linePath","lineSelectionHelper","s.dim","s"],"mappings":";;;;;;;;;;;;;AA4BM,MAAO,IAAY,SAAQ,eAAkD,CAAA;AAajF,IAAA,WAAA,CAAa,MAAmC,EAAA;AAC9C,QAAA,KAAK,EAAE,CAAA;QAZC,IAAc,CAAA,cAAA,GAAG,iBAA+C,CAAA;AACnE,QAAA,IAAA,CAAA,MAAM,GAA+B,IAAI,CAAC,cAAc,CAAA;AAE/D,QAAA,IAAA,CAAA,KAAK,GAAyB,KAAK,CAAC,SAAS,CAAC,SAAS,CAAC,CAAA;AACxD,QAAA,IAAA,CAAA,MAAM,GAAG;AACP,YAAA,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,GAAG;gBACrB,SAAS,EAAE,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC;gBACrC,UAAU,EAAE,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC;AAC5C,aAAA;SACF,CAAA;AAIC,QAAA,IAAI,MAAM;AAAE,YAAA,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAA;KACnC;AAED,IAAA,IAAI,KAAK,GAAA;QACP,MAAM,EAAE,MAAM,EAAE,EAAE,SAAS,EAAE,EAAE,GAAG,IAAI,CAAA;QACtC,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,EAAsB,CAAA;QACxD,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;cAC9D,SAAS,CAAC,KAAK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AAAL,MAAM,EAAE,CAAC;AACvB,iBAAA,OAAO,CAACM,GAAK,EAAE,CAAC,IAAI,CAAC,KAAK,KAAK,CAAC,CAAA;AACpC,SAAA;KACF;IAEO,eAAe,GAAA;AACrB,QAAA,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAA;QAEvB,IAAI,MAAM,CAAC,gBAAgB,EAAE;AAC3B,YAAA,IAAI,CAAC,CAAC;AACH,iBAAA,SAAS,CAAC,CAAI,CAAA,EAAAN,MAAM,EAAE,CAAC;AACvB,iBAAA,OAAO,CAACM,GAAK,EAAE,KAAK,CAAC,CAAA;AACzB,SAAA;KACF;;AAxMM,IAAS,CAAA,SAAA,GAAGC,KAAC;;;;"}
|
package/components/line/style.js
CHANGED
|
@@ -5,6 +5,10 @@ const globalStyles = injectGlobal `
|
|
|
5
5
|
--vis-line-cursor: default;
|
|
6
6
|
--vis-line-stroke-dasharray: none;
|
|
7
7
|
--vis-line-stroke-dashoffset: 0;
|
|
8
|
+
|
|
9
|
+
--vis-line-gapfill-stroke-dasharray: 2 3;
|
|
10
|
+
--vis-line-gapfill-stroke-opacity: 0.8;
|
|
11
|
+
--vis-line-gapfill-stroke-dashoffset: 0;
|
|
8
12
|
}
|
|
9
13
|
`;
|
|
10
14
|
const root = css `
|
|
@@ -29,7 +33,14 @@ const lineSelectionHelper = css `
|
|
|
29
33
|
`;
|
|
30
34
|
const dim = css `
|
|
31
35
|
opacity: 0.2;
|
|
36
|
+
`;
|
|
37
|
+
const interpolatedPath = css `
|
|
38
|
+
label: interpolated-path;
|
|
39
|
+
fill: none;
|
|
40
|
+
stroke-dasharray: var(--vis-line-gapfill-stroke-dasharray);
|
|
41
|
+
stroke-dashoffset: var(--vis-line-gapfill-stroke-dashoffset);
|
|
42
|
+
stroke-opacity: var(--vis-line-gapfill-stroke-opacity);
|
|
32
43
|
`;
|
|
33
44
|
|
|
34
|
-
export { dim, globalStyles, line, linePath, lineSelectionHelper, root };
|
|
45
|
+
export { dim, globalStyles, interpolatedPath, line, linePath, lineSelectionHelper, root };
|
|
35
46
|
//# sourceMappingURL=style.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"style.js","sources":["../../../src/components/line/style.ts"],"sourcesContent":["import { css, injectGlobal } from '@emotion/css'\n\nexport const globalStyles = injectGlobal`\n :root {\n --vis-line-cursor: default;\n --vis-line-stroke-dasharray: none;\n --vis-line-stroke-dashoffset: 0;\n }\n`\n\nexport const root = css`\n label: line-component;\n`\n\nexport const line = css`\n label: line;\n transition: opacity 200ms;\n cursor: var(--vis-line-cursor);\n`\n\nexport const linePath = css`\n label: linePath;\n fill: none;\n stroke-dasharray: var(--vis-line-stroke-dasharray);\n stroke-dashoffset: var(--vis-line-stroke-dashoffset);\n`\n\nexport const lineSelectionHelper = css`\n label: lineSelectionHelper;\n fill: none;\n stroke: rgba(0, 0, 0, 0);\n stroke-width: 8px;\n`\n\nexport const dim = css`\n opacity: 0.2;\n`\n"],"names":[],"mappings":";;AAEO,MAAM,YAAY,GAAG,YAAY,CAAA
|
|
1
|
+
{"version":3,"file":"style.js","sources":["../../../src/components/line/style.ts"],"sourcesContent":["import { css, injectGlobal } from '@emotion/css'\n\nexport const globalStyles = injectGlobal`\n :root {\n --vis-line-cursor: default;\n --vis-line-stroke-dasharray: none;\n --vis-line-stroke-dashoffset: 0;\n\n --vis-line-gapfill-stroke-dasharray: 2 3;\n --vis-line-gapfill-stroke-opacity: 0.8;\n --vis-line-gapfill-stroke-dashoffset: 0;\n }\n`\n\nexport const root = css`\n label: line-component;\n`\n\nexport const line = css`\n label: line;\n transition: opacity 200ms;\n cursor: var(--vis-line-cursor);\n`\n\nexport const linePath = css`\n label: linePath;\n fill: none;\n stroke-dasharray: var(--vis-line-stroke-dasharray);\n stroke-dashoffset: var(--vis-line-stroke-dashoffset);\n`\n\nexport const lineSelectionHelper = css`\n label: lineSelectionHelper;\n fill: none;\n stroke: rgba(0, 0, 0, 0);\n stroke-width: 8px;\n`\n\nexport const dim = css`\n opacity: 0.2;\n`\n\nexport const interpolatedPath = css`\n label: interpolated-path;\n fill: none;\n stroke-dasharray: var(--vis-line-gapfill-stroke-dasharray);\n stroke-dashoffset: var(--vis-line-gapfill-stroke-dashoffset);\n stroke-opacity: var(--vis-line-gapfill-stroke-opacity);\n`\n"],"names":[],"mappings":";;AAEO,MAAM,YAAY,GAAG,YAAY,CAAA,CAAA;;;;;;;;;;EAUvC;AAEM,MAAM,IAAI,GAAG,GAAG,CAAA,CAAA;;EAEtB;AAEM,MAAM,IAAI,GAAG,GAAG,CAAA,CAAA;;;;EAItB;AAEM,MAAM,QAAQ,GAAG,GAAG,CAAA,CAAA;;;;;EAK1B;AAEM,MAAM,mBAAmB,GAAG,GAAG,CAAA,CAAA;;;;;EAKrC;AAEM,MAAM,GAAG,GAAG,GAAG,CAAA,CAAA;;EAErB;AAEM,MAAM,gBAAgB,GAAG,GAAG,CAAA,CAAA;;;;;;;;;;"}
|
|
@@ -26,7 +26,7 @@ export interface NestedDonutConfigInterface<Datum> extends ComponentConfigInterf
|
|
|
26
26
|
showBackground?: boolean;
|
|
27
27
|
/** Sort function for segments. Default `undefined` */
|
|
28
28
|
sort?: (a: NestedDonutSegment<Datum>, b: NestedDonutSegment<Datum>) => number;
|
|
29
|
-
/** Array of accessor functions to defined the nested groups
|
|
29
|
+
/** Array of accessor functions to defined the nested groups */
|
|
30
30
|
layers: StringAccessor<Datum>[];
|
|
31
31
|
/**
|
|
32
32
|
* Configuration properties for individual layers. Accepts an accessor or constant of type:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sources":["../../../src/components/nested-donut/config.ts"],"sourcesContent":["// Core\nimport { ComponentConfigInterface, ComponentDefaultConfig } from 'core/component/config'\n\n// Types\nimport { ColorAccessor, GenericAccessor, NumericAccessor, StringAccessor } from 'types/accessor'\nimport { NestedDonutDirection, NestedDonutLayerSettings, NestedDonutSegment } from './types'\n\nexport interface NestedDonutConfigInterface<Datum> extends ComponentConfigInterface {\n /** Diagram angle range. Default: `[0, 2 * Math.PI]` */\n angleRange?: [number, number];\n /**\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
|
|
1
|
+
{"version":3,"file":"config.js","sources":["../../../src/components/nested-donut/config.ts"],"sourcesContent":["// Core\nimport { ComponentConfigInterface, ComponentDefaultConfig } from 'core/component/config'\n\n// Types\nimport { ColorAccessor, GenericAccessor, NumericAccessor, StringAccessor } from 'types/accessor'\nimport { NestedDonutDirection, NestedDonutLayerSettings, NestedDonutSegment } from './types'\n\nexport interface NestedDonutConfigInterface<Datum> extends ComponentConfigInterface {\n /** Diagram angle range. Default: `[0, 2 * Math.PI]` */\n angleRange?: [number, number];\n /**\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 /**\n * Configuration properties for individual layers. Accepts an accessor or constant of type:\n * {\n * backgroundColor?: string;\n * labelAlignment?: NestedDonutSegmentLabelAlignment;\n * width?: number | string;\n * }\n */\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 /**\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 /** Show labels for individual segments. Default: `true` */\n showSegmentLabels?: boolean;\n}\n\nexport const NestedDonutDefaultConfig: NestedDonutConfigInterface<unknown> = {\n ...ComponentDefaultConfig,\n angleRange: [0, 2 * Math.PI],\n centralLabel: undefined,\n centralSubLabel: undefined,\n centralSubLabelWrap: true,\n cornerRadius: 0,\n direction: NestedDonutDirection.Inwards,\n emptySegmentAngle: Math.PI / 180,\n hideOverflowingSegmentLabels: true,\n layers: [],\n layerPadding: 0,\n layerSettings: undefined,\n segmentColor: undefined,\n segmentLabel: undefined,\n segmentLabelColor: undefined,\n showBackground: false,\n showEmptySegments: false,\n showSegmentLabels: true,\n sort: undefined,\n value: undefined,\n}\n"],"names":[],"mappings":";;;AAAA;MAwEa,wBAAwB,GAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EAChC,sBAAsB,CACzB,EAAA,EAAA,UAAU,EAAE,CAAC,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC,EAC5B,YAAY,EAAE,SAAS,EACvB,eAAe,EAAE,SAAS,EAC1B,mBAAmB,EAAE,IAAI,EACzB,YAAY,EAAE,CAAC,EACf,SAAS,EAAE,oBAAoB,CAAC,OAAO,EACvC,iBAAiB,EAAE,IAAI,CAAC,EAAE,GAAG,GAAG,EAChC,4BAA4B,EAAE,IAAI,EAClC,MAAM,EAAE,EAAE,EACV,YAAY,EAAE,CAAC,EACf,aAAa,EAAE,SAAS,EACxB,YAAY,EAAE,SAAS,EACvB,YAAY,EAAE,SAAS,EACvB,iBAAiB,EAAE,SAAS,EAC5B,cAAc,EAAE,KAAK,EACrB,iBAAiB,EAAE,KAAK,EACxB,iBAAiB,EAAE,IAAI,EACvB,IAAI,EAAE,SAAS,EACf,KAAK,EAAE,SAAS,EAAA;;;;"}
|
|
@@ -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 // Undefined by default to allow proper fallback to var(--vis-font-family)\n '--vis-nested-donut-font-family': undefined as 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,SAAsB;;AAGxD,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;;EAEtB;AAEM,MAAM,aAAa,GAAG,GAAG,CAAA;;EAE/B;MAEY,SAAS,GAAG,cAAc,CAAC,cAAc,EAAC;AACvD,wBAAwB,CAAC,cAAc,EAAE,IAAI,CAAC,CAAA;AAEvC,MAAM,UAAU,GAAG,GAAG,CAAA;;;;;EAK5B;AAEM,MAAM,OAAO,GAAG,GAAG,CAAA;;GAExB;AAEK,MAAM,WAAW,GAAG,GAAG,CAAA;;EAE7B;AAEM,MAAM,UAAU,GAAG,GAAG,CAAA;;;;EAI5B;AAEM,MAAM,YAAY,GAAG,GAAG,CAAA;;;;;;EAM9B;AAEM,MAAM,YAAY,GAAG,GAAG,CAAA;;;;;;;;EAQ9B;AAEM,MAAM,eAAe,GAAG,GAAG,CAAA;;;;;;;;;;;;"}
|
|
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 as 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,SAAsB;;AAGxD,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;;;;;;;;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"label.js","sources":["../../../../src/components/sankey/modules/label.ts"],"sourcesContent":["import { Selection } from 'd3-selection'\n\n// Utils\nimport { estimateTextSize, trimSVGText, wrapSVGText } from 'utils/text'\nimport { smartTransition } from 'utils/d3'\nimport { getString, getValue } from 'utils/data'\nimport { getColor } from 'utils/color'\nimport { getCSSVariableValueInPixels } from 'utils/misc'\n\n// Types\nimport { GenericAccessor } from 'types/accessor'\nimport { FitMode, VerticalAlign } from 'types/text'\nimport { Position } from 'types/position'\n\n// Local Types\nimport { SankeyInputLink, SankeyInputNode, SankeyNode, SankeySubLabelPlacement } from '../types'\n\n// Config\nimport { SankeyConfigInterface } from '../config'\n\n// Styles\nimport * as s from '../style'\n\n\nconst NODE_LABEL_SPACING = 10\nconst LABEL_BLOCK_PADDING = 6.5\n\nfunction getLabelBackground (\n width: number,\n height: number,\n orientation: Position.Left | Position.Right,\n arrowWidth = 5,\n arrowHeight = 8\n): string {\n const halfHeight = height / 2\n const halfArrowHeight = arrowHeight / 2\n\n if (orientation === Position.Left) {\n const rightArrowPos = `L 0 ${halfHeight - halfArrowHeight} L ${+arrowWidth} ${halfHeight} L 0 ${halfHeight + halfArrowHeight}`\n return `\n M 0 0\n ${rightArrowPos}\n L 0 ${height}\n L ${-width} ${height}\n L ${-width} 0\n L 0 0 `\n } else {\n const leftArrowPos = `L 0 ${halfHeight - halfArrowHeight} L ${-arrowWidth} ${halfHeight} L 0 ${halfHeight + halfArrowHeight}`\n return `\n M 0 0\n ${leftArrowPos}\n L 0 ${height}\n L ${width} ${height}\n L ${width} 0\n L 0 0 `\n }\n}\n\nexport function getLabelOrientation<N extends SankeyInputNode, L extends SankeyInputLink> (\n d: SankeyNode<N, L>,\n sankeyWidth: number,\n labelPosition: GenericAccessor<Position.Auto | Position.Left | Position.Right | string, SankeyNode<N, L>>\n): (Position.Left | Position.Right) {\n let orientation = getValue(d, labelPosition)\n if (orientation === Position.Auto || !orientation) {\n orientation = d.x0 < sankeyWidth / 2 ? Position.Left : Position.Right\n }\n\n return orientation as (Position.Left | Position.Right)\n}\n\nexport const requiredLabelSpace = (labelWidth: number, labelFontSize: number): { width: number; height: number } => {\n return {\n height: labelFontSize * 2.5 + 2 * LABEL_BLOCK_PADDING, // Assuming 2.5 lines per label\n width: labelWidth + 2 * NODE_LABEL_SPACING + 2 * LABEL_BLOCK_PADDING,\n }\n}\n\nexport function getLabelGroupXTranslate<N extends SankeyInputNode, L extends SankeyInputLink> (\n d: SankeyNode<N, L>,\n config: SankeyConfigInterface<N, L>,\n width: number\n): number {\n const orientation = getLabelOrientation(d, width, config.labelPosition)\n switch (orientation) {\n case Position.Right: return config.nodeWidth + NODE_LABEL_SPACING\n case Position.Left:\n default:\n return -NODE_LABEL_SPACING\n }\n}\n\nexport function getLabelGroupYTranslate<N extends SankeyInputNode, L extends SankeyInputLink> (\n d: SankeyNode<N, L>,\n labelGroupHeight: number,\n config: SankeyConfigInterface<N, L>\n): number {\n const nodeHeight = d.y1 - d.y0\n if (config.labelBackground && (nodeHeight < labelGroupHeight)) return (nodeHeight - labelGroupHeight) / 2\n\n switch (config.labelVerticalAlign) {\n case VerticalAlign.Bottom: return nodeHeight - labelGroupHeight\n case VerticalAlign.Middle: return nodeHeight / 2 - labelGroupHeight / 2\n case VerticalAlign.Top:\n default: return 0\n }\n}\n\nexport function getLabelTextAnchor<N extends SankeyInputNode, L extends SankeyInputLink> (\n d: SankeyNode<N, L>,\n config: SankeyConfigInterface<N, L>,\n width: number\n): string {\n const orientation = getLabelOrientation(d, width, config.labelPosition)\n switch (orientation) {\n case Position.Right: return 'start'\n case Position.Left:\n default:\n return 'end'\n }\n}\n\nexport function getSubLabelTextAnchor<N extends SankeyInputNode, L extends SankeyInputLink> (\n d: SankeyNode<N, L>,\n config: SankeyConfigInterface<N, L>,\n width: number\n): string {\n const isSublabelInline = config.subLabelPlacement === SankeySubLabelPlacement.Inline\n const orientation = getLabelOrientation(d, width, config.labelPosition)\n switch (orientation) {\n case Position.Right: return isSublabelInline ? 'end' : 'start'\n case Position.Left:\n default:\n return isSublabelInline ? 'start' : 'end'\n }\n}\n\nexport function renderLabel<N extends SankeyInputNode, L extends SankeyInputLink> (\n labelGroup: Selection<SVGGElement, SankeyNode<N, L>, SVGGElement, any>,\n d: SankeyNode<N, L>,\n config: SankeyConfigInterface<N, L>,\n width: number,\n duration: number,\n forceExpand = false\n): { x: number; y: number; width: number; height: number; layer: number; selection: any; hidden?: boolean } {\n const labelTextSelection: Selection<SVGTextElement, SankeyNode<N, L>, SVGGElement, SankeyNode<N, L>> = labelGroup.select(`.${s.label}`)\n const labelShowBackground = config.labelBackground || forceExpand\n const sublabelTextSelection: Selection<SVGTextElement, SankeyNode<N, L>, SVGGElement, SankeyNode<N, L>> = labelGroup.select(`.${s.sublabel}`)\n const labelPadding = labelShowBackground ? LABEL_BLOCK_PADDING : 0\n const isSublabelInline = config.subLabelPlacement === SankeySubLabelPlacement.Inline\n const separator = config.labelForceWordBreak ? '' : config.labelTextSeparator\n const fastEstimatesMode = true // Fast but inaccurate\n const fontWidthToHeightRatio = 0.52\n const dy = 0.32\n const labelOrientation = getLabelOrientation(d, width, config.labelPosition)\n const labelOrientationMult = labelOrientation === Position.Left ? -1 : 1\n const labelText = getString(d, config.label)\n const sublabelText = getString(d, config.subLabel)\n let wasTrimmed = false\n\n const labelFontSize = config.labelFontSize ?? getCSSVariableValueInPixels('var(--vis-sankey-node-label-font-size)', labelGroup.node())\n const subLabelFontSize = config.subLabelFontSize ?? getCSSVariableValueInPixels('var(--vis-sankey-node-sublabel-font-size)', labelGroup.node())\n\n // Render the main label, wrap / trim it and estimate its size\n const labelsFontSizeDifference = sublabelText ? labelFontSize - subLabelFontSize : 0\n const labelTranslateY = labelPadding + ((isSublabelInline && labelsFontSizeDifference < 0) ? -0.6 * labelsFontSizeDifference : 0)\n labelTextSelection\n .text(labelText)\n .attr('font-size', labelFontSize)\n .style('fill', getColor(d, config.labelColor))\n .attr('transform', `translate(${labelOrientationMult * labelPadding},${labelTranslateY})`)\n .style('cursor', (d: SankeyNode<N, L>) => getString(d, config.labelCursor))\n\n const labelMaxWidth = isSublabelInline ? config.labelMaxWidth * (1 - (sublabelText ? config.subLabelToLabelInlineWidthRatio : 0)) : config.labelMaxWidth\n if (config.labelFit === FitMode.Wrap || forceExpand) wrapSVGText(labelTextSelection, labelMaxWidth, separator)\n else wasTrimmed = trimSVGText(labelTextSelection, labelMaxWidth, config.labelTrimMode, fastEstimatesMode, labelFontSize, fontWidthToHeightRatio)\n\n const labelSize = estimateTextSize(labelTextSelection, labelFontSize, dy, fastEstimatesMode, fontWidthToHeightRatio)\n\n // Render the sub-label, wrap / trim it and estimate its size\n const sublabelTranslateX = labelOrientationMult * (labelPadding + (isSublabelInline ? config.labelMaxWidth : 0))\n const sublabelMarginTop = 0\n const sublabelTranslateY = labelPadding + (isSublabelInline\n ? (labelsFontSizeDifference > 0 ? 0.6 * labelsFontSizeDifference : 0)\n : labelSize.height + sublabelMarginTop)\n sublabelTextSelection\n .text(sublabelText)\n .attr('font-size', subLabelFontSize)\n .style('fill', getColor(d, config.subLabelColor))\n .attr('transform', `translate(${sublabelTranslateX},${sublabelTranslateY})`)\n .style('cursor', (d: SankeyNode<N, L>) => getString(d, config.labelCursor))\n\n const sublabelMaxWidth = isSublabelInline ? config.labelMaxWidth * config.subLabelToLabelInlineWidthRatio : config.labelMaxWidth\n if (config.labelFit === FitMode.Wrap || forceExpand) wrapSVGText(sublabelTextSelection, sublabelMaxWidth, separator)\n else wasTrimmed = wasTrimmed || trimSVGText(sublabelTextSelection, sublabelMaxWidth, config.labelTrimMode, fastEstimatesMode, subLabelFontSize, fontWidthToHeightRatio)\n\n labelGroup.classed(s.labelTrimmed, wasTrimmed)\n const sublabelSize = estimateTextSize(sublabelTextSelection, subLabelFontSize, dy, fastEstimatesMode, fontWidthToHeightRatio)\n\n // Draw the background if needed\n const labelGroupHeight = (isSublabelInline ? Math.max(labelSize.height, sublabelSize.height) : (labelSize.height + sublabelSize.height)) + 2 * labelPadding\n const labelBackground = labelGroup.select(`.${s.labelBackground}`)\n\n labelBackground\n .attr('d', labelShowBackground ? getLabelBackground(config.labelMaxWidth + 2 * labelPadding, labelGroupHeight, labelOrientation as (Position.Left | Position.Right)) : null)\n\n // Position the label\n const labelTextAnchor = getLabelTextAnchor(d, config, width)\n const sublabelTextAnchor = getSubLabelTextAnchor(d, config, width)\n const xTranslate = getLabelGroupXTranslate(d, config, width)\n const yTranslate = getLabelGroupYTranslate(d, labelGroupHeight, config)\n\n labelTextSelection.attr('text-anchor', labelTextAnchor)\n sublabelTextSelection.attr('text-anchor', sublabelTextAnchor)\n\n const hasTransform = !!labelGroup.attr('transform')\n smartTransition(labelGroup, hasTransform ? duration : 0)\n .attr('transform', `translate(${xTranslate},${yTranslate})`)\n\n return {\n x: d.x0 + xTranslate,\n y: d.y0 + yTranslate,\n width: config.labelMaxWidth,\n height: labelGroupHeight,\n layer: d.layer,\n selection: labelGroup,\n }\n}\n"],"names":["s.label","s.sublabel","s.labelTrimmed","labelBackground","s.labelBackground"],"mappings":";;;;;;;;;;AAEA;AAsBA,MAAM,kBAAkB,GAAG,EAAE,CAAA;AAC7B,MAAM,mBAAm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AC,CAAC,EAAE,GAAG,UAAU;QACpB,KAAK,EAAE,MAAM,CAAC,aAAa;AAC3B,QAAA,MAAM,EAAE,gBAAgB;QACxB,KAAK,EAAE,CAAC,CAAC,KAAK;AACd,QAAA,SAAS,EAAE,UAAU;KACtB,CAAA;AACH;;;;"}
|
|
1
|
+
{"version":3,"file":"label.js","sources":["../../../../src/components/sankey/modules/label.ts"],"sourcesContent":["import { Selection } from 'd3-selection'\n\n// Utils\nimport { estimateTextSize, trimSVGText, wrapSVGText } from 'utils/text'\nimport { smartTransition } from 'utils/d3'\nimport { getString, getValue } from 'utils/data'\nimport { getColor } from 'utils/color'\nimport { getCSSVariableValueInPixels } from 'utils/misc'\n\n// Types\nimport { GenericAccessor } from 'types/accessor'\nimport { FitMode, VerticalAlign } from 'types/text'\nimport { Position } from 'types/position'\n\n// Local Types\nimport { SankeyInputLink, SankeyInputNode, SankeyNode, SankeySubLabelPlacement } from '../types'\n\n// Config\nimport { SankeyConfigInterface } from '../config'\n\n// Styles\nimport * as s from '../style'\n\n\nconst NODE_LABEL_SPACING = 10\nconst LABEL_BLOCK_PADDING = 6.5\n\nfunction getLabelBackground (\n width: number,\n height: number,\n orientation: Position.Left | Position.Right,\n arrowWidth = 5,\n arrowHeight = 8\n): string {\n const halfHeight = height / 2\n const halfArrowHeight = arrowHeight / 2\n\n if (orientation === Position.Left) {\n const rightArrowPos = `L 0 ${halfHeight - halfArrowHeight} L ${+arrowWidth} ${halfHeight} L 0 ${halfHeight + halfArrowHeight}`\n return `\n M 0 0\n ${rightArrowPos}\n L 0 ${height}\n L ${-width} ${height}\n L ${-width} 0\n L 0 0 `\n } else {\n const leftArrowPos = `L 0 ${halfHeight - halfArrowHeight} L ${-arrowWidth} ${halfHeight} L 0 ${halfHeight + halfArrowHeight}`\n return `\n M 0 0\n ${leftArrowPos}\n L 0 ${height}\n L ${width} ${height}\n L ${width} 0\n L 0 0 `\n }\n}\n\nexport function getLabelOrientation<N extends SankeyInputNode, L extends SankeyInputLink> (\n d: SankeyNode<N, L>,\n sankeyWidth: number,\n labelPosition: GenericAccessor<Position.Auto | Position.Left | Position.Right | string, SankeyNode<N, L>>\n): (Position.Left | Position.Right) {\n let orientation = getValue(d, labelPosition)\n if (orientation === Position.Auto || !orientation) {\n orientation = d.x0 < sankeyWidth / 2 ? Position.Left : Position.Right\n }\n\n return orientation as (Position.Left | Position.Right)\n}\n\nexport const requiredLabelSpace = (labelWidth: number, labelFontSize: number): { width: number; height: number } => {\n return {\n height: labelFontSize * 2.5 + 2 * LABEL_BLOCK_PADDING, // Assuming 2.5 lines per label\n width: labelWidth + 2 * NODE_LABEL_SPACING + 2 * LABEL_BLOCK_PADDING,\n }\n}\n\nexport function getLabelGroupXTranslate<N extends SankeyInputNode, L extends SankeyInputLink> (\n d: SankeyNode<N, L>,\n config: SankeyConfigInterface<N, L>,\n width: number\n): number {\n const orientation = getLabelOrientation(d, width, config.labelPosition)\n switch (orientation) {\n case Position.Right: return config.nodeWidth + NODE_LABEL_SPACING\n case Position.Left:\n default:\n return -NODE_LABEL_SPACING\n }\n}\n\nexport function getLabelGroupYTranslate<N extends SankeyInputNode, L extends SankeyInputLink> (\n d: SankeyNode<N, L>,\n labelGroupHeight: number,\n config: SankeyConfigInterface<N, L>\n): number {\n const nodeHeight = d.y1 - d.y0\n if (config.labelBackground && (nodeHeight < labelGroupHeight)) return (nodeHeight - labelGroupHeight) / 2\n\n switch (config.labelVerticalAlign) {\n case VerticalAlign.Bottom: return nodeHeight - labelGroupHeight\n case VerticalAlign.Middle: return nodeHeight / 2 - labelGroupHeight / 2\n case VerticalAlign.Top:\n default: return 0\n }\n}\n\nexport function getLabelTextAnchor<N extends SankeyInputNode, L extends SankeyInputLink> (\n d: SankeyNode<N, L>,\n config: SankeyConfigInterface<N, L>,\n width: number\n): string {\n const orientation = getLabelOrientation(d, width, config.labelPosition)\n switch (orientation) {\n case Position.Right: return 'start'\n case Position.Left:\n default:\n return 'end'\n }\n}\n\nexport function getSubLabelTextAnchor<N extends SankeyInputNode, L extends SankeyInputLink> (\n d: SankeyNode<N, L>,\n config: SankeyConfigInterface<N, L>,\n width: number\n): string {\n const isSublabelInline = config.subLabelPlacement === SankeySubLabelPlacement.Inline\n const orientation = getLabelOrientation(d, width, config.labelPosition)\n switch (orientation) {\n case Position.Right: return isSublabelInline ? 'end' : 'start'\n case Position.Left:\n default:\n return isSublabelInline ? 'start' : 'end'\n }\n}\n\nexport function renderLabel<N extends SankeyInputNode, L extends SankeyInputLink> (\n labelGroup: Selection<SVGGElement, SankeyNode<N, L>, SVGGElement, any>,\n d: SankeyNode<N, L>,\n config: SankeyConfigInterface<N, L>,\n width: number,\n duration: number,\n forceExpand = false\n): { x: number; y: number; width: number; height: number; layer: number; selection: any; hidden?: boolean } {\n const labelTextSelection: Selection<SVGTextElement, SankeyNode<N, L>, SVGGElement, SankeyNode<N, L>> = labelGroup.select(`.${s.label}`)\n const labelShowBackground = config.labelBackground || forceExpand\n const sublabelTextSelection: Selection<SVGTextElement, SankeyNode<N, L>, SVGGElement, SankeyNode<N, L>> = labelGroup.select(`.${s.sublabel}`)\n const labelPadding = labelShowBackground ? LABEL_BLOCK_PADDING : 0\n const isSublabelInline = config.subLabelPlacement === SankeySubLabelPlacement.Inline\n const separator = config.labelForceWordBreak ? '' : config.labelTextSeparator\n const fastEstimatesMode = true // Fast but inaccurate\n const fontWidthToHeightRatio = 0.52\n const dy = 0.32\n const labelOrientation = getLabelOrientation(d, width, config.labelPosition)\n const labelOrientationMult = labelOrientation === Position.Left ? -1 : 1\n const labelText = getString(d, config.label)\n const sublabelText = getString(d, config.subLabel)\n let wasTrimmed = false\n\n const labelFontSize = config.labelFontSize ?? getCSSVariableValueInPixels('var(--vis-sankey-node-label-font-size)', labelGroup.node())\n const subLabelFontSize = config.subLabelFontSize ?? getCSSVariableValueInPixels('var(--vis-sankey-node-sublabel-font-size)', labelGroup.node())\n\n // Render the main label, wrap / trim it and estimate its size\n const labelsFontSizeDifference = sublabelText ? labelFontSize - subLabelFontSize : 0\n const labelTranslateY = labelPadding + ((isSublabelInline && labelsFontSizeDifference < 0) ? -0.6 * labelsFontSizeDifference : 0)\n labelTextSelection\n .text(labelText)\n .attr('font-size', labelFontSize)\n .style('fill', getColor(d, config.labelColor))\n .attr('transform', `translate(${labelOrientationMult * labelPadding},${labelTranslateY})`)\n .style('cursor', (d: SankeyNode<N, L>) => getString(d, config.labelCursor))\n\n const labelMaxWidth = isSublabelInline ? config.labelMaxWidth * (1 - (sublabelText ? config.subLabelToLabelInlineWidthRatio : 0)) : config.labelMaxWidth\n if (config.labelFit === FitMode.Wrap || forceExpand) wrapSVGText(labelTextSelection, labelMaxWidth, separator)\n else wasTrimmed = trimSVGText(labelTextSelection, labelMaxWidth, config.labelTrimMode, fastEstimatesMode, labelFontSize, fontWidthToHeightRatio)\n\n const labelSize = estimateTextSize(labelTextSelection, labelFontSize, dy, fastEstimatesMode, fontWidthToHeightRatio)\n\n // Render the sub-label, wrap / trim it and estimate its size\n const sublabelTranslateX = labelOrientationMult * (labelPadding + (isSublabelInline ? config.labelMaxWidth : 0))\n const sublabelMarginTop = 0\n const sublabelTranslateY = labelPadding + (isSublabelInline\n ? (labelsFontSizeDifference > 0 ? 0.6 * labelsFontSizeDifference : 0)\n : labelSize.height + sublabelMarginTop)\n sublabelTextSelection\n .text(sublabelText)\n .attr('font-size', subLabelFontSize)\n .style('fill', getColor(d, config.subLabelColor))\n .attr('transform', `translate(${sublabelTranslateX},${sublabelTranslateY})`)\n .style('cursor', (d: SankeyNode<N, L>) => getString(d, config.labelCursor))\n\n const sublabelMaxWidth = isSublabelInline ? config.labelMaxWidth * config.subLabelToLabelInlineWidthRatio : config.labelMaxWidth\n if (config.labelFit === FitMode.Wrap || forceExpand) wrapSVGText(sublabelTextSelection, sublabelMaxWidth, separator)\n else wasTrimmed = wasTrimmed || trimSVGText(sublabelTextSelection, sublabelMaxWidth, config.labelTrimMode, fastEstimatesMode, subLabelFontSize, fontWidthToHeightRatio)\n\n labelGroup.classed(s.labelTrimmed, wasTrimmed)\n const sublabelSize = estimateTextSize(sublabelTextSelection, subLabelFontSize, dy, fastEstimatesMode, fontWidthToHeightRatio)\n\n // Draw the background if needed\n const labelGroupHeight = (isSublabelInline ? Math.max(labelSize.height, sublabelSize.height) : (labelSize.height + sublabelSize.height)) + 2 * labelPadding\n const labelBackground = labelGroup.select(`.${s.labelBackground}`)\n\n labelBackground\n .attr('d', labelShowBackground ? getLabelBackground(config.labelMaxWidth + 2 * labelPadding, labelGroupHeight, labelOrientation as (Position.Left | Position.Right)) : null)\n\n // Position the label\n const labelTextAnchor = getLabelTextAnchor(d, config, width)\n const sublabelTextAnchor = getSubLabelTextAnchor(d, config, width)\n const xTranslate = getLabelGroupXTranslate(d, config, width)\n const yTranslate = getLabelGroupYTranslate(d, labelGroupHeight, config)\n\n labelTextSelection.attr('text-anchor', labelTextAnchor)\n sublabelTextSelection.attr('text-anchor', sublabelTextAnchor)\n\n const hasTransform = !!labelGroup.attr('transform')\n smartTransition(labelGroup, hasTransform ? duration : 0)\n .attr('transform', `translate(${xTranslate},${yTranslate})`)\n\n return {\n x: d.x0 + xTranslate,\n y: d.y0 + yTranslate,\n width: config.labelMaxWidth,\n height: labelGroupHeight,\n layer: d.layer,\n selection: labelGroup,\n }\n}\n"],"names":["s.label","s.sublabel","s.labelTrimmed","labelBackground","s.labelBackground"],"mappings":";;;;;;;;;;AAEA;AAsBA,MAAM,kBAAkB,GAAG,EAAE,CAAA;AAC7B,MAAM,mBAAmB,GAAG,GAAG,CAAA;AAE/B,SAAS,kBAAkB,CACzB,KAAa,EACb,MAAc,EACd,WAA2C,EAC3C,UAAU,GAAG,CAAC,EACd,WAAW,GAAG,CAAC,EAAA;AAEf,IAAA,MAAM,UAAU,GAAG,MAAM,GAAG,CAAC,CAAA;AAC7B,IAAA,MAAM,eAAe,GAAG,WAAW,GAAG,CAAC,CAAA;AAEvC,IAAA,IAAI,WAAW,KAAK,QAAQ,CAAC,IAAI,EAAE;A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/sankey/modules/link.ts"],"sourcesContent":["import { Selection } from 'd3-selection'\nimport { Transition } from 'd3-transition'\nimport { interpolateNumber } from 'd3-interpolate'\n\n// Utils\nimport { getColor } from 'utils/color'\nimport { getString } from 'utils/data'\nimport { smartTransition } from 'utils/d3'\n\n// Local Types\nimport { SankeyInputLink, SankeyInputNode, SankeyLink } from '../types'\n\n// Config\nimport { SankeyConfigInterface } from '../config'\n\n// Styles\nimport * as s from '../style'\n\nexport type LinkPathOptions = {\n x0: number;\n x1: number;\n y0: number;\n y1: number;\n width: number;\n}\n\nexport function linkPath ({ x0, x1, y0, y1, width }: LinkPathOptions): string {\n const top0 = y0 - width / 2\n const top1 = y1 - width / 2\n const bottom0 = y0 + width / 2\n const bottom1 = y1 + width / 2\n const centerX = (x0 + x1) / 2\n\n return `\n M ${x0}, ${top0}\n\n C ${centerX}, ${top0}\n ${centerX}, ${top1}\n ${x1}, ${top1}\n\n L ${x1}, ${bottom1}\n\n C ${centerX}, ${bottom1}\n ${centerX}, ${bottom0}\n ${x0}, ${bottom0}\n z\n `\n}\n\nexport type LinkAnimState = { x0: number; x1: number; y0: number; y1: number; width: number }\n\nexport interface LinkElement extends SVGPathElement {\n _animState?: LinkAnimState;\n}\n\nexport function createLinks<N extends SankeyInputNode, L extends SankeyInputLink> (\n sel: Selection<SVGGElement, SankeyLink<N, L>, SVGGElement, unknown>\n): void {\n sel.append('path').attr('class', s.linkPath)\n .attr('d', (d: SankeyLink<N, L>, i: number, el: ArrayLike<LinkElement>) => {\n el[i]._animState = {\n x0: d.source.x1,\n x1: d.target.x0,\n y0: d.y0,\n y1: d.y1,\n width: Math.max(1, d.width),\n }\n return linkPath(el[i]._animState)\n })\n sel.append('path').attr('class', s.linkSelectionHelper)\n sel.style('opacity', 0)\n}\n\nexport function updateLinks<N extends SankeyInputNode, L extends SankeyInputLink> (\n sel: Selection<SVGGElement, SankeyLink<N, L>, SVGGElement, unknown>,\n config: SankeyConfigInterface<N, L>,\n duration: number\n): void {\n smartTransition(sel, duration)\n .style('opacity', (d: SankeyLink<N, L>) => d._state.greyout ? 0.2 : 1)\n\n const linkSelection = sel.select<SVGPathElement>(`.${s.linkPath}`)\n .style('cursor', (d: SankeyLink<N, L>) => getString(d, config.linkCursor))\n\n const selectionTransition = smartTransition(linkSelection, duration)\n .style('fill', (link: SankeyLink<N, L>) => getColor(link, config.linkColor))\n\n if (duration) {\n (selectionTransition as Transition<SVGPathElement, SankeyLink<N, L>, SVGGElement, unknown>)\n .attrTween('d', (d: SankeyLink<N, L>, i: number, el: ArrayLike<LinkElement>) => {\n const previous = el[i]._animState\n const next = {\n x0: d.source.x1,\n x1: d.target.x0,\n y0: d.y0,\n y1: d.y1,\n width: Math.max(1, d.width),\n }\n const interpolator = {\n x0: interpolateNumber(previous.x0, next.x0),\n x1: interpolateNumber(previous.x1, next.x1),\n y0: interpolateNumber(previous.y0, next.y0),\n y1: interpolateNumber(previous.y1, next.y1),\n width: interpolateNumber(previous.width, next.width),\n }\n el[i]._animState = next\n\n return function (t: number) {\n return linkPath({\n x0: interpolator.x0(t),\n x1: interpolator.x1(t),\n y0: interpolator.y0(t),\n y1: interpolator.y1(t),\n width: interpolator.width(t),\n })\n }\n })\n } else {\n linkSelection.attr('d', (d: SankeyLink<N, L>) => linkPath({\n x0: d.source.x1,\n x1: d.target.x0,\n y0: d.y0,\n y1: d.y1,\n width: Math.max(1, d.width),\n }))\n }\n\n sel.select(`.${s.linkSelectionHelper}`)\n .attr('d', (d: SankeyLink<N, L>) => linkPath({\n x0: d.source.x1,\n x1: d.target.x0,\n y0: d.y0,\n y1: d.y1,\n width: Math.max(10, d.width),\n }))\n .style('cursor', d => getString(d, config.linkCursor))\n}\n\nexport function removeLinks<N extends SankeyInputNode, L extends SankeyInputLink> (\n sel: Selection<SVGGElement, SankeyLink<N, L>, SVGGElement, unknown>\n): void {\n sel.remove()\n}\n"],"names":["s.linkPath","s.linkSelectionHelper"],"mappings":";;;;;;AA0BgB,SAAA,QAAQ,CAAE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B,KAAK,QAAQ,CAAC;AACxD,YAAA,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE;AACf,YAAA,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE;YACf,EAAE,EAAE,CAAC,CAAC,EAAE;YACR,EAAE,EAAE,CAAC,CAAC,EAAE;YACR,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC;AAC5B,SAAA,CAAC,CAAC,CAAA;AACJ,KAAA;IAED,GAAG,CAAC,MAAM,CAAC,CAAA,CAAA,EAAIC,mBAAqB,EAAE,CAAC;SACpC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAmB,KAAK,QAAQ,CAAC;AAC3C,QAAA,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE;AACf,QAAA,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE;QACf,EAAE,EAAE,CAAC,CAAC,EAAE;QACR,EAAE,EAAE,CAAC,CAAC,EAAE;QACR,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC;AAC7B,KAAA,CAAC,CAAC;AACF,SAAA,KAAK,CAAC,QAAQ,EAAE,CAAC,IAAI,SAAS,CAAC,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC,CAAC,CAAA;AAC1D,CAAC;AAEK,SAAU,WAAW,CACzB,GAAmE,EAAA;IAEnE,GAAG,CAAC,MAAM,EAAE,CAAA;AACd;;;;"}
|
|
1
|
+
{"version":3,"file":"link.js","sources":["../../../../src/components/sankey/modules/link.ts"],"sourcesContent":["import { Selection } from 'd3-selection'\nimport { Transition } from 'd3-transition'\nimport { interpolateNumber } from 'd3-interpolate'\n\n// Utils\nimport { getColor } from 'utils/color'\nimport { getString } from 'utils/data'\nimport { smartTransition } from 'utils/d3'\n\n// Local Types\nimport { SankeyInputLink, SankeyInputNode, SankeyLink } from '../types'\n\n// Config\nimport { SankeyConfigInterface } from '../config'\n\n// Styles\nimport * as s from '../style'\n\nexport type LinkPathOptions = {\n x0: number;\n x1: number;\n y0: number;\n y1: number;\n width: number;\n}\n\nexport function linkPath ({ x0, x1, y0, y1, width }: LinkPathOptions): string {\n const top0 = y0 - width / 2\n const top1 = y1 - width / 2\n const bottom0 = y0 + width / 2\n const bottom1 = y1 + width / 2\n const centerX = (x0 + x1) / 2\n\n return `\n M ${x0}, ${top0}\n\n C ${centerX}, ${top0}\n ${centerX}, ${top1}\n ${x1}, ${top1}\n\n L ${x1}, ${bottom1}\n\n C ${centerX}, ${bottom1}\n ${centerX}, ${bottom0}\n ${x0}, ${bottom0}\n z\n `\n}\n\nexport type LinkAnimState = { x0: number; x1: number; y0: number; y1: number; width: number }\n\nexport interface LinkElement extends SVGPathElement {\n _animState?: LinkAnimState;\n}\n\nexport function createLinks<N extends SankeyInputNode, L extends SankeyInputLink> (\n sel: Selection<SVGGElement, SankeyLink<N, L>, SVGGElement, unknown>\n): void {\n sel.append('path').attr('class', s.linkPath)\n .attr('d', (d: SankeyLink<N, L>, i: number, el: ArrayLike<LinkElement>) => {\n el[i]._animState = {\n x0: d.source.x1,\n x1: d.target.x0,\n y0: d.y0,\n y1: d.y1,\n width: Math.max(1, d.width),\n }\n return linkPath(el[i]._animState)\n })\n sel.append('path').attr('class', s.linkSelectionHelper)\n sel.style('opacity', 0)\n}\n\nexport function updateLinks<N extends SankeyInputNode, L extends SankeyInputLink> (\n sel: Selection<SVGGElement, SankeyLink<N, L>, SVGGElement, unknown>,\n config: SankeyConfigInterface<N, L>,\n duration: number\n): void {\n smartTransition(sel, duration)\n .style('opacity', (d: SankeyLink<N, L>) => d._state.greyout ? 0.2 : 1)\n\n const linkSelection = sel.select<SVGPathElement>(`.${s.linkPath}`)\n .style('cursor', (d: SankeyLink<N, L>) => getString(d, config.linkCursor))\n\n const selectionTransition = smartTransition(linkSelection, duration)\n .style('fill', (link: SankeyLink<N, L>) => getColor(link, config.linkColor))\n\n if (duration) {\n (selectionTransition as Transition<SVGPathElement, SankeyLink<N, L>, SVGGElement, unknown>)\n .attrTween('d', (d: SankeyLink<N, L>, i: number, el: ArrayLike<LinkElement>) => {\n const previous = el[i]._animState\n const next = {\n x0: d.source.x1,\n x1: d.target.x0,\n y0: d.y0,\n y1: d.y1,\n width: Math.max(1, d.width),\n }\n const interpolator = {\n x0: interpolateNumber(previous.x0, next.x0),\n x1: interpolateNumber(previous.x1, next.x1),\n y0: interpolateNumber(previous.y0, next.y0),\n y1: interpolateNumber(previous.y1, next.y1),\n width: interpolateNumber(previous.width, next.width),\n }\n el[i]._animState = next\n\n return function (t: number) {\n return linkPath({\n x0: interpolator.x0(t),\n x1: interpolator.x1(t),\n y0: interpolator.y0(t),\n y1: interpolator.y1(t),\n width: interpolator.width(t),\n })\n }\n })\n } else {\n linkSelection.attr('d', (d: SankeyLink<N, L>) => linkPath({\n x0: d.source.x1,\n x1: d.target.x0,\n y0: d.y0,\n y1: d.y1,\n width: Math.max(1, d.width),\n }))\n }\n\n sel.select(`.${s.linkSelectionHelper}`)\n .attr('d', (d: SankeyLink<N, L>) => linkPath({\n x0: d.source.x1,\n x1: d.target.x0,\n y0: d.y0,\n y1: d.y1,\n width: Math.max(10, d.width),\n }))\n .style('cursor', d => getString(d, config.linkCursor))\n}\n\nexport function removeLinks<N extends SankeyInputNode, L extends SankeyInputLink> (\n sel: Selection<SVGGElement, SankeyLink<N, L>, SVGGElement, unknown>\n): void {\n sel.remove()\n}\n"],"names":["s.linkPath","s.linkSelectionHelper"],"mappings":";;;;;;AA0BgB,SAAA,QAAQ,CAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,KAAK,EAAmB,EAAA;AAClE,IAAA,MAAM,IAAI,GAAG,EAAE,GAAG,KAAK,GAAG,CAAC,CAAA;AAC3B,IAAA,MAAM,IAAI,GAAG,EAAE,GAAG,KAAK,GAAG,CAAC,CAAA;AAC3B,IAAA,MAAM,OAAO,GAAG,EAAE,GAAG,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;YACR,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC;AAC5B,SAAA,CAAC,CAAC,CAAA;AACJ,KAAA;IAED,GAAG,CAAC,MAAM,CAAC,CAAA,CAAA,EAAIC,mBAAqB,EAAE,CAAC;SACpC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAmB,KAAK,QAAQ,CAAC;AAC3C,QAAA,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE;AACf,QAAA,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE;QACf,EAAE,EAAE,CAAC,CAAC,EAAE;QACR,EAAE,EAAE,CAAC,CAAC,EAAE;QACR,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC;AAC7B,KAAA,CAAC,CAAC;AACF,SAAA,KAAK,CAAC,QAAQ,EAAE,CAAC,IAAI,SAAS,CAAC,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC,CAAC,CAAA;AAC1D,CAAC;AAEK,SAAU,WAAW,CACzB,GAAmE,EAAA;IAEnE,GAAG,CAAC,MAAM,EAAE,CAAA;AACd;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"style.js","sources":["../../../src/components/sankey/style.ts"],"sourcesContent":["import { css, injectGlobal } from '@emotion/css'\nimport { UNOVIS_ICON_FONT_FAMILY_DEFAULT } from 'styles/index'\n\nexport const SANKEY_ICON_SIZE = 22\n\nexport const root = css`\n label: sankey-component;\n`\n\nexport const variables = injectGlobal`\n :root {\n /* Links */\n --vis-sankey-link-cursor: default;\n --vis-sankey-link-color: var(--vis-color-main-light);\n --vis-sankey-link-opacity: 0.5;\n --vis-sankey-link-hover-opacity: 1.0;\n /* Nodes */\n --vis-sankey-node-cursor: default;\n --vis-sankey-node-color: var(--vis-color-main);\n --vis-sankey-node-label-color: #575c65;\n --vis-sankey-node-opacity: 0.9;\n --vis-sankey-node-hover-opacity: 1.0;\n /* Node Labels */\n --vis-sankey-node-label-background-fill-color: #ffffff;\n --vis-sankey-node-label-background-stroke-color: #eaeaea;\n --vis-sankey-node-label-background-opacity: 0.9;\n --vis-sankey-node-label-color: #575c65;\n --vis-sankey-node-label-cursor: default;\n --vis-sankey-node-label-font-weight: 600;\n --vis-sankey-node-label-font-size: 12px;\n --vis-sankey-node-label-text-decoration: none;\n\n --vis-sankey-node-sublabel-font-size: 10px;\n --vis-sankey-node-sublabel-font-weight: 500;\n\n /* Icons */\n --vis-sankey-icon-size: ${SANKEY_ICON_SIZE}px;\n --vis-sankey-icon-color: #ffffff;\n --vis-sankey-icon-stroke-opacity: 0.6;\n --vis-sankey-icon-font-family: ${UNOVIS_ICON_FONT_FAMILY_DEFAULT};\n\n // Undefined by default to allow proper fallback to var(--vis-font-family)\n /* --vis-sankey-label-font-family: */\n\n /* Dark Theme */\n --vis-dark-sankey-link-color: var(--vis-color-main-dark);\n --vis-dark-sankey-node-color: var(--vis-color-main);\n --vis-dark-sankey-node-label-color: #eaeaea;\n --vis-dark-sankey-node-label-background-fill-color: #292b34;\n --vis-dark-sankey-node-label-background-stroke-color: #575c65;\n --vis-dark-sankey-icon-color: #292b34;\n }\n\n body.theme-dark ${`.${root}`} {\n --vis-sankey-node-color: var(--vis-dark-sankey-node-color);\n --vis-sankey-link-color: var(--vis-dark-sankey-link-color);\n --vis-sankey-node-label-color: var(--vis-dark-sankey-node-label-color);\n --vis-sankey-node-label-background-fill-color: var(--vis-dark-sankey-label-background-fill-color);\n --vis-sankey-node-label-background-stroke-color: var(--vis-dark-sankey-label-background-stroke-color);\n --vis-sankey-icon-color: var(--vis-dark-sankey-icon-color);\n }\n`\n\nexport const links = css`\n label: links;\n`\n\nexport const nodes = css`\n label: nodes;\n`\n\nexport const link = css`\n label: link;\n\n path {\n cursor: var(--vis-sankey-link-cursor);\n fill: var(--vis-sankey-link-color);\n fill-opacity: var(--vis-sankey-link-opacity);\n }\n\n &:hover {\n path {\n fill-opacity: var(--vis-sankey-link-hover-opacity);\n }\n }\n`\n\nexport const linkPath = css`\n label: visible;\n`\n\nexport const linkSelectionHelper = css`\n label: transparent;\n opacity: 0;\n`\n\nexport const labelGroup = css`\n label: label-group;\n cursor: var(--vis-sankey-node-label-cursor);\n`\n\nexport const labelTrimmed = css`\n label: label-trimmed;\n`\n\nexport const label = css`\n label: label;\n dominant-baseline: hanging;\n\n fill: var(--vis-sankey-node-label-color);\n text-decoration: var(--vis-sankey-node-label-text-decoration);\n font-weight: var(--vis-sankey-node-label-font-weight);\n user-select: none;\n\n &, tspan {\n font-family: var(--vis-sankey-label-font-family, var(--vis-font-family));\n dominant-baseline: hanging;\n }\n`\n\nexport const sublabel = css`\n label: sub-label;\n dominant-baseline: hanging;\n\n fill: var(--vis-sankey-node-label-color);\n user-select: none;\n\n &, tspan {\n font-family: var(--vis-sankey-label-font-family, var(--vis-font-family));\n font-weight: var(--vis-sankey-node-sublabel-font-weight);\n dominant-baseline: hanging;\n }\n`\n\nexport const labelBackground = css`\n label: label-background;\n stroke: var(--vis-sankey-node-label-background-stroke-color);\n fill: var(--vis-sankey-node-label-background-fill-color);\n opacity: var(--vis-sankey-node-label-background-opacity);\n`\n\nexport const hidden = css`\n label: hidden;\n visibility: hidden;\n`\n\nexport const forceShow = css`\n label: forceShow;\n visibility: visible;\n`\n\nexport const nodeGroup = css`\n label: node-group;\n`\n\nexport const node = css`\n label: node;\n\n cursor: var(--vis-sankey-node-cursor);\n fill: var(--vis-sankey-node-color);\n opacity: var(--vis-sankey-node-opacity);\n\n &:hover {\n opacity: var(--vis-sankey-node-hover-opacity);\n }\n`\n\nexport const nodeIcon = css`\n label: icon;\n\n font-family: var(--vis-sankey-icon-font-family);\n text-anchor: middle;\n font-size: var(--vis-sankey-icon-size);\n fill: var(--vis-sankey-node-icon-color);\n stroke: var(--vis-sankey-node-color);\n stroke-opacity: var(--vis-sankey-icon-stroke-opacity);\n user-select: none;\n pointer-events: none;\n`\n\nexport const nodeExit = css`\n label: node-exit;\n`\n\nexport const background = css`\n label: background;\n`\n"],"names":[],"mappings":";;;AAGO,MAAM,gBAAgB,GAAG,GAAE;AAE3B,MAAM,IAAI,GAAG,GAAG,CAAA;;EAEtB;AAEM,MAAM,SAAS,GAAG,YAAY,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;8BA2BP,gBAAgB,CAAA;;;qCAGT,+BAA+B,CAAA;;;;;;;;;;;;;;AAchD,kBAAA,EAAA,CAAA,CAAA,EAAI,IAAI,CAAE,CAAA,CAAA;;;;;;;;EAQ7B;AAEM,MAAM,KAAK,GAAG,GAAG,CAAA;;EAEvB;AAEM,MAAM,KAAK,GAAG,GAAG,CAAA;;EAEvB;AAEM,MAAM,IAAI,GAAG,GAAG,CAAA;;;;;;;;;;;;;;EActB;AAEM,MAAM,QAAQ,GAAG,GAAG,CAAA;;EAE1B;AAEM,MAAM,mBAAmB,GAAG,GAAG,CAAA;;;EAGrC;AAEM,MAAM,UAAU,GAAG,GAAG,CAAA;;;EAG5B;AAEM,MAAM,YAAY,GAAG,GAAG,CAAA;;EAE9B;AAEM,MAAM,KAAK,GAAG,GAAG,CAAA;;;;;;;;;;;;;EAavB;AAEM,MAAM,QAAQ,GAAG,GAAG,CAAA;;;;;;;;;;;;EAY1B;AAEM,MAAM,eAAe,GAAG,GAAG,CAAA;;;;;EAKjC;AAEM,MAAM,MAAM,GAAG,GAAG,CAAA;;;EAGxB;AAEM,MAAM,SAAS,GAAG,GAAG,CAAA;;;EAG3B;AAEM,MAAM,SAAS,GAAG,GAAG,CAAA;;EAE3B;AAEM,MAAM,IAAI,GAAG,GAAG,CAAA;;;;;;;;;;EAUtB;AAEM,MAAM,QAAQ,GAAG,GAAG,CAAA;;;;;;;;;;;EAW1B;AAEM,MAAM,QAAQ,GAAG,GAAG,CAAA;;EAE1B;AAEM,MAAM,UAAU,GAAG,GAAG,CAAA;;;;;;"}
|
|
1
|
+
{"version":3,"file":"style.js","sources":["../../../src/components/sankey/style.ts"],"sourcesContent":["import { css, injectGlobal } from '@emotion/css'\nimport { UNOVIS_ICON_FONT_FAMILY_DEFAULT } from 'styles/index'\n\nexport const SANKEY_ICON_SIZE = 22\n\nexport const root = css`\n label: sankey-component;\n`\n\nexport const variables = injectGlobal`\n :root {\n /* Links */\n --vis-sankey-link-cursor: default;\n --vis-sankey-link-color: var(--vis-color-main-light);\n --vis-sankey-link-opacity: 0.5;\n --vis-sankey-link-hover-opacity: 1.0;\n /* Nodes */\n --vis-sankey-node-cursor: default;\n --vis-sankey-node-color: var(--vis-color-main);\n --vis-sankey-node-label-color: #575c65;\n --vis-sankey-node-opacity: 0.9;\n --vis-sankey-node-hover-opacity: 1.0;\n /* Node Labels */\n --vis-sankey-node-label-background-fill-color: #ffffff;\n --vis-sankey-node-label-background-stroke-color: #eaeaea;\n --vis-sankey-node-label-background-opacity: 0.9;\n --vis-sankey-node-label-color: #575c65;\n --vis-sankey-node-label-cursor: default;\n --vis-sankey-node-label-font-weight: 600;\n --vis-sankey-node-label-font-size: 12px;\n --vis-sankey-node-label-text-decoration: none;\n\n --vis-sankey-node-sublabel-font-size: 10px;\n --vis-sankey-node-sublabel-font-weight: 500;\n\n /* Icons */\n --vis-sankey-icon-size: ${SANKEY_ICON_SIZE}px;\n --vis-sankey-icon-color: #ffffff;\n --vis-sankey-icon-stroke-opacity: 0.6;\n --vis-sankey-icon-font-family: ${UNOVIS_ICON_FONT_FAMILY_DEFAULT};\n\n // Undefined by default to allow proper fallback to var(--vis-font-family)\n /* --vis-sankey-label-font-family: */\n\n /* Dark Theme */\n --vis-dark-sankey-link-color: var(--vis-color-main-dark);\n --vis-dark-sankey-node-color: var(--vis-color-main);\n --vis-dark-sankey-node-label-color: #eaeaea;\n --vis-dark-sankey-node-label-background-fill-color: #292b34;\n --vis-dark-sankey-node-label-background-stroke-color: #575c65;\n --vis-dark-sankey-icon-color: #292b34;\n }\n\n body.theme-dark ${`.${root}`} {\n --vis-sankey-node-color: var(--vis-dark-sankey-node-color);\n --vis-sankey-link-color: var(--vis-dark-sankey-link-color);\n --vis-sankey-node-label-color: var(--vis-dark-sankey-node-label-color);\n --vis-sankey-node-label-background-fill-color: var(--vis-dark-sankey-label-background-fill-color);\n --vis-sankey-node-label-background-stroke-color: var(--vis-dark-sankey-label-background-stroke-color);\n --vis-sankey-icon-color: var(--vis-dark-sankey-icon-color);\n }\n`\n\nexport const links = css`\n label: links;\n`\n\nexport const nodes = css`\n label: nodes;\n`\n\nexport const link = css`\n label: link;\n\n path {\n cursor: var(--vis-sankey-link-cursor);\n fill: var(--vis-sankey-link-color);\n fill-opacity: var(--vis-sankey-link-opacity);\n }\n\n &:hover {\n path {\n fill-opacity: var(--vis-sankey-link-hover-opacity);\n }\n }\n`\n\nexport const linkPath = css`\n label: visible;\n`\n\nexport const linkSelectionHelper = css`\n label: transparent;\n opacity: 0;\n`\n\nexport const labelGroup = css`\n label: label-group;\n cursor: var(--vis-sankey-node-label-cursor);\n`\n\nexport const labelTrimmed = css`\n label: label-trimmed;\n`\n\nexport const label = css`\n label: label;\n dominant-baseline: hanging;\n\n fill: var(--vis-sankey-node-label-color);\n text-decoration: var(--vis-sankey-node-label-text-decoration);\n font-weight: var(--vis-sankey-node-label-font-weight);\n user-select: none;\n\n &, tspan {\n font-family: var(--vis-sankey-label-font-family, var(--vis-font-family));\n dominant-baseline: hanging;\n }\n`\n\nexport const sublabel = css`\n label: sub-label;\n dominant-baseline: hanging;\n\n fill: var(--vis-sankey-node-label-color);\n user-select: none;\n\n &, tspan {\n font-family: var(--vis-sankey-label-font-family, var(--vis-font-family));\n font-weight: var(--vis-sankey-node-sublabel-font-weight);\n dominant-baseline: hanging;\n }\n`\n\nexport const labelBackground = css`\n label: label-background;\n stroke: var(--vis-sankey-node-label-background-stroke-color);\n fill: var(--vis-sankey-node-label-background-fill-color);\n opacity: var(--vis-sankey-node-label-background-opacity);\n`\n\nexport const hidden = css`\n label: hidden;\n visibility: hidden;\n`\n\nexport const forceShow = css`\n label: forceShow;\n visibility: visible;\n`\n\nexport const nodeGroup = css`\n label: node-group;\n`\n\nexport const node = css`\n label: node;\n\n cursor: var(--vis-sankey-node-cursor);\n fill: var(--vis-sankey-node-color);\n opacity: var(--vis-sankey-node-opacity);\n\n &:hover {\n opacity: var(--vis-sankey-node-hover-opacity);\n }\n`\n\nexport const nodeIcon = css`\n label: icon;\n\n font-family: var(--vis-sankey-icon-font-family);\n text-anchor: middle;\n font-size: var(--vis-sankey-icon-size);\n fill: var(--vis-sankey-node-icon-color);\n stroke: var(--vis-sankey-node-color);\n stroke-opacity: var(--vis-sankey-icon-stroke-opacity);\n user-select: none;\n pointer-events: none;\n`\n\nexport const nodeExit = css`\n label: node-exit;\n`\n\nexport const background = css`\n label: background;\n`\n"],"names":[],"mappings":";;;AAGO,MAAM,gBAAgB,GAAG,GAAE;AAE3B,MAAM,IAAI,GAAG,GAAG,CAAA,CAAA;;EAEtB;AAEM,MAAM,SAAS,GAAG,YAAY,CAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;8BA2BP,gBAAgB,CAAA;;;qCAGT,+BAA+B,CAAA;;;;;;;;;;;;;;AAchD,kBAAA,EAAA,CAAA,CAAA,EAAI,IAAI,CAAE,CAAA,CAAA;;;;;;;;EAQ7B;AAEM,MAAM,KAAK,GAAG,GAAG,CAAA,CAAA;;EAEvB;AAEM,MAAM,KAAK,GAAG,GAAG,CAAA,CAAA;;EAEvB;AAEM,MAAM,IAAI,GAAG,GAAG,CAAA,CAAA;;;;;;;;;;;;;;EActB;AAEM,MAAM,QAAQ,GAAG,GAAG,CAAA,CAAA;;EAE1B;AAEM,MAAM,mBAAmB,GAAG,GAAG,CAAA,CAAA;;;EAGrC;AAEM,MAAM,UAAU,GAAG,GAAG,CAAA,CAAA;;;EAG5B;AAEM,MAAM,YAAY,GAAG,GAAG,CAAA,CAAA;;EAE9B;AAEM,MAAM,KAAK,GAAG,GAAG,CAAA,CAAA;;;;;;;;;;;;;EAavB;AAEM,MAAM,QAAQ,GAAG,GAAG,CAAA,CAAA;;;;;;;;;;;;EAY1B;AAEM,MAAM,eAAe,GAAG,GAAG,CAAA,CAAA;;;;;EAKjC;AAEM,MAAM,MAAM,GAAG,GAAG,CAAA,CAAA;;;EAGxB;AAEM,MAAM,SAAS,GAAG,GAAG,CAAA,CAAA;;;EAG3B;AAEM,MAAM,SAAS,GAAG,GAAG,CAAA,CAAA;;EAE3B;AAEM,MAAM,IAAI,GAAG,GAAG,CAAA,CAAA;;;;;;;;;;EAUtB;AAEM,MAAM,QAAQ,GAAG,GAAG,CAAA,CAAA;;;;;;;;;;;EAW1B;AAEM,MAAM,QAAQ,GAAG,GAAG,CAAA,CAAA;;EAE1B;AAEM,MAAM,UAAU,GAAG,GAAG,CAAA,CAAA;;;;;;"}
|
|
@@ -22,6 +22,7 @@ export declare class Scatter<Datum> extends XYComponentCore<Datum, ScatterConfig
|
|
|
22
22
|
setData(data: Datum[]): void;
|
|
23
23
|
get bleed(): Spacing;
|
|
24
24
|
_render(customDuration?: number): void;
|
|
25
|
+
private _hasLabels;
|
|
25
26
|
private _resolveLabelOverlap;
|
|
26
27
|
private _updateSizeScale;
|
|
27
28
|
private _getOnScreenData;
|
|
@@ -98,7 +98,17 @@ class Scatter extends XYComponentCore {
|
|
|
98
98
|
updatePoints(this._points, config, this.xScale, this.yScale, duration);
|
|
99
99
|
removePoints(points.exit(), this.xScale, this.yScale, duration);
|
|
100
100
|
// Take care of overlapping labels
|
|
101
|
-
this.
|
|
101
|
+
if (this._hasLabels()) {
|
|
102
|
+
this._resolveLabelOverlap();
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
_hasLabels() {
|
|
106
|
+
// If label config is not defined, no labels will be shown
|
|
107
|
+
if (!this.config.label)
|
|
108
|
+
return false;
|
|
109
|
+
// Check if any point in the flattened data has a label
|
|
110
|
+
const pointDataFlat = flatten(this._pointData);
|
|
111
|
+
return pointDataFlat.some(d => d._point.label);
|
|
102
112
|
}
|
|
103
113
|
_resolveLabelOverlap() {
|
|
104
114
|
if (!this.config.labelHideOverlapping) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/components/scatter/index.ts"],"sourcesContent":["import { Selection, select } from 'd3-selection'\nimport { max, min } from 'd3-array'\n\n// Core\nimport { XYComponentCore } from 'core/xy-component'\n\n// Utils\nimport { isNumber, getExtent, getNumber, getString, isArray, flatten, getValue } from 'utils/data'\nimport { getColor } from 'utils/color'\nimport { smartTransition } from 'utils/d3'\nimport { getCSSVariableValueInPixels } from 'utils/misc'\n\n// Types\nimport { Spacing } from 'types/spacing'\nimport { SymbolType } from 'types/symbol'\nimport { NumericAccessor } from 'types/accessor'\nimport { Position } from 'types/position'\nimport { ContinuousScale } from 'types/scale'\n\n// Local Types\nimport { ScatterPointGroupNode, ScatterPoint } from './types'\n\n// Config\nimport { ScatterDefaultConfig, ScatterConfigInterface } from './config'\n\n// Modules\nimport { createPoints, updatePoints, removePoints } from './modules/point'\nimport { collideLabels, getEstimatedLabelBBox } from './modules/utils'\n\n// Styles\nimport * as s from './style'\n\n\nexport class Scatter<Datum> extends XYComponentCore<Datum, ScatterConfigInterface<Datum>> {\n static selectors = s\n protected _defaultConfig = ScatterDefaultConfig as ScatterConfigInterface<Datum>\n public config: ScatterConfigInterface<Datum> = this._defaultConfig\n\n events = {\n [Scatter.selectors.point]: {\n mouseenter: this._onPointMouseOver.bind(this),\n mouseleave: this._onPointMouseOut.bind(this),\n },\n }\n\n private _pointData: ScatterPoint<Datum>[][] = []\n private _points: Selection<SVGGElement, ScatterPoint<Datum>, SVGGElement, ScatterPoint<Datum>[]>\n private _sizeScale: ContinuousScale\n private _collideLabelsAnimFrameId: ReturnType<typeof requestAnimationFrame>\n\n constructor (config?: ScatterConfigInterface<Datum>) {\n super()\n if (config) this.setConfig(config)\n }\n\n setConfig (config: ScatterConfigInterface<Datum>): void {\n super.setConfig(config)\n this._updateSizeScale()\n }\n\n setData (data: Datum[]): void {\n super.setData(data)\n this._updateSizeScale()\n }\n\n get bleed (): Spacing {\n this._pointData = this._getOnScreenData()\n const pointDataFlat: ScatterPoint<Datum>[] = flatten(this._pointData)\n\n const yRangeStart = min(this.yScale.range())\n const yRangeEnd = max(this.yScale.range())\n const xRangeStart = this.xScale.range()[0]\n const xRangeEnd = this.xScale.range()[1]\n\n const fontSizePx = getCSSVariableValueInPixels('var(--vis-scatter-point-label-text-font-size)', this.element)\n\n const extent = pointDataFlat.reduce((ext, d) => {\n const x = this.xScale(d._point.xValue)\n const y = this.yScale(d._point.yValue)\n const r = d._point.sizePx / 2\n\n ext.minX = Math.min(ext.minX, x - r)\n ext.maxX = Math.max(ext.maxX, x + r)\n ext.minY = Math.min(ext.minY, y - r)\n ext.maxY = Math.max(ext.maxY, y + r)\n\n if (d._point.label) {\n const labelBBox = getEstimatedLabelBBox(d, d._point.labelPosition, this.xScale, this.yScale, fontSizePx)\n ext.minX = Math.min(ext.minX, labelBBox.x)\n ext.maxX = Math.max(ext.maxX, labelBBox.x + labelBBox.width)\n ext.minY = Math.min(ext.minY, labelBBox.y)\n ext.maxY = Math.max(ext.maxY, labelBBox.y + labelBBox.height)\n }\n return ext\n }, {\n minX: Number.POSITIVE_INFINITY,\n maxX: Number.NEGATIVE_INFINITY,\n minY: Number.POSITIVE_INFINITY,\n maxY: Number.NEGATIVE_INFINITY,\n })\n\n const coeff = 1.2 // Multiplier to take into account subsequent scale range changes and shape irregularities\n const top = extent.minY < yRangeStart ? coeff * (yRangeStart - extent.minY) : 0\n const bottom = extent.maxY > yRangeEnd ? coeff * (extent.maxY - yRangeEnd) : 0\n const left = extent.minX < xRangeStart ? coeff * (xRangeStart - extent.minX) : 0\n const right = extent.maxX > xRangeEnd ? coeff * (extent.maxX - xRangeEnd) : 0\n\n return { top, bottom, left, right }\n }\n\n _render (customDuration?: number): void {\n const { config } = this\n const duration = isNumber(customDuration) ? customDuration : config.duration\n\n // Groups\n const pointGroups = this.g\n .selectAll<SVGGElement, ScatterPoint<Datum>[]>(`.${s.pointGroup}`)\n .data(this._pointData)\n\n const pointGroupsEnter = pointGroups\n .enter()\n .append('g')\n .attr('class', s.pointGroup)\n\n const pointGroupsMerged = pointGroupsEnter.merge(pointGroups)\n smartTransition(pointGroupsMerged, duration)\n .style('opacity', 1)\n\n const pointGroupExit = pointGroups.exit().attr('class', s.pointGroupExit)\n smartTransition(pointGroupExit, duration).style('opacity', 0).remove()\n\n // Points\n const points = pointGroupsMerged\n .selectAll<SVGGElement, ScatterPoint<Datum>>(`.${s.point}`)\n .data(\n d => d,\n d => `${getString(d, config.id, d._point.pointIndex) ?? d._point.pointIndex}`\n )\n\n const pointsEnter = points.enter().append('g')\n .attr('class', s.point)\n createPoints(pointsEnter, this.xScale, this.yScale)\n\n this._points = pointsEnter.merge(points)\n updatePoints(this._points, config, this.xScale, this.yScale, duration)\n\n removePoints(points.exit<ScatterPoint<Datum>>(), this.xScale, this.yScale, duration)\n\n // Take care of overlapping labels\n this._resolveLabelOverlap()\n }\n\n private _resolveLabelOverlap (): void {\n if (!this.config.labelHideOverlapping) {\n const label = this._points.selectAll<SVGTextElement, ScatterPoint<Datum>>('text')\n label.attr('opacity', null)\n return\n }\n\n cancelAnimationFrame(this._collideLabelsAnimFrameId)\n this._collideLabelsAnimFrameId = requestAnimationFrame(() => {\n collideLabels(this._points, this.config, this.xScale, this.yScale)\n })\n }\n\n private _updateSizeScale (): void {\n const { config, datamodel } = this\n\n this._sizeScale = config.sizeScale.copy()\n this._sizeScale.domain(getExtent(datamodel.data, config.size))\n this._sizeScale.range(config.sizeRange ?? [0, 0])\n }\n\n private _getOnScreenData (): ScatterPoint<Datum>[][] {\n const { config, datamodel: { data } } = this\n\n const xDomain = this.xScale.domain().map((d: number | Date) => +d) // Convert Date to number\n const yDomain = this.yScale.domain().map((d: number | Date) => +d) // Convert Date to number\n const yAccessors = (isArray(config.y) ? config.y : [config.y]) as NumericAccessor<Datum>[]\n\n const maxSizeValue = max<number>(flatten(yAccessors.map((y, j) => data?.map(d => getNumber(d, config.size, j)))))\n const maxSizePx = config.sizeRange ? this._sizeScale(maxSizeValue) : maxSizeValue\n\n const maxSizeXDomain = (this.xScale.invert(maxSizePx) as number) - (this.xScale.invert(0) as number)\n const maxSizeYDomain = Math.abs((this.yScale.invert(maxSizePx) as number) - (this.yScale.invert(0) as number))\n\n return yAccessors.map((y, j) => {\n return data?.reduce<ScatterPoint<Datum>[]>((acc, d, i) => {\n const xValue = getNumber(d, config.x, i)\n const yValue = getNumber(d, y, j)\n const pointSize = getNumber(d, config.size, i)\n const pointSizeScaled = config.sizeRange ? this._sizeScale(pointSize) : pointSize\n const pointSizeXDomain = (this.xScale.invert(pointSizeScaled) as number) - (this.xScale.invert(0) as number)\n const pointSizeYDomain = Math.abs((this.yScale.invert(pointSizeScaled) as number) - (this.yScale.invert(0) as number))\n\n if (\n ((xValue - pointSizeXDomain / 2) >= (xDomain[0] - maxSizeXDomain / 2)) &&\n ((xValue + pointSizeXDomain / 2) <= (xDomain[1] + maxSizeXDomain / 2)) &&\n ((yValue - pointSizeYDomain / 2) >= (yDomain[0] - maxSizeYDomain / 2)) &&\n ((yValue + pointSizeYDomain / 2) <= (yDomain[1] + maxSizeYDomain / 2))\n ) {\n acc.push({\n ...d,\n _point: {\n xValue: xValue,\n yValue: yValue,\n sizePx: pointSizeScaled,\n color: getColor(d, config.color, j),\n strokeColor: getColor(d, config.strokeColor, j, true),\n strokeWidthPx: getNumber(d, config.strokeWidth, j),\n shape: getString(d, config.shape, j) as SymbolType,\n label: getString(d, config.label, j),\n labelColor: getColor(d, config.labelColor, j, true),\n labelPosition: getValue(d, config.labelPosition, i) as Position,\n cursor: getString(d, config.cursor, j),\n groupIndex: j,\n pointIndex: i,\n },\n })\n }\n\n return acc\n }, []) ?? []\n })\n }\n\n private _onPointMouseOver (d: ScatterPoint<Datum>, event: MouseEvent): void {\n const point = select(event.target as SVGGElement)\n const pointNode = point.node() as ScatterPointGroupNode | null\n if (pointNode) pointNode._forceShowLabel = true\n\n point.raise()\n this._resolveLabelOverlap()\n }\n\n private _onPointMouseOut (d: ScatterPoint<Datum>, event: MouseEvent): void {\n const pointNode = select(event.target as SVGGElement).node() as ScatterPointGroupNode | null\n if (pointNode) delete pointNode._forceShowLabel\n\n this._resolveLabelOverlap()\n }\n}\n"],"names":["s.pointGroup","pointGroupExit","s.pointGroupExit","s.point","s"],"mappings":";;;;;;;;;;;;;AAiCM,MAAO,OAAe,SAAQ,eAAqD,CAAA;AAiBvF,IAAA,WAAA,CAAa,MAAsC,EAAA;AACjD,QAAA,KAAK,EAAE,CAAA;QAhBC,IAAc,CAAA,cAAA,GAAG,oBAAqD,CAAA;AACzE,QAAA,IAAA,CAAA,MAAM,GAAkC,IAAI,CAAC,cAAc,CAAA;AAElE,QAAA,IAAA,CAAA,MAAM,GAAG;AACP,YAAA,CAAC,OAAO,CAAC,SAAS,CAAC,KAAK,GAAG;gBACzB,UAAU,EAAE,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC;gBAC7C,UAAU,EAAE,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC;AAC7C,aAAA;SACF,CAAA;QAEO,IAAU,CAAA,UAAA,GAA4B,EAAE,CAAA;AAO9C,QAAA,IAAI,MAAM;AAAE,YAAA,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAA;KACnC;AAED,IAAA,SAAS,CAAE,MAAqC,EAAA;AAC9C,QAAA,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,CAAA;QACvB,IAAI,CAAC,gBAAgB,EAAE,CAAA;KACxB;AAED,IAAA,OAAO,CAAE,IAAa,EAAA;AACpB,QAAA,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;QACnB,IAAI,CAAC,gBAAgB,EAAE,CAAA;KACxB;AAED,IAAA,IAAI,KAAK,GAAA;AACP,QAAA,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,gBAAgB,EAAE,CAAA;QACzC,MAAM,aAAa,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B,CAAE,CAAsB,EAAE,KAAiB,EAAA;QACjE,MAAM,SAAS,GAAG,MAAM,CAAC,KAAK,CAAC,MAAqB,CAAC,CAAC,IAAI,EAAkC,CAAA;AAC5F,QAAA,IAAI,SAAS;YAAE,OAAO,SAAS,CAAC,eAAe,CAAA;QAE/C,IAAI,CAAC,oBAAoB,EAAE,CAAA;KAC5B;;AA9MM,OAAS,CAAA,SAAA,GAAGC,KAAC;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/components/scatter/index.ts"],"sourcesContent":["import { Selection, select } from 'd3-selection'\nimport { max, min } from 'd3-array'\n\n// Core\nimport { XYComponentCore } from 'core/xy-component'\n\n// Utils\nimport { isNumber, getExtent, getNumber, getString, isArray, flatten, getValue } from 'utils/data'\nimport { getColor } from 'utils/color'\nimport { smartTransition } from 'utils/d3'\nimport { getCSSVariableValueInPixels } from 'utils/misc'\n\n// Types\nimport { Spacing } from 'types/spacing'\nimport { SymbolType } from 'types/symbol'\nimport { NumericAccessor } from 'types/accessor'\nimport { Position } from 'types/position'\nimport { ContinuousScale } from 'types/scale'\n\n// Local Types\nimport { ScatterPointGroupNode, ScatterPoint } from './types'\n\n// Config\nimport { ScatterDefaultConfig, ScatterConfigInterface } from './config'\n\n// Modules\nimport { createPoints, updatePoints, removePoints } from './modules/point'\nimport { collideLabels, getEstimatedLabelBBox } from './modules/utils'\n\n// Styles\nimport * as s from './style'\n\n\nexport class Scatter<Datum> extends XYComponentCore<Datum, ScatterConfigInterface<Datum>> {\n static selectors = s\n protected _defaultConfig = ScatterDefaultConfig as ScatterConfigInterface<Datum>\n public config: ScatterConfigInterface<Datum> = this._defaultConfig\n\n events = {\n [Scatter.selectors.point]: {\n mouseenter: this._onPointMouseOver.bind(this),\n mouseleave: this._onPointMouseOut.bind(this),\n },\n }\n\n private _pointData: ScatterPoint<Datum>[][] = []\n private _points: Selection<SVGGElement, ScatterPoint<Datum>, SVGGElement, ScatterPoint<Datum>[]>\n private _sizeScale: ContinuousScale\n private _collideLabelsAnimFrameId: ReturnType<typeof requestAnimationFrame>\n\n constructor (config?: ScatterConfigInterface<Datum>) {\n super()\n if (config) this.setConfig(config)\n }\n\n setConfig (config: ScatterConfigInterface<Datum>): void {\n super.setConfig(config)\n this._updateSizeScale()\n }\n\n setData (data: Datum[]): void {\n super.setData(data)\n this._updateSizeScale()\n }\n\n get bleed (): Spacing {\n this._pointData = this._getOnScreenData()\n const pointDataFlat: ScatterPoint<Datum>[] = flatten(this._pointData)\n\n const yRangeStart = min(this.yScale.range())\n const yRangeEnd = max(this.yScale.range())\n const xRangeStart = this.xScale.range()[0]\n const xRangeEnd = this.xScale.range()[1]\n\n const fontSizePx = getCSSVariableValueInPixels('var(--vis-scatter-point-label-text-font-size)', this.element)\n\n const extent = pointDataFlat.reduce((ext, d) => {\n const x = this.xScale(d._point.xValue)\n const y = this.yScale(d._point.yValue)\n const r = d._point.sizePx / 2\n\n ext.minX = Math.min(ext.minX, x - r)\n ext.maxX = Math.max(ext.maxX, x + r)\n ext.minY = Math.min(ext.minY, y - r)\n ext.maxY = Math.max(ext.maxY, y + r)\n\n if (d._point.label) {\n const labelBBox = getEstimatedLabelBBox(d, d._point.labelPosition, this.xScale, this.yScale, fontSizePx)\n ext.minX = Math.min(ext.minX, labelBBox.x)\n ext.maxX = Math.max(ext.maxX, labelBBox.x + labelBBox.width)\n ext.minY = Math.min(ext.minY, labelBBox.y)\n ext.maxY = Math.max(ext.maxY, labelBBox.y + labelBBox.height)\n }\n return ext\n }, {\n minX: Number.POSITIVE_INFINITY,\n maxX: Number.NEGATIVE_INFINITY,\n minY: Number.POSITIVE_INFINITY,\n maxY: Number.NEGATIVE_INFINITY,\n })\n\n const coeff = 1.2 // Multiplier to take into account subsequent scale range changes and shape irregularities\n const top = extent.minY < yRangeStart ? coeff * (yRangeStart - extent.minY) : 0\n const bottom = extent.maxY > yRangeEnd ? coeff * (extent.maxY - yRangeEnd) : 0\n const left = extent.minX < xRangeStart ? coeff * (xRangeStart - extent.minX) : 0\n const right = extent.maxX > xRangeEnd ? coeff * (extent.maxX - xRangeEnd) : 0\n\n return { top, bottom, left, right }\n }\n\n _render (customDuration?: number): void {\n const { config } = this\n const duration = isNumber(customDuration) ? customDuration : config.duration\n\n // Groups\n const pointGroups = this.g\n .selectAll<SVGGElement, ScatterPoint<Datum>[]>(`.${s.pointGroup}`)\n .data(this._pointData)\n\n const pointGroupsEnter = pointGroups\n .enter()\n .append('g')\n .attr('class', s.pointGroup)\n\n const pointGroupsMerged = pointGroupsEnter.merge(pointGroups)\n smartTransition(pointGroupsMerged, duration)\n .style('opacity', 1)\n\n const pointGroupExit = pointGroups.exit().attr('class', s.pointGroupExit)\n smartTransition(pointGroupExit, duration).style('opacity', 0).remove()\n\n // Points\n const points = pointGroupsMerged\n .selectAll<SVGGElement, ScatterPoint<Datum>>(`.${s.point}`)\n .data(\n d => d,\n d => `${getString(d, config.id, d._point.pointIndex) ?? d._point.pointIndex}`\n )\n\n const pointsEnter = points.enter().append('g')\n .attr('class', s.point)\n createPoints(pointsEnter, this.xScale, this.yScale)\n\n this._points = pointsEnter.merge(points)\n updatePoints(this._points, config, this.xScale, this.yScale, duration)\n\n removePoints(points.exit<ScatterPoint<Datum>>(), this.xScale, this.yScale, duration)\n\n // Take care of overlapping labels\n if (this._hasLabels()) {\n this._resolveLabelOverlap()\n }\n }\n\n private _hasLabels (): boolean {\n // If label config is not defined, no labels will be shown\n if (!this.config.label) return false\n\n // Check if any point in the flattened data has a label\n const pointDataFlat: ScatterPoint<Datum>[] = flatten(this._pointData)\n return pointDataFlat.some(d => d._point.label)\n }\n\n private _resolveLabelOverlap (): void {\n if (!this.config.labelHideOverlapping) {\n const label = this._points.selectAll<SVGTextElement, ScatterPoint<Datum>>('text')\n label.attr('opacity', null)\n return\n }\n\n cancelAnimationFrame(this._collideLabelsAnimFrameId)\n this._collideLabelsAnimFrameId = requestAnimationFrame(() => {\n collideLabels(this._points, this.config, this.xScale, this.yScale)\n })\n }\n\n private _updateSizeScale (): void {\n const { config, datamodel } = this\n\n this._sizeScale = config.sizeScale.copy()\n this._sizeScale.domain(getExtent(datamodel.data, config.size))\n this._sizeScale.range(config.sizeRange ?? [0, 0])\n }\n\n private _getOnScreenData (): ScatterPoint<Datum>[][] {\n const { config, datamodel: { data } } = this\n\n const xDomain = this.xScale.domain().map((d: number | Date) => +d) // Convert Date to number\n const yDomain = this.yScale.domain().map((d: number | Date) => +d) // Convert Date to number\n const yAccessors = (isArray(config.y) ? config.y : [config.y]) as NumericAccessor<Datum>[]\n\n const maxSizeValue = max<number>(flatten(yAccessors.map((y, j) => data?.map(d => getNumber(d, config.size, j)))))\n const maxSizePx = config.sizeRange ? this._sizeScale(maxSizeValue) : maxSizeValue\n\n const maxSizeXDomain = (this.xScale.invert(maxSizePx) as number) - (this.xScale.invert(0) as number)\n const maxSizeYDomain = Math.abs((this.yScale.invert(maxSizePx) as number) - (this.yScale.invert(0) as number))\n\n return yAccessors.map((y, j) => {\n return data?.reduce<ScatterPoint<Datum>[]>((acc, d, i) => {\n const xValue = getNumber(d, config.x, i)\n const yValue = getNumber(d, y, j)\n const pointSize = getNumber(d, config.size, i)\n const pointSizeScaled = config.sizeRange ? this._sizeScale(pointSize) : pointSize\n const pointSizeXDomain = (this.xScale.invert(pointSizeScaled) as number) - (this.xScale.invert(0) as number)\n const pointSizeYDomain = Math.abs((this.yScale.invert(pointSizeScaled) as number) - (this.yScale.invert(0) as number))\n\n if (\n ((xValue - pointSizeXDomain / 2) >= (xDomain[0] - maxSizeXDomain / 2)) &&\n ((xValue + pointSizeXDomain / 2) <= (xDomain[1] + maxSizeXDomain / 2)) &&\n ((yValue - pointSizeYDomain / 2) >= (yDomain[0] - maxSizeYDomain / 2)) &&\n ((yValue + pointSizeYDomain / 2) <= (yDomain[1] + maxSizeYDomain / 2))\n ) {\n acc.push({\n ...d,\n _point: {\n xValue: xValue,\n yValue: yValue,\n sizePx: pointSizeScaled,\n color: getColor(d, config.color, j),\n strokeColor: getColor(d, config.strokeColor, j, true),\n strokeWidthPx: getNumber(d, config.strokeWidth, j),\n shape: getString(d, config.shape, j) as SymbolType,\n label: getString(d, config.label, j),\n labelColor: getColor(d, config.labelColor, j, true),\n labelPosition: getValue(d, config.labelPosition, i) as Position,\n cursor: getString(d, config.cursor, j),\n groupIndex: j,\n pointIndex: i,\n },\n })\n }\n\n return acc\n }, []) ?? []\n })\n }\n\n private _onPointMouseOver (d: ScatterPoint<Datum>, event: MouseEvent): void {\n const point = select(event.target as SVGGElement)\n const pointNode = point.node() as ScatterPointGroupNode | null\n if (pointNode) pointNode._forceShowLabel = true\n\n point.raise()\n this._resolveLabelOverlap()\n }\n\n private _onPointMouseOut (d: ScatterPoint<Datum>, event: MouseEvent): void {\n const pointNode = select(event.target as SVGGElement).node() as ScatterPointGroupNode | null\n if (pointNode) delete pointNode._forceShowLabel\n\n this._resolveLabelOverlap()\n }\n}\n"],"names":["s.pointGroup","pointGroupExit","s.pointGroupExit","s.point","s"],"mappings":";;;;;;;;;;;;;AAiCM,MAAO,OAAe,SAAQ,eAAqD,CAAA;AAiBvF,IAAA,WAAA,CAAa,MAAsC,EAAA;AACjD,QAAA,KAAK,EAAE,CAAA;QAhBC,IAAc,CAAA,cAAA,GAAG,oBAAqD,CAAA;AACzE,QAAA,IAAA,CAAA,MAAM,GAAkC,IAAI,CAAC,cAAc,CAAA;AAElE,QAAA,IAAA,CAAA,MAAM,GAAG;AACP,YAAA,CAAC,OAAO,CAAC,SAAS,CAAC,KAAK,GAAG;gBACzB,UAAU,EAAE,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC;gBAC7C,UAAU,EAAE,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC;AAC7C,aAAA;SACF,CAAA;QAEO,IAAU,CAAA,UAAA,GAA4B,EAAE,CAAA;AAO9C,QAAA,IAAI,MAAM;AAAE,YAAA,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAA;KACn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,CAAC,aAAa,EAAE,CAAC,CAAa;4BAC/D,MAAM,EAAE,SAAS,CAAC,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;AACtC,4BAAA,UAAU,EAAE,CAAC;AACb,4BAAA,UAAU,EAAE,CAAC;AACd,yBAAA,EAAA,CAAA,CACD,CAAA;AACH,iBAAA;AAED,gBAAA,OAAO,GAAG,CAAA;AACZ,aAAC,EAAE,EAAE,CAAC,MAAA,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,EAAA,GAAI,EAAE,CAAA;AACd,SAAC,CAAC,CAAA;KACH;IAEO,iBAAiB,CAAE,CAAsB,EAAE,KAAiB,EAAA;QAClE,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,MAAqB,CAAC,CAAA;AACjD,QAAA,MAAM,SAAS,GAAG,KAAK,CAAC,IAAI,EAAkC,CAAA;AAC9D,QAAA,IAAI,SAAS;AAAE,YAAA,SAAS,CAAC,eAAe,GAAG,IAAI,CAAA;QAE/C,KAAK,CAAC,KAAK,EAAE,CAAA;QACb,IAAI,CAAC,oBAAoB,EAAE,CAAA;KAC5B;IAEO,gBAAgB,CAAE,CAAsB,EAAE,KAAiB,EAAA;QACjE,MAAM,SAAS,GAAG,MAAM,CAAC,KAAK,CAAC,MAAqB,CAAC,CAAC,IAAI,EAAkC,CAAA;AAC5F,QAAA,IAAI,SAAS;YAAE,OAAO,SAAS,CAAC,eAAe,CAAA;QAE/C,IAAI,CAAC,oBAAoB,EAAE,CAAA;KAC5B;;AAzNM,OAAS,CAAA,SAAA,GAAGC,KAAC;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"style.js","sources":["../../../src/components/scatter/style.ts"],"sourcesContent":["import { css, injectGlobal } from '@emotion/css'\n\nexport const globalStyles = injectGlobal`\n :root {\n --vis-scatter-cursor: default;\n --vis-scatter-fill-color: var(--vis-color-main);\n --vis-scatter-stroke-color: 'none';\n --vis-scatter-stroke-width: 1px;\n --vis-scatter-fill-opacity: 1;\n --vis-scatter-stroke-opacity: 1;\n --vis-scatter-hover-stroke-width: 2px;\n\n --vis-scatter-point-label-text-color-dark: #5b5f6d;\n --vis-scatter-point-label-text-color-light: #fff;\n --vis-scatter-point-label-text-font-weight: 500;\n --vis-scatter-point-label-text-font-size: 12px;\n // Undefined by default to allow proper fallback to var(--vis-font-family)\n /* --vis-scatter-point-label-text-font-family: */\n }\n`\n\nexport const root = css`\n label: scatter-component;\n`\n\nexport const pointGroup = css`\n label: point-group;\n`\n\nexport const pointGroupExit = css`\n label: point-group-exit;\n`\n\nexport const point = css`\n label: point;\n\n > path {\n cursor: var(--vis-scatter-cursor);\n fill: var(--vis-scatter-fill-color);\n fill-opacity: var(--vis-scatter-fill-opacity);\n stroke-opacity: var(--vis-scatter-stroke-opacity);\n stroke-width: var(--vis-scatter-stroke-width);\n stroke: var(--vis-scatter-stroke-color);\n\n &:hover {\n stroke-width: var(--vis-scatter-hover-stroke-width);\n }\n }\n\n > text {\n font-weight: var(--vis-scatter-point-label-text-font-weight);\n font-size: var(--vis-scatter-point-label-text-font-size);\n font-family: var(--vis-scatter-point-label-text-font-family, var(--vis-font-family));\n fill: var(--vis-scatter-point-label-text-color-dark);\n user-select: none;\n }\n`\n"],"names":[],"mappings":";;AAEO,MAAM,YAAY,GAAG,YAAY,CAAA;;;;;;;;;;;;;;;;;EAiBvC;AAEM,MAAM,IAAI,GAAG,GAAG,CAAA;;EAEtB;AAEM,MAAM,UAAU,GAAG,GAAG,CAAA;;EAE5B;AAEM,MAAM,cAAc,GAAG,GAAG,CAAA;;EAEhC;AAEM,MAAM,KAAK,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"style.js","sources":["../../../src/components/scatter/style.ts"],"sourcesContent":["import { css, injectGlobal } from '@emotion/css'\n\nexport const globalStyles = injectGlobal`\n :root {\n --vis-scatter-cursor: default;\n --vis-scatter-fill-color: var(--vis-color-main);\n --vis-scatter-stroke-color: 'none';\n --vis-scatter-stroke-width: 1px;\n --vis-scatter-fill-opacity: 1;\n --vis-scatter-stroke-opacity: 1;\n --vis-scatter-hover-stroke-width: 2px;\n\n --vis-scatter-point-label-text-color-dark: #5b5f6d;\n --vis-scatter-point-label-text-color-light: #fff;\n --vis-scatter-point-label-text-font-weight: 500;\n --vis-scatter-point-label-text-font-size: 12px;\n // Undefined by default to allow proper fallback to var(--vis-font-family)\n /* --vis-scatter-point-label-text-font-family: */\n }\n`\n\nexport const root = css`\n label: scatter-component;\n`\n\nexport const pointGroup = css`\n label: point-group;\n`\n\nexport const pointGroupExit = css`\n label: point-group-exit;\n`\n\nexport const point = css`\n label: point;\n\n > path {\n cursor: var(--vis-scatter-cursor);\n fill: var(--vis-scatter-fill-color);\n fill-opacity: var(--vis-scatter-fill-opacity);\n stroke-opacity: var(--vis-scatter-stroke-opacity);\n stroke-width: var(--vis-scatter-stroke-width);\n stroke: var(--vis-scatter-stroke-color);\n\n &:hover {\n stroke-width: var(--vis-scatter-hover-stroke-width);\n }\n }\n\n > text {\n font-weight: var(--vis-scatter-point-label-text-font-weight);\n font-size: var(--vis-scatter-point-label-text-font-size);\n font-family: var(--vis-scatter-point-label-text-font-family, var(--vis-font-family));\n fill: var(--vis-scatter-point-label-text-color-dark);\n user-select: none;\n }\n`\n"],"names":[],"mappings":";;AAEO,MAAM,YAAY,GAAG,YAAY,CAAA,CAAA;;;;;;;;;;;;;;;;;EAiBvC;AAEM,MAAM,IAAI,GAAG,GAAG,CAAA,CAAA;;EAEtB;AAEM,MAAM,UAAU,GAAG,GAAG,CAAA,CAAA;;EAE5B;AAEM,MAAM,cAAc,GAAG,GAAG,CAAA,CAAA;;EAEhC;AAEM,MAAM,KAAK,GAAG,GAAG,CAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"style.js","sources":["../../../src/components/stacked-bar/style.ts"],"sourcesContent":["import { css, injectGlobal } from '@emotion/css'\n\nexport const root = css`\n label: stacked-bar-component;\n`\n\nexport const globalStyles = injectGlobal`\n :root {\n --vis-stacked-bar-cursor: default;\n --vis-stacked-bar-fill-color: var(--vis-color-main);\n --vis-stacked-bar-stroke-color: none;\n --vis-stacked-bar-stroke-width: 0px;\n --vis-stacked-bar-hover-stroke-width: none;\n --vis-stacked-bar-hover-stroke-color: none;\n\n /* Dark Theme */\n --vis-dark-stacked-bar-stroke-color: none;\n }\n\n body.theme-dark ${`.${root}`} {\n --vis-stacked-bar-stroke-color: var(--vis-dark-stacked-bar-stroke-color);\n }\n`\n\nexport const bar = css`\n label: bar;\n fill: var(--vis-stacked-bar-fill-color);\n stroke: var(--vis-stacked-bar-stroke-color);\n stroke-width: var(--vis-stacked-bar-stroke-width);\n cursor: var(--vis-stacked-bar-cursor);\n\n &:hover {\n stroke-width: var(--vis-stacked-bar-hover-stroke-width);\n stroke: var(--vis-stacked-bar-hover-stroke-color);\n }\n`\n\nexport const barGroup = css`\n label: barGroup;\n`\n\nexport const barGroupExit = css`\n label: barGroupExit;\n`\n"],"names":[],"mappings":";;AAEO,MAAM,IAAI,GAAG,GAAG,CAAA;;EAEtB;AAEM,MAAM,YAAY,GAAG,YAAY,CAAA;;;;;;;;;;;;;AAapB,kBAAA,EAAA,CAAA,CAAA,EAAI,IAAI,CAAE,CAAA,CAAA;;;EAG7B;AAEM,MAAM,GAAG,GAAG,GAAG,CAAA;;;;;;;;;;;EAWrB;AAEM,MAAM,QAAQ,GAAG,GAAG,CAAA;;EAE1B;AAEM,MAAM,YAAY,GAAG,GAAG,CAAA;;;;;;"}
|
|
1
|
+
{"version":3,"file":"style.js","sources":["../../../src/components/stacked-bar/style.ts"],"sourcesContent":["import { css, injectGlobal } from '@emotion/css'\n\nexport const root = css`\n label: stacked-bar-component;\n`\n\nexport const globalStyles = injectGlobal`\n :root {\n --vis-stacked-bar-cursor: default;\n --vis-stacked-bar-fill-color: var(--vis-color-main);\n --vis-stacked-bar-stroke-color: none;\n --vis-stacked-bar-stroke-width: 0px;\n --vis-stacked-bar-hover-stroke-width: none;\n --vis-stacked-bar-hover-stroke-color: none;\n\n /* Dark Theme */\n --vis-dark-stacked-bar-stroke-color: none;\n }\n\n body.theme-dark ${`.${root}`} {\n --vis-stacked-bar-stroke-color: var(--vis-dark-stacked-bar-stroke-color);\n }\n`\n\nexport const bar = css`\n label: bar;\n fill: var(--vis-stacked-bar-fill-color);\n stroke: var(--vis-stacked-bar-stroke-color);\n stroke-width: var(--vis-stacked-bar-stroke-width);\n cursor: var(--vis-stacked-bar-cursor);\n\n &:hover {\n stroke-width: var(--vis-stacked-bar-hover-stroke-width);\n stroke: var(--vis-stacked-bar-hover-stroke-color);\n }\n`\n\nexport const barGroup = css`\n label: barGroup;\n`\n\nexport const barGroupExit = css`\n label: barGroupExit;\n`\n"],"names":[],"mappings":";;AAEO,MAAM,IAAI,GAAG,GAAG,CAAA,CAAA;;EAEtB;AAEM,MAAM,YAAY,GAAG,YAAY,CAAA,CAAA;;;;;;;;;;;;;AAapB,kBAAA,EAAA,CAAA,CAAA,EAAI,IAAI,CAAE,CAAA,CAAA;;;EAG7B;AAEM,MAAM,GAAG,GAAG,GAAG,CAAA,CAAA;;;;;;;;;;;EAWrB;AAEM,MAAM,QAAQ,GAAG,GAAG,CAAA,CAAA;;EAE1B;AAEM,MAAM,YAAY,GAAG,GAAG,CAAA,CAAA;;;;;;"}
|