@unovis/ts 1.3.0-beta.3 → 1.3.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/area/config.d.ts +6 -10
- package/components/area/config.js +3 -12
- package/components/area/config.js.map +1 -1
- package/components/area/index.d.ts +5 -6
- package/components/area/index.js +10 -9
- package/components/area/index.js.map +1 -1
- package/components/axis/config.d.ts +3 -27
- package/components/axis/config.js +3 -30
- package/components/axis/config.js.map +1 -1
- package/components/axis/index.d.ts +4 -3
- package/components/axis/index.js +8 -5
- package/components/axis/index.js.map +1 -1
- package/components/brush/config.d.ts +2 -12
- package/components/brush/config.js +11 -20
- package/components/brush/config.js.map +1 -1
- package/components/brush/index.d.ts +4 -3
- package/components/brush/index.js +4 -3
- package/components/brush/index.js.map +1 -1
- package/components/bullet-legend/config.d.ts +1 -10
- package/components/bullet-legend/config.js +11 -14
- package/components/bullet-legend/config.js.map +1 -1
- package/components/bullet-legend/index.d.ts +4 -3
- package/components/bullet-legend/index.js +5 -2
- package/components/bullet-legend/index.js.map +1 -1
- package/components/chord-diagram/config.d.ts +7 -23
- package/components/chord-diagram/config.js +4 -23
- package/components/chord-diagram/config.js.map +1 -1
- package/components/chord-diagram/index.d.ts +4 -3
- package/components/chord-diagram/index.js +8 -7
- package/components/chord-diagram/index.js.map +1 -1
- package/components/chord-diagram/modules/label.d.ts +3 -3
- package/components/chord-diagram/modules/label.js +1 -1
- package/components/chord-diagram/modules/label.js.map +1 -1
- package/components/chord-diagram/modules/link.d.ts +2 -2
- package/components/chord-diagram/modules/link.js.map +1 -1
- package/components/chord-diagram/modules/node.d.ts +2 -2
- package/components/chord-diagram/modules/node.js.map +1 -1
- package/components/chord-diagram/types.d.ts +3 -2
- package/components/chord-diagram/types.js.map +1 -1
- package/components/crosshair/config.d.ts +4 -14
- package/components/crosshair/config.js +3 -16
- package/components/crosshair/config.js.map +1 -1
- package/components/crosshair/index.d.ts +4 -3
- package/components/crosshair/index.js +4 -3
- package/components/crosshair/index.js.map +1 -1
- package/components/donut/config.d.ts +3 -20
- package/components/donut/config.js +3 -24
- package/components/donut/config.js.map +1 -1
- package/components/donut/index.d.ts +4 -3
- package/components/donut/index.js +5 -4
- package/components/donut/index.js.map +1 -1
- package/components/donut/modules/arc.d.ts +3 -3
- package/components/donut/modules/arc.js.map +1 -1
- package/components/flow-legend/config.d.ts +1 -11
- package/components/flow-legend/config.js +11 -16
- package/components/flow-legend/config.js.map +1 -1
- package/components/flow-legend/index.d.ts +4 -3
- package/components/flow-legend/index.js +5 -2
- package/components/flow-legend/index.js.map +1 -1
- package/components/free-brush/config.d.ts +2 -12
- package/components/free-brush/config.js +11 -20
- package/components/free-brush/config.js.map +1 -1
- package/components/free-brush/index.d.ts +4 -3
- package/components/free-brush/index.js +13 -12
- package/components/free-brush/index.js.map +1 -1
- package/components/graph/config.d.ts +3 -75
- package/components/graph/config.js +13 -79
- package/components/graph/config.js.map +1 -1
- package/components/graph/index.d.ts +8 -7
- package/components/graph/index.js +7 -5
- package/components/graph/index.js.map +1 -1
- package/components/graph/modules/layout.d.ts +7 -7
- package/components/graph/modules/layout.js +7 -2
- package/components/graph/modules/layout.js.map +1 -1
- package/components/graph/modules/link/helper.d.ts +5 -5
- package/components/graph/modules/link/helper.js.map +1 -1
- package/components/graph/modules/link/index.d.ts +6 -6
- package/components/graph/modules/link/index.js.map +1 -1
- package/components/graph/modules/node/helper.d.ts +1 -1
- package/components/graph/modules/node/helper.js.map +1 -1
- package/components/graph/modules/node/index.d.ts +9 -6
- package/components/graph/modules/node/index.js +7 -9
- package/components/graph/modules/node/index.js.map +1 -1
- package/components/graph/modules/panel/helper.d.ts +4 -4
- package/components/graph/modules/panel/helper.js.map +1 -1
- package/components/graph/modules/panel/index.d.ts +3 -3
- package/components/graph/modules/panel/index.js.map +1 -1
- package/components/graph/modules/shape.js +2 -2
- package/components/graph/modules/shape.js.map +1 -1
- package/components/grouped-bar/config.d.ts +5 -13
- package/components/grouped-bar/config.js +3 -16
- package/components/grouped-bar/config.js.map +1 -1
- package/components/grouped-bar/index.d.ts +5 -9
- package/components/grouped-bar/index.js +5 -15
- package/components/grouped-bar/index.js.map +1 -1
- package/components/leaflet-flow-map/config.d.ts +2 -16
- package/components/leaflet-flow-map/config.js +3 -21
- package/components/leaflet-flow-map/config.js.map +1 -1
- package/components/leaflet-flow-map/index.d.ts +4 -3
- package/components/leaflet-flow-map/index.js +3 -2
- package/components/leaflet-flow-map/index.js.map +1 -1
- package/components/leaflet-map/config.d.ts +4 -59
- package/components/leaflet-map/config.js +24 -68
- package/components/leaflet-map/config.js.map +1 -1
- package/components/leaflet-map/index.d.ts +5 -4
- package/components/leaflet-map/index.js +4 -3
- package/components/leaflet-map/index.js.map +1 -1
- package/components/leaflet-map/modules/clusterBackground.d.ts +4 -2
- package/components/leaflet-map/modules/clusterBackground.js.map +1 -1
- package/components/leaflet-map/modules/map.d.ts +4 -4
- package/components/leaflet-map/modules/map.js +6 -6
- package/components/leaflet-map/modules/map.js.map +1 -1
- package/components/leaflet-map/modules/node.d.ts +3 -0
- package/components/leaflet-map/modules/node.js +8 -12
- package/components/leaflet-map/modules/node.js.map +1 -1
- package/components/leaflet-map/modules/utils.d.ts +4 -4
- package/components/leaflet-map/modules/utils.js +6 -2
- package/components/leaflet-map/modules/utils.js.map +1 -1
- package/components/leaflet-map/renderer/mapboxgl-layer.d.ts +2 -2
- package/components/leaflet-map/renderer/mapboxgl-layer.js.map +1 -1
- package/components/leaflet-map/renderer/mapboxgl-utils.d.ts +5 -1
- package/components/leaflet-map/renderer/mapboxgl-utils.js +3 -3
- package/components/leaflet-map/renderer/mapboxgl-utils.js.map +1 -1
- package/components/leaflet-map/style.js.map +1 -1
- package/components/leaflet-map/types.d.ts +5 -1
- package/components/leaflet-map/types.js.map +1 -1
- package/components/line/config.d.ts +6 -11
- package/components/line/config.js +3 -13
- package/components/line/config.js.map +1 -1
- package/components/line/index.d.ts +6 -5
- package/components/line/index.js +7 -6
- package/components/line/index.js.map +1 -1
- package/components/nested-donut/config.d.ts +2 -21
- package/components/nested-donut/config.js +3 -24
- package/components/nested-donut/config.js.map +1 -1
- package/components/nested-donut/index.d.ts +4 -3
- package/components/nested-donut/index.js +18 -8
- package/components/nested-donut/index.js.map +1 -1
- package/components/nested-donut/modules/arc.d.ts +3 -3
- package/components/nested-donut/modules/arc.js.map +1 -1
- package/components/nested-donut/modules/label.d.ts +2 -2
- package/components/nested-donut/modules/label.js.map +1 -1
- package/components/nested-donut/style.js.map +1 -1
- package/components/sankey/config.d.ts +3 -48
- package/components/sankey/config.js +11 -58
- package/components/sankey/config.js.map +1 -1
- package/components/sankey/index.d.ts +4 -3
- package/components/sankey/index.js +3 -2
- package/components/sankey/index.js.map +1 -1
- package/components/sankey/modules/label.d.ts +7 -7
- package/components/sankey/modules/label.js.map +1 -1
- package/components/sankey/modules/link.d.ts +12 -2
- package/components/sankey/modules/link.js +4 -8
- package/components/sankey/modules/link.js.map +1 -1
- package/components/sankey/modules/node.d.ts +7 -7
- package/components/sankey/modules/node.js +1 -1
- package/components/sankey/modules/node.js.map +1 -1
- package/components/scatter/config.d.ts +5 -17
- package/components/scatter/config.js +3 -19
- package/components/scatter/config.js.map +1 -1
- package/components/scatter/index.d.ts +4 -3
- package/components/scatter/index.js +8 -8
- package/components/scatter/index.js.map +1 -1
- package/components/scatter/modules/point.d.ts +2 -2
- package/components/scatter/modules/point.js.map +1 -1
- package/components/scatter/modules/utils.d.ts +2 -2
- package/components/scatter/modules/utils.js.map +1 -1
- package/components/stacked-bar/config.d.ts +5 -13
- package/components/stacked-bar/config.js +3 -16
- package/components/stacked-bar/config.js.map +1 -1
- package/components/stacked-bar/index.d.ts +4 -3
- package/components/stacked-bar/index.js +4 -3
- package/components/stacked-bar/index.js.map +1 -1
- package/components/timeline/config.d.ts +5 -16
- package/components/timeline/config.js +3 -21
- package/components/timeline/config.js.map +1 -1
- package/components/timeline/index.d.ts +4 -3
- package/components/timeline/index.js +4 -3
- package/components/timeline/index.js.map +1 -1
- package/components/tooltip/config.d.ts +1 -15
- package/components/tooltip/config.js +12 -16
- package/components/tooltip/config.js.map +1 -1
- package/components/tooltip/index.d.ts +6 -4
- package/components/tooltip/index.js +15 -6
- package/components/tooltip/index.js.map +1 -1
- package/components/tooltip/style.d.ts +6 -0
- package/components/tooltip/style.js +13 -14
- package/components/tooltip/style.js.map +1 -1
- package/components/topojson-map/config.d.ts +4 -36
- package/components/topojson-map/config.js +3 -38
- package/components/topojson-map/config.js.map +1 -1
- package/components/topojson-map/index.d.ts +4 -3
- package/components/topojson-map/index.js +4 -5
- package/components/topojson-map/index.js.map +1 -1
- package/components/vis-controls/config.d.ts +1 -5
- package/components/vis-controls/config.js +6 -9
- package/components/vis-controls/config.js.map +1 -1
- package/components/vis-controls/index.d.ts +3 -2
- package/components/vis-controls/index.js +5 -2
- package/components/vis-controls/index.js.map +1 -1
- package/components/xy-labels/config.d.ts +4 -16
- package/components/xy-labels/config.js +3 -20
- package/components/xy-labels/config.js.map +1 -1
- package/components/xy-labels/index.d.ts +4 -3
- package/components/xy-labels/index.js +3 -2
- package/components/xy-labels/index.js.map +1 -1
- package/components/xy-labels/modules/label.d.ts +3 -3
- package/components/xy-labels/modules/label.js +1 -1
- package/components/xy-labels/modules/label.js.map +1 -1
- package/containers/single-container/config.d.ts +2 -4
- package/containers/single-container/config.js +3 -8
- package/containers/single-container/config.js.map +1 -1
- package/containers/single-container/index.d.ts +4 -3
- package/containers/single-container/index.js +2 -2
- package/containers/single-container/index.js.map +1 -1
- package/containers/xy-container/config.d.ts +2 -22
- package/containers/xy-container/config.js +3 -26
- package/containers/xy-container/config.js.map +1 -1
- package/containers/xy-container/index.d.ts +5 -2
- package/containers/xy-container/index.js +9 -8
- package/containers/xy-container/index.js.map +1 -1
- package/core/component/config.d.ts +1 -6
- package/core/component/config.js +6 -12
- package/core/component/config.js.map +1 -1
- package/core/component/index.d.ts +7 -5
- package/core/component/index.js +14 -9
- package/core/component/index.js.map +1 -1
- package/core/container/config.d.ts +1 -21
- package/core/container/config.js +21 -25
- package/core/container/config.js.map +1 -1
- package/core/container/index.d.ts +5 -4
- package/core/container/index.js +4 -3
- package/core/container/index.js.map +1 -1
- package/core/xy-component/config.d.ts +2 -10
- package/core/xy-component/config.js +3 -16
- package/core/xy-component/config.js.map +1 -1
- package/core/xy-component/index.d.ts +5 -4
- package/core/xy-component/index.js +2 -0
- package/core/xy-component/index.js.map +1 -1
- package/data-models/map-graph.d.ts +1 -1
- package/data-models/map-graph.js +4 -7
- package/data-models/map-graph.js.map +1 -1
- package/package.json +3 -1
- package/styles/colors.d.ts +2 -2
- package/styles/index.d.ts +1 -1
- package/styles/patterns.js +2 -1
- package/styles/patterns.js.map +1 -1
- package/types/accessor.d.ts +5 -5
- package/types/component.js +2 -0
- package/types/component.js.map +1 -1
- package/utils/d3.d.ts +10 -1
- package/utils/d3.js.map +1 -1
- package/utils/data.d.ts +7 -7
- package/utils/data.js +2 -1
- package/utils/data.js.map +1 -1
- package/utils/text.js +2 -2
- package/utils/text.js.map +1 -1
- package/core/config/index.d.ts +0 -3
- package/core/config/index.js +0 -16
- package/core/config/index.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/components/free-brush/index.ts"],"sourcesContent":["import { Selection } from 'd3-selection'\nimport { brush, BrushBehavior, brushX, brushY, D3BrushEvent } from 'd3-brush'\nimport { XYComponentCore } from 'core/xy-component'\nimport { clamp, isNumber } from 'utils/data'\nimport { smartTransition } from 'utils/d3'\n\n// Types\nimport { ContinuousScale } from 'types/scale'\nimport { FreeBrushMode, FreeBrushSelection, FreeBrushSelectionInPixels } from './types'\n\n// Config\nimport { FreeBrushConfig, FreeBrushConfigInterface } from './config'\n\n// Styles\nimport * as s from './style'\n\nexport class FreeBrush<Datum> extends XYComponentCore<Datum, FreeBrushConfig<Datum>, FreeBrushConfigInterface<Datum>> {\n static selectors = s\n config: FreeBrushConfig<Datum> = new FreeBrushConfig()\n private brush: Selection<SVGGElement, unknown, SVGGElement, unknown>\n private brushBehaviour: BrushBehavior<unknown>\n private _firstRender = true\n\n constructor (config: FreeBrushConfigInterface<Datum>) {\n super()\n if (config) this.config.init(config)\n\n this.brush = this.g\n .append('g')\n .attr('class', s.brush)\n }\n\n _render (customDuration?: number): void {\n const { config } = this\n const xScale = this.xScale\n const yScale = this.yScale\n const duration = isNumber(customDuration) ? customDuration : config.duration\n\n if (this._firstRender) this.brush.classed(s.hide, this._firstRender && config.autoHide)\n\n // Sometimes Brush stops emitting 'start' and 'end' events. Possible explanation:\n // \"... mouseup will only fire when performed within the browser, which can lead to losing track of the button state.\"\n // https://stackoverflow.com/a/48970682\n //\n // D3 code related to the problem:\n // https://github.com/d3/d3-brush/blob/ec2bce6f15074a9ead7f9a84c61335be51c123a3/src/brush.js#L301\n //\n // We're clearing brush's event emitter state to force it to get re-initialized\n // Caveat of this solution: If you're doing a brush selection and a render happens\n // (e.g. due to a data or config update), it'll reset the brush.\n //\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n if (this.brush.node().__brush) this.brush.node().__brush.emitter = undefined\n\n this.brushBehaviour = this._getBrushBehaviour(config.mode)\n\n this.brushBehaviour\n .handleSize(config.handleWidth)\n .extent([[0, 0], [this._width, this._height]])\n .on('start', this._onBrushStart.bind(this))\n .on('brush', this._onBrushMove.bind(this))\n .on('end', this._onBrushEnd.bind(this))\n\n this.brush\n .call(this.brushBehaviour)\n\n // Calculate the brush range from configured selection and apply it\n let brushRange: FreeBrushSelectionInPixels\n switch (config.mode) {\n case FreeBrushMode.XY: {\n const xSelectionRange = this._dataRangeToPixelRange([config.selection?.[0][0], config.selection?.[0][1]], xScale)\n const ySelectionRange = this._dataRangeToPixelRange([config.selection?.[1][0], config.selection?.[1][1]], yScale, true)\n brushRange = (xSelectionRange && ySelectionRange) ? [[xSelectionRange[0], ySelectionRange[0]], [xSelectionRange[1], ySelectionRange[1]]] : null\n break\n }\n case FreeBrushMode.X:\n case FreeBrushMode.Y:\n default: {\n const scale = config.mode === FreeBrushMode.Y ? yScale : xScale\n brushRange = this._dataRangeToPixelRange(config.selection as [number, number], scale, config.mode === FreeBrushMode.Y)\n }\n }\n\n smartTransition(this.brush, duration)\n .call(this.brushBehaviour.move, brushRange) // Sets up the brush and calls brush events\n .on('end interrupt', () => { this._firstRender = false })\n\n if (!duration) this._firstRender = false\n }\n\n private _onBrush (event: D3BrushEvent<unknown>): void {\n const { config } = this\n const userDriven = !!event?.sourceEvent\n\n // Selection from the brush events is in Screen Space (pixels)\n // In case of two dimensional brush is comes as [ [xMinPx, yMinPx], [xMaxPx, yMaxPx] ],\n // while in the config we'll be storing it as [ [xMin, xMax], [yMin, yMax] ]\n const s = (event?.selection) as FreeBrushSelectionInPixels\n if (!this._isSelectionValid(s)) {\n config.selection = null\n return\n }\n\n // Convert the raw brush selection from pixels to data units, store it in the config and trigger the onBrush callback\n let selectedDomain: FreeBrushSelection\n switch (config.mode) {\n case FreeBrushMode.XY: {\n const xSelection = this._pixelRangeToDataRange([s[0][0], s[1][0]], this.xScale, config.selectionMinLength?.[0] ?? config.selectionMinLength)\n const ySelection = this._pixelRangeToDataRange([s[0][1], s[1][1]], this.yScale, config.selectionMinLength?.[1] ?? config.selectionMinLength, true)\n selectedDomain = (xSelection && ySelection) ? [\n [xSelection?.[0], xSelection?.[1]],\n [ySelection?.[0], ySelection?.[1]],\n ] : null\n break\n }\n case FreeBrushMode.Y: {\n selectedDomain = this._pixelRangeToDataRange(s as [number, number], this.yScale, config.selectionMinLength, true)\n break\n }\n case FreeBrushMode.X:\n default: {\n selectedDomain = this._pixelRangeToDataRange(s as [number, number], this.xScale, config.selectionMinLength)\n break\n }\n }\n\n if (selectedDomain === null || selectedDomain[0] === null || selectedDomain[1] === null) {\n this.brush.call(this.brushBehaviour.move, null)\n return\n }\n\n config.selection = selectedDomain\n if (!this._firstRender) config.onBrush(selectedDomain, event, userDriven)\n }\n\n private _pixelRangeToDataRange (selectionInPixels: [number, number], scale: ContinuousScale, constraint: number, reversed?: boolean): [number, number] | null {\n const selectedDomain = selectionInPixels.map(n => scale.invert(n)) as [number, number]\n if (reversed) selectedDomain.reverse()\n\n const domain = scale.domain() as [number, number]\n const domainLength = Math.abs(domain[1] - domain[0])\n const selectionLength = Math.abs(selectedDomain[1] - selectedDomain[0])\n\n if (constraint >= domainLength) {\n console.warn('Unovis | FreeBrush: Configured domain constraint is bigger than the brush domain')\n }\n\n if ((selectionLength < constraint) && (constraint < domainLength)) return null\n else return selectedDomain\n }\n\n private _dataRangeToPixelRange (selectionInDataUnits: [number, number], scale: ContinuousScale, reversed?: boolean): [number, number] | null {\n if (!selectionInDataUnits) return null\n\n const range = scale.range()\n const s = [...selectionInDataUnits]\n if (reversed) {\n range.reverse()\n s.reverse()\n }\n const selectionMin = clamp(scale(s[0]) ?? 0, range[0], range[1])\n const selectionMax = clamp(scale(s[1]) ?? 0, range[0], range[1])\n return (selectionMax - selectionMin) ? [selectionMin, selectionMax] : null\n }\n\n private _isSelectionValid (s: FreeBrushSelection | FreeBrushSelectionInPixels): boolean {\n const { config } = this\n\n if (config.mode === FreeBrushMode.XY) {\n return s && Array.isArray(s[0]) && Array.isArray(s[1])\n } else {\n return s && isNumber(s[0]) && isNumber(s[1])\n }\n }\n\n private _getBrushBehaviour (mode: FreeBrushMode): BrushBehavior<unknown> {\n switch (mode) {\n case FreeBrushMode.X: return brushX()\n case FreeBrushMode.Y: return brushY()\n default: return brush()\n }\n }\n\n private _onBrushStart (event: D3BrushEvent<unknown>): void {\n const { config } = this\n const userDriven = !!event?.sourceEvent\n this._onBrush(event)\n if (config.autoHide && userDriven) this.brush.classed(s.hide, false)\n if (!this._firstRender) config.onBrushStart?.(config.selection, event, userDriven)\n }\n\n private _onBrushMove (event: D3BrushEvent<unknown>): void {\n const { config } = this\n\n this._onBrush(event)\n if (!this._firstRender) config.onBrushMove?.(config.selection, event, !!event?.sourceEvent)\n }\n\n private _onBrushEnd (event: D3BrushEvent<unknown>): void {\n const { config } = this\n\n this._onBrush(event)\n if (config.autoHide) this.brush.classed(s.hide, true)\n if (!this._firstRender) config.onBrushEnd?.(config.selection, event, !!event?.sourceEvent)\n }\n}\n"],"names":["s.brush","s.hide","brush","s"],"mappings":";;;;;;;;;AAgBM,MAAO,SAAiB,SAAQ,eAA+E,CAAA;AAOnH,IAAA,WAAA,CAAa,MAAuC,EAAA;AAClD,QAAA,KAAK,EAAE,CAAA;AANT,QAAA,IAAA,CAAA,MAAM,GAA2B,IAAI,eAAe,EAAE,CAAA;QAG9C,IAAY,CAAA,YAAA,GAAG,IAAI,CAAA;AAIzB,QAAA,IAAI,MAAM;AAAE,YAAA,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;AAEpC,QAAA,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC;aAChB,MAAM,CAAC,GAAG,CAAC;AACX,aAAA,IAAI,CAAC,OAAO,EAAEA,KAAO,CAAC,CAAA;KAC1B;AAED,IAAA,OAAO,CAAE,cAAuB,EAAA;;AAC9B,QAAA,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAA;AACvB,QAAA,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAA;AAC1B,QAAA,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAA;AAC1B,QAAA,MAAM,QAAQ,GAAG,QAAQ,CAAC,cAAc,CAAC,GAAG,cAAc,GAAG,MAAM,CAAC,QAAQ,CAAA;QAE5E,IAAI,IAAI,CAAC,YAAY;AAAE,YAAA,IAAI,CAAC,KAAK,CAAC,OAAO,CAACC,IAAM,EAAE,IAAI,CAAC,YAAY,IAAI,MAAM,CAAC,QAAQ,CAAC,CAAA;;;;;;;;;;;;;;AAevF,QAAA,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,OAAO;YAAE,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,OAAO,GAAG,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AA,CAAA,GAAA,KAAA,CAAA,GAAL,KAAK,CAAE,WAAW,CAAA,CAAC,CAAA;KAC5F;AAEO,IAAA,WAAW,CAAE,KAA4B,EAAA;;AAC/C,QAAA,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAA;AAEvB,QAAA,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;QACpB,IAAI,MAAM,CAAC,QAAQ;YAAE,IAAI,CAAC,KAAK,CAAC,OAAO,CAACA,IAAM,EAAE,IAAI,CAAC,CAAA;QACrD,IAAI,CAAC,IAAI,CAAC,YAAY;YAAE,CAAA,EAAA,GAAA,MAAM,CAAC,UAAU,MAAjB,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,IAAA,CAAA,MAAM,EAAc,MAAM,CAAC,SAAS,EAAE,KAAK,EAAE,CAAC,EAAC,KAAK,KAAA,IAAA,IAAL,KAAK,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAL,KAAK,CAAE,WAAW,CAAA,CAAC,CAAA;KAC3F;;AA5LM,SAAS,CAAA,SAAA,GAAGE,KAAC;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/components/free-brush/index.ts"],"sourcesContent":["import { Selection } from 'd3-selection'\nimport { brush, BrushBehavior, brushX, brushY, D3BrushEvent } from 'd3-brush'\nimport { XYComponentCore } from 'core/xy-component'\nimport { clamp, isArray, isNumber } from 'utils/data'\nimport { smartTransition } from 'utils/d3'\n\n// Types\nimport { ContinuousScale } from 'types/scale'\nimport { FreeBrushMode, FreeBrushSelection, FreeBrushSelectionInPixels } from './types'\n\n// Config\nimport { FreeBrushDefaultConfig, FreeBrushConfigInterface } from './config'\n\n// Styles\nimport * as s from './style'\n\nexport class FreeBrush<Datum> extends XYComponentCore<Datum, FreeBrushConfigInterface<Datum>> {\n static selectors = s\n protected _defaultConfig = FreeBrushDefaultConfig as FreeBrushConfigInterface<Datum>\n public config: FreeBrushConfigInterface<Datum> = this._defaultConfig\n\n private brush: Selection<SVGGElement, unknown, SVGGElement, unknown>\n private brushBehaviour: BrushBehavior<unknown>\n private _firstRender = true\n\n constructor (config: FreeBrushConfigInterface<Datum>) {\n super()\n if (config) this.setConfig(config)\n\n this.brush = this.g\n .append('g')\n .attr('class', s.brush)\n }\n\n _render (customDuration?: number): void {\n const { config } = this\n const xScale = this.xScale\n const yScale = this.yScale\n const duration = isNumber(customDuration) ? customDuration : config.duration\n\n if (this._firstRender) this.brush.classed(s.hide, this._firstRender && config.autoHide)\n\n // Sometimes Brush stops emitting 'start' and 'end' events. Possible explanation:\n // \"... mouseup will only fire when performed within the browser, which can lead to losing track of the button state.\"\n // https://stackoverflow.com/a/48970682\n //\n // D3 code related to the problem:\n // https://github.com/d3/d3-brush/blob/ec2bce6f15074a9ead7f9a84c61335be51c123a3/src/brush.js#L301\n //\n // We're clearing brush's event emitter state to force it to get re-initialized\n // Caveat of this solution: If you're doing a brush selection and a render happens\n // (e.g. due to a data or config update), it'll reset the brush.\n //\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n if (this.brush.node().__brush) this.brush.node().__brush.emitter = undefined\n\n this.brushBehaviour = this._getBrushBehaviour(config.mode)\n\n this.brushBehaviour\n .handleSize(config.handleWidth)\n .extent([[0, 0], [this._width, this._height]])\n .on('start', this._onBrushStart.bind(this))\n .on('brush', this._onBrushMove.bind(this))\n .on('end', this._onBrushEnd.bind(this))\n\n this.brush\n .call(this.brushBehaviour)\n\n // Calculate the brush range from configured selection and apply it\n let brushRange: FreeBrushSelectionInPixels\n switch (config.mode) {\n case FreeBrushMode.XY: {\n const selection = config.selection as [[number, number], [number, number]] | undefined\n const xSelectionRange = this._dataRangeToPixelRange([selection?.[0][0], selection?.[0][1]], xScale)\n const ySelectionRange = this._dataRangeToPixelRange([selection?.[1][0], selection?.[1][1]], yScale, true)\n brushRange = (xSelectionRange && ySelectionRange) ? [[xSelectionRange[0], ySelectionRange[0]], [xSelectionRange[1], ySelectionRange[1]]] : null\n break\n }\n case FreeBrushMode.X:\n case FreeBrushMode.Y:\n default: {\n const scale = config.mode === FreeBrushMode.Y ? yScale : xScale\n brushRange = this._dataRangeToPixelRange(config.selection as [number, number], scale, config.mode === FreeBrushMode.Y)\n }\n }\n\n smartTransition(this.brush, duration)\n .call(this.brushBehaviour.move, brushRange) // Sets up the brush and calls brush events\n .on('end interrupt', () => { this._firstRender = false })\n\n if (!duration) this._firstRender = false\n }\n\n private _onBrush (event: D3BrushEvent<unknown>): void {\n const { config } = this\n const userDriven = !!event?.sourceEvent\n\n // Selection from the brush events is in Screen Space (pixels)\n // In case of two dimensional brush is comes as [ [xMinPx, yMinPx], [xMaxPx, yMaxPx] ],\n // while in the config we'll be storing it as [ [xMin, xMax], [yMin, yMax] ]\n const s = (event?.selection) as FreeBrushSelectionInPixels\n if (!this._isSelectionValid(s)) {\n config.selection = null\n return\n }\n\n // Convert the raw brush selection from pixels to data units, store it in the config and trigger the onBrush callback\n let selectedDomain: FreeBrushSelection\n switch (config.mode) {\n case FreeBrushMode.XY: {\n const selection = s as [[number, number], [number, number]]\n const xSelection = this._pixelRangeToDataRange([selection[0][0], selection[1][0]], this.xScale, isArray(config.selectionMinLength) ? config.selectionMinLength[0] : config.selectionMinLength)\n const ySelection = this._pixelRangeToDataRange([selection[0][1], selection[1][1]], this.yScale, isArray(config.selectionMinLength) ? config.selectionMinLength[1] : config.selectionMinLength, true)\n selectedDomain = (xSelection && ySelection) ? [\n [xSelection?.[0], xSelection?.[1]],\n [ySelection?.[0], ySelection?.[1]],\n ] : null\n break\n }\n case FreeBrushMode.Y: {\n selectedDomain = this._pixelRangeToDataRange(s as [number, number], this.yScale, isArray(config.selectionMinLength) ? config.selectionMinLength[1] : config.selectionMinLength, true)\n break\n }\n case FreeBrushMode.X:\n default: {\n selectedDomain = this._pixelRangeToDataRange(s as [number, number], this.xScale, isArray(config.selectionMinLength) ? config.selectionMinLength[0] : config.selectionMinLength)\n break\n }\n }\n\n if (selectedDomain === null || selectedDomain[0] === null || selectedDomain[1] === null) {\n this.brush.call(this.brushBehaviour.move, null)\n return\n }\n\n config.selection = selectedDomain\n if (!this._firstRender) config.onBrush(selectedDomain, event, userDriven)\n }\n\n private _pixelRangeToDataRange (selectionInPixels: [number, number], scale: ContinuousScale, constraint: number, reversed?: boolean): [number, number] | null {\n const selectedDomain = selectionInPixels.map(n => scale.invert(n)) as [number, number]\n if (reversed) selectedDomain.reverse()\n\n const domain = scale.domain() as [number, number]\n const domainLength = Math.abs(domain[1] - domain[0])\n const selectionLength = Math.abs(selectedDomain[1] - selectedDomain[0])\n\n if (constraint >= domainLength) {\n console.warn('Unovis | FreeBrush: Configured domain constraint is bigger than the brush domain')\n }\n\n if ((selectionLength < constraint) && (constraint < domainLength)) return null\n else return selectedDomain\n }\n\n private _dataRangeToPixelRange (selectionInDataUnits: [number, number], scale: ContinuousScale, reversed?: boolean): [number, number] | null {\n if (!selectionInDataUnits) return null\n\n const range = scale.range()\n const s = [...selectionInDataUnits]\n if (reversed) {\n range.reverse()\n s.reverse()\n }\n const selectionMin = clamp(scale(s[0]) ?? 0, range[0], range[1])\n const selectionMax = clamp(scale(s[1]) ?? 0, range[0], range[1])\n return (selectionMax - selectionMin) ? [selectionMin, selectionMax] : null\n }\n\n private _isSelectionValid (s: FreeBrushSelection | FreeBrushSelectionInPixels): boolean {\n const { config } = this\n\n if (config.mode === FreeBrushMode.XY) {\n return s && Array.isArray(s[0]) && Array.isArray(s[1])\n } else {\n return s && isNumber(s[0]) && isNumber(s[1])\n }\n }\n\n private _getBrushBehaviour (mode: FreeBrushMode): BrushBehavior<unknown> {\n switch (mode) {\n case FreeBrushMode.X: return brushX()\n case FreeBrushMode.Y: return brushY()\n default: return brush()\n }\n }\n\n private _onBrushStart (event: D3BrushEvent<unknown>): void {\n const { config } = this\n const userDriven = !!event?.sourceEvent\n this._onBrush(event)\n if (config.autoHide && userDriven) this.brush.classed(s.hide, false)\n if (!this._firstRender) config.onBrushStart?.(config.selection, event, userDriven)\n }\n\n private _onBrushMove (event: D3BrushEvent<unknown>): void {\n const { config } = this\n\n this._onBrush(event)\n if (!this._firstRender) config.onBrushMove?.(config.selection, event, !!event?.sourceEvent)\n }\n\n private _onBrushEnd (event: D3BrushEvent<unknown>): void {\n const { config } = this\n\n this._onBrush(event)\n if (config.autoHide) this.brush.classed(s.hide, true)\n if (!this._firstRender) config.onBrushEnd?.(config.selection, event, !!event?.sourceEvent)\n }\n}\n"],"names":["s.brush","s.hide","brush","s"],"mappings":";;;;;;;;;AAgBM,MAAO,SAAiB,SAAQ,eAAuD,CAAA;AAS3F,IAAA,WAAA,CAAa,MAAuC,EAAA;AAClD,QAAA,KAAK,EAAE,CAAA;QARC,IAAc,CAAA,cAAA,GAAG,sBAAyD,CAAA;AAC7E,QAAA,IAAA,CAAA,MAAM,GAAoC,IAAI,CAAC,cAAc,CAAA;QAI5D,IAAY,CAAA,YAAA,GAAG,IAAI,CAAA;AAIzB,QAAA,IAAI,MAAM;AAAE,YAAA,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAA;AAElC,QAAA,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC;aAChB,MAAM,CAAC,GAAG,CAAC;AACX,aAAA,IAAI,CAAC,OAAO,EAAEA,KAAO,CAAC,CAAA;KAC1B;AAED,IAAA,OAAO,CAAE,cAAuB,EAAA;AAC9B,QAAA,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAA;AACvB,QAAA,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAA;AAC1B,QAAA,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAA;AAC1B,QAAA,MAAM,QAAQ,GAAG,QAAQ,CAAC,cAAc,CAAC,GAAG,cAAc,GAAG,MAAM,CAAC,QAAQ,CAAA;QAE5E,IAAI,IAAI,CAAC,YAAY;AAAE,YAAA,IAAI,CAAC,KAAK,CAAC,OAAO,CAACC,IAAM,EAAE,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AAI,CAAC,YAAY;YAAE,CAAA,EAAA,GAAA,MAAM,CAAC,WAAW,MAAlB,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,IAAA,CAAA,MAAM,EAAe,MAAM,CAAC,SAAS,EAAE,KAAK,EAAE,CAAC,EAAC,KAAK,KAAA,IAAA,IAAL,KAAK,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAL,KAAK,CAAE,WAAW,CAAA,CAAC,CAAA;KAC5F;AAEO,IAAA,WAAW,CAAE,KAA4B,EAAA;;AAC/C,QAAA,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAA;AAEvB,QAAA,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;QACpB,IAAI,MAAM,CAAC,QAAQ;YAAE,IAAI,CAAC,KAAK,CAAC,OAAO,CAACA,IAAM,EAAE,IAAI,CAAC,CAAA;QACrD,IAAI,CAAC,IAAI,CAAC,YAAY;YAAE,CAAA,EAAA,GAAA,MAAM,CAAC,UAAU,MAAjB,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,IAAA,CAAA,MAAM,EAAc,MAAM,CAAC,SAAS,EAAE,KAAK,EAAE,CAAC,EAAC,KAAK,KAAA,IAAA,IAAL,KAAK,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAL,KAAK,CAAE,WAAW,CAAA,CAAC,CAAA;KAC3F;;AAhMM,SAAS,CAAA,SAAA,GAAGE,KAAC;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ComponentConfigInterface
|
|
1
|
+
import { ComponentConfigInterface } from "../../core/component/config";
|
|
2
2
|
import { TrimMode } from "../../types/text";
|
|
3
3
|
import { GraphInputLink, GraphInputNode } from "../../types/graph";
|
|
4
4
|
import { BooleanAccessor, ColorAccessor, NumericAccessor, StringAccessor, GenericAccessor } from "../../types/accessor";
|
|
@@ -13,7 +13,7 @@ export interface GraphConfigInterface<N extends GraphInputNode, L extends GraphI
|
|
|
13
13
|
/** Interval to re-render the graph when zooming. Default: `100` */
|
|
14
14
|
zoomThrottledUpdateNodeThreshold?: number;
|
|
15
15
|
/** Zoom event callback. Default: `undefined` */
|
|
16
|
-
onZoom?: (zoomScale: number, zoomScaleExtent: number) => void;
|
|
16
|
+
onZoom?: (zoomScale: number, zoomScaleExtent: [number, number]) => void;
|
|
17
17
|
/** Type of the graph layout. Default: `GraphLayoutType.Force` */
|
|
18
18
|
layoutType?: GraphLayoutType | string;
|
|
19
19
|
/** Fit the graph to container on data or config updates, or on container resize. Default: `true` */
|
|
@@ -163,76 +163,4 @@ export interface GraphConfigInterface<N extends GraphInputNode, L extends GraphI
|
|
|
163
163
|
/** Panels configuration. An array of `GraphPanelConfig` objects. Default: `[]` */
|
|
164
164
|
panels?: GraphPanelConfig[] | undefined;
|
|
165
165
|
}
|
|
166
|
-
export declare
|
|
167
|
-
duration: number;
|
|
168
|
-
zoomScaleExtent: [number, number];
|
|
169
|
-
disableZoom: boolean;
|
|
170
|
-
disableDrag: boolean;
|
|
171
|
-
zoomThrottledUpdateNodeThreshold: number;
|
|
172
|
-
onZoom: any;
|
|
173
|
-
layoutType: GraphLayoutType;
|
|
174
|
-
layoutAutofit: boolean;
|
|
175
|
-
layoutAutofitTolerance: number;
|
|
176
|
-
layoutNonConnectedAside: boolean;
|
|
177
|
-
layoutGroupOrder: any[];
|
|
178
|
-
layoutParallelSubGroupsPerRow: number;
|
|
179
|
-
layoutParallelNodesPerColumn: number;
|
|
180
|
-
layoutParallelGroupSpacing: any;
|
|
181
|
-
layoutParallelSortConnectionsByGroup: any;
|
|
182
|
-
layoutNodeGroup: (n: N) => string;
|
|
183
|
-
layoutParallelNodeSubGroup: (n: N) => string;
|
|
184
|
-
forceLayoutSettings: {
|
|
185
|
-
linkDistance: number;
|
|
186
|
-
linkStrength: number;
|
|
187
|
-
charge: number;
|
|
188
|
-
forceXStrength: number;
|
|
189
|
-
forceYStrength: number;
|
|
190
|
-
};
|
|
191
|
-
dagreLayoutSettings: {
|
|
192
|
-
rankdir: string;
|
|
193
|
-
ranker: string;
|
|
194
|
-
};
|
|
195
|
-
layoutElkSettings: GenericAccessor<GraphElkLayoutSettings, string> | undefined;
|
|
196
|
-
layoutElkNodeGroups: StringAccessor<N>[] | undefined;
|
|
197
|
-
linkFlowAnimDuration: number;
|
|
198
|
-
linkFlowParticleSize: number;
|
|
199
|
-
linkWidth: number;
|
|
200
|
-
linkStyle: GraphLinkStyle;
|
|
201
|
-
linkBandWidth: number;
|
|
202
|
-
linkArrow: any;
|
|
203
|
-
linkStroke: any;
|
|
204
|
-
linkFlow: boolean;
|
|
205
|
-
linkLabel: any;
|
|
206
|
-
linkLabelShiftFromCenter: boolean;
|
|
207
|
-
linkNeighborSpacing: number;
|
|
208
|
-
linkDisabled: boolean;
|
|
209
|
-
selectedLinkId: any;
|
|
210
|
-
nodeGaugeAnimDuration: number;
|
|
211
|
-
nodeSize: number;
|
|
212
|
-
nodeStrokeWidth: number;
|
|
213
|
-
nodeShape: GraphNodeShape;
|
|
214
|
-
nodeGaugeValue: number;
|
|
215
|
-
nodeIcon: (n: N) => string;
|
|
216
|
-
nodeIconSize: any;
|
|
217
|
-
nodeLabel: (n: N) => string;
|
|
218
|
-
nodeLabelTrim: boolean;
|
|
219
|
-
nodeLabelTrimLength: number;
|
|
220
|
-
nodeLabelTrimMode: TrimMode;
|
|
221
|
-
nodeSubLabel: string;
|
|
222
|
-
nodeSubLabelTrim: boolean;
|
|
223
|
-
nodeSubLabelTrimLength: number;
|
|
224
|
-
nodeSubLabelTrimMode: TrimMode;
|
|
225
|
-
nodeSideLabels: any;
|
|
226
|
-
nodeBottomIcon: any;
|
|
227
|
-
nodeDisabled: boolean;
|
|
228
|
-
nodeFill: (n: N) => string;
|
|
229
|
-
nodeGaugeFill: any;
|
|
230
|
-
nodeStroke: (n: N) => string;
|
|
231
|
-
nodeEnterPosition: any;
|
|
232
|
-
nodeEnterScale: number;
|
|
233
|
-
nodeExitPosition: any;
|
|
234
|
-
nodeExitScale: number;
|
|
235
|
-
nodeSort: any;
|
|
236
|
-
selectedNodeId: any;
|
|
237
|
-
panels: GraphPanelConfig[] | undefined;
|
|
238
|
-
}
|
|
166
|
+
export declare const GraphDefaultConfig: GraphConfigInterface<GraphInputNode, GraphInputLink>;
|
|
@@ -1,84 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ComponentDefaultConfig } from '../../core/component/config.js';
|
|
2
2
|
import { TrimMode } from '../../types/text.js';
|
|
3
3
|
import { GraphLayoutType, GraphLinkStyle, GraphNodeShape } from './types.js';
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
this.layoutAutofit = true;
|
|
17
|
-
this.layoutAutofitTolerance = 8.0;
|
|
18
|
-
this.layoutNonConnectedAside = false;
|
|
19
|
-
this.layoutGroupOrder = [];
|
|
20
|
-
this.layoutParallelSubGroupsPerRow = 1;
|
|
21
|
-
this.layoutParallelNodesPerColumn = 6;
|
|
22
|
-
this.layoutParallelGroupSpacing = undefined;
|
|
23
|
-
this.layoutParallelSortConnectionsByGroup = undefined;
|
|
24
|
-
this.layoutNodeGroup = (n) => n['group'];
|
|
25
|
-
this.layoutParallelNodeSubGroup = (n) => n['subgroup'];
|
|
26
|
-
this.forceLayoutSettings = {
|
|
27
|
-
linkDistance: 60,
|
|
28
|
-
linkStrength: 0.45,
|
|
29
|
-
charge: -500,
|
|
30
|
-
forceXStrength: 0.15,
|
|
31
|
-
forceYStrength: 0.25,
|
|
32
|
-
};
|
|
33
|
-
this.dagreLayoutSettings = {
|
|
34
|
-
rankdir: 'BT',
|
|
35
|
-
ranker: 'longest-path',
|
|
36
|
-
};
|
|
37
|
-
this.layoutElkSettings = undefined;
|
|
38
|
-
this.layoutElkNodeGroups = undefined;
|
|
39
|
-
this.linkFlowAnimDuration = 20000;
|
|
40
|
-
this.linkFlowParticleSize = 2;
|
|
41
|
-
this.linkWidth = 1;
|
|
42
|
-
this.linkStyle = GraphLinkStyle.Solid;
|
|
43
|
-
this.linkBandWidth = 0;
|
|
44
|
-
this.linkArrow = undefined;
|
|
45
|
-
this.linkStroke = undefined;
|
|
46
|
-
this.linkFlow = false;
|
|
47
|
-
this.linkLabel = undefined;
|
|
48
|
-
this.linkLabelShiftFromCenter = true;
|
|
49
|
-
this.linkNeighborSpacing = 8;
|
|
50
|
-
this.linkDisabled = false;
|
|
51
|
-
this.selectedLinkId = undefined;
|
|
52
|
-
this.nodeGaugeAnimDuration = 1500;
|
|
53
|
-
this.nodeSize = 30;
|
|
54
|
-
this.nodeStrokeWidth = 3;
|
|
55
|
-
this.nodeShape = GraphNodeShape.Circle;
|
|
56
|
-
this.nodeGaugeValue = 0;
|
|
57
|
-
this.nodeIcon = (n) => n['icon'];
|
|
58
|
-
this.nodeIconSize = undefined;
|
|
59
|
-
this.nodeLabel = (n) => n['label'];
|
|
60
|
-
this.nodeLabelTrim = true;
|
|
61
|
-
this.nodeLabelTrimLength = 15;
|
|
62
|
-
this.nodeLabelTrimMode = TrimMode.Middle;
|
|
63
|
-
this.nodeSubLabel = '';
|
|
64
|
-
this.nodeSubLabelTrim = true;
|
|
65
|
-
this.nodeSubLabelTrimLength = 15;
|
|
66
|
-
this.nodeSubLabelTrimMode = TrimMode.Middle;
|
|
67
|
-
this.nodeSideLabels = undefined;
|
|
68
|
-
this.nodeBottomIcon = undefined;
|
|
69
|
-
this.nodeDisabled = false;
|
|
70
|
-
this.nodeFill = (n) => n['fill'];
|
|
71
|
-
this.nodeGaugeFill = undefined;
|
|
72
|
-
this.nodeStroke = (n) => n['stroke'];
|
|
73
|
-
this.nodeEnterPosition = undefined;
|
|
74
|
-
this.nodeEnterScale = 0.75;
|
|
75
|
-
this.nodeExitPosition = undefined;
|
|
76
|
-
this.nodeExitScale = 0.75;
|
|
77
|
-
this.nodeSort = undefined;
|
|
78
|
-
this.selectedNodeId = undefined;
|
|
79
|
-
this.panels = undefined;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
5
|
+
// Config
|
|
6
|
+
const GraphDefaultConfig = Object.assign(Object.assign({}, ComponentDefaultConfig), { duration: 1000, zoomScaleExtent: [0.35, 1.25], disableZoom: false, disableDrag: false, zoomThrottledUpdateNodeThreshold: 100, onZoom: undefined, layoutType: GraphLayoutType.Force, layoutAutofit: true, layoutAutofitTolerance: 8.0, layoutNonConnectedAside: false, layoutGroupOrder: [], layoutParallelSubGroupsPerRow: 1, layoutParallelNodesPerColumn: 6, layoutParallelGroupSpacing: undefined, layoutParallelSortConnectionsByGroup: undefined, layoutNodeGroup: (n) => n.group, layoutParallelNodeSubGroup: (n) => n.subgroup, forceLayoutSettings: {
|
|
7
|
+
linkDistance: 60,
|
|
8
|
+
linkStrength: 0.45,
|
|
9
|
+
charge: -500,
|
|
10
|
+
forceXStrength: 0.15,
|
|
11
|
+
forceYStrength: 0.25,
|
|
12
|
+
}, dagreLayoutSettings: {
|
|
13
|
+
rankdir: 'BT',
|
|
14
|
+
ranker: 'longest-path',
|
|
15
|
+
}, layoutElkSettings: undefined, layoutElkNodeGroups: undefined, linkFlowAnimDuration: 20000, linkFlowParticleSize: 2, linkWidth: 1, linkStyle: GraphLinkStyle.Solid, linkBandWidth: 0, linkArrow: undefined, linkStroke: undefined, linkFlow: false, linkLabel: undefined, linkLabelShiftFromCenter: true, linkNeighborSpacing: 8, linkDisabled: false, selectedLinkId: undefined, nodeGaugeAnimDuration: 1500, nodeSize: 30, nodeStrokeWidth: 3, nodeShape: GraphNodeShape.Circle, nodeGaugeValue: 0, nodeIcon: (n) => n.icon, nodeIconSize: undefined, nodeLabel: (n) => n.label, nodeLabelTrim: true, nodeLabelTrimLength: 15, nodeLabelTrimMode: TrimMode.Middle, nodeSubLabel: '', nodeSubLabelTrim: true, nodeSubLabelTrimLength: 15, nodeSubLabelTrimMode: TrimMode.Middle, nodeSideLabels: undefined, nodeBottomIcon: undefined, nodeDisabled: false, nodeFill: (n) => n.fill, nodeGaugeFill: undefined, nodeStroke: (n) => n.stroke, nodeEnterPosition: undefined, nodeEnterScale: 0.75, nodeExitPosition: undefined, nodeExitScale: 0.75, nodeSort: undefined, selectedNodeId: undefined, panels: undefined });
|
|
82
16
|
|
|
83
|
-
export {
|
|
17
|
+
export { GraphDefaultConfig };
|
|
84
18
|
//# sourceMappingURL=config.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sources":["../../../src/components/graph/config.ts"],"sourcesContent":["/* eslint-disable dot-notation */\n// Config\nimport { ComponentConfigInterface, ComponentConfig } from 'core/component/config'\n\n// Types\nimport { TrimMode } from 'types/text'\nimport { GraphInputLink, GraphInputNode } from 'types/graph'\nimport { BooleanAccessor, ColorAccessor, NumericAccessor, StringAccessor, GenericAccessor } from 'types/accessor'\n\n// Local Types\nimport {\n GraphLayoutType,\n GraphCircleLabel,\n GraphLinkStyle,\n GraphLinkArrowStyle,\n GraphPanelConfig,\n GraphForceLayoutSettings,\n GraphElkLayoutSettings,\n GraphNodeShape,\n} from './types'\n\nexport interface GraphConfigInterface<N extends GraphInputNode, L extends GraphInputLink> extends ComponentConfigInterface {\n // Zoom and drag\n /** Zoom level constraints. Default: [0.35, 1.25] */\n zoomScaleExtent?: [number, number];\n /** Disable zooming. Default: `false` */\n disableZoom?: boolean;\n /** Disable node dragging. Default: `false` */\n disableDrag?: boolean;\n /** Interval to re-render the graph when zooming. Default: `100` */\n zoomThrottledUpdateNodeThreshold?: number;\n /** Zoom event callback. Default: `undefined` */\n onZoom?: (zoomScale: number, zoomScaleExtent: number) => void;\n\n // Layout general settings\n /** Type of the graph layout. Default: `GraphLayoutType.Force` */\n layoutType?: GraphLayoutType | string;\n /** Fit the graph to container on data or config updates, or on container resize. Default: `true` */\n layoutAutofit?: boolean;\n /** Tolerance constant defining whether the graph should be fitted to container\n * (on data or config update, or container resize) after a zoom / pan interaction or not.\n * `0` — Stop fitting after any pan or zoom\n * `Number.POSITIVE_INFINITY` — Always fit\n * Default: `8.0` */\n layoutAutofitTolerance?: number;\n /** Place non-connected nodes at the bottom of the graph. Default: `false` */\n layoutNonConnectedAside?: boolean;\n\n // Settings for Parallel and Concentric layouts\n /** Node group accessor function.\n * Only for `GraphLayoutType.Parallel`, `GraphLayoutType.ParallelHorizontal` and `GraphLayoutType.Concentric` layouts.\n * Default: `node => node.group` */\n layoutNodeGroup?: StringAccessor<N>;\n /** Order of the layout groups.\n * Only for `GraphLayoutType.Parallel`, `GraphLayoutType.ParallelHorizontal` and `GraphLayoutType.Concentric` layouts.\n * Default: `[]` */\n layoutGroupOrder?: string[];\n\n // Setting for Parallel layouts only\n /** Sets the number of nodes in a sub-group after which they'll continue on the next column (or row if `layoutType` is\n * `GraphLayoutType.ParallelHorizontal`).\n * Only for `GraphLayoutType.Parallel` and `GraphLayoutType.ParallelHorizontal` layouts.\n * Default: `6` */\n layoutParallelNodesPerColumn?: number;\n /** Node sub-group accessor function.\n * Only for `GraphLayoutType.Parallel` and `GraphLayoutType.ParallelHorizontal` layouts.\n * Default: `node => node.subgroup` */\n layoutParallelNodeSubGroup?: StringAccessor<N>;\n /** Number of sub-groups per row (or column if `layoutType` is `GraphLayoutType.ParallelHorizontal`) in a group.\n * Only for `GraphLayoutType.Parallel` and `GraphLayoutType.ParallelHorizontal` layouts.\n * Default: `1` */\n layoutParallelSubGroupsPerRow?: number;\n /** Spacing between groups.\n * Only for `GraphLayoutType.Parallel` and `GraphLayoutType.ParallelHorizontal` layouts.\n * Default: `undefined` */\n layoutParallelGroupSpacing?: number;\n /** Set a group by name to have priority in sorting the graph links.\n * Only for `GraphLayoutType.Parallel` and `GraphLayoutType.ParallelHorizontal` layouts.\n * Default: `undefined` */\n layoutParallelSortConnectionsByGroup?: string;\n\n // Force layout\n /** Force Layout settings, see the `d3-force` package for more details */\n forceLayoutSettings?: GraphForceLayoutSettings;\n\n // Dagre layout\n /** Darge Layout settings, see the `dagrejs` package\n * for more details: https://github.com/dagrejs/dagre/wiki#configuring-the-layout\n */\n dagreLayoutSettings?: {\n /** Direction for rank node. `TB`, `BT`, `LR`, or `RL`. Default: `BT` */\n rankdir: string;\n /** Type of algorithm to assigns a rank to each node in the input graph.\n * `network-simplex`, `tight-tree` or `longest-path`.\n * Default: `longest-path` */\n ranker: string;\n /** Other configurable Dagre settings. https://github.com/dagrejs/dagre/wiki */\n [key: string]: any;\n };\n\n // ELK layout\n /** ELK layout options, see the `elkjs` package for more details: https://github.com/kieler/elkjs.\n * If you want to specify custom layout option for each node group, you can provide an accessor function that\n * receives group name ('root' for the top-level configuration) as the first argument and returns an object containing\n * layout options. Default: `undefined`\n */\n layoutElkSettings?: GenericAccessor<GraphElkLayoutSettings, string> | undefined;\n /** Array of accessor functions to define nested node groups for the ELK Layered layout.\n * E.g.: `[n => n.group, n => n.subGroup]`.\n * Default: `undefined` */\n layoutElkNodeGroups?: StringAccessor<N>[];\n\n // Links\n /** Link width accessor function ot constant value. Default: `1` */\n linkWidth?: NumericAccessor<L>;\n /** Link style accessor function or constant value. Default: `GraphLinkStyle.Solid` */\n linkStyle?: GenericAccessor<GraphLinkStyle, L>;\n /** Link band width accessor function or constant value. Default: `0` */\n linkBandWidth?: NumericAccessor<L>;\n /** Link arrow accessor function or constant value. Default: `undefined` */\n linkArrow?: GenericAccessor<GraphLinkArrowStyle, L> | undefined;\n /** Link stroke color accessor function or constant value. Default: `undefined` */\n linkStroke?: ColorAccessor<L>;\n /** Link disabled state accessor function or constant value. Default: `false` */\n linkDisabled?: BooleanAccessor<L>;\n /** Link flow animation accessor function or constant value. Default: `false` */\n linkFlow?: BooleanAccessor<L>;\n /** Animation duration of the flow (traffic) circles. Default: `20000` */\n linkFlowAnimDuration?: number;\n /** Size of the moving particles that represent traffic flow. Default: `2` */\n linkFlowParticleSize?: number;\n /** Link label accessor function or constant value. Default: `undefined` */\n linkLabel?: GenericAccessor<GraphCircleLabel, L> | undefined;\n /** Shift label along the link center a little bit to avoid overlap with the link arrow. Default: `true` */\n linkLabelShiftFromCenter?: BooleanAccessor<L>;\n /** Spacing between neighboring links. Default: `8` */\n linkNeighborSpacing?: number;\n /** Set selected link by its unique id. Default: `undefined` */\n selectedLinkId?: number | string;\n\n // Nodes\n /** Node size accessor function or constant value. Default: `30` */\n nodeSize?: NumericAccessor<N>;\n /** Node stroke width accessor function or constant value. Default: `3` */\n nodeStrokeWidth?: NumericAccessor<N>;\n /** Node shape accessor function or constant value. Default: `GraphNodeShape.Circle` */\n nodeShape?: GenericAccessor<GraphNodeShape | string, N>;\n /** Node gauge outline accessor function or constant value in the range [0,100]. Default: `0` */\n nodeGaugeValue?: NumericAccessor<N>;\n /** Node gauge outline fill color accessor function or constant value. Default: `undefined` */\n nodeGaugeFill?: ColorAccessor<N>;\n /** Animation duration of the node gauge outline. Default: `1500` */\n nodeGaugeAnimDuration?: number;\n /** Node central icon accessor function or constant value. Default: `node => node.icon` */\n nodeIcon?: StringAccessor<N>;\n /** Node central icon size accessor function or constant value. Default: `undefined` */\n nodeIconSize?: NumericAccessor<N>;\n /** Node label accessor function or constant value. Default: `node => node.label` */\n nodeLabel?: StringAccessor<N>;\n /** Defines whether to trim the node labels or not. Default: `true` */\n nodeLabelTrim?: BooleanAccessor<N>;\n /** Node label trimming mode. Default: `TrimMode.Middle` */\n nodeLabelTrimMode?: GenericAccessor<TrimMode | string, N>;\n /** Node label maximum allowed text length above which the label will be trimmed. Default: `15` */\n nodeLabelTrimLength?: NumericAccessor<N>;\n /** Node sub-label accessor function or constant value: Default: `''` */\n nodeSubLabel?: StringAccessor<N>;\n /** Defines whether to trim the node sub-labels or not. Default: `true` */\n nodeSubLabelTrim?: BooleanAccessor<N>;\n /** Node sub-label trimming mode. Default: `TrimMode.Middle` */\n nodeSubLabelTrimMode?: GenericAccessor<TrimMode | string, N>;\n /** Node sub-label maximum allowed text length above which the label will be trimmed. Default: `15` */\n nodeSubLabelTrimLength?: NumericAccessor<N>;\n /** Node circular side labels accessor function. The function should return an array of GraphCircleLabel objects. Default: `undefined` */\n nodeSideLabels?: GenericAccessor<GraphCircleLabel[], N>;\n /** Node bottom icon accessor function. Default: `undefined` */\n nodeBottomIcon?: StringAccessor<N>;\n /** Node disabled state accessor function or constant value. Default: `false` */\n nodeDisabled?: BooleanAccessor<N>;\n /** Node fill color accessor function or constant value. Default: `node => node.fill` */\n nodeFill?: ColorAccessor<N>;\n /** Node stroke color accessor function or constant value. Default: `node => node.stroke` */\n nodeStroke?: ColorAccessor<N>;\n /** Sorting function to determine node placement. Default: `undefined` */\n nodeSort?: ((a: N, b: N) => number);\n /** Specify the initial position for entering nodes as [x, y]. Default: `undefined` */\n nodeEnterPosition?: GenericAccessor<[number, number], N> | undefined;\n /** Specify the initial scale for entering nodes in the range [0,1]. Default: `0.75` */\n nodeEnterScale?: NumericAccessor<N> | undefined;\n /** Specify the destination position for exiting nodes as [x, y]. Default: `undefined` */\n nodeExitPosition?: GenericAccessor<[number, number], N> | undefined;\n /** Specify the destination scale for exiting nodes in the range [0,1]. Default: `0.75` */\n nodeExitScale?: NumericAccessor<N> | undefined;\n /** Set selected node by unique id. Default: `undefined` */\n selectedNodeId?: number | string;\n\n /** Panels configuration. An array of `GraphPanelConfig` objects. Default: `[]` */\n panels?: GraphPanelConfig[] | undefined;\n}\n\nexport class GraphConfig<N extends GraphInputNode, L extends GraphInputLink> extends ComponentConfig implements GraphConfigInterface<N, L> {\n duration = 1000\n zoomScaleExtent: [number, number] = [0.35, 1.25]\n disableZoom = false\n disableDrag = false\n zoomThrottledUpdateNodeThreshold = 100\n onZoom = undefined\n layoutType = GraphLayoutType.Force\n layoutAutofit = true\n layoutAutofitTolerance = 8.0\n layoutNonConnectedAside = false\n\n layoutGroupOrder = []\n layoutParallelSubGroupsPerRow = 1\n layoutParallelNodesPerColumn = 6\n layoutParallelGroupSpacing = undefined\n layoutParallelSortConnectionsByGroup = undefined\n layoutNodeGroup = (n: N): string => n['group']\n layoutParallelNodeSubGroup = (n: N): string => n['subgroup']\n\n forceLayoutSettings = {\n linkDistance: 60,\n linkStrength: 0.45,\n charge: -500,\n forceXStrength: 0.15,\n forceYStrength: 0.25,\n }\n\n dagreLayoutSettings = {\n rankdir: 'BT',\n ranker: 'longest-path',\n }\n\n layoutElkSettings: GenericAccessor<GraphElkLayoutSettings, string> | undefined = undefined\n layoutElkNodeGroups: StringAccessor<N>[] | undefined = undefined\n\n linkFlowAnimDuration = 20000\n linkFlowParticleSize = 2\n linkWidth = 1\n linkStyle = GraphLinkStyle.Solid\n linkBandWidth = 0\n linkArrow = undefined\n linkStroke = undefined\n linkFlow = false\n linkLabel = undefined\n linkLabelShiftFromCenter = true\n linkNeighborSpacing = 8\n linkDisabled = false\n selectedLinkId = undefined\n nodeGaugeAnimDuration = 1500\n\n nodeSize = 30\n nodeStrokeWidth = 3\n nodeShape = GraphNodeShape.Circle\n nodeGaugeValue = 0\n nodeIcon = (n: N): string => n['icon']\n nodeIconSize = undefined\n nodeLabel = (n: N): string => n['label']\n nodeLabelTrim = true\n nodeLabelTrimLength = 15\n nodeLabelTrimMode = TrimMode.Middle\n nodeSubLabel = ''\n nodeSubLabelTrim = true\n nodeSubLabelTrimLength = 15\n nodeSubLabelTrimMode = TrimMode.Middle\n nodeSideLabels = undefined\n nodeBottomIcon = undefined\n nodeDisabled = false\n nodeFill = (n: N): string => n['fill']\n nodeGaugeFill = undefined\n nodeStroke = (n: N): string => n['stroke']\n nodeEnterPosition = undefined\n nodeEnterScale = 0.75\n nodeExitPosition = undefined\n nodeExitScale = 0.75\n nodeSort = undefined\n\n selectedNodeId = undefined\n panels: GraphPanelConfig[] | undefined = undefined\n}\n"],"names":[],"mappings":";;;;AAAA;AAwMM,MAAO,WAAgE,SAAQ,eAAe,CAAA;AAApG,IAAA,WAAA,GAAA;;QACE,IAAQ,CAAA,QAAA,GAAG,IAAI,CAAA;AACf,QA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ACvB,IAAsB,CAAA,sBAAA,GAAG,EAAE,CAAA;AAC3B,QAAA,IAAA,CAAA,oBAAoB,GAAG,QAAQ,CAAC,MAAM,CAAA;QACtC,IAAc,CAAA,cAAA,GAAG,SAAS,CAAA;QAC1B,IAAc,CAAA,cAAA,GAAG,SAAS,CAAA;QAC1B,IAAY,CAAA,YAAA,GAAG,KAAK,CAAA;QACpB,IAAQ,CAAA,QAAA,GAAG,CAAC,CAAI,KAAa,CAAC,CAAC,MAAM,CAAC,CAAA;QACtC,IAAa,CAAA,aAAA,GAAG,SAAS,CAAA;QACzB,IAAU,CAAA,UAAA,GAAG,CAAC,CAAI,KAAa,CAAC,CAAC,QAAQ,CAAC,CAAA;QAC1C,IAAiB,CAAA,iBAAA,GAAG,SAAS,CAAA;QAC7B,IAAc,CAAA,cAAA,GAAG,IAAI,CAAA;QACrB,IAAgB,CAAA,gBAAA,GAAG,SAAS,CAAA;QAC5B,IAAa,CAAA,aAAA,GAAG,IAAI,CAAA;QACpB,IAAQ,CAAA,QAAA,GAAG,SAAS,CAAA;QAEpB,IAAc,CAAA,cAAA,GAAG,SAAS,CAAA;QAC1B,IAAM,CAAA,MAAA,GAAmC,SAAS,CAAA;KACnD;AAAA;;;;"}
|
|
1
|
+
{"version":3,"file":"config.js","sources":["../../../src/components/graph/config.ts"],"sourcesContent":["// Config\nimport { ComponentConfigInterface, ComponentDefaultConfig } from 'core/component/config'\n\n// Types\nimport { TrimMode } from 'types/text'\nimport { GraphInputLink, GraphInputNode } from 'types/graph'\nimport { BooleanAccessor, ColorAccessor, NumericAccessor, StringAccessor, GenericAccessor } from 'types/accessor'\n\n// Local Types\nimport {\n GraphLayoutType,\n GraphCircleLabel,\n GraphLinkStyle,\n GraphLinkArrowStyle,\n GraphPanelConfig,\n GraphForceLayoutSettings,\n GraphElkLayoutSettings,\n GraphNodeShape,\n} from './types'\n\nexport interface GraphConfigInterface<N extends GraphInputNode, L extends GraphInputLink> extends ComponentConfigInterface {\n // Zoom and drag\n /** Zoom level constraints. Default: [0.35, 1.25] */\n zoomScaleExtent?: [number, number];\n /** Disable zooming. Default: `false` */\n disableZoom?: boolean;\n /** Disable node dragging. Default: `false` */\n disableDrag?: boolean;\n /** Interval to re-render the graph when zooming. Default: `100` */\n zoomThrottledUpdateNodeThreshold?: number;\n /** Zoom event callback. Default: `undefined` */\n onZoom?: (zoomScale: number, zoomScaleExtent: [number, number]) => void;\n\n // Layout general settings\n /** Type of the graph layout. Default: `GraphLayoutType.Force` */\n layoutType?: GraphLayoutType | string;\n /** Fit the graph to container on data or config updates, or on container resize. Default: `true` */\n layoutAutofit?: boolean;\n /** Tolerance constant defining whether the graph should be fitted to container\n * (on data or config update, or container resize) after a zoom / pan interaction or not.\n * `0` — Stop fitting after any pan or zoom\n * `Number.POSITIVE_INFINITY` — Always fit\n * Default: `8.0` */\n layoutAutofitTolerance?: number;\n /** Place non-connected nodes at the bottom of the graph. Default: `false` */\n layoutNonConnectedAside?: boolean;\n\n // Settings for Parallel and Concentric layouts\n /** Node group accessor function.\n * Only for `GraphLayoutType.Parallel`, `GraphLayoutType.ParallelHorizontal` and `GraphLayoutType.Concentric` layouts.\n * Default: `node => node.group` */\n layoutNodeGroup?: StringAccessor<N>;\n /** Order of the layout groups.\n * Only for `GraphLayoutType.Parallel`, `GraphLayoutType.ParallelHorizontal` and `GraphLayoutType.Concentric` layouts.\n * Default: `[]` */\n layoutGroupOrder?: string[];\n\n // Setting for Parallel layouts only\n /** Sets the number of nodes in a sub-group after which they'll continue on the next column (or row if `layoutType` is\n * `GraphLayoutType.ParallelHorizontal`).\n * Only for `GraphLayoutType.Parallel` and `GraphLayoutType.ParallelHorizontal` layouts.\n * Default: `6` */\n layoutParallelNodesPerColumn?: number;\n /** Node sub-group accessor function.\n * Only for `GraphLayoutType.Parallel` and `GraphLayoutType.ParallelHorizontal` layouts.\n * Default: `node => node.subgroup` */\n layoutParallelNodeSubGroup?: StringAccessor<N>;\n /** Number of sub-groups per row (or column if `layoutType` is `GraphLayoutType.ParallelHorizontal`) in a group.\n * Only for `GraphLayoutType.Parallel` and `GraphLayoutType.ParallelHorizontal` layouts.\n * Default: `1` */\n layoutParallelSubGroupsPerRow?: number;\n /** Spacing between groups.\n * Only for `GraphLayoutType.Parallel` and `GraphLayoutType.ParallelHorizontal` layouts.\n * Default: `undefined` */\n layoutParallelGroupSpacing?: number;\n /** Set a group by name to have priority in sorting the graph links.\n * Only for `GraphLayoutType.Parallel` and `GraphLayoutType.ParallelHorizontal` layouts.\n * Default: `undefined` */\n layoutParallelSortConnectionsByGroup?: string;\n\n // Force layout\n /** Force Layout settings, see the `d3-force` package for more details */\n forceLayoutSettings?: GraphForceLayoutSettings;\n\n // Dagre layout\n /** Darge Layout settings, see the `dagrejs` package\n * for more details: https://github.com/dagrejs/dagre/wiki#configuring-the-layout\n */\n dagreLayoutSettings?: {\n /** Direction for rank node. `TB`, `BT`, `LR`, or `RL`. Default: `BT` */\n rankdir: string;\n /** Type of algorithm to assigns a rank to each node in the input graph.\n * `network-simplex`, `tight-tree` or `longest-path`.\n * Default: `longest-path` */\n ranker: string;\n /** Other configurable Dagre settings. https://github.com/dagrejs/dagre/wiki */\n [key: string]: any;\n };\n\n // ELK layout\n /** ELK layout options, see the `elkjs` package for more details: https://github.com/kieler/elkjs.\n * If you want to specify custom layout option for each node group, you can provide an accessor function that\n * receives group name ('root' for the top-level configuration) as the first argument and returns an object containing\n * layout options. Default: `undefined`\n */\n layoutElkSettings?: GenericAccessor<GraphElkLayoutSettings, string> | undefined;\n /** Array of accessor functions to define nested node groups for the ELK Layered layout.\n * E.g.: `[n => n.group, n => n.subGroup]`.\n * Default: `undefined` */\n layoutElkNodeGroups?: StringAccessor<N>[];\n\n // Links\n /** Link width accessor function ot constant value. Default: `1` */\n linkWidth?: NumericAccessor<L>;\n /** Link style accessor function or constant value. Default: `GraphLinkStyle.Solid` */\n linkStyle?: GenericAccessor<GraphLinkStyle, L>;\n /** Link band width accessor function or constant value. Default: `0` */\n linkBandWidth?: NumericAccessor<L>;\n /** Link arrow accessor function or constant value. Default: `undefined` */\n linkArrow?: GenericAccessor<GraphLinkArrowStyle, L> | undefined;\n /** Link stroke color accessor function or constant value. Default: `undefined` */\n linkStroke?: ColorAccessor<L>;\n /** Link disabled state accessor function or constant value. Default: `false` */\n linkDisabled?: BooleanAccessor<L>;\n /** Link flow animation accessor function or constant value. Default: `false` */\n linkFlow?: BooleanAccessor<L>;\n /** Animation duration of the flow (traffic) circles. Default: `20000` */\n linkFlowAnimDuration?: number;\n /** Size of the moving particles that represent traffic flow. Default: `2` */\n linkFlowParticleSize?: number;\n /** Link label accessor function or constant value. Default: `undefined` */\n linkLabel?: GenericAccessor<GraphCircleLabel, L> | undefined;\n /** Shift label along the link center a little bit to avoid overlap with the link arrow. Default: `true` */\n linkLabelShiftFromCenter?: BooleanAccessor<L>;\n /** Spacing between neighboring links. Default: `8` */\n linkNeighborSpacing?: number;\n /** Set selected link by its unique id. Default: `undefined` */\n selectedLinkId?: number | string;\n\n // Nodes\n /** Node size accessor function or constant value. Default: `30` */\n nodeSize?: NumericAccessor<N>;\n /** Node stroke width accessor function or constant value. Default: `3` */\n nodeStrokeWidth?: NumericAccessor<N>;\n /** Node shape accessor function or constant value. Default: `GraphNodeShape.Circle` */\n nodeShape?: GenericAccessor<GraphNodeShape | string, N>;\n /** Node gauge outline accessor function or constant value in the range [0,100]. Default: `0` */\n nodeGaugeValue?: NumericAccessor<N>;\n /** Node gauge outline fill color accessor function or constant value. Default: `undefined` */\n nodeGaugeFill?: ColorAccessor<N>;\n /** Animation duration of the node gauge outline. Default: `1500` */\n nodeGaugeAnimDuration?: number;\n /** Node central icon accessor function or constant value. Default: `node => node.icon` */\n nodeIcon?: StringAccessor<N>;\n /** Node central icon size accessor function or constant value. Default: `undefined` */\n nodeIconSize?: NumericAccessor<N>;\n /** Node label accessor function or constant value. Default: `node => node.label` */\n nodeLabel?: StringAccessor<N>;\n /** Defines whether to trim the node labels or not. Default: `true` */\n nodeLabelTrim?: BooleanAccessor<N>;\n /** Node label trimming mode. Default: `TrimMode.Middle` */\n nodeLabelTrimMode?: GenericAccessor<TrimMode | string, N>;\n /** Node label maximum allowed text length above which the label will be trimmed. Default: `15` */\n nodeLabelTrimLength?: NumericAccessor<N>;\n /** Node sub-label accessor function or constant value: Default: `''` */\n nodeSubLabel?: StringAccessor<N>;\n /** Defines whether to trim the node sub-labels or not. Default: `true` */\n nodeSubLabelTrim?: BooleanAccessor<N>;\n /** Node sub-label trimming mode. Default: `TrimMode.Middle` */\n nodeSubLabelTrimMode?: GenericAccessor<TrimMode | string, N>;\n /** Node sub-label maximum allowed text length above which the label will be trimmed. Default: `15` */\n nodeSubLabelTrimLength?: NumericAccessor<N>;\n /** Node circular side labels accessor function. The function should return an array of GraphCircleLabel objects. Default: `undefined` */\n nodeSideLabels?: GenericAccessor<GraphCircleLabel[], N>;\n /** Node bottom icon accessor function. Default: `undefined` */\n nodeBottomIcon?: StringAccessor<N>;\n /** Node disabled state accessor function or constant value. Default: `false` */\n nodeDisabled?: BooleanAccessor<N>;\n /** Node fill color accessor function or constant value. Default: `node => node.fill` */\n nodeFill?: ColorAccessor<N>;\n /** Node stroke color accessor function or constant value. Default: `node => node.stroke` */\n nodeStroke?: ColorAccessor<N>;\n /** Sorting function to determine node placement. Default: `undefined` */\n nodeSort?: ((a: N, b: N) => number);\n /** Specify the initial position for entering nodes as [x, y]. Default: `undefined` */\n nodeEnterPosition?: GenericAccessor<[number, number], N> | undefined;\n /** Specify the initial scale for entering nodes in the range [0,1]. Default: `0.75` */\n nodeEnterScale?: NumericAccessor<N> | undefined;\n /** Specify the destination position for exiting nodes as [x, y]. Default: `undefined` */\n nodeExitPosition?: GenericAccessor<[number, number], N> | undefined;\n /** Specify the destination scale for exiting nodes in the range [0,1]. Default: `0.75` */\n nodeExitScale?: NumericAccessor<N> | undefined;\n /** Set selected node by unique id. Default: `undefined` */\n selectedNodeId?: number | string;\n\n /** Panels configuration. An array of `GraphPanelConfig` objects. Default: `[]` */\n panels?: GraphPanelConfig[] | undefined;\n}\n\nexport const GraphDefaultConfig: GraphConfigInterface<GraphInputNode, GraphInputLink> = {\n ...ComponentDefaultConfig,\n duration: 1000,\n zoomScaleExtent: [0.35, 1.25],\n disableZoom: false,\n disableDrag: false,\n zoomThrottledUpdateNodeThreshold: 100,\n onZoom: undefined,\n layoutType: GraphLayoutType.Force,\n layoutAutofit: true,\n layoutAutofitTolerance: 8.0,\n layoutNonConnectedAside: false,\n\n layoutGroupOrder: [],\n layoutParallelSubGroupsPerRow: 1,\n layoutParallelNodesPerColumn: 6,\n layoutParallelGroupSpacing: undefined,\n layoutParallelSortConnectionsByGroup: undefined,\n layoutNodeGroup: (n: GraphInputNode): string => (n as { group: string }).group,\n layoutParallelNodeSubGroup: (n: GraphInputNode): string => (n as { subgroup: string }).subgroup,\n\n forceLayoutSettings: {\n linkDistance: 60,\n linkStrength: 0.45,\n charge: -500,\n forceXStrength: 0.15,\n forceYStrength: 0.25,\n },\n\n dagreLayoutSettings: {\n rankdir: 'BT',\n ranker: 'longest-path',\n },\n\n layoutElkSettings: undefined,\n layoutElkNodeGroups: undefined,\n\n linkFlowAnimDuration: 20000,\n linkFlowParticleSize: 2,\n linkWidth: 1,\n linkStyle: GraphLinkStyle.Solid,\n linkBandWidth: 0,\n linkArrow: undefined,\n linkStroke: undefined,\n linkFlow: false,\n linkLabel: undefined,\n linkLabelShiftFromCenter: true,\n linkNeighborSpacing: 8,\n linkDisabled: false,\n selectedLinkId: undefined,\n nodeGaugeAnimDuration: 1500,\n\n nodeSize: 30,\n nodeStrokeWidth: 3,\n nodeShape: GraphNodeShape.Circle,\n nodeGaugeValue: 0,\n nodeIcon: (n: GraphInputNode): string => (n as { icon: string }).icon,\n nodeIconSize: undefined,\n nodeLabel: (n: GraphInputNode): string => (n as { label: string }).label,\n nodeLabelTrim: true,\n nodeLabelTrimLength: 15,\n nodeLabelTrimMode: TrimMode.Middle,\n nodeSubLabel: '',\n nodeSubLabelTrim: true,\n nodeSubLabelTrimLength: 15,\n nodeSubLabelTrimMode: TrimMode.Middle,\n nodeSideLabels: undefined,\n nodeBottomIcon: undefined,\n nodeDisabled: false,\n nodeFill: (n: GraphInputNode): string => (n as { fill: string }).fill,\n nodeGaugeFill: undefined,\n nodeStroke: (n: GraphInputNode): string => (n as { stroke: string }).stroke,\n nodeEnterPosition: undefined,\n nodeEnterScale: 0.75,\n nodeExitPosition: undefined,\n nodeExitScale: 0.75,\n nodeSort: undefined,\n\n selectedNodeId: undefined,\n panels: undefined,\n}\n"],"names":[],"mappings":";;;;AAAA;MAuMa,kBAAkB,GAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EAC1B,sBAAsB,CACzB,EAAA,EAAA,QAAQ,EAAE,IAAI,EACd,eAAe,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,EAC7B,WAAW,EAAE,KAAK,EAClB,WAAW,EAAE,KAAK,EAClB,gCAAgC,EAAE,GAAG,EACrC,MAAM,EAAE,SAAS,EACjB,UAAU,EAAE,eAAe,CAAC,KAAK,EACjC,aAAa,EAAE,IAAI,EACnB,sBAAsB,EAAE,GAAG,EAC3B,uBAAuB,EAAE,KAAK,EAE9B,gBAAgB,EAAE,EAAE,EACpB,6BAA6B,EAAE,CAAC,EAChC,4BAA4B,EAAE,CAAC,EAC/B,0BAA0B,EAAE,SAAS,EACrC,oCAAoC,EAAE,SAAS,EAC/C,eAAe,EAAE,CAAC,CAAiB,KAAc,CAAuB,CAAC,KAAK,EAC9E,0BAA0B,EAAE,CAAC,CAAiB,KAAc,CAA0B,CAAC,QAAQ,EAE/F,mBAAmB,EAAE;AACnB,QAAA,YAAY,EAAE,EAAE;AAChB,QAAA,YAAY,EAAE,IAAI;QAClB,MAAM,EAAE,CAAC,GAAG;AACZ,QAAA,cAAc,EAAE,IAAI;AACpB,QAAA,cAAc,EAAE,IAAI;AACrB,KAAA,EAED,mBAAmB,EAAE;AACnB,QAAA,OAAO,E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AAI,EACnB,QAAQ,EAAE,SAAS,EAEnB,cAAc,EAAE,SAAS,EACzB,MAAM,EAAE,SAAS,EAAA;;;;"}
|
|
@@ -4,12 +4,12 @@ import { GraphDataModel } from "../../data-models/graph";
|
|
|
4
4
|
import { GraphInputLink, GraphInputNode } from "../../types/graph";
|
|
5
5
|
import { Spacing } from "../../types/spacing";
|
|
6
6
|
import { GraphNode, GraphLink } from './types';
|
|
7
|
-
import {
|
|
7
|
+
import { GraphConfigInterface } from './config';
|
|
8
8
|
import * as nodeSelectors from './modules/node/style';
|
|
9
9
|
export declare class Graph<N extends GraphInputNode, L extends GraphInputLink> extends ComponentCore<{
|
|
10
10
|
nodes: N[];
|
|
11
11
|
links?: L[];
|
|
12
|
-
},
|
|
12
|
+
}, GraphConfigInterface<N, L>> {
|
|
13
13
|
static selectors: {
|
|
14
14
|
root: string;
|
|
15
15
|
background: string;
|
|
@@ -31,7 +31,8 @@ export declare class Graph<N extends GraphInputNode, L extends GraphInputLink> e
|
|
|
31
31
|
};
|
|
32
32
|
static nodeSelectors: typeof nodeSelectors;
|
|
33
33
|
g: Selection<SVGGElement, unknown, null, undefined>;
|
|
34
|
-
|
|
34
|
+
protected _defaultConfig: GraphConfigInterface<N, L>;
|
|
35
|
+
config: GraphConfigInterface<N, L>;
|
|
35
36
|
datamodel: GraphDataModel<N, L, GraphNode<N, L>, GraphLink<N, L>>;
|
|
36
37
|
private _selectedNode;
|
|
37
38
|
private _selectedLink;
|
|
@@ -60,16 +61,16 @@ export declare class Graph<N extends GraphInputNode, L extends GraphInputLink> e
|
|
|
60
61
|
mouseover?: undefined;
|
|
61
62
|
mouseout?: undefined;
|
|
62
63
|
} | {
|
|
63
|
-
click: (d: GraphNode<N>) => void;
|
|
64
|
-
mouseover: (d: GraphNode<N>) => void;
|
|
65
|
-
mouseout: (d: GraphNode<N>) => void;
|
|
64
|
+
click: (d: GraphNode<N, L>) => void;
|
|
65
|
+
mouseover: (d: GraphNode<N, L>) => void;
|
|
66
|
+
mouseout: (d: GraphNode<N, L>) => void;
|
|
66
67
|
} | {
|
|
67
68
|
click: (d: GraphLink<N, L>) => void;
|
|
68
69
|
mouseover: (d: GraphLink<N, L>) => void;
|
|
69
70
|
mouseout: (d: GraphLink<N, L>) => void;
|
|
70
71
|
};
|
|
71
72
|
};
|
|
72
|
-
get selectedNode(): GraphNode<N>;
|
|
73
|
+
get selectedNode(): GraphNode<N, L>;
|
|
73
74
|
get selectedLink(): GraphLink<N, L>;
|
|
74
75
|
constructor(config?: GraphConfigInterface<N, L>);
|
|
75
76
|
setData(data: {
|
|
@@ -10,7 +10,7 @@ import { isNumber, clamp, getBoolean, isFunction, shallowDiff, unique, clean } f
|
|
|
10
10
|
import { stringToHtmlId } from '../../utils/misc.js';
|
|
11
11
|
import { smartTransition } from '../../utils/d3.js';
|
|
12
12
|
import { GraphLayoutType, GraphLinkArrowStyle } from './types.js';
|
|
13
|
-
import {
|
|
13
|
+
import { GraphDefaultConfig } from './config.js';
|
|
14
14
|
import { background, graphGroup, root } from './style.js';
|
|
15
15
|
import * as style from './modules/node/style.js';
|
|
16
16
|
import { nodes, gNode, gNodeExit, node, nodeGauge, sideLabelGroup, label } from './modules/node/style.js';
|
|
@@ -27,7 +27,8 @@ import { applyLayoutCircular, applyELKLayout, applyLayoutConcentric, applyLayout
|
|
|
27
27
|
class Graph extends ComponentCore {
|
|
28
28
|
constructor(config) {
|
|
29
29
|
super();
|
|
30
|
-
this.
|
|
30
|
+
this._defaultConfig = GraphDefaultConfig;
|
|
31
|
+
this.config = this._defaultConfig;
|
|
31
32
|
this.datamodel = new GraphDataModel();
|
|
32
33
|
this._isFirstRender = true;
|
|
33
34
|
this._shouldRecalculateLayout = false;
|
|
@@ -50,7 +51,7 @@ class Graph extends ComponentCore {
|
|
|
50
51
|
},
|
|
51
52
|
};
|
|
52
53
|
if (config)
|
|
53
|
-
this.
|
|
54
|
+
this.setConfig(config);
|
|
54
55
|
this._backgroundRect = this.g.append('rect').attr('class', background);
|
|
55
56
|
this._graphGroup = this.g.append('g').attr('class', graphGroup);
|
|
56
57
|
this._zoomBehavior = zoom()
|
|
@@ -447,8 +448,9 @@ class Graph extends ComponentCore {
|
|
|
447
448
|
// refit the layout after recalculation (e.g. on container resize)
|
|
448
449
|
if (event === null || event === void 0 ? void 0 : event.sourceEvent) {
|
|
449
450
|
const diff = Object.keys(transform).reduce((acc, prop) => {
|
|
450
|
-
const
|
|
451
|
-
const
|
|
451
|
+
const propVal = transform[prop];
|
|
452
|
+
const initialPropVal = this._initialTransform[prop];
|
|
453
|
+
const dVal = Math.abs(propVal - initialPropVal);
|
|
452
454
|
return prop === 'k' ? 2 * dVal : dVal / 50;
|
|
453
455
|
}, 0);
|
|
454
456
|
if (diff > config.layoutAutofitTolerance)
|