@unovis/ts 1.5.0-version.8 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/axis/config.d.ts +10 -1
- package/components/axis/config.js +1 -1
- package/components/axis/config.js.map +1 -1
- package/components/axis/index.d.ts +19 -19
- package/components/axis/index.js +63 -8
- package/components/axis/index.js.map +1 -1
- package/components/axis/style.d.ts +1 -0
- package/components/axis/style.js +7 -2
- package/components/axis/style.js.map +1 -1
- package/components/crosshair/index.js +6 -0
- package/components/crosshair/index.js.map +1 -1
- package/components/graph/config.d.ts +2 -9
- package/components/graph/config.js +2 -5
- package/components/graph/config.js.map +1 -1
- package/components/graph/index.d.ts +9 -3
- package/components/graph/index.js +3 -3
- package/components/graph/index.js.map +1 -1
- package/components/tooltip/index.d.ts +7 -0
- package/components/tooltip/index.js +17 -5
- package/components/tooltip/index.js.map +1 -1
- package/containers/xy-container/index.js +3 -2
- package/containers/xy-container/index.js.map +1 -1
- package/core/container/index.js +7 -6
- package/core/container/index.js.map +1 -1
- package/package.json +2 -2
- package/types/graph.d.ts +0 -4
- package/utils/data.d.ts +1 -1
- package/utils/data.js +6 -7
- package/utils/data.js.map +1 -1
|
@@ -36,6 +36,10 @@ class Tooltip {
|
|
|
36
36
|
var _a;
|
|
37
37
|
this.prevConfig = this.config;
|
|
38
38
|
this.config = merge(this._defaultConfig, config);
|
|
39
|
+
// Reset `this._overriddenHorizontalPlacement` if the `horizontalPlacement` has changed
|
|
40
|
+
if (this.prevConfig.horizontalPlacement !== this.config.horizontalPlacement) {
|
|
41
|
+
this.overrideHorizontalPlacement(undefined);
|
|
42
|
+
}
|
|
39
43
|
if (this.config.container && (this.config.container !== ((_a = this.prevConfig) === null || _a === void 0 ? void 0 : _a.container))) {
|
|
40
44
|
this.setContainer(this.config.container);
|
|
41
45
|
}
|
|
@@ -94,9 +98,10 @@ class Tooltip {
|
|
|
94
98
|
const { config } = this;
|
|
95
99
|
const tooltipWidth = this.element.offsetWidth;
|
|
96
100
|
const tooltipHeight = this.element.offsetHeight;
|
|
97
|
-
const horizontalPlacement =
|
|
98
|
-
|
|
99
|
-
|
|
101
|
+
const horizontalPlacement = this._overriddenHorizontalPlacement ||
|
|
102
|
+
(config.horizontalPlacement === Position.Auto
|
|
103
|
+
? Position.Center
|
|
104
|
+
: config.horizontalPlacement);
|
|
100
105
|
const verticalPlacement = config.verticalPlacement === Position.Auto
|
|
101
106
|
? ((pos.y - tooltipHeight) < 0 ? Position.Bottom : Position.Top)
|
|
102
107
|
: config.verticalPlacement;
|
|
@@ -137,10 +142,10 @@ class Tooltip {
|
|
|
137
142
|
pageX: hoveredElementRect.x,
|
|
138
143
|
pageY: hoveredElementRect.y,
|
|
139
144
|
}, this._container);
|
|
140
|
-
const horizontalPlacement = config.horizontalPlacement === Position.Auto
|
|
145
|
+
const horizontalPlacement = this._overriddenHorizontalPlacement || (config.horizontalPlacement === Position.Auto
|
|
141
146
|
? (elementPos[0] - tooltipWidth < 0 ? Position.Right
|
|
142
147
|
: elementPos[0] + tooltipWidth > containerWidth ? Position.Left : Position.Center)
|
|
143
|
-
: config.horizontalPlacement;
|
|
148
|
+
: config.horizontalPlacement);
|
|
144
149
|
let translateX = 0;
|
|
145
150
|
switch (horizontalPlacement) {
|
|
146
151
|
case Position.Left:
|
|
@@ -177,6 +182,13 @@ class Tooltip {
|
|
|
177
182
|
isContainerBody() {
|
|
178
183
|
return this._container === document.body;
|
|
179
184
|
}
|
|
185
|
+
/** Allows to override the horizontal placement of the tooltip which is useful when you want to define custom positioning behavior.
|
|
186
|
+
* This method has been added for Crosshair to allow it position tooltip left or right of the crosshair line
|
|
187
|
+
* (see the `_showTooltip` method of the Crosshair component).
|
|
188
|
+
*/
|
|
189
|
+
overrideHorizontalPlacement(placement) {
|
|
190
|
+
this._overriddenHorizontalPlacement = placement;
|
|
191
|
+
}
|
|
180
192
|
render(html) {
|
|
181
193
|
var _a;
|
|
182
194
|
const { config, prevConfig } = this;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/components/tooltip/index.ts"],"sourcesContent":["import { select, Selection, pointer } from 'd3-selection'\n\n// Core\nimport { ComponentCore } from 'core/component'\n\n// Types\nimport { Position } from 'types/position'\n\n// Utils\nimport { merge, throttle } from 'utils/data'\n\n// Config\nimport { TooltipDefaultConfig, TooltipConfigInterface } from './config'\n\n// Style\nimport * as s from './style'\n\nexport class Tooltip {\n element: HTMLElement\n div: Selection<HTMLElement, unknown, null, undefined>\n protected _defaultConfig = TooltipDefaultConfig as TooltipConfigInterface\n public config: TooltipConfigInterface = this._defaultConfig\n prevConfig: TooltipConfigInterface\n components: ComponentCore<unknown>[]\n static selectors = s\n private _setUpEventsThrottled = throttle(this._setUpEvents, 500)\n private _setContainerPositionThrottled = throttle(this._setContainerPosition, 500)\n private _isShown = false\n private _container: HTMLElement\n private _mutationObserver: MutationObserver\n private _hoveredElement: HTMLElement | SVGElement\n private _position: [number, number]\n\n constructor (config: TooltipConfigInterface = {}) {\n this.element = document.createElement('div')\n this.div = select(this.element).attr('class', s.root)\n\n this.setConfig(config)\n this.components = this.config.components\n\n // Set up MutationObserver to automatically re-position the tooltip\n // if the content has been dynamically changed\n this._mutationObserver = new MutationObserver(() => {\n if (!this._isShown) return\n\n // Handle changes to the content of this.div\n // Add your logic here\n if (!this.config.followCursor && this._hoveredElement) {\n this.placeByElement(this._hoveredElement)\n } else if (this._position) {\n this.place({ x: this._position[0], y: this._position[1] })\n }\n })\n\n this._mutationObserver.observe(this.div.node(), { childList: true, subtree: true })\n }\n\n public setConfig (config: TooltipConfigInterface): void {\n this.prevConfig = this.config\n this.config = merge(this._defaultConfig, config)\n\n if (this.config.container && (this.config.container !== this.prevConfig?.container)) {\n this.setContainer(this.config.container)\n }\n\n this._setUpAttributes()\n }\n\n public setContainer (container: HTMLElement): void {\n this.element.parentNode?.removeChild(this.element)\n\n this._container = container\n this._container.appendChild(this.element)\n\n this._setContainerPositionThrottled()\n }\n\n public getContainer (): HTMLElement {\n return this._container\n }\n\n public hasContainer (): boolean {\n return !!this._container && this._container.isConnected\n }\n\n public setComponents (components: ComponentCore<unknown>[]): void {\n this.components = components\n }\n\n public update (): void {\n if (!this._container) return\n\n this._setUpEventsThrottled()\n }\n\n /** Show the tooltip by providing content and position */\n public show (html: string | HTMLElement | null | void, pos: { x: number; y: number }): void {\n this.render(html)\n this.place(pos)\n }\n\n /** Hide the tooltip */\n public hide (): void {\n this.div\n .classed(s.show, false) // The `show` class triggers the opacity transition\n .on('transitionend', () => {\n // We hide the element once the transition completes\n // This ensures container overflow will not occur when the window is resized\n this.div.classed(s.hidden, !this._isShown)\n })\n\n this._isShown = false\n }\n\n /** Simply displays the tooltip with its previous content on position */\n public display (): void {\n this.div\n .classed(s.hidden, false) // The `hidden` class sets `display: none;`\n .classed(s.show, true) // The `show` class triggers the opacity transition\n\n this._isShown = true\n }\n\n public place (pos: { x: number; y: number }): void {\n this._position = [pos.x, pos.y]\n\n if (!this.hasContainer()) {\n console.warn('Unovis | Tooltip: Container was not set or is not initialized yet')\n return\n }\n\n const { config } = this\n const tooltipWidth = this.element.offsetWidth\n const tooltipHeight = this.element.offsetHeight\n\n const horizontalPlacement = config.horizontalPlacement === Position.Auto\n ? Position.Center\n : config.horizontalPlacement\n\n const verticalPlacement = config.verticalPlacement === Position.Auto\n ? ((pos.y - tooltipHeight) < 0 ? Position.Bottom : Position.Top)\n : config.verticalPlacement\n\n // Todo: Get rid of the hardcoded margin in version 2.0\n // Can be simply replaced with `verticalShift` and `horizontalShift`\n // but it'll be a breaking change\n const margin = 5\n const translateX = horizontalPlacement === Position.Left ? -tooltipWidth - margin - config.horizontalShift\n : horizontalPlacement === Position.Center ? -tooltipWidth / 2\n : margin + config.horizontalShift\n\n const translateY = verticalPlacement === Position.Bottom ? margin + config.verticalShift\n : verticalPlacement === Position.Center ? -tooltipHeight / 2\n : -margin - config.verticalShift - tooltipHeight\n\n // translateX and translateY variables shift the tooltip from the default position (above the cursor, centred horizontally)\n const [top, left] = this._constraintPosToContainer(pos.x + translateX, pos.y + translateY, tooltipWidth, tooltipHeight)\n this._applyPosition(top, left, tooltipHeight)\n }\n\n public placeByElement (hoveredElement: SVGElement | HTMLElement): void {\n const { config } = this\n\n // Store the hovered element and the event for future reference,\n // i.e. to re-position the tooltip if the content has been changed\n // by something else and it was captured by the MutationObserver\n this._hoveredElement = hoveredElement\n\n // Todo: Get rid of the hardcoded margin in version 2.0\n // Can be simply replaced with `verticalShift` and `horizontalShift`\n // but it'll be a breaking change\n const margin = 5\n const tooltipWidth = this.element.offsetWidth\n const tooltipHeight = this.element.offsetHeight\n const isContainerBody = this.isContainerBody()\n const containerWidth = isContainerBody ? window.innerWidth : this._container.scrollWidth\n const hoveredElementRect = hoveredElement.getBoundingClientRect()\n\n // We use D3's point transformation to get the correct position of the element by pretending it's a pointer event\n // See more: https://github.com/d3/d3-selection/blob/main/src/pointer.js\n const elementPos = isContainerBody ? [hoveredElementRect.x, hoveredElementRect.y] : pointer({\n clientX: hoveredElementRect.x,\n clientY: hoveredElementRect.y,\n pageX: hoveredElementRect.x,\n pageY: hoveredElementRect.y,\n }, this._container)\n\n const horizontalPlacement = config.horizontalPlacement === Position.Auto\n ? (elementPos[0] - tooltipWidth < 0 ? Position.Right\n : elementPos[0] + tooltipWidth > containerWidth ? Position.Left : Position.Center)\n : config.horizontalPlacement\n\n let translateX = 0\n switch (horizontalPlacement) {\n case Position.Left:\n translateX = -tooltipWidth - margin - config.horizontalShift\n break\n case Position.Right:\n translateX = hoveredElementRect.width + margin + config.horizontalShift\n break\n case Position.Center:\n default:\n translateX = (-tooltipWidth + hoveredElementRect.width) / 2\n break\n }\n\n const verticalPlacement = config.verticalPlacement === Position.Auto\n ? (horizontalPlacement !== Position.Center ? Position.Center\n : elementPos[1] - tooltipHeight < 0 ? Position.Bottom : Position.Top)\n : config.verticalPlacement\n\n let translateY = -tooltipHeight\n switch (verticalPlacement) {\n case Position.Center:\n translateY += (tooltipHeight + hoveredElementRect.height) / 2\n break\n case Position.Bottom:\n translateY += tooltipHeight + hoveredElementRect.height + margin + config.verticalShift\n break\n case Position.Top:\n default:\n translateY += -margin - config.verticalShift\n break\n }\n\n const [top, left] = this._constraintPosToContainer(elementPos[0] + translateX, elementPos[1] + translateY, tooltipWidth, tooltipHeight)\n this._applyPosition(top, left, tooltipHeight)\n }\n\n public isContainerBody (): boolean {\n return this._container === document.body\n }\n\n public render (html: string | HTMLElement | null | void): void {\n const { config, prevConfig } = this\n if (html instanceof HTMLElement) {\n const node = this.div.select(':first-child').node()\n if (node !== html) this.div.html('').append(() => html)\n } else if (html) {\n this.div.html(html)\n }\n\n this.div\n .classed(config.className ?? '', Boolean(config.className))\n .classed(s.nonInteractive, !config.allowHover || config.followCursor)\n\n // Remove the previous class name if it was set\n if (prevConfig?.className && prevConfig.className !== config.className) {\n this.div.classed(prevConfig.className, false)\n }\n\n this.display()\n }\n\n private _applyPosition (x: number, y: number, tooltipHeight: number): void {\n const isContainerBody = this.isContainerBody()\n const containerHeight = isContainerBody ? window.innerHeight : this._container.scrollHeight\n\n this.div\n .classed(s.positionFixed, isContainerBody)\n .style('top', isContainerBody ? `${y}px` : 'unset')\n .style('bottom', !isContainerBody ? `${containerHeight - y - tooltipHeight}px` : 'unset')\n .style('left', `${x}px`)\n }\n\n private _constraintPosToContainer (top: number, left: number, tooltipWidth: number, tooltipHeight: number): [number, number] {\n const isContainerBody = this.isContainerBody()\n const containerHeight = isContainerBody ? window.innerHeight : this._container.scrollHeight\n const containerWidth = isContainerBody ? window.innerWidth : this._container.scrollWidth\n\n // // Constraint to container\n const paddingX = 10\n const hitRight = top > (containerWidth - tooltipWidth - paddingX)\n const hitLeft = top < paddingX\n const constrainedLeft = hitRight ? containerWidth - tooltipWidth - paddingX\n : hitLeft ? paddingX : top\n\n const paddingY = 10\n const hitBottom = left > (containerHeight - tooltipHeight - paddingY)\n const hitTop = left < paddingY\n const constrainedTop = hitBottom ? containerHeight - tooltipHeight - paddingY\n : hitTop ? paddingY : left\n\n return [\n containerWidth < tooltipWidth ? 0 : constrainedLeft,\n containerHeight < tooltipHeight ? 0 : constrainedTop,\n ]\n }\n\n private _setContainerPosition (): void {\n // Tooltip position calculation relies on the parent position\n // If it's not set (static), we set it to `relative` (not a good practice)\n if (this._container !== document.body && getComputedStyle(this._container)?.position === 'static') {\n this._container.style.position = 'relative'\n }\n }\n\n private _setUpEvents (): void {\n const { config } = this\n\n // We use the Event Delegation pattern to set up Tooltip events\n // Every component will have single `mousemove` and `mouseleave` event listener functions, where we'll check\n // the `path` of the event and trigger corresponding callbacks\n this.components.forEach(component => {\n const selection = select(component.element)\n selection\n .on('mousemove.tooltip', (e: MouseEvent) => {\n const path: (HTMLElement | SVGGElement)[] = (e.composedPath && e.composedPath()) || (e as any).path || [e.target]\n\n // Go through all of the configured triggers\n for (const className of Object.keys(config.triggers)) {\n const template = config.triggers[className]\n if (!template) continue // Skip if the trigger is not configured\n\n const els = selection.selectAll<HTMLElement | SVGGElement, unknown>(`.${className}`).nodes()\n\n // Go through all of the elements in the event path (from the deepest element upwards)\n for (const el of path) {\n if (el === selection.node()) break // Break on the component's level (usually the `<g>` element)\n if (el.classList.contains(className)) { // If there's a match, show the tooltip\n const i = els.indexOf(el)\n const d = select(el).datum()\n const content = template(d, i, els)\n const [x, y] = this.isContainerBody() ? [e.clientX, e.clientY] : pointer(e, this._container)\n if (content === null) {\n // If the content is `null`, we hide the tooltip\n this.hide()\n } else {\n // Otherwise we show the tooltip, but don't render the content if it's `undefined` or\n // an empty string. This way we can allow it to work with things like `createPortal` in React\n this.render(content)\n if (config.followCursor) this.place({ x, y })\n else this.placeByElement(el)\n }\n\n // Stop propagation to prevent other interfering events from being triggered, e.g. Crosshair\n e.stopPropagation()\n\n // Stop looking for other matches\n return\n }\n }\n }\n\n // Hide the tooltip if the event didn't pass through any of the configured triggers.\n // We use the `this._isShown` condition as a little performance optimization tweak\n // (we don't want the tooltip to update its class on every mouse movement, see `this.hide()`).\n if (this._isShown) this.hide()\n })\n .on('mouseleave.tooltip', (e: MouseEvent) => {\n e.stopPropagation() // Stop propagation to prevent other interfering events from being triggered, e.g. Crosshair\n this.hide()\n })\n })\n\n // Set up Tooltip hover\n if (config.allowHover && !config.followCursor) {\n this.div\n .on('mouseenter.tooltip', this.display.bind(this))\n .on('mouseleave.tooltip', this.hide.bind(this))\n } else {\n this.div\n .on('mouseenter.tooltip', null)\n .on('mouseleave.tooltip', null)\n }\n }\n\n private _setUpAttributes (): void {\n const attributesMap = this.config.attributes\n if (!attributesMap) return\n\n Object.keys(attributesMap).forEach(attr => {\n this.div.attr(attr, attributesMap[attr])\n })\n }\n\n public destroy (): void {\n this._mutationObserver.disconnect()\n this.div?.remove()\n }\n}\n"],"names":["s.root","s.show","s.hidden","s.nonInteractive","s.positionFixed","s"],"mappings":";;;;;;;MAiBa,OAAO,CAAA;AAgBlB,IAAA,WAAA,CAAa,SAAiC,EAAE,EAAA;QAbtC,IAAc,CAAA,cAAA,GAAG,oBAA8C,CAAA;AAClE,QAAA,IAAA,CAAA,MAAM,GAA2B,IAAI,CAAC,cAAc,CAAA;QAInD,IAAqB,CAAA,qBAAA,GAAG,QAAQ,CAAC,IAAI,CAAC,YAAY,EAAE,GAAG,CAAC,CAAA;QACxD,IAA8B,CAAA,8BAAA,GAAG,QAAQ,CAAC,IAAI,CAAC,qBAAqB,EAAE,GAAG,CAAC,CAAA;QAC1E,IAAQ,CAAA,QAAA,GAAG,KAAK,CAAA;QAOtB,IAAI,CAAC,OAAO,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAA;AAC5C,QAAA,IAAI,CAAC,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,OAAO,EAAEA,IAAM,CAAC,CAAA;AAErD,QAAA,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAA;QACtB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,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CAAC;AACjD,iBAAA,EAAE,CAAC,oBAAoB,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;AAClD,SAAA;AAAM,aAAA;AACL,YAAA,IAAI,CAAC,GAAG;AACL,iBAAA,EAAE,CAAC,oBAAoB,EAAE,IAAI,CAAC;AAC9B,iBAAA,EAAE,CAAC,oBAAoB,EAAE,IAAI,CAAC,CAAA;AAClC,SAAA;KACF;IAEO,gBAAgB,GAAA;AACtB,QAAA,MAAM,aAAa,GAAG,IAAI,CAAC,MAAM,CAAC,UAAU,CAAA;AAC5C,QAAA,IAAI,CAAC,aAAa;YAAE,OAAM;QAE1B,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,OAAO,CAAC,IAAI,IAAG;AACxC,YAAA,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,aAAa,CAAC,IAAI,CAAC,CAAC,CAAA;AAC1C,SAAC,CAAC,CAAA;KACH;IAEM,OAAO,GAAA;;AACZ,QAAA,IAAI,CAAC,iBAAiB,CAAC,UAAU,EAAE,CAAA;AACnC,QAAA,CAAA,EAAA,GAAA,IAAI,CAAC,GAAG,MAAE,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,MAAM,EAAE,CAAA;KACnB;;AAnWM,OAAS,CAAA,SAAA,GAAGC,KAAC;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/components/tooltip/index.ts"],"sourcesContent":["import { select, Selection, pointer } from 'd3-selection'\n\n// Core\nimport { ComponentCore } from 'core/component'\n\n// Types\nimport { Position } from 'types/position'\n\n// Utils\nimport { merge, throttle } from 'utils/data'\n\n// Config\nimport { TooltipDefaultConfig, TooltipConfigInterface } from './config'\n\n// Style\nimport * as s from './style'\n\nexport class Tooltip {\n element: HTMLElement\n div: Selection<HTMLElement, unknown, null, undefined>\n protected _defaultConfig = TooltipDefaultConfig as TooltipConfigInterface\n public config: TooltipConfigInterface = this._defaultConfig\n prevConfig: TooltipConfigInterface\n components: ComponentCore<unknown>[]\n static selectors = s\n private _setUpEventsThrottled = throttle(this._setUpEvents, 500)\n private _setContainerPositionThrottled = throttle(this._setContainerPosition, 500)\n private _isShown = false\n private _container: HTMLElement\n private _mutationObserver: MutationObserver\n private _hoveredElement: HTMLElement | SVGElement\n private _position: [number, number]\n private _overriddenHorizontalPlacement: Position.Left | Position.Right | string | undefined\n\n constructor (config: TooltipConfigInterface = {}) {\n this.element = document.createElement('div')\n this.div = select(this.element).attr('class', s.root)\n\n this.setConfig(config)\n this.components = this.config.components\n\n // Set up MutationObserver to automatically re-position the tooltip\n // if the content has been dynamically changed\n this._mutationObserver = new MutationObserver(() => {\n if (!this._isShown) return\n\n // Handle changes to the content of this.div\n // Add your logic here\n if (!this.config.followCursor && this._hoveredElement) {\n this.placeByElement(this._hoveredElement)\n } else if (this._position) {\n this.place({ x: this._position[0], y: this._position[1] })\n }\n })\n\n this._mutationObserver.observe(this.div.node(), { childList: true, subtree: true })\n }\n\n public setConfig (config: TooltipConfigInterface): void {\n this.prevConfig = this.config\n this.config = merge(this._defaultConfig, config)\n\n // Reset `this._overriddenHorizontalPlacement` if the `horizontalPlacement` has changed\n if (this.prevConfig.horizontalPlacement !== this.config.horizontalPlacement) {\n this.overrideHorizontalPlacement(undefined)\n }\n\n if (this.config.container && (this.config.container !== this.prevConfig?.container)) {\n this.setContainer(this.config.container)\n }\n\n this._setUpAttributes()\n }\n\n public setContainer (container: HTMLElement): void {\n this.element.parentNode?.removeChild(this.element)\n\n this._container = container\n this._container.appendChild(this.element)\n\n this._setContainerPositionThrottled()\n }\n\n public getContainer (): HTMLElement {\n return this._container\n }\n\n public hasContainer (): boolean {\n return !!this._container && this._container.isConnected\n }\n\n public setComponents (components: ComponentCore<unknown>[]): void {\n this.components = components\n }\n\n public update (): void {\n if (!this._container) return\n\n this._setUpEventsThrottled()\n }\n\n /** Show the tooltip by providing content and position */\n public show (html: string | HTMLElement | null | void, pos: { x: number; y: number }): void {\n this.render(html)\n this.place(pos)\n }\n\n /** Hide the tooltip */\n public hide (): void {\n this.div\n .classed(s.show, false) // The `show` class triggers the opacity transition\n .on('transitionend', () => {\n // We hide the element once the transition completes\n // This ensures container overflow will not occur when the window is resized\n this.div.classed(s.hidden, !this._isShown)\n })\n\n this._isShown = false\n }\n\n /** Simply displays the tooltip with its previous content on position */\n public display (): void {\n this.div\n .classed(s.hidden, false) // The `hidden` class sets `display: none;`\n .classed(s.show, true) // The `show` class triggers the opacity transition\n\n this._isShown = true\n }\n\n public place (pos: { x: number; y: number }): void {\n this._position = [pos.x, pos.y]\n\n if (!this.hasContainer()) {\n console.warn('Unovis | Tooltip: Container was not set or is not initialized yet')\n return\n }\n\n const { config } = this\n const tooltipWidth = this.element.offsetWidth\n const tooltipHeight = this.element.offsetHeight\n\n const horizontalPlacement = this._overriddenHorizontalPlacement ||\n (config.horizontalPlacement === Position.Auto\n ? Position.Center\n : config.horizontalPlacement)\n\n const verticalPlacement = config.verticalPlacement === Position.Auto\n ? ((pos.y - tooltipHeight) < 0 ? Position.Bottom : Position.Top)\n : config.verticalPlacement\n\n // Todo: Get rid of the hardcoded margin in version 2.0\n // Can be simply replaced with `verticalShift` and `horizontalShift`\n // but it'll be a breaking change\n const margin = 5\n const translateX = horizontalPlacement === Position.Left ? -tooltipWidth - margin - config.horizontalShift\n : horizontalPlacement === Position.Center ? -tooltipWidth / 2\n : margin + config.horizontalShift\n\n const translateY = verticalPlacement === Position.Bottom ? margin + config.verticalShift\n : verticalPlacement === Position.Center ? -tooltipHeight / 2\n : -margin - config.verticalShift - tooltipHeight\n\n // translateX and translateY variables shift the tooltip from the default position (above the cursor, centred horizontally)\n const [top, left] = this._constraintPosToContainer(pos.x + translateX, pos.y + translateY, tooltipWidth, tooltipHeight)\n this._applyPosition(top, left, tooltipHeight)\n }\n\n public placeByElement (hoveredElement: SVGElement | HTMLElement): void {\n const { config } = this\n\n // Store the hovered element and the event for future reference,\n // i.e. to re-position the tooltip if the content has been changed\n // by something else and it was captured by the MutationObserver\n this._hoveredElement = hoveredElement\n\n // Todo: Get rid of the hardcoded margin in version 2.0\n // Can be simply replaced with `verticalShift` and `horizontalShift`\n // but it'll be a breaking change\n const margin = 5\n const tooltipWidth = this.element.offsetWidth\n const tooltipHeight = this.element.offsetHeight\n const isContainerBody = this.isContainerBody()\n const containerWidth = isContainerBody ? window.innerWidth : this._container.scrollWidth\n const hoveredElementRect = hoveredElement.getBoundingClientRect()\n\n // We use D3's point transformation to get the correct position of the element by pretending it's a pointer event\n // See more: https://github.com/d3/d3-selection/blob/main/src/pointer.js\n const elementPos = isContainerBody ? [hoveredElementRect.x, hoveredElementRect.y] : pointer({\n clientX: hoveredElementRect.x,\n clientY: hoveredElementRect.y,\n pageX: hoveredElementRect.x,\n pageY: hoveredElementRect.y,\n }, this._container)\n\n const horizontalPlacement = this._overriddenHorizontalPlacement || (\n config.horizontalPlacement === Position.Auto\n ? (elementPos[0] - tooltipWidth < 0 ? Position.Right\n : elementPos[0] + tooltipWidth > containerWidth ? Position.Left : Position.Center)\n : config.horizontalPlacement\n )\n\n let translateX = 0\n switch (horizontalPlacement) {\n case Position.Left:\n translateX = -tooltipWidth - margin - config.horizontalShift\n break\n case Position.Right:\n translateX = hoveredElementRect.width + margin + config.horizontalShift\n break\n case Position.Center:\n default:\n translateX = (-tooltipWidth + hoveredElementRect.width) / 2\n break\n }\n\n const verticalPlacement = config.verticalPlacement === Position.Auto\n ? (horizontalPlacement !== Position.Center ? Position.Center\n : elementPos[1] - tooltipHeight < 0 ? Position.Bottom : Position.Top)\n : config.verticalPlacement\n\n let translateY = -tooltipHeight\n switch (verticalPlacement) {\n case Position.Center:\n translateY += (tooltipHeight + hoveredElementRect.height) / 2\n break\n case Position.Bottom:\n translateY += tooltipHeight + hoveredElementRect.height + margin + config.verticalShift\n break\n case Position.Top:\n default:\n translateY += -margin - config.verticalShift\n break\n }\n\n const [top, left] = this._constraintPosToContainer(elementPos[0] + translateX, elementPos[1] + translateY, tooltipWidth, tooltipHeight)\n this._applyPosition(top, left, tooltipHeight)\n }\n\n public isContainerBody (): boolean {\n return this._container === document.body\n }\n\n /** Allows to override the horizontal placement of the tooltip which is useful when you want to define custom positioning behavior.\n * This method has been added for Crosshair to allow it position tooltip left or right of the crosshair line\n * (see the `_showTooltip` method of the Crosshair component).\n */\n public overrideHorizontalPlacement (placement: Position.Left | Position.Right | string | undefined): void {\n this._overriddenHorizontalPlacement = placement\n }\n\n public render (html: string | HTMLElement | null | void): void {\n const { config, prevConfig } = this\n if (html instanceof HTMLElement) {\n const node = this.div.select(':first-child').node()\n if (node !== html) this.div.html('').append(() => html)\n } else if (html) {\n this.div.html(html)\n }\n\n this.div\n .classed(config.className ?? '', Boolean(config.className))\n .classed(s.nonInteractive, !config.allowHover || config.followCursor)\n\n // Remove the previous class name if it was set\n if (prevConfig?.className && prevConfig.className !== config.className) {\n this.div.classed(prevConfig.className, false)\n }\n\n this.display()\n }\n\n private _applyPosition (x: number, y: number, tooltipHeight: number): void {\n const isContainerBody = this.isContainerBody()\n const containerHeight = isContainerBody ? window.innerHeight : this._container.scrollHeight\n\n this.div\n .classed(s.positionFixed, isContainerBody)\n .style('top', isContainerBody ? `${y}px` : 'unset')\n .style('bottom', !isContainerBody ? `${containerHeight - y - tooltipHeight}px` : 'unset')\n .style('left', `${x}px`)\n }\n\n private _constraintPosToContainer (top: number, left: number, tooltipWidth: number, tooltipHeight: number): [number, number] {\n const isContainerBody = this.isContainerBody()\n const containerHeight = isContainerBody ? window.innerHeight : this._container.scrollHeight\n const containerWidth = isContainerBody ? window.innerWidth : this._container.scrollWidth\n\n // // Constraint to container\n const paddingX = 10\n const hitRight = top > (containerWidth - tooltipWidth - paddingX)\n const hitLeft = top < paddingX\n const constrainedLeft = hitRight ? containerWidth - tooltipWidth - paddingX\n : hitLeft ? paddingX : top\n\n const paddingY = 10\n const hitBottom = left > (containerHeight - tooltipHeight - paddingY)\n const hitTop = left < paddingY\n const constrainedTop = hitBottom ? containerHeight - tooltipHeight - paddingY\n : hitTop ? paddingY : left\n\n return [\n containerWidth < tooltipWidth ? 0 : constrainedLeft,\n containerHeight < tooltipHeight ? 0 : constrainedTop,\n ]\n }\n\n private _setContainerPosition (): void {\n // Tooltip position calculation relies on the parent position\n // If it's not set (static), we set it to `relative` (not a good practice)\n if (this._container !== document.body && getComputedStyle(this._container)?.position === 'static') {\n this._container.style.position = 'relative'\n }\n }\n\n private _setUpEvents (): void {\n const { config } = this\n\n // We use the Event Delegation pattern to set up Tooltip events\n // Every component will have single `mousemove` and `mouseleave` event listener functions, where we'll check\n // the `path` of the event and trigger corresponding callbacks\n this.components.forEach(component => {\n const selection = select(component.element)\n selection\n .on('mousemove.tooltip', (e: MouseEvent) => {\n const path: (HTMLElement | SVGGElement)[] = (e.composedPath && e.composedPath()) || (e as any).path || [e.target]\n\n // Go through all of the configured triggers\n for (const className of Object.keys(config.triggers)) {\n const template = config.triggers[className]\n if (!template) continue // Skip if the trigger is not configured\n\n const els = selection.selectAll<HTMLElement | SVGGElement, unknown>(`.${className}`).nodes()\n\n // Go through all of the elements in the event path (from the deepest element upwards)\n for (const el of path) {\n if (el === selection.node()) break // Break on the component's level (usually the `<g>` element)\n if (el.classList.contains(className)) { // If there's a match, show the tooltip\n const i = els.indexOf(el)\n const d = select(el).datum()\n const content = template(d, i, els)\n const [x, y] = this.isContainerBody() ? [e.clientX, e.clientY] : pointer(e, this._container)\n if (content === null) {\n // If the content is `null`, we hide the tooltip\n this.hide()\n } else {\n // Otherwise we show the tooltip, but don't render the content if it's `undefined` or\n // an empty string. This way we can allow it to work with things like `createPortal` in React\n this.render(content)\n if (config.followCursor) this.place({ x, y })\n else this.placeByElement(el)\n }\n\n // Stop propagation to prevent other interfering events from being triggered, e.g. Crosshair\n e.stopPropagation()\n\n // Stop looking for other matches\n return\n }\n }\n }\n\n // Hide the tooltip if the event didn't pass through any of the configured triggers.\n // We use the `this._isShown` condition as a little performance optimization tweak\n // (we don't want the tooltip to update its class on every mouse movement, see `this.hide()`).\n if (this._isShown) this.hide()\n })\n .on('mouseleave.tooltip', (e: MouseEvent) => {\n e.stopPropagation() // Stop propagation to prevent other interfering events from being triggered, e.g. Crosshair\n this.hide()\n })\n })\n\n // Set up Tooltip hover\n if (config.allowHover && !config.followCursor) {\n this.div\n .on('mouseenter.tooltip', this.display.bind(this))\n .on('mouseleave.tooltip', this.hide.bind(this))\n } else {\n this.div\n .on('mouseenter.tooltip', null)\n .on('mouseleave.tooltip', null)\n }\n }\n\n private _setUpAttributes (): void {\n const attributesMap = this.config.attributes\n if (!attributesMap) return\n\n Object.keys(attributesMap).forEach(attr => {\n this.div.attr(attr, attributesMap[attr])\n })\n }\n\n public destroy (): void {\n this._mutationObserver.disconnect()\n this.div?.remove()\n }\n}\n"],"names":["s.root","s.show","s.hidden","s.nonInteractive","s.positionFixed","s"],"mappings":";;;;;;;MAiBa,OAAO,CAAA;AAiBlB,IAAA,WAAA,CAAa,SAAiC,EAAE,EAAA;QAdtC,IAAc,CAAA,cAAA,GAAG,oBAA8C,CAAA;AAClE,QAAA,IAAA,CAAA,MAAM,GAA2B,IAAI,CAAC,cAAc,CAAA;QAInD,IAAqB,CAAA,qBAAA,GAAG,QAAQ,CAAC,IAAI,CAAC,YAAY,EAAE,GAAG,CAAC,CAAA;QACxD,IAA8B,CAAA,8BAAA,GAAG,QAAQ,CAAC,IAAI,CAAC,qBAAqB,EAAE,GAAG,CAAC,CAAA;QAC1E,IAAQ,CAAA,QAAA,GAAG,KAAK,CAAA;QAQtB,IAAI,CAAC,OAAO,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAA;AAC5C,QAAA,IAAI,CAAC,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,OAAO,EAAEA,IAAM,CAAC,CAAA;AAErD,QAAA,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAA;QAC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ACnB;;AApXM,OAAS,CAAA,SAAA,GAAGC,KAAC;;;;"}
|
|
@@ -263,8 +263,8 @@ class XYContainer extends ContainerCore {
|
|
|
263
263
|
return;
|
|
264
264
|
// Set initial scale range
|
|
265
265
|
const isYDirectionSouth = config.yDirection === Direction.South;
|
|
266
|
-
const xRange = [(_a = config.padding.left) !== null && _a !== void 0 ? _a : 0,
|
|
267
|
-
const yRange = [
|
|
266
|
+
const xRange = [(_a = config.padding.left) !== null && _a !== void 0 ? _a : 0, this.width - ((_b = config.padding.right) !== null && _b !== void 0 ? _b : 0)];
|
|
267
|
+
const yRange = [this.height - ((_c = config.padding.bottom) !== null && _c !== void 0 ? _c : 0), (_d = config.padding.top) !== null && _d !== void 0 ? _d : 0];
|
|
268
268
|
if (isYDirectionSouth)
|
|
269
269
|
yRange.reverse();
|
|
270
270
|
for (const c of components) {
|
|
@@ -304,6 +304,7 @@ class XYContainer extends ContainerCore {
|
|
|
304
304
|
const { config: { xAxis, yAxis } } = this;
|
|
305
305
|
// At first we need to set the domain to the scales
|
|
306
306
|
const components = clean([...this.components, xAxis, yAxis]);
|
|
307
|
+
this._setScales(...components);
|
|
307
308
|
this._updateScalesDomain(...components);
|
|
308
309
|
// Calculate margin required by the axes
|
|
309
310
|
// We do two iterations on the first render, because the amount and size of ticks can change
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/containers/xy-container/index.ts"],"sourcesContent":["import { css } from '@emotion/css'\nimport { extent, merge as mergeArrays } from 'd3-array'\nimport { Selection } from 'd3-selection'\n\n// Global CSS variables (side effects import)\nimport 'styles/index'\n\n// Core\nimport { ContainerCore } from 'core/container'\nimport { XYComponentCore } from 'core/xy-component'\nimport { XYComponentConfigInterface } from 'core/xy-component/config'\n\n// Data Model\nimport { CoreDataModel } from 'data-models/core'\n\n// Types\nimport { Spacing } from 'types/spacing'\nimport { AxisType } from 'components/axis/types'\nimport { ScaleDimension } from 'types/scale'\nimport { Direction } from 'types/direction'\n\n// Utils\nimport { clamp, clean, flatten } from 'utils/data'\nimport { guid } from 'utils/misc'\n\n// Config\nimport { XYContainerDefaultConfig, XYContainerConfigInterface } from './config'\nimport {\n AreaConfigInterface,\n BrushConfigInterface,\n LineConfigInterface,\n ScatterConfigInterface,\n StackedBarConfigInterface,\n TimelineConfigInterface,\n} from '../../components'\n\nexport type XYConfigInterface<Datum> = XYComponentConfigInterface<Datum>\n| StackedBarConfigInterface<Datum>\n| LineConfigInterface<Datum>\n| ScatterConfigInterface<Datum>\n| BrushConfigInterface<Datum>\n| TimelineConfigInterface<Datum>\n| AreaConfigInterface<Datum>\n\nexport class XYContainer<Datum> extends ContainerCore {\n protected _defaultConfig = XYContainerDefaultConfig as XYContainerConfigInterface<Datum>\n protected _svgDefs: Selection<SVGDefsElement, unknown, null, undefined>\n public datamodel: CoreDataModel<Datum[]> = new CoreDataModel()\n public config: XYContainerConfigInterface<Datum> = this._defaultConfig\n private _clipPath: Selection<SVGClipPathElement, unknown, null, undefined>\n private _clipPathId = guid()\n private _axisMargin: Spacing = { top: 0, bottom: 0, left: 0, right: 0 }\n private _firstRender = true\n\n constructor (element: HTMLElement, config?: XYContainerConfigInterface<Datum>, data?: Datum[]) {\n super(element)\n\n this._clipPath = this.svg.append('clipPath')\n .attr('id', this._clipPathId)\n this._clipPath.append('rect')\n\n // When the base tag is specified on the HTML head,\n // Safari fails to find the corresponding filter URL.\n // We have to provide tull url in order to fix that\n const highlightFilterId = 'saturate'\n const baseUrl = window.location.href.replace(window.location.hash, '')\n this.svg.attr('class', css`\n --highlight-filter-id: url(${baseUrl}#${highlightFilterId}); // defining a css variable\n `)\n\n this._svgDefs.append('filter')\n .attr('id', highlightFilterId)\n .attr('filterUnits', 'objectBoundingBox')\n .html('<feColorMatrix type=\"saturate\" in=\"SourceGraphic\" values=\"1.35\"/>')\n\n if (config) {\n this.updateContainer(config, true)\n }\n\n if (data) {\n this.setData(data, true)\n }\n\n // Render if there are axes or components with data\n if (\n this.config.xAxis ||\n this.config.yAxis ||\n this.components?.some(c => c.datamodel.data)\n ) {\n this.render()\n }\n\n // Force re-render axes when fonts are loaded\n (document as any).fonts?.ready.then(() => {\n if (!this._firstRender) this._renderAxes(0)\n })\n }\n\n get components (): XYComponentCore<Datum>[] {\n return this.config.components\n }\n\n // Overriding ContainerCore default get width method to work with axis auto margin\n get width (): number {\n const margin = this._getMargin()\n return clamp(this.containerWidth - margin.left - margin.right, 0, Number.POSITIVE_INFINITY)\n }\n\n // Overriding ContainerCore default get height method to work with axis auto margin\n get height (): number {\n const margin = this._getMargin()\n\n return clamp(this.containerHeight - margin.top - margin.bottom, 0, Number.POSITIVE_INFINITY)\n }\n\n public setData (data: Datum[], preventRender?: boolean): void {\n const { components, config } = this\n if (!data) return\n this.datamodel.data = data\n\n components.forEach((c) => {\n c.setData(data)\n })\n\n config.crosshair?.setData(data)\n config.xAxis?.setData(data)\n config.yAxis?.setData(data)\n config.tooltip?.hide()\n if (!preventRender) this.render()\n }\n\n public updateContainer (containerConfig: XYContainerConfigInterface<Datum>, preventRender?: boolean): void {\n super.updateContainer(containerConfig)\n this._removeAllChildren()\n\n // If there were any new components added we need to pass them data\n this.setData(this.datamodel.data, true)\n\n // Set up the axes\n if (containerConfig.xAxis) {\n this.config.xAxis.config.type = AxisType.X\n this.element.appendChild(containerConfig.xAxis.element)\n }\n if (containerConfig.yAxis) {\n this.config.yAxis.config.type = AxisType.Y\n this.element.appendChild(containerConfig.yAxis.element)\n }\n\n // Re-insert elements to the DOM\n for (const c of this.components) {\n this.element.appendChild(c.element)\n }\n\n // Set up the tooltip\n const tooltip = containerConfig.tooltip\n if (tooltip) {\n if (!tooltip.hasContainer()) tooltip.setContainer(this._container)\n tooltip.setComponents(this.components)\n }\n\n // Set up the crosshair\n const crosshair = containerConfig.crosshair\n if (crosshair) {\n crosshair.setContainer(this.svg)\n crosshair.tooltip = tooltip\n\n this.element.appendChild(crosshair.element)\n }\n\n // Set up annotations\n const annotations = containerConfig.annotations\n if (annotations) {\n this.element.appendChild(annotations.element)\n }\n\n // Clipping path\n this.element.appendChild(this._clipPath.node())\n\n // Defs\n this.element.appendChild(this._svgDefs.node())\n this.element.appendChild(this._svgDefsExternal.node())\n\n // Rendering\n if (!preventRender) this.render()\n }\n\n public updateComponents (componentConfigs: XYConfigInterface<Datum>[], preventRender?: boolean): void {\n const { config } = this\n\n this.components.forEach((c, i) => {\n const componentConfig = componentConfigs[i]\n if (componentConfig) {\n c.setConfig(componentConfigs[i])\n }\n })\n\n this._updateScales(...this.components, config.xAxis, config.yAxis, config.crosshair)\n if (!preventRender) this.render()\n }\n\n public update (containerConfig: XYContainerConfigInterface<Datum>, componentConfigs?: XYComponentConfigInterface<Datum>[], data?: Datum[]): void {\n if (data) this.datamodel.data = data // Just updating the data model because the `updateContainer` method has the `setData` step inside\n if (containerConfig) this.updateContainer(containerConfig, true)\n if (componentConfigs) this.updateComponents(componentConfigs, true)\n this.render()\n }\n\n protected _preRender (): void {\n const { config } = this\n super._preRender()\n\n // Calculate extra margin required to fit the axes\n if (config.autoMargin) {\n this._setAutoMargin()\n }\n\n // Pass size to the components\n const components = clean([...this.components, config.xAxis, config.yAxis, config.crosshair, config.annotations])\n for (const c of components) {\n c.setSize(this.width, this.height, this.containerWidth, this.containerHeight)\n }\n\n // Update Scales of all the components at once to calculate required paddings and sync them\n this._updateScales(...this.components, config.xAxis, config.yAxis, config.crosshair)\n }\n\n protected _render (customDuration?: number): void {\n const { config } = this\n super._render()\n\n // Get chart total margin after auto margin calculations\n const margin = this._getMargin()\n\n // Render components\n for (const c of this.components) {\n c.g.attr('transform', `translate(${margin.left},${margin.top})`)\n .style('clip-path', c.clippable ? `url(#${this._clipPathId})` : null)\n .style('-webkit-clip-path', c.clippable ? `url(#${this._clipPathId})` : null)\n\n c.render(customDuration)\n }\n\n this._renderAxes(this._firstRender ? 0 : customDuration)\n\n // Clip RectsetSize\n // Extending the clipping path to allow small overflow (e.g. Line will looks better that way when it touches the edges)\n const clipPathExtension = 2\n this._clipPath.select('rect')\n .attr('x', -clipPathExtension)\n .attr('y', -clipPathExtension)\n .attr('width', this.width + 2 * clipPathExtension)\n .attr('height', this.height + 2 * clipPathExtension)\n\n // Tooltip\n config.tooltip?.update() // Re-bind events\n\n // Crosshair\n const crosshair = config.crosshair\n if (crosshair) {\n // Pass accessors\n const yAccessors = this.components.filter(c => !c.stacked).map(c => c.config.y)\n const yStackedAccessors = this.components.filter(c => c.stacked).map(c => c.config.y)\n const baselineComponentConfig = this.components.find(c => (c.config as AreaConfigInterface<Datum>).baseline)?.config as AreaConfigInterface<Datum>\n const baselineAccessor = baselineComponentConfig?.baseline\n\n crosshair.accessors = {\n x: this.components[0]?.config.x,\n y: flatten(yAccessors),\n yStacked: flatten(yStackedAccessors),\n baseline: baselineAccessor,\n }\n\n crosshair.g.attr('transform', `translate(${margin.left},${margin.top})`)\n .style('clip-path', `url(#${this._clipPathId})`)\n .style('-webkit-clip-path', `url(#${this._clipPathId})`)\n crosshair.hide()\n }\n\n config.annotations?.g.attr('transform', `translate(${margin.left},${margin.top})`)\n config.annotations?.render()\n\n this._firstRender = false\n }\n\n private _updateScales<T extends XYComponentCore<Datum>> (...components: T[]): void {\n const c = clean(components || this.components)\n this._setScales(...c)\n this._updateScalesDomain(...c)\n this._updateScalesRange(...c)\n }\n\n private _setScales<T extends XYComponentCore<Datum>> (...components: T[]): void {\n const { config } = this\n if (!components) return\n\n // Set the X and Y scales\n if (config.xScale) components.forEach(c => c.setScale(ScaleDimension.X, config.xScale))\n if (config.yScale) components.forEach(c => c.setScale(ScaleDimension.Y, config.yScale))\n }\n\n private _updateScalesDomain<T extends XYComponentCore<Datum>> (...components: T[]): void {\n const { config } = this\n if (!components) return\n\n const componentsWithDomain = components.filter(c => !c.config.excludeFromDomainCalculation)\n\n // Loop over all the dimensions\n Object.values(ScaleDimension).forEach((dimension: ScaleDimension) => {\n const [min, max] = extent(\n mergeArrays(\n componentsWithDomain.map(c => c.getDataExtent(dimension, config.scaleByDomain))\n ) as number[]\n ) // Components with undefined dimension accessors will return [undefined, undefined] but d3.extent will take care of that\n\n const configuredDomain = dimension === ScaleDimension.Y ? config.yDomain : config.xDomain\n const configuredDomainMinConstraint = dimension === ScaleDimension.Y ? config.yDomainMinConstraint : config.xDomainMinConstraint\n const configuredDomainMaxConstraint = dimension === ScaleDimension.Y ? config.yDomainMaxConstraint : config.xDomainMaxConstraint\n const domainMin = configuredDomain?.[0] ?? min ?? 0\n const domainMax = configuredDomain?.[1] ?? max ?? 1\n const domain = [\n clamp(domainMin, configuredDomainMinConstraint?.[0] ?? Number.NEGATIVE_INFINITY, configuredDomainMinConstraint?.[1] ?? Number.POSITIVE_INFINITY),\n clamp(domainMax, configuredDomainMaxConstraint?.[0] ?? Number.NEGATIVE_INFINITY, configuredDomainMaxConstraint?.[1] ?? Number.POSITIVE_INFINITY),\n ]\n\n // Extend the X and Y domains if they're empty and `preventEmptyDomain` was explicitly set to `true`\n // or just the X domain if there is no data provided and `preventEmptyDomain` set to `null`\n if (domain[0] === domain[1]) {\n const hasDataProvided = componentsWithDomain.some(c => c.datamodel.data?.length > 0)\n if (config.preventEmptyDomain || (config.preventEmptyDomain === null && (!hasDataProvided || dimension === ScaleDimension.Y))) {\n domain[1] = domain[0] + 1\n }\n }\n\n components.forEach(c => c.setScaleDomain(dimension, domain))\n })\n }\n\n private _updateScalesRange<T extends XYComponentCore<Datum>> (...components: T[]): void {\n const { config } = this\n if (!components) return\n\n // Set initial scale range\n const isYDirectionSouth = config.yDirection === Direction.South\n const xRange: [number, number] = [config.padding.left ?? 0, this.width - config.padding.right ?? 0]\n const yRange: [number, number] = [this.height - config.padding.bottom ?? 0, config.padding.top ?? 0]\n if (isYDirectionSouth) yRange.reverse()\n\n for (const c of components) {\n c.setSize(this.width, this.height, this.containerWidth, this.containerHeight)\n c.setScaleRange(ScaleDimension.X, config.xRange ?? xRange)\n c.setScaleRange(ScaleDimension.Y, config.yRange ?? yRange)\n }\n\n // Get and combine bleed\n const bleed = components.map(c => c.bleed).reduce((bleed, b) => {\n for (const key of Object.keys(bleed)) {\n const k = key as keyof Spacing\n if (bleed[k] < b[k]) bleed[k] = b[k]\n }\n return bleed\n }, { top: 0, bottom: 0, left: 0, right: 0 })\n\n // Update scale range\n for (const c of components) {\n c.setScaleRange(ScaleDimension.X, [xRange[0] + bleed.left, xRange[1] - bleed.right])\n c.setScaleRange(\n ScaleDimension.Y,\n isYDirectionSouth\n ? [yRange[0] + bleed.top, yRange[1] - bleed.bottom] // if Y axis is directed downwards\n : [yRange[0] - bleed.bottom, yRange[1] + bleed.top] // if Y axis is directed upwards\n )\n }\n }\n\n private _renderAxes (duration: number): void {\n const { config: { xAxis, yAxis } } = this\n const margin = this._getMargin()\n\n const axes = clean([xAxis, yAxis])\n axes.forEach(axis => {\n const offset = axis.getOffset(margin)\n axis.g.attr('transform', `translate(${offset.left},${offset.top})`)\n axis.render(duration)\n })\n }\n\n private _setAutoMargin (): void {\n const { config: { xAxis, yAxis } } = this\n\n // At first we need to set the domain to the scales\n const components = clean([...this.components, xAxis, yAxis])\n this._updateScalesDomain(...components)\n\n // Calculate margin required by the axes\n // We do two iterations on the first render, because the amount and size of ticks can change\n // after new margin are calculated and applied (axes dimensions will change).\n // That's needed for correct label placement.\n const numIterations = this._firstRender ? 2 : 1\n for (let i = 0; i < numIterations; i += 1) {\n const axisMargin: Spacing = { top: 0, bottom: 0, left: 0, right: 0 }\n this._updateScalesRange(...components)\n const axes = clean([xAxis, yAxis])\n axes.forEach(axis => {\n axis.preRender()\n\n const m = axis.getRequiredMargin()\n if (axisMargin.top < m.top) axisMargin.top = m.top\n if (axisMargin.bottom < m.bottom) axisMargin.bottom = m.bottom\n if (axisMargin.left < m.left) axisMargin.left = m.left\n if (axisMargin.right < m.right) axisMargin.right = m.right\n })\n this._axisMargin = axisMargin\n }\n }\n\n private _getMargin (): Spacing {\n const { config: { margin } } = this\n\n return {\n top: margin.top + this._axisMargin.top,\n bottom: margin.bottom + this._axisMargin.bottom,\n left: margin.left + this._axisMargin.left,\n right: margin.right + this._axisMargin.right,\n }\n }\n\n public destroy (): void {\n const { components, config: { tooltip, crosshair, annotations, xAxis, yAxis } } = this\n super.destroy()\n\n for (const c of components) c?.destroy()\n tooltip?.destroy()\n crosshair?.destroy()\n annotations?.destroy()\n xAxis?.destroy()\n yAxis?.destroy()\n }\n}\n"],"names":["mergeArrays"],"mappings":";;;;;;;;;;;;AA4CM,MAAO,WAAmB,SAAQ,aAAa,CAAA;AAUnD,IAAA,WAAA,CAAa,OAAoB,EAAE,MAA0C,EAAE,IAAc,EAAA;;QAC3F,KAAK,CAAC,OAAO,CAAC,CAAA;QAVN,IAAc,CAAA,cAAA,GAAG,wBAA6D,CAAA;AAEjF,QAAA,IAAA,CAAA,SAAS,GAA2B,IAAI,aAAa,EAAE,CAAA;AACvD,QAAA,IAAA,CAAA,MAAM,GAAsC,IAAI,CAAC,cAAc,CAAA;QAE9D,IAAW,CAAA,WAAA,GAAG,IAAI,EAAE,CAAA;AACpB,QAAA,IAAA,CAAA,WAAW,GAAY,EAAE,GAAG,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAA;QAC/D,IAAY,CAAA,YAAA,GAAG,IAAI,CAAA;QAKzB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,UAAU,CAAC;AACzC,aAAA,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,CAAA;AAC/B,QAAA,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;;;;QAK7B,MAAM,iBAAiB,GAAG,UAAU,CAAA;AACpC,QAAA,MAAM,OAAO,GAAG,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,EAAE,CAAC,CAAA;QACtE,IAAI,CAAC,GAAG,CAAC,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;YACzC,KAAK,EAAE,MAAM,CAAC,KAAK,GAAG,IAAI,CAAC,WAAW,CAAC,KAAK;SAC7C,CAAA;KACF;IAEM,OAAO,GAAA;AACZ,QAAA,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,GAAG,IAAI,CAAA;QACtF,KAAK,CAAC,OAAO,EAAE,CAAA;QAEf,KAAK,MAAM,CAAC,IAAI,UAAU;AAAE,YAAA,CAAC,aAAD,CAAC,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAD,CAAC,CAAE,OAAO,EAAE,CAAA;AACxC,QAAA,OAAO,aAAP,OAAO,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAP,OAAO,CAAE,OAAO,EAAE,CAAA;AAClB,QAAA,SAAS,aAAT,SAAS,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAT,SAAS,CAAE,OAAO,EAAE,CAAA;AACpB,QAAA,WAAW,aAAX,WAAW,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAX,WAAW,CAAE,OAAO,EAAE,CAAA;AACtB,QAAA,KAAK,aAAL,KAAK,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAL,KAAK,CAAE,OAAO,EAAE,CAAA;AAChB,QAAA,KAAK,aAAL,KAAK,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAL,KAAK,CAAE,OAAO,EAAE,CAAA;KACjB;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/containers/xy-container/index.ts"],"sourcesContent":["import { css } from '@emotion/css'\nimport { extent, merge as mergeArrays } from 'd3-array'\nimport { Selection } from 'd3-selection'\n\n// Global CSS variables (side effects import)\nimport 'styles/index'\n\n// Core\nimport { ContainerCore } from 'core/container'\nimport { XYComponentCore } from 'core/xy-component'\nimport { XYComponentConfigInterface } from 'core/xy-component/config'\n\n// Data Model\nimport { CoreDataModel } from 'data-models/core'\n\n// Types\nimport { Spacing } from 'types/spacing'\nimport { AxisType } from 'components/axis/types'\nimport { ScaleDimension } from 'types/scale'\nimport { Direction } from 'types/direction'\n\n// Utils\nimport { clamp, clean, flatten } from 'utils/data'\nimport { guid } from 'utils/misc'\n\n// Config\nimport { XYContainerDefaultConfig, XYContainerConfigInterface } from './config'\nimport {\n AreaConfigInterface,\n BrushConfigInterface,\n LineConfigInterface,\n ScatterConfigInterface,\n StackedBarConfigInterface,\n TimelineConfigInterface,\n} from '../../components'\n\nexport type XYConfigInterface<Datum> = XYComponentConfigInterface<Datum>\n| StackedBarConfigInterface<Datum>\n| LineConfigInterface<Datum>\n| ScatterConfigInterface<Datum>\n| BrushConfigInterface<Datum>\n| TimelineConfigInterface<Datum>\n| AreaConfigInterface<Datum>\n\nexport class XYContainer<Datum> extends ContainerCore {\n protected _defaultConfig = XYContainerDefaultConfig as XYContainerConfigInterface<Datum>\n protected _svgDefs: Selection<SVGDefsElement, unknown, null, undefined>\n public datamodel: CoreDataModel<Datum[]> = new CoreDataModel()\n public config: XYContainerConfigInterface<Datum> = this._defaultConfig\n private _clipPath: Selection<SVGClipPathElement, unknown, null, undefined>\n private _clipPathId = guid()\n private _axisMargin: Spacing = { top: 0, bottom: 0, left: 0, right: 0 }\n private _firstRender = true\n\n constructor (element: HTMLElement, config?: XYContainerConfigInterface<Datum>, data?: Datum[]) {\n super(element)\n\n this._clipPath = this.svg.append('clipPath')\n .attr('id', this._clipPathId)\n this._clipPath.append('rect')\n\n // When the base tag is specified on the HTML head,\n // Safari fails to find the corresponding filter URL.\n // We have to provide tull url in order to fix that\n const highlightFilterId = 'saturate'\n const baseUrl = window.location.href.replace(window.location.hash, '')\n this.svg.attr('class', css`\n --highlight-filter-id: url(${baseUrl}#${highlightFilterId}); // defining a css variable\n `)\n\n this._svgDefs.append('filter')\n .attr('id', highlightFilterId)\n .attr('filterUnits', 'objectBoundingBox')\n .html('<feColorMatrix type=\"saturate\" in=\"SourceGraphic\" values=\"1.35\"/>')\n\n if (config) {\n this.updateContainer(config, true)\n }\n\n if (data) {\n this.setData(data, true)\n }\n\n // Render if there are axes or components with data\n if (\n this.config.xAxis ||\n this.config.yAxis ||\n this.components?.some(c => c.datamodel.data)\n ) {\n this.render()\n }\n\n // Force re-render axes when fonts are loaded\n (document as any).fonts?.ready.then(() => {\n if (!this._firstRender) this._renderAxes(0)\n })\n }\n\n get components (): XYComponentCore<Datum>[] {\n return this.config.components\n }\n\n // Overriding ContainerCore default get width method to work with axis auto margin\n get width (): number {\n const margin = this._getMargin()\n return clamp(this.containerWidth - margin.left - margin.right, 0, Number.POSITIVE_INFINITY)\n }\n\n // Overriding ContainerCore default get height method to work with axis auto margin\n get height (): number {\n const margin = this._getMargin()\n\n return clamp(this.containerHeight - margin.top - margin.bottom, 0, Number.POSITIVE_INFINITY)\n }\n\n public setData (data: Datum[], preventRender?: boolean): void {\n const { components, config } = this\n if (!data) return\n this.datamodel.data = data\n\n components.forEach((c) => {\n c.setData(data)\n })\n\n config.crosshair?.setData(data)\n config.xAxis?.setData(data)\n config.yAxis?.setData(data)\n config.tooltip?.hide()\n if (!preventRender) this.render()\n }\n\n public updateContainer (containerConfig: XYContainerConfigInterface<Datum>, preventRender?: boolean): void {\n super.updateContainer(containerConfig)\n this._removeAllChildren()\n\n // If there were any new components added we need to pass them data\n this.setData(this.datamodel.data, true)\n\n // Set up the axes\n if (containerConfig.xAxis) {\n this.config.xAxis.config.type = AxisType.X\n this.element.appendChild(containerConfig.xAxis.element)\n }\n if (containerConfig.yAxis) {\n this.config.yAxis.config.type = AxisType.Y\n this.element.appendChild(containerConfig.yAxis.element)\n }\n\n // Re-insert elements to the DOM\n for (const c of this.components) {\n this.element.appendChild(c.element)\n }\n\n // Set up the tooltip\n const tooltip = containerConfig.tooltip\n if (tooltip) {\n if (!tooltip.hasContainer()) tooltip.setContainer(this._container)\n tooltip.setComponents(this.components)\n }\n\n // Set up the crosshair\n const crosshair = containerConfig.crosshair\n if (crosshair) {\n crosshair.setContainer(this.svg)\n crosshair.tooltip = tooltip\n\n this.element.appendChild(crosshair.element)\n }\n\n // Set up annotations\n const annotations = containerConfig.annotations\n if (annotations) {\n this.element.appendChild(annotations.element)\n }\n\n // Clipping path\n this.element.appendChild(this._clipPath.node())\n\n // Defs\n this.element.appendChild(this._svgDefs.node())\n this.element.appendChild(this._svgDefsExternal.node())\n\n // Rendering\n if (!preventRender) this.render()\n }\n\n public updateComponents (componentConfigs: XYConfigInterface<Datum>[], preventRender?: boolean): void {\n const { config } = this\n\n this.components.forEach((c, i) => {\n const componentConfig = componentConfigs[i]\n if (componentConfig) {\n c.setConfig(componentConfigs[i])\n }\n })\n\n this._updateScales(...this.components, config.xAxis, config.yAxis, config.crosshair)\n if (!preventRender) this.render()\n }\n\n public update (containerConfig: XYContainerConfigInterface<Datum>, componentConfigs?: XYComponentConfigInterface<Datum>[], data?: Datum[]): void {\n if (data) this.datamodel.data = data // Just updating the data model because the `updateContainer` method has the `setData` step inside\n if (containerConfig) this.updateContainer(containerConfig, true)\n if (componentConfigs) this.updateComponents(componentConfigs, true)\n this.render()\n }\n\n protected _preRender (): void {\n const { config } = this\n super._preRender()\n\n // Calculate extra margin required to fit the axes\n if (config.autoMargin) {\n this._setAutoMargin()\n }\n\n // Pass size to the components\n const components = clean([...this.components, config.xAxis, config.yAxis, config.crosshair, config.annotations])\n for (const c of components) {\n c.setSize(this.width, this.height, this.containerWidth, this.containerHeight)\n }\n\n // Update Scales of all the components at once to calculate required paddings and sync them\n this._updateScales(...this.components, config.xAxis, config.yAxis, config.crosshair)\n }\n\n protected _render (customDuration?: number): void {\n const { config } = this\n super._render()\n\n // Get chart total margin after auto margin calculations\n const margin = this._getMargin()\n\n // Render components\n for (const c of this.components) {\n c.g.attr('transform', `translate(${margin.left},${margin.top})`)\n .style('clip-path', c.clippable ? `url(#${this._clipPathId})` : null)\n .style('-webkit-clip-path', c.clippable ? `url(#${this._clipPathId})` : null)\n\n c.render(customDuration)\n }\n\n this._renderAxes(this._firstRender ? 0 : customDuration)\n\n // Clip RectsetSize\n // Extending the clipping path to allow small overflow (e.g. Line will looks better that way when it touches the edges)\n const clipPathExtension = 2\n this._clipPath.select('rect')\n .attr('x', -clipPathExtension)\n .attr('y', -clipPathExtension)\n .attr('width', this.width + 2 * clipPathExtension)\n .attr('height', this.height + 2 * clipPathExtension)\n\n // Tooltip\n config.tooltip?.update() // Re-bind events\n\n // Crosshair\n const crosshair = config.crosshair\n if (crosshair) {\n // Pass accessors\n const yAccessors = this.components.filter(c => !c.stacked).map(c => c.config.y)\n const yStackedAccessors = this.components.filter(c => c.stacked).map(c => c.config.y)\n const baselineComponentConfig = this.components.find(c => (c.config as AreaConfigInterface<Datum>).baseline)?.config as AreaConfigInterface<Datum>\n const baselineAccessor = baselineComponentConfig?.baseline\n\n crosshair.accessors = {\n x: this.components[0]?.config.x,\n y: flatten(yAccessors),\n yStacked: flatten(yStackedAccessors),\n baseline: baselineAccessor,\n }\n\n crosshair.g.attr('transform', `translate(${margin.left},${margin.top})`)\n .style('clip-path', `url(#${this._clipPathId})`)\n .style('-webkit-clip-path', `url(#${this._clipPathId})`)\n crosshair.hide()\n }\n\n config.annotations?.g.attr('transform', `translate(${margin.left},${margin.top})`)\n config.annotations?.render()\n\n this._firstRender = false\n }\n\n private _updateScales<T extends XYComponentCore<Datum>> (...components: T[]): void {\n const c = clean(components || this.components)\n this._setScales(...c)\n this._updateScalesDomain(...c)\n this._updateScalesRange(...c)\n }\n\n private _setScales<T extends XYComponentCore<Datum>> (...components: T[]): void {\n const { config } = this\n if (!components) return\n\n // Set the X and Y scales\n if (config.xScale) components.forEach(c => c.setScale(ScaleDimension.X, config.xScale))\n if (config.yScale) components.forEach(c => c.setScale(ScaleDimension.Y, config.yScale))\n }\n\n private _updateScalesDomain<T extends XYComponentCore<Datum>> (...components: T[]): void {\n const { config } = this\n if (!components) return\n\n const componentsWithDomain = components.filter(c => !c.config.excludeFromDomainCalculation)\n\n // Loop over all the dimensions\n Object.values(ScaleDimension).forEach((dimension: ScaleDimension) => {\n const [min, max] = extent(\n mergeArrays(\n componentsWithDomain.map(c => c.getDataExtent(dimension, config.scaleByDomain))\n ) as number[]\n ) // Components with undefined dimension accessors will return [undefined, undefined] but d3.extent will take care of that\n\n const configuredDomain = dimension === ScaleDimension.Y ? config.yDomain : config.xDomain\n const configuredDomainMinConstraint = dimension === ScaleDimension.Y ? config.yDomainMinConstraint : config.xDomainMinConstraint\n const configuredDomainMaxConstraint = dimension === ScaleDimension.Y ? config.yDomainMaxConstraint : config.xDomainMaxConstraint\n const domainMin = configuredDomain?.[0] ?? min ?? 0\n const domainMax = configuredDomain?.[1] ?? max ?? 1\n const domain = [\n clamp(domainMin, configuredDomainMinConstraint?.[0] ?? Number.NEGATIVE_INFINITY, configuredDomainMinConstraint?.[1] ?? Number.POSITIVE_INFINITY),\n clamp(domainMax, configuredDomainMaxConstraint?.[0] ?? Number.NEGATIVE_INFINITY, configuredDomainMaxConstraint?.[1] ?? Number.POSITIVE_INFINITY),\n ]\n\n // Extend the X and Y domains if they're empty and `preventEmptyDomain` was explicitly set to `true`\n // or just the X domain if there is no data provided and `preventEmptyDomain` set to `null`\n if (domain[0] === domain[1]) {\n const hasDataProvided = componentsWithDomain.some(c => c.datamodel.data?.length > 0)\n if (config.preventEmptyDomain || (config.preventEmptyDomain === null && (!hasDataProvided || dimension === ScaleDimension.Y))) {\n domain[1] = domain[0] + 1\n }\n }\n\n components.forEach(c => c.setScaleDomain(dimension, domain))\n })\n }\n\n private _updateScalesRange<T extends XYComponentCore<Datum>> (...components: T[]): void {\n const { config } = this\n if (!components) return\n\n // Set initial scale range\n const isYDirectionSouth = config.yDirection === Direction.South\n const xRange: [number, number] = [config.padding.left ?? 0, this.width - (config.padding.right ?? 0)]\n const yRange: [number, number] = [this.height - (config.padding.bottom ?? 0), config.padding.top ?? 0]\n if (isYDirectionSouth) yRange.reverse()\n\n for (const c of components) {\n c.setSize(this.width, this.height, this.containerWidth, this.containerHeight)\n c.setScaleRange(ScaleDimension.X, config.xRange ?? xRange)\n c.setScaleRange(ScaleDimension.Y, config.yRange ?? yRange)\n }\n\n // Get and combine bleed\n const bleed = components.map(c => c.bleed).reduce((bleed, b) => {\n for (const key of Object.keys(bleed)) {\n const k = key as keyof Spacing\n if (bleed[k] < b[k]) bleed[k] = b[k]\n }\n return bleed\n }, { top: 0, bottom: 0, left: 0, right: 0 })\n\n // Update scale range\n for (const c of components) {\n c.setScaleRange(ScaleDimension.X, [xRange[0] + bleed.left, xRange[1] - bleed.right])\n c.setScaleRange(\n ScaleDimension.Y,\n isYDirectionSouth\n ? [yRange[0] + bleed.top, yRange[1] - bleed.bottom] // if Y axis is directed downwards\n : [yRange[0] - bleed.bottom, yRange[1] + bleed.top] // if Y axis is directed upwards\n )\n }\n }\n\n private _renderAxes (duration: number): void {\n const { config: { xAxis, yAxis } } = this\n const margin = this._getMargin()\n\n const axes = clean([xAxis, yAxis])\n axes.forEach(axis => {\n const offset = axis.getOffset(margin)\n axis.g.attr('transform', `translate(${offset.left},${offset.top})`)\n axis.render(duration)\n })\n }\n\n private _setAutoMargin (): void {\n const { config: { xAxis, yAxis } } = this\n\n // At first we need to set the domain to the scales\n const components = clean([...this.components, xAxis, yAxis])\n this._setScales(...components)\n this._updateScalesDomain(...components)\n\n // Calculate margin required by the axes\n // We do two iterations on the first render, because the amount and size of ticks can change\n // after new margin are calculated and applied (axes dimensions will change).\n // That's needed for correct label placement.\n const numIterations = this._firstRender ? 2 : 1\n for (let i = 0; i < numIterations; i += 1) {\n const axisMargin: Spacing = { top: 0, bottom: 0, left: 0, right: 0 }\n this._updateScalesRange(...components)\n const axes = clean([xAxis, yAxis])\n axes.forEach(axis => {\n axis.preRender()\n\n const m = axis.getRequiredMargin()\n if (axisMargin.top < m.top) axisMargin.top = m.top\n if (axisMargin.bottom < m.bottom) axisMargin.bottom = m.bottom\n if (axisMargin.left < m.left) axisMargin.left = m.left\n if (axisMargin.right < m.right) axisMargin.right = m.right\n })\n this._axisMargin = axisMargin\n }\n }\n\n private _getMargin (): Spacing {\n const { config: { margin } } = this\n\n return {\n top: margin.top + this._axisMargin.top,\n bottom: margin.bottom + this._axisMargin.bottom,\n left: margin.left + this._axisMargin.left,\n right: margin.right + this._axisMargin.right,\n }\n }\n\n public destroy (): void {\n const { components, config: { tooltip, crosshair, annotations, xAxis, yAxis } } = this\n super.destroy()\n\n for (const c of components) c?.destroy()\n tooltip?.destroy()\n crosshair?.destroy()\n annotations?.destroy()\n xAxis?.destroy()\n yAxis?.destroy()\n }\n}\n"],"names":["mergeArrays"],"mappings":";;;;;;;;;;;;AA4CM,MAAO,WAAmB,SAAQ,aAAa,CAAA;AAUnD,IAAA,WAAA,CAAa,OAAoB,EAAE,MAA0C,EAAE,IAAc,EAAA;;QAC3F,KAAK,CAAC,OAAO,CAAC,CAAA;QAVN,IAAc,CAAA,cAAA,GAAG,wBAA6D,CAAA;AAEjF,QAAA,IAAA,CAAA,SAAS,GAA2B,IAAI,aAAa,EAAE,CAAA;AACvD,QAAA,IAAA,CAAA,MAAM,GAAsC,IAAI,CAAC,cAAc,CAAA;QAE9D,IAAW,CAAA,WAAA,GAAG,IAAI,EAAE,CAAA;AACpB,QAAA,IAAA,CAAA,WAAW,GAAY,EAAE,GAAG,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAA;QAC/D,IAAY,CAAA,YAAA,GAAG,IAAI,CAAA;QAKzB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,UAAU,CAAC;AACzC,aAAA,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,CAAA;AAC/B,QAAA,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;;;;QAK7B,MAAM,iBAAiB,GAAG,UAAU,CAAA;AACpC,QAAA,MAAM,OAAO,GAA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
|
26
26
|
this.element = this.svg.node();
|
|
27
27
|
}
|
|
28
28
|
updateContainer(config) {
|
|
29
|
+
var _a;
|
|
29
30
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
30
31
|
this.prevConfig = this.config;
|
|
31
32
|
this.config = merge(this._defaultConfig, config);
|
|
33
|
+
// Add `svgDefs` if provided in the config
|
|
34
|
+
if ((config === null || config === void 0 ? void 0 : config.svgDefs) !== ((_a = this.prevConfig) === null || _a === void 0 ? void 0 : _a.svgDefs)) {
|
|
35
|
+
this._svgDefsExternal.selectAll('*').remove();
|
|
36
|
+
this._svgDefsExternal.html(config.svgDefs);
|
|
37
|
+
}
|
|
32
38
|
}
|
|
33
39
|
// The `_preRender` step should be used to perform some actions before rendering.
|
|
34
40
|
// For example, calculating scales, setting component sizes, etc ...
|
|
@@ -36,12 +42,7 @@ class ContainerCore {
|
|
|
36
42
|
_preRender() { }
|
|
37
43
|
// The `_render` step should be used to perform the actual rendering
|
|
38
44
|
_render(duration) {
|
|
39
|
-
const { config
|
|
40
|
-
// Add `svgDefs` if provided in the config
|
|
41
|
-
if ((config === null || config === void 0 ? void 0 : config.svgDefs) !== (prevConfig === null || prevConfig === void 0 ? void 0 : prevConfig.svgDefs)) {
|
|
42
|
-
this._svgDefsExternal.selectAll('*').remove();
|
|
43
|
-
this._svgDefsExternal.html(config.svgDefs);
|
|
44
|
-
}
|
|
45
|
+
const { config } = this;
|
|
45
46
|
// Apply the `aria-label` attribute
|
|
46
47
|
select(this._container)
|
|
47
48
|
.attr('aria-label', config.ariaLabel);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/core/container/index.ts"],"sourcesContent":["import { select, Selection } from 'd3-selection'\n\n// Types\nimport { Sizing } from 'types/component'\n\n// Utils\nimport { isEqual, clamp, merge } from 'utils/data'\nimport { ResizeObserver } from 'utils/resize-observer'\n\n// Config\nimport { ContainerDefaultConfig, ContainerConfigInterface } from './config'\n\nexport class ContainerCore {\n public svg: Selection<SVGSVGElement, unknown, null, undefined>\n public element: SVGSVGElement\n public prevConfig: ContainerConfigInterface\n public config: ContainerConfigInterface\n\n protected _defaultConfig: ContainerConfigInterface = ContainerDefaultConfig\n protected _container: HTMLElement\n protected _renderAnimationFrameId: number\n protected _isFirstRender = true\n protected _resizeObserver: ResizeObserver | undefined\n protected _resizeObserverAnimationFrameId: number\n protected _svgDefs: Selection<SVGDefsElement, unknown, null, undefined>\n protected _svgDefsExternal: Selection<SVGDefsElement, unknown, null, undefined>\n private _containerSize: { width: number; height: number }\n\n // eslint-disable-next-line @typescript-eslint/naming-convention\n static DEFAULT_CONTAINER_HEIGHT = 300\n\n constructor (element: HTMLElement) {\n this._renderAnimationFrameId = null\n this._container = element\n\n // Setting `role` attribute to `image` to make the container accessible\n const container = select(this._container)\n container.attr('role', 'figure')\n\n // Create SVG element for visualizations\n this.svg = container.append('svg')\n // We set `display` to `block` because inline elements have an invisible\n // inline space that adds 4px to the height of the container\n .style('display', 'block')\n .attr('xmlns', 'http://www.w3.org/2000/svg')\n .attr('height', ContainerCore.DEFAULT_CONTAINER_HEIGHT) // Overriding default SVG height of 150\n .attr('aria-hidden', true)\n\n this._svgDefs = this.svg.append('defs')\n this._svgDefsExternal = this.svg.append('defs')\n this.element = this.svg.node()\n }\n\n public updateContainer<T extends ContainerConfigInterface> (config: T): void {\n // eslint-disable-next-line @typescript-eslint/naming-convention\n this.prevConfig = this.config\n this.config = merge(this._defaultConfig, config)\n }\n\n // The `_preRender` step should be used to perform some actions before rendering.\n // For example, calculating scales, setting component sizes, etc ...\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n protected _preRender (): void {}\n\n // The `_render` step should be used to perform the actual rendering\n protected _render (duration?: number): void {\n const { config, prevConfig } = this\n\n // Add `svgDefs` if provided in the config\n if (config?.svgDefs !== prevConfig?.svgDefs) {\n this._svgDefsExternal.selectAll('*').remove()\n this._svgDefsExternal.html(config.svgDefs)\n }\n\n // Apply the `aria-label` attribute\n select(this._container)\n .attr('aria-label', config.ariaLabel)\n\n this._isFirstRender = false\n }\n\n // Warning: Some Containers (i.e. Single Container) may override this method, so if you introduce any changes here,\n // make sure to check that other containers didn't break after them.\n public render (duration = this.config.duration): void {\n const width = this.config.width || this.containerWidth\n const height = this.config.height || this.containerHeight\n\n // We set SVG size in `render()` instead of `_render()`, because the size values in pixels will become\n // available only in the next animation when being accessed via `element.clientWidth` and `element.clientHeight`,\n // and we rely on those values when setting width and size of the components.\n this.svg\n .attr('width', width)\n .attr('height', height)\n\n // Set up Resize Observer. We do it in `render()` to capture container size change if it happened\n // in the next animation frame after the initial `render` was called.\n if (!this._resizeObserver) this._setUpResizeObserver()\n\n // Schedule the actual rendering in the next frame\n cancelAnimationFrame(this._renderAnimationFrameId)\n this._renderAnimationFrameId = requestAnimationFrame(() => {\n this._preRender()\n this._render(duration)\n })\n }\n\n get containerWidth (): number {\n return this.config.width\n ? this.element.clientWidth\n : (this._container.clientWidth || this._container.getBoundingClientRect().width)\n }\n\n get containerHeight (): number {\n return this.config.height\n ? this.element.clientHeight\n : (this._container.clientHeight || this._container.getBoundingClientRect().height || ContainerCore.DEFAULT_CONTAINER_HEIGHT)\n }\n\n get width (): number {\n return clamp(this.containerWidth - this.config.margin.left - this.config.margin.right, 0, Number.POSITIVE_INFINITY)\n }\n\n get height (): number {\n return clamp(this.containerHeight - this.config.margin.top - this.config.margin.bottom, 0, Number.POSITIVE_INFINITY)\n }\n\n protected _removeAllChildren (): void {\n while (this.element.firstChild) {\n this.element.removeChild(this.element.firstChild)\n }\n }\n\n protected _onResize (): void {\n const { config } = this\n const redrawOnResize = config.sizing === Sizing.Fit || config.sizing === Sizing.FitWidth\n if (redrawOnResize) this.render(0)\n }\n\n protected _setUpResizeObserver (): void {\n if (this._resizeObserver) return\n\n const containerRect = this._container.getBoundingClientRect()\n this._containerSize = { width: containerRect.width, height: containerRect.height }\n\n this._resizeObserver = new ResizeObserver((entries, observer) => {\n // Using request animation frame to avoid multiple resize events when scrollbars appear/disappear\n // See more: https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver#observation_errors\n cancelAnimationFrame(this._resizeObserverAnimationFrameId)\n this._resizeObserverAnimationFrameId = requestAnimationFrame(() => {\n const resizedContainerRect = this._container.getBoundingClientRect()\n const resizedContainerSize = { width: resizedContainerRect.width, height: resizedContainerRect.height }\n const hasSizeChanged = !isEqual(this._containerSize, resizedContainerSize)\n // Do resize only if element is attached to the DOM\n // will come in useful when some ancestor of container becomes detached\n if (hasSizeChanged && resizedContainerSize.width && resizedContainerSize.height) {\n this._containerSize = resizedContainerSize\n this._onResize()\n }\n })\n })\n this._resizeObserver.observe(this._container)\n }\n\n public destroy (): void {\n cancelAnimationFrame(this._renderAnimationFrameId)\n cancelAnimationFrame(this._resizeObserverAnimationFrameId)\n this._resizeObserver?.disconnect()\n this.svg.remove()\n }\n}\n"],"names":[],"mappings":";;;;;;MAYa,aAAa,CAAA;AAmBxB,IAAA,WAAA,CAAa,OAAoB,EAAA;QAbvB,IAAc,CAAA,cAAA,GAA6B,sBAAsB,CAAA;QAGjE,IAAc,CAAA,cAAA,GAAG,IAAI,CAAA;AAW7B,QAAA,IAAI,CAAC,uBAAuB,GAAG,IAAI,CAAA;AACnC,QAAA,IAAI,CAAC,UAAU,GAAG,OAAO,CAAA;;QAGzB,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;AACzC,QAAA,SAAS,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;;QAGhC,IAAI,CAAC,GAAG,GAAG,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC;;;AAG/B,aAAA,KAAK,CAAC,SAAS,EAAE,OAAO,CAAC;AACzB,aAAA,IAAI,CAAC,OAAO,EAAE,4BAA4B,CAAC;aAC3C,IAAI,CAAC,QAAQ,EAAE,aAAa,CAAC,wBAAwB,CAAC;AACtD,aAAA,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,CAAA;QAE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AAK;gBAChE,MAAM,oBAAoB,GAAG,IAAI,CAAC,UAAU,CAAC,qBAAqB,EAAE,CAAA;AACpE,gBAAA,MAAM,oBAAoB,GAAG,EAAE,KAAK,EAAE,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,oBAAoB,CAAC,MAAM,EAAE,CAAA;gBACvG,MAAM,cAAc,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,cAAc,EAAE,oBAAoB,CAAC,CAAA;;;gBAG1E,IAAI,cAAc,IAAI,oBAAoB,CAAC,KAAK,IAAI,oBAAoB,CAAC,MAAM,EAAE;AAC/E,oBAAA,IAAI,CAAC,cAAc,GAAG,oBAAoB,CAAA;oBAC1C,IAAI,CAAC,SAAS,EAAE,CAAA;AACjB,iBAAA;AACH,aAAC,CAAC,CAAA;AACJ,SAAC,CAAC,CAAA;QACF,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;KAC9C;IAEM,OAAO,GAAA;;AACZ,QAAA,oBAAoB,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAA;AAClD,QAAA,oBAAoB,CAAC,IAAI,CAAC,+BAA+B,CAAC,CAAA;AAC1D,QAAA,CAAA,EAAA,GAAA,IAAI,CAAC,eAAe,MAAE,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,UAAU,EAAE,CAAA;AAClC,QAAA,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,CAAA;KAClB;;AA5ID;AACO,aAAwB,CAAA,wBAAA,GAAG,GAAG;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/core/container/index.ts"],"sourcesContent":["import { select, Selection } from 'd3-selection'\n\n// Types\nimport { Sizing } from 'types/component'\n\n// Utils\nimport { isEqual, clamp, merge } from 'utils/data'\nimport { ResizeObserver } from 'utils/resize-observer'\n\n// Config\nimport { ContainerDefaultConfig, ContainerConfigInterface } from './config'\n\nexport class ContainerCore {\n public svg: Selection<SVGSVGElement, unknown, null, undefined>\n public element: SVGSVGElement\n public prevConfig: ContainerConfigInterface\n public config: ContainerConfigInterface\n\n protected _defaultConfig: ContainerConfigInterface = ContainerDefaultConfig\n protected _container: HTMLElement\n protected _renderAnimationFrameId: number\n protected _isFirstRender = true\n protected _resizeObserver: ResizeObserver | undefined\n protected _resizeObserverAnimationFrameId: number\n protected _svgDefs: Selection<SVGDefsElement, unknown, null, undefined>\n protected _svgDefsExternal: Selection<SVGDefsElement, unknown, null, undefined>\n private _containerSize: { width: number; height: number }\n\n // eslint-disable-next-line @typescript-eslint/naming-convention\n static DEFAULT_CONTAINER_HEIGHT = 300\n\n constructor (element: HTMLElement) {\n this._renderAnimationFrameId = null\n this._container = element\n\n // Setting `role` attribute to `image` to make the container accessible\n const container = select(this._container)\n container.attr('role', 'figure')\n\n // Create SVG element for visualizations\n this.svg = container.append('svg')\n // We set `display` to `block` because inline elements have an invisible\n // inline space that adds 4px to the height of the container\n .style('display', 'block')\n .attr('xmlns', 'http://www.w3.org/2000/svg')\n .attr('height', ContainerCore.DEFAULT_CONTAINER_HEIGHT) // Overriding default SVG height of 150\n .attr('aria-hidden', true)\n\n this._svgDefs = this.svg.append('defs')\n this._svgDefsExternal = this.svg.append('defs')\n this.element = this.svg.node()\n }\n\n public updateContainer<T extends ContainerConfigInterface> (config: T): void {\n // eslint-disable-next-line @typescript-eslint/naming-convention\n this.prevConfig = this.config\n this.config = merge(this._defaultConfig, config)\n\n // Add `svgDefs` if provided in the config\n if (config?.svgDefs !== this.prevConfig?.svgDefs) {\n this._svgDefsExternal.selectAll('*').remove()\n this._svgDefsExternal.html(config.svgDefs)\n }\n }\n\n // The `_preRender` step should be used to perform some actions before rendering.\n // For example, calculating scales, setting component sizes, etc ...\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n protected _preRender (): void {}\n\n // The `_render` step should be used to perform the actual rendering\n protected _render (duration?: number): void {\n const { config } = this\n\n // Apply the `aria-label` attribute\n select(this._container)\n .attr('aria-label', config.ariaLabel)\n\n this._isFirstRender = false\n }\n\n // Warning: Some Containers (i.e. Single Container) may override this method, so if you introduce any changes here,\n // make sure to check that other containers didn't break after them.\n public render (duration = this.config.duration): void {\n const width = this.config.width || this.containerWidth\n const height = this.config.height || this.containerHeight\n\n // We set SVG size in `render()` instead of `_render()`, because the size values in pixels will become\n // available only in the next animation when being accessed via `element.clientWidth` and `element.clientHeight`,\n // and we rely on those values when setting width and size of the components.\n this.svg\n .attr('width', width)\n .attr('height', height)\n\n // Set up Resize Observer. We do it in `render()` to capture container size change if it happened\n // in the next animation frame after the initial `render` was called.\n if (!this._resizeObserver) this._setUpResizeObserver()\n\n // Schedule the actual rendering in the next frame\n cancelAnimationFrame(this._renderAnimationFrameId)\n this._renderAnimationFrameId = requestAnimationFrame(() => {\n this._preRender()\n this._render(duration)\n })\n }\n\n get containerWidth (): number {\n return this.config.width\n ? this.element.clientWidth\n : (this._container.clientWidth || this._container.getBoundingClientRect().width)\n }\n\n get containerHeight (): number {\n return this.config.height\n ? this.element.clientHeight\n : (this._container.clientHeight || this._container.getBoundingClientRect().height || ContainerCore.DEFAULT_CONTAINER_HEIGHT)\n }\n\n get width (): number {\n return clamp(this.containerWidth - this.config.margin.left - this.config.margin.right, 0, Number.POSITIVE_INFINITY)\n }\n\n get height (): number {\n return clamp(this.containerHeight - this.config.margin.top - this.config.margin.bottom, 0, Number.POSITIVE_INFINITY)\n }\n\n protected _removeAllChildren (): void {\n while (this.element.firstChild) {\n this.element.removeChild(this.element.firstChild)\n }\n }\n\n protected _onResize (): void {\n const { config } = this\n const redrawOnResize = config.sizing === Sizing.Fit || config.sizing === Sizing.FitWidth\n if (redrawOnResize) this.render(0)\n }\n\n protected _setUpResizeObserver (): void {\n if (this._resizeObserver) return\n\n const containerRect = this._container.getBoundingClientRect()\n this._containerSize = { width: containerRect.width, height: containerRect.height }\n\n this._resizeObserver = new ResizeObserver((entries, observer) => {\n // Using request animation frame to avoid multiple resize events when scrollbars appear/disappear\n // See more: https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver#observation_errors\n cancelAnimationFrame(this._resizeObserverAnimationFrameId)\n this._resizeObserverAnimationFrameId = requestAnimationFrame(() => {\n const resizedContainerRect = this._container.getBoundingClientRect()\n const resizedContainerSize = { width: resizedContainerRect.width, height: resizedContainerRect.height }\n const hasSizeChanged = !isEqual(this._containerSize, resizedContainerSize)\n // Do resize only if element is attached to the DOM\n // will come in useful when some ancestor of container becomes detached\n if (hasSizeChanged && resizedContainerSize.width && resizedContainerSize.height) {\n this._containerSize = resizedContainerSize\n this._onResize()\n }\n })\n })\n this._resizeObserver.observe(this._container)\n }\n\n public destroy (): void {\n cancelAnimationFrame(this._renderAnimationFrameId)\n cancelAnimationFrame(this._resizeObserverAnimationFrameId)\n this._resizeObserver?.disconnect()\n this.svg.remove()\n }\n}\n"],"names":[],"mappings":";;;;;;MAYa,aAAa,CAAA;AAmBxB,IAAA,WAAA,CAAa,OAAoB,EAAA;QAbvB,IAAc,CAAA,cAAA,GAA6B,sBAAsB,CAAA;QAGjE,IAAc,CAAA,cAAA,GAAG,IAAI,CAAA;AAW7B,QAAA,IAAI,CAAC,uBAAuB,GAAG,IAAI,CAAA;AACnC,QAAA,IAAI,CAAC,UAAU,GAAG,OAAO,CAAA;;QAGzB,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;AACzC,QAAA,SAAS,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;;QAGhC,IAAI,CAAC,GAAG,GAAG,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC;;;AAG/B,aAAA,KAAK,CAAC,SAAS,EAAE,OAAO,CAAC;AACzB,aAAA,IAAI,CAAC,OAAO,EAAE,4BAA4B,CAAC;aAC3C,IAAI,CAAC,QAAQ,EAAE,aAAa,CAAC,wBAAwB,CAAC;AACtD,aAAA,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,CAAA;Q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C,+BAA+B,GAAG,qBAAqB,CAAC,MAAK;gBAChE,MAAM,oBAAoB,GAAG,IAAI,CAAC,UAAU,CAAC,qBAAqB,EAAE,CAAA;AACpE,gBAAA,MAAM,oBAAoB,GAAG,EAAE,KAAK,EAAE,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,oBAAoB,CAAC,MAAM,EAAE,CAAA;gBACvG,MAAM,cAAc,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,cAAc,EAAE,oBAAoB,CAAC,CAAA;;;gBAG1E,IAAI,cAAc,IAAI,oBAAoB,CAAC,KAAK,IAAI,oBAAoB,CAAC,MAAM,EAAE;AAC/E,oBAAA,IAAI,CAAC,cAAc,GAAG,oBAAoB,CAAA;oBAC1C,IAAI,CAAC,SAAS,EAAE,CAAA;AACjB,iBAAA;AACH,aAAC,CAAC,CAAA;AACJ,SAAC,CAAC,CAAA;QACF,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;KAC9C;IAEM,OAAO,GAAA;;AACZ,QAAA,oBAAoB,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAA;AAClD,QAAA,oBAAoB,CAAC,IAAI,CAAC,+BAA+B,CAAC,CAAA;AAC1D,QAAA,CAAA,EAAA,GAAA,IAAI,CAAC,eAAe,MAAE,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,UAAU,EAAE,CAAA;AAClC,QAAA,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,CAAA;KAClB;;AA5ID;AACO,aAAwB,CAAA,wBAAA,GAAG,GAAG;;;;"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unovis/ts",
|
|
3
|
-
"description": "Modular data visualization framework for React, Angular, Svelte, and vanilla TypeScript or JavaScript",
|
|
4
|
-
"version": "1.5.0
|
|
3
|
+
"description": "Modular data visualization framework for React, Angular, Svelte, Vue, Solid, and vanilla TypeScript or JavaScript",
|
|
4
|
+
"version": "1.5.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/f5/unovis.git",
|
package/types/graph.d.ts
CHANGED
|
@@ -8,10 +8,6 @@ export interface GraphInputLink {
|
|
|
8
8
|
source: number | string | GraphInputNode;
|
|
9
9
|
target: number | string | GraphInputNode;
|
|
10
10
|
}
|
|
11
|
-
export declare type GraphInputData<N extends GraphInputNode = GraphInputNode, L extends GraphInputLink = GraphInputLink> = {
|
|
12
|
-
nodes: N[];
|
|
13
|
-
links?: L[];
|
|
14
|
-
};
|
|
15
11
|
export declare type GraphNodeCore<N extends GraphInputNode, L extends GraphInputLink> = N & {
|
|
16
12
|
links: GraphLinkCore<N, L>[];
|
|
17
13
|
/** Unique id */
|
package/utils/data.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export declare const isObject: <T>(a: T) => boolean;
|
|
|
11
11
|
export declare const isAClassInstance: <T>(a: T) => boolean;
|
|
12
12
|
export declare const isPlainObject: <T>(a: T) => boolean;
|
|
13
13
|
export declare const isEmpty: <T>(obj: T) => boolean;
|
|
14
|
-
export declare const isEqual: (a
|
|
14
|
+
export declare const isEqual: (a?: unknown | null, b?: unknown | null, visited?: Set<any>) => boolean;
|
|
15
15
|
export declare const without: <T>(arr: T[], ...args: T[]) => T[];
|
|
16
16
|
export declare const flatten: <T>(arr: (T | T[])[]) => T[];
|
|
17
17
|
export declare const cloneDeep: <T>(obj: T, stack?: Map<any, any>) => T;
|
package/utils/data.js
CHANGED
|
@@ -16,7 +16,7 @@ const isEmpty = (obj) => {
|
|
|
16
16
|
!Object.entries((obj || {})).length;
|
|
17
17
|
};
|
|
18
18
|
// Based on https://github.com/maplibre/maplibre-gl-js/blob/e78ad7944ef768e67416daa4af86b0464bd0f617/src/style-spec/util/deep_equal.ts, 3-Clause BSD license
|
|
19
|
-
const isEqual = (a, b,
|
|
19
|
+
const isEqual = (a, b, visited = new Set()) => {
|
|
20
20
|
if (Array.isArray(a)) {
|
|
21
21
|
if (!Array.isArray(b) || a.length !== b.length)
|
|
22
22
|
return false;
|
|
@@ -25,7 +25,7 @@ const isEqual = (a, b, skipKeys = [], visited = new Set()) => {
|
|
|
25
25
|
else
|
|
26
26
|
visited.add(a);
|
|
27
27
|
for (let i = 0; i < a.length; i++) {
|
|
28
|
-
if (!isEqual(a[i], b[i],
|
|
28
|
+
if (!isEqual(a[i], b[i], visited))
|
|
29
29
|
return false;
|
|
30
30
|
}
|
|
31
31
|
return true;
|
|
@@ -38,16 +38,15 @@ const isEqual = (a, b, skipKeys = [], visited = new Set()) => {
|
|
|
38
38
|
return false;
|
|
39
39
|
if (a === b)
|
|
40
40
|
return true;
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
if (keysA.length !== keysB.length)
|
|
41
|
+
const keys = Object.keys(a);
|
|
42
|
+
if (keys.length !== Object.keys(b).length)
|
|
44
43
|
return false;
|
|
45
44
|
if (visited.has(a))
|
|
46
45
|
return true;
|
|
47
46
|
else
|
|
48
47
|
visited.add(a);
|
|
49
|
-
for (const key
|
|
50
|
-
if (!isEqual(a[key], b[key],
|
|
48
|
+
for (const key in a) {
|
|
49
|
+
if (!isEqual(a[key], b[key], visited))
|
|
51
50
|
return false;
|
|
52
51
|
}
|
|
53
52
|
return true;
|