@unovis/ts 1.3.0-beta.3 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +7 -6
- 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
package/core/component/index.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { select } from 'd3-selection';
|
|
2
2
|
import { CoreDataModel } from '../../data-models/core.js';
|
|
3
|
-
import { throttle } from '../../utils/data.js';
|
|
3
|
+
import { throttle, merge } from '../../utils/data.js';
|
|
4
4
|
import { guid } from '../../utils/misc.js';
|
|
5
5
|
import { ComponentType, Sizing } from '../../types/component.js';
|
|
6
|
+
import { ComponentDefaultConfig } from './config.js';
|
|
6
7
|
|
|
7
8
|
class ComponentCore {
|
|
8
9
|
constructor(type = ComponentType.SVG) {
|
|
@@ -11,6 +12,8 @@ class ComponentCore {
|
|
|
11
12
|
this.datamodel = new CoreDataModel();
|
|
12
13
|
this.sizing = Sizing.Fit; // Supported by SingleContainer and a subset of components only (Sankey)
|
|
13
14
|
this.events = {};
|
|
15
|
+
/** Default configuration */
|
|
16
|
+
this._defaultConfig = ComponentDefaultConfig;
|
|
14
17
|
/** Component width in pixels. This property is set automatically by the container. */
|
|
15
18
|
this._width = 400;
|
|
16
19
|
/** Component height in pixels. This property is set automatically by the container. */
|
|
@@ -30,16 +33,16 @@ class ComponentCore {
|
|
|
30
33
|
this.uid = guid();
|
|
31
34
|
this.g = select(this.element);
|
|
32
35
|
// Setting the root class if available
|
|
36
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
37
|
+
// @ts-ignore
|
|
33
38
|
// eslint-disable-next-line dot-notation
|
|
34
39
|
const rootClass = (_b = (_a = this.constructor) === null || _a === void 0 ? void 0 : _a['selectors']) === null || _b === void 0 ? void 0 : _b.root;
|
|
35
40
|
if (rootClass)
|
|
36
41
|
this.g.attr('class', rootClass);
|
|
37
42
|
}
|
|
38
43
|
setConfig(config) {
|
|
39
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
40
|
-
const ConfigModel = this.config.constructor;
|
|
41
44
|
this.prevConfig = this.config; // Store the previous config instance
|
|
42
|
-
this.config =
|
|
45
|
+
this.config = merge(this._defaultConfig, config);
|
|
43
46
|
}
|
|
44
47
|
setData(data) {
|
|
45
48
|
this.datamodel.data = data;
|
|
@@ -80,9 +83,9 @@ class ComponentCore {
|
|
|
80
83
|
const attributeMap = this.config.attributes;
|
|
81
84
|
Object.keys(attributeMap).forEach(className => {
|
|
82
85
|
Object.keys(attributeMap[className]).forEach(attr => {
|
|
83
|
-
this.g
|
|
84
|
-
.selectAll(`.${className}`)
|
|
85
|
-
|
|
86
|
+
const selection = this.g
|
|
87
|
+
.selectAll(`.${className}`);
|
|
88
|
+
selection.attr(attr, attributeMap[className][attr]);
|
|
86
89
|
});
|
|
87
90
|
});
|
|
88
91
|
}
|
|
@@ -95,11 +98,13 @@ class ComponentCore {
|
|
|
95
98
|
_bindEvents(events = this.events, suffix = '') {
|
|
96
99
|
Object.keys(events).forEach(className => {
|
|
97
100
|
Object.keys(events[className]).forEach(eventType => {
|
|
98
|
-
const selection = this.g
|
|
101
|
+
const selection = this.g
|
|
102
|
+
.selectAll(`.${className}`);
|
|
99
103
|
selection.on(eventType + suffix, (event, d) => {
|
|
100
104
|
const els = selection.nodes();
|
|
101
105
|
const i = els.indexOf(event.currentTarget);
|
|
102
|
-
|
|
106
|
+
const eventFunction = events[className][eventType];
|
|
107
|
+
return eventFunction(d, event, i, els);
|
|
103
108
|
});
|
|
104
109
|
});
|
|
105
110
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/core/component/index.ts"],"sourcesContent":["import { select, Selection } from 'd3-selection'\nimport { Transition } from 'd3-transition'\n\n// Core\nimport { CoreDataModel } from 'data-models/core'\n\n// Utils\nimport { throttle } from 'utils/data'\nimport { guid } from 'utils/misc'\n\n// Types\nimport { ComponentType, Sizing } from 'types/component'\nimport { Spacing } from 'types/spacing'\n\n// Local Types\nimport { VisEventCallback, VisEventType } from './types'\n\n// Config\nimport { ComponentConfig, ComponentConfigInterface } from './config'\n\nexport class ComponentCore<\n CoreDatum,\n ConfigClass extends ComponentConfig = ComponentConfig,\n ConfigInterface extends ComponentConfigInterface = ComponentConfigInterface,\n> {\n element: SVGGElement | HTMLElement\n type: ComponentType = ComponentType.SVG\n g: Selection<SVGGElement, unknown, null, undefined> | Selection<HTMLElement, unknown, null, undefined>\n config: ConfigClass\n prevConfig: ConfigClass\n datamodel: CoreDataModel<CoreDatum> = new CoreDataModel()\n sizing: Sizing | string = Sizing.Fit // Supported by SingleContainer and a subset of components only (Sankey)\n uid: string\n\n events: {\n [selector: string]: {\n [eventType in VisEventType]?: VisEventCallback;\n };\n } = {}\n\n /** Component width in pixels. This property is set automatically by the container. */\n protected _width = 400\n /** Component height in pixels. This property is set automatically by the container. */\n protected _height = 200\n /** Container width in pixels. This property is set automatically by the container. */\n protected _containerWidth: number | undefined = undefined\n /** Container height in pixels. This property is set automatically by the container. */\n protected _containerHeight: number | undefined = undefined\n\n _setUpComponentEventsThrottled = throttle(this._setUpComponentEvents, 500)\n _setCustomAttributesThrottled = throttle(this._setCustomAttributes, 500)\n\n constructor (type = ComponentType.SVG) {\n if (type === ComponentType.SVG) {\n this.element = document.createElementNS('http://www.w3.org/2000/svg', 'g')\n } else {\n this.element = document.createElement('div')\n }\n this.uid = guid()\n this.g = select(this.element) as Selection<SVGGElement, unknown, null, undefined> | Selection<HTMLElement, unknown, null, undefined>\n\n // Setting the root class if available\n // eslint-disable-next-line dot-notation\n const rootClass = this.constructor?.['selectors']?.root as string\n if (rootClass) this.g.attr('class', rootClass)\n }\n\n setConfig (config: ConfigInterface): void {\n // eslint-disable-next-line @typescript-eslint/naming-convention\n const ConfigModel = (this.config.constructor as typeof ComponentConfig)\n this.prevConfig = this.config // Store the previous config instance\n this.config = new ConfigModel().init(config) as ConfigClass\n }\n\n setData (data: CoreDatum): void {\n this.datamodel.data = data\n }\n\n setSize (width: number, height: number, containerWidth: number, containerHeight: number): void {\n if (isFinite(width)) this._width = width\n if (isFinite(height)) this._height = height\n if (isFinite(containerWidth)) this._containerWidth = containerWidth\n if (isFinite(containerHeight)) this._containerHeight = containerHeight\n }\n\n render (duration = this.config.duration): void {\n this._render(duration)\n\n // While transition is in progress, we add the 'animating' attribute to the component's SVG group\n const ANIMATING_ATTR = 'animating'\n if (duration) {\n this.g.attr(ANIMATING_ATTR, '')\n const transition = this.g\n .transition(ANIMATING_ATTR)\n .duration(duration) as Transition<SVGGElement | HTMLElement, unknown, null, undefined>\n\n transition.on('end interrupt', () => {\n this.g.attr(ANIMATING_ATTR, null)\n })\n }\n this._setUpComponentEventsThrottled()\n this._setCustomAttributesThrottled()\n }\n\n get bleed (): Spacing {\n return { top: 0, bottom: 0, left: 0, right: 0 }\n }\n\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n _render (duration = this.config.duration): void {\n }\n\n private _setCustomAttributes (): void {\n const attributeMap = this.config.attributes\n\n Object.keys(attributeMap).forEach(className => {\n Object.keys(attributeMap[className]).forEach(attr => {\n (this.g as Selection<SVGGElement | HTMLElement, unknown, null, undefined>)\n .selectAll(`.${className}`)\n .attr(attr, attributeMap[className][attr])\n })\n })\n }\n\n private _setUpComponentEvents (): void {\n // Set up default events\n this._bindEvents(this.events)\n\n // Set up user-defined events\n this._bindEvents(this.config.events, '.user')\n }\n\n private _bindEvents (events = this.events, suffix = ''): void {\n Object.keys(events).forEach(className => {\n Object.keys(events[className]).forEach(eventType => {\n const selection = (this.g as Selection<SVGGElement | HTMLElement, unknown, null, undefined>).selectAll(`.${className}`)\n selection.on(eventType + suffix, (event: Event, d) => {\n const els = selection.nodes()\n const i = els.indexOf(event.currentTarget as SVGGElement | HTMLElement)\n return events[className][eventType](d, event, i, els)\n })\n })\n })\n }\n\n public destroy (): void {\n this.g?.remove()\n this.element = undefined\n }\n\n public isDestroyed (): boolean {\n return !this.element\n }\n}\n"],"names":[],"mappings":";;;;;;MAoBa,aAAa,CAAA;AAgCxB,IAAA,WAAA,CAAa,IAAI,GAAG,aAAa,CAAC,GAAG,EAAA;;AA1BrC,QAAA,IAAA,CAAA,IAAI,GAAkB,aAAa,CAAC,GAAG,CAAA;AAIvC,QAAA,IAAA,CAAA,SAAS,GAA6B,IAAI,aAAa,EAAE,CAAA;AACzD,QAAA,IAAA,CAAA,MAAM,GAAoB,MAAM,CAAC,GAAG,CAAA;QAGpC,IAAM,CAAA,MAAA,GAIF,EAAE,CAAA;;QAGI,IAAM,CAAA,MAAA,GAAG,GAAG,CAAA;;QAEZ,IAAO,CAAA,OAAA,GAAG,GAAG,CAAA;;QAEb,IAAe,CAAA,eAAA,GAAuB,SAAS,CAAA;;QAE/C,IAAgB,CAAA,gBAAA,GAAuB,SAAS,CAAA;QAE1D,IAA8B,CAAA,8BAAA,GAAG,QAAQ,CAAC,IAAI,CAAC,qBAAqB,EAAE,GAAG,CAAC,CAAA;QAC1E,IAA6B,CAAA,6BAAA,GAAG,QAAQ,CAAC,I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AO,CAAC,KAAK,CAAC,aAA0C,CAAC,CAAA;AACvE,oBAAA,OAAO,MAAM,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,CAAC,CAAA;AACvD,iBAAC,CAAC,CAAA;AACJ,aAAC,CAAC,CAAA;AACJ,SAAC,CAAC,CAAA;KACH;IAEM,OAAO,GAAA;;AACZ,QAAA,CAAA,EAAA,GAAA,IAAI,CAAC,CAAC,MAAE,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,MAAM,EAAE,CAAA;AAChB,QAAA,IAAI,CAAC,OAAO,GAAG,SAAS,CAAA;KACzB;IAEM,WAAW,GAAA;AAChB,QAAA,OAAO,CAAC,IAAI,CAAC,OAAO,CAAA;KACrB;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/core/component/index.ts"],"sourcesContent":["import { select, Selection, ValueFn } from 'd3-selection'\nimport { Transition } from 'd3-transition'\n\n// Core\nimport { CoreDataModel } from 'data-models/core'\n\n// Utils\nimport { merge, throttle } from 'utils/data'\nimport { guid } from 'utils/misc'\n\n// Types\nimport { ComponentType, Sizing } from 'types/component'\nimport { Spacing } from 'types/spacing'\n\n// Local Types\nimport { VisEventCallback, VisEventType } from './types'\n\n// Config\nimport { ComponentDefaultConfig, ComponentConfigInterface } from './config'\n\nexport class ComponentCore<\n CoreDatum,\n ConfigInterface extends ComponentConfigInterface = ComponentConfigInterface,\n> {\n public element: SVGGElement | HTMLElement\n public type: ComponentType = ComponentType.SVG\n public g: Selection<SVGGElement, unknown, null, undefined> | Selection<HTMLElement, unknown, null, undefined>\n public config: ComponentConfigInterface\n public prevConfig: ComponentConfigInterface\n public datamodel: CoreDataModel<CoreDatum> = new CoreDataModel()\n public sizing: Sizing | string = Sizing.Fit // Supported by SingleContainer and a subset of components only (Sankey)\n public uid: string\n\n protected events: {\n [selector: string]: {\n [eventType in VisEventType]?: VisEventCallback;\n };\n } = {}\n\n /** Default configuration */\n protected _defaultConfig: ComponentConfigInterface = ComponentDefaultConfig\n /** Component width in pixels. This property is set automatically by the container. */\n protected _width = 400\n /** Component height in pixels. This property is set automatically by the container. */\n protected _height = 200\n /** Container width in pixels. This property is set automatically by the container. */\n protected _containerWidth: number | undefined = undefined\n /** Container height in pixels. This property is set automatically by the container. */\n protected _containerHeight: number | undefined = undefined\n\n _setUpComponentEventsThrottled = throttle(this._setUpComponentEvents, 500)\n _setCustomAttributesThrottled = throttle(this._setCustomAttributes, 500)\n\n constructor (type = ComponentType.SVG) {\n if (type === ComponentType.SVG) {\n this.element = document.createElementNS('http://www.w3.org/2000/svg', 'g')\n } else {\n this.element = document.createElement('div')\n }\n this.uid = guid()\n this.g = select(this.element) as Selection<SVGGElement, unknown, null, undefined> | Selection<HTMLElement, unknown, null, undefined>\n\n // Setting the root class if available\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n // eslint-disable-next-line dot-notation\n const rootClass = this.constructor?.['selectors']?.root as string\n if (rootClass) this.g.attr('class', rootClass)\n }\n\n setConfig (config: ConfigInterface): void {\n this.prevConfig = this.config // Store the previous config instance\n this.config = merge(this._defaultConfig, config)\n }\n\n setData (data: CoreDatum): void {\n this.datamodel.data = data\n }\n\n setSize (width: number, height: number, containerWidth: number, containerHeight: number): void {\n if (isFinite(width)) this._width = width\n if (isFinite(height)) this._height = height\n if (isFinite(containerWidth)) this._containerWidth = containerWidth\n if (isFinite(containerHeight)) this._containerHeight = containerHeight\n }\n\n render (duration = this.config.duration): void {\n this._render(duration)\n\n // While transition is in progress, we add the 'animating' attribute to the component's SVG group\n const ANIMATING_ATTR = 'animating'\n if (duration) {\n this.g.attr(ANIMATING_ATTR, '')\n const transition = this.g\n .transition(ANIMATING_ATTR)\n .duration(duration) as Transition<SVGGElement | HTMLElement, unknown, null, undefined>\n\n transition.on('end interrupt', () => {\n this.g.attr(ANIMATING_ATTR, null)\n })\n }\n this._setUpComponentEventsThrottled()\n this._setCustomAttributesThrottled()\n }\n\n get bleed (): Spacing {\n return { top: 0, bottom: 0, left: 0, right: 0 }\n }\n\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n _render (duration = this.config.duration): void {\n }\n\n private _setCustomAttributes (): void {\n const attributeMap = this.config.attributes\n\n Object.keys(attributeMap).forEach(className => {\n Object.keys(attributeMap[className]).forEach(attr => {\n const selection = (this.g as Selection<SVGGElement | HTMLElement, unknown, null, undefined>)\n .selectAll<SVGGElement | HTMLElement, unknown>(`.${className}`)\n\n selection.attr(attr, attributeMap[className][attr] as ValueFn<SVGGElement | HTMLElement, unknown, string | number | boolean>)\n })\n })\n }\n\n private _setUpComponentEvents (): void {\n // Set up default events\n this._bindEvents(this.events)\n\n // Set up user-defined events\n this._bindEvents(this.config.events, '.user')\n }\n\n private _bindEvents (events = this.events, suffix = ''): void {\n Object.keys(events).forEach(className => {\n Object.keys(events[className]).forEach(eventType => {\n const selection = (this.g as Selection<SVGGElement | HTMLElement, unknown, null, undefined>)\n .selectAll<SVGGElement | HTMLElement, unknown>(`.${className}`)\n selection.on(eventType + suffix, (event: MouseEvent & WheelEvent & PointerEvent & TouchEvent, d) => {\n const els = selection.nodes()\n const i = els.indexOf(event.currentTarget as SVGGElement | HTMLElement)\n const eventFunction = events[className][eventType as VisEventType]\n return eventFunction(d, event, i, els)\n })\n })\n })\n }\n\n public destroy (): void {\n this.g?.remove()\n this.element = undefined\n }\n\n public isDestroyed (): boolean {\n return !this.element\n }\n}\n"],"names":[],"mappings":";;;;;;;MAoBa,aAAa,CAAA;AAiCxB,IAAA,WAAA,CAAa,IAAI,GAAG,aAAa,CAAC,GAAG,EAAA;;AA5B9B,QAAA,IAAA,CAAA,IAAI,GAAkB,aAAa,CAAC,GAAG,CAAA;AAIvC,QAAA,IAAA,CAAA,SAAS,GAA6B,IAAI,aAAa,EAAE,CAAA;AACzD,QAAA,IAAA,CAAA,MAAM,GAAoB,MAA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;AACtC,YAAA,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,SAAS,IAAG;AACjD,gBAAA,MAAM,SAAS,GAAI,IAAI,CAAC,CAAoE;AACzF,qBAAA,SAAS,CAAqC,CAAA,CAAA,EAAI,SAAS,CAAA,CAAE,CAAC,CAAA;AACjE,gBAAA,SAAS,CAAC,EAAE,CAAC,SAAS,GAAG,MAAM,EAAE,CAAC,KAA0D,EAAE,CAAC,KAAI;AACjG,oBAAA,MAAM,GAAG,GAAG,SAAS,CAAC,KAAK,EAAE,CAAA;oBAC7B,MAAM,CAAC,GAAG,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,aAA0C,CAAC,CAAA;oBACvE,MAAM,aAAa,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC,SAAyB,CAAC,CAAA;oBAClE,OAAO,aAAa,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,CAAC,CAAA;AACxC,iBAAC,CAAC,CAAA;AACJ,aAAC,CAAC,CAAA;AACJ,SAAC,CAAC,CAAA;KACH;IAEM,OAAO,GAAA;;AACZ,QAAA,CAAA,EAAA,GAAA,IAAI,CAAC,CAAC,MAAE,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,MAAM,EAAE,CAAA;AAChB,QAAA,IAAI,CAAC,OAAO,GAAG,SAAS,CAAA;KACzB;IAEM,WAAW,GAAA;AAChB,QAAA,OAAO,CAAC,IAAI,CAAC,OAAO,CAAA;KACrB;AACF;;;;"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Config } from "../config";
|
|
2
1
|
import { Sizing } from "../../types/component";
|
|
3
2
|
import { Spacing } from "../../types/spacing";
|
|
4
3
|
export interface ContainerConfigInterface {
|
|
@@ -31,23 +30,4 @@ export interface ContainerConfigInterface {
|
|
|
31
30
|
*/
|
|
32
31
|
ariaLabel?: string | null | undefined;
|
|
33
32
|
}
|
|
34
|
-
export declare
|
|
35
|
-
duration: any;
|
|
36
|
-
margin: {
|
|
37
|
-
top: number;
|
|
38
|
-
bottom: number;
|
|
39
|
-
left: number;
|
|
40
|
-
right: number;
|
|
41
|
-
};
|
|
42
|
-
padding: {
|
|
43
|
-
top: number;
|
|
44
|
-
bottom: number;
|
|
45
|
-
left: number;
|
|
46
|
-
right: number;
|
|
47
|
-
};
|
|
48
|
-
sizing: Sizing;
|
|
49
|
-
width: any;
|
|
50
|
-
height: any;
|
|
51
|
-
svgDefs: any;
|
|
52
|
-
ariaLabel: any;
|
|
53
|
-
}
|
|
33
|
+
export declare const ContainerDefaultConfig: ContainerConfigInterface;
|
package/core/container/config.js
CHANGED
|
@@ -1,30 +1,26 @@
|
|
|
1
|
-
import { Config } from '../config/index.js';
|
|
2
1
|
import { Sizing } from '../../types/component.js';
|
|
3
2
|
|
|
4
3
|
// Core
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
this.ariaLabel = undefined;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
4
|
+
const ContainerDefaultConfig = {
|
|
5
|
+
duration: undefined,
|
|
6
|
+
margin: {
|
|
7
|
+
top: 0,
|
|
8
|
+
bottom: 0,
|
|
9
|
+
left: 0,
|
|
10
|
+
right: 0,
|
|
11
|
+
},
|
|
12
|
+
padding: {
|
|
13
|
+
top: 0,
|
|
14
|
+
bottom: 0,
|
|
15
|
+
left: 0,
|
|
16
|
+
right: 0,
|
|
17
|
+
},
|
|
18
|
+
sizing: Sizing.Fit,
|
|
19
|
+
width: undefined,
|
|
20
|
+
height: undefined,
|
|
21
|
+
svgDefs: undefined,
|
|
22
|
+
ariaLabel: undefined,
|
|
23
|
+
};
|
|
28
24
|
|
|
29
|
-
export {
|
|
25
|
+
export { ContainerDefaultConfig };
|
|
30
26
|
//# sourceMappingURL=config.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sources":["../../../src/core/container/config.ts"],"sourcesContent":["// Core\
|
|
1
|
+
{"version":3,"file":"config.js","sources":["../../../src/core/container/config.ts"],"sourcesContent":["// Core\n\n// Types\nimport { Sizing } from 'types/component'\nimport { Spacing } from 'types/spacing'\n\nexport interface ContainerConfigInterface {\n /** Animation duration of all the components within the container. Default: `undefined` */\n duration?: number;\n /** Margins. Default: `{ top: 0, bottom: 0, left: 0, right: 0 }` */\n margin?: Spacing;\n /** Padding. Default: `{ top: 0, bottom: 0, left: 0, right: 0 }` */\n padding?: Spacing;\n /** Defines whether components should fit into the container or the container should expand to fit to the component's size. Default: `Sizing.Fit` */\n sizing?: Sizing | string;\n /** Width in pixels or in CSS units.\n * Percentage units `\"%\"` are not supported here. If you want to set `width` as a percentage, do it via `style`\n * of the corresponding DOM element.\n * By default, Container automatically fits to the size of the parent element.\n * Default: `undefined`\n */\n width?: number | string;\n /** Height in pixels or in CSS units.\n * Percentage units `\"%\"` are not supported here. If you want to set `height` as a percentage, do it via `style`\n * of the corresponding DOM element.\n * By default, Container automatically fits to the size of the parent element.\n * Default: `undefined`\n */\n height?: number | string;\n /** Custom SVG defs available to all the components within the container. Default: `undefined`. */\n svgDefs?: string;\n /** Alternative text description of the chart for accessibility purposes. It will be applied as an\n * `aria-label` attribute to the div element containing your chart. Default: `undefined`.\n */\n ariaLabel?: string | null | undefined;\n}\n\nexport const ContainerDefaultConfig: ContainerConfigInterface = {\n duration: undefined,\n margin: {\n top: 0,\n bottom: 0,\n left: 0,\n right: 0,\n },\n\n padding: {\n top: 0,\n bottom: 0,\n left: 0,\n right: 0,\n },\n\n sizing: Sizing.Fit,\n width: undefined,\n height: undefined,\n\n svgDefs: undefined,\n ariaLabel: undefined,\n}\n"],"names":[],"mappings":";;AAAA;AAqCa,MAAA,sBAAsB,GAA6B;AAC9D,IAAA,QAAQ,EAAE,SAAS;AACnB,IAAA,MAAM,EAAE;AACN,QAAA,GAAG,EAAE,CAAC;AACN,QAAA,MAAM,EAAE,CAAC;AACT,QAAA,IAAI,EAAE,CAAC;AACP,QAAA,KAAK,EAAE,CAAC;AACT,KAAA;AAED,IAAA,OAAO,EAAE;AACP,QAAA,GAAG,EAAE,CAAC;AACN,QAAA,MAAM,EAAE,CAAC;AACT,QAAA,IAAI,EAAE,CAAC;AACP,QAAA,KAAK,EAAE,CAAC;AACT,KAAA;IAED,MAAM,EAAE,MAAM,CAAC,GAAG;AAClB,IAAA,KAAK,EAAE,SAAS;AAChB,IAAA,MAAM,EAAE,SAAS;AAEjB,IAAA,OAAO,EAAE,SAAS;AAClB,IAAA,SAAS,EAAE,SAAS;;;;;"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { Selection } from 'd3-selection';
|
|
2
|
-
import {
|
|
2
|
+
import { ContainerConfigInterface } from './config';
|
|
3
3
|
export declare class ContainerCore {
|
|
4
4
|
svg: Selection<SVGSVGElement, unknown, null, undefined>;
|
|
5
5
|
element: SVGSVGElement;
|
|
6
|
-
prevConfig:
|
|
7
|
-
config:
|
|
6
|
+
prevConfig: ContainerConfigInterface;
|
|
7
|
+
config: ContainerConfigInterface;
|
|
8
|
+
protected _defaultConfig: ContainerConfigInterface;
|
|
8
9
|
protected _container: HTMLElement;
|
|
9
10
|
protected _requestedAnimationFrame: number;
|
|
10
11
|
protected _isFirstRender: boolean;
|
|
@@ -16,7 +17,7 @@ export declare class ContainerCore {
|
|
|
16
17
|
updateContainer<T extends ContainerConfigInterface>(config: T): void;
|
|
17
18
|
protected _preRender(): void;
|
|
18
19
|
protected _render(duration?: number): void;
|
|
19
|
-
render(duration?:
|
|
20
|
+
render(duration?: number): void;
|
|
20
21
|
get containerWidth(): number;
|
|
21
22
|
get containerHeight(): number;
|
|
22
23
|
get width(): number;
|
package/core/container/index.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { select } from 'd3-selection';
|
|
2
2
|
import { Sizing } from '../../types/component.js';
|
|
3
|
-
import { clamp, isEqual } from '../../utils/data.js';
|
|
3
|
+
import { merge, clamp, isEqual } from '../../utils/data.js';
|
|
4
4
|
import { ResizeObserver } from '../../utils/resize-observer.js';
|
|
5
|
+
import { ContainerDefaultConfig } from './config.js';
|
|
5
6
|
|
|
6
7
|
class ContainerCore {
|
|
7
8
|
constructor(element) {
|
|
9
|
+
this._defaultConfig = ContainerDefaultConfig;
|
|
8
10
|
this._isFirstRender = true;
|
|
9
11
|
this._requestedAnimationFrame = null;
|
|
10
12
|
this._container = element;
|
|
@@ -24,9 +26,8 @@ class ContainerCore {
|
|
|
24
26
|
}
|
|
25
27
|
updateContainer(config) {
|
|
26
28
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
27
|
-
const ConfigModel = this.config.constructor;
|
|
28
29
|
this.prevConfig = this.config;
|
|
29
|
-
this.config =
|
|
30
|
+
this.config = merge(this._defaultConfig, config);
|
|
30
31
|
}
|
|
31
32
|
// The `_preRender` step should be used to perform some actions before rendering.
|
|
32
33
|
// For example, calculating scales, setting component sizes, etc ...
|
|
@@ -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 } from 'utils/data'\nimport { ResizeObserver } from 'utils/resize-observer'\n\n// Config\nimport { ContainerConfig, ContainerConfigInterface } from './config'\n\nexport class ContainerCore {\n svg: Selection<SVGSVGElement, unknown, null, undefined>\n element: SVGSVGElement\n prevConfig: ContainerConfig\n config: ContainerConfig\n\n protected _container: HTMLElement\n protected _requestedAnimationFrame: number\n protected _isFirstRender = true\n protected _resizeObserver: ResizeObserver | undefined\n protected _svgDefs: 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._requestedAnimationFrame = 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.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 const ConfigModel = (this.config.constructor as typeof ContainerConfig)\n this.prevConfig = this.config\n this.config = new ConfigModel().init(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 } = this\n\n // Add `svgDefs` if provided in the config\n if (config.svgDefs) {\n this.svg.select('.svgDefs').remove()\n this.svg.append('defs').attr('class', 'svgDefs').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._requestedAnimationFrame)\n this._requestedAnimationFrame = 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 const containerRect = this._container.getBoundingClientRect()\n this._containerSize = { width: containerRect.width, height: containerRect.height }\n\n this._resizeObserver = new ResizeObserver((entries, observer) => {\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 this._resizeObserver.observe(this._container)\n }\n\n public destroy (): void {\n cancelAnimationFrame(this._requestedAnimationFrame)\n this._resizeObserver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AAC,MAAM,EAAE,CAAA;KAClB;;AArID;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 _requestedAnimationFrame: number\n protected _isFirstRender = true\n protected _resizeObserver: ResizeObserver | undefined\n protected _svgDefs: 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._requestedAnimationFrame = 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.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 } = this\n\n // Add `svgDefs` if provided in the config\n if (config.svgDefs) {\n this.svg.select('.svgDefs').remove()\n this.svg.append('defs').attr('class', 'svgDefs').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._requestedAnimationFrame)\n this._requestedAnimationFrame = 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 const containerRect = this._container.getBoundingClientRect()\n this._containerSize = { width: containerRect.width, height: containerRect.height }\n\n this._resizeObserver = new ResizeObserver((entries, observer) => {\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 this._resizeObserver.observe(this._container)\n }\n\n public destroy (): void {\n cancelAnimationFrame(this._requestedAnimationFrame)\n this._resizeObserver?.disconnect()\n this.svg.remove()\n }\n}\n"],"names":[],"mappings":";;;;;;MAYa,aAAa,CAAA;AAiBxB,IAAA,WAAA,CAAa,OAAoB,EAAA;QAXvB,IAAc,CAAA,cAAA,GAA6B,sBAAsB,CAAA;QAGjE,IAAc,CAAA,cAAA,GAAG,IAAI,CAAA;AAS7B,QAAA,IAAI,CAAC,wBAAwB,GAAG,IAAI,CAAA;AACpC,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;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K,IAAI,oBAAoB,CAAC,MAAM,EAAE;AAC/E,gBAAA,IAAI,CAAC,cAAc,GAAG,oBAAoB,CAAA;gBAC1C,IAAI,CAAC,SAAS,EAAE,CAAA;AACjB,aAAA;AACH,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,wBAAwB,CAAC,CAAA;AACnD,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;;AApID;AACO,aAAwB,CAAA,wBAAA,GAAG,GAAG;;;;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ContinuousScale } from "../../types/scale";
|
|
2
2
|
import { ColorAccessor, NumericAccessor } from "../../types/accessor";
|
|
3
|
-
import {
|
|
3
|
+
import { ComponentConfigInterface } from '../component/config';
|
|
4
4
|
export interface XYComponentConfigInterface<Datum> extends ComponentConfigInterface {
|
|
5
5
|
/** Accessor function for getting the values along the X axis. Default: `undefined` */
|
|
6
6
|
x: NumericAccessor<Datum>;
|
|
@@ -27,12 +27,4 @@ export interface XYComponentConfigInterface<Datum> extends ComponentConfigInterf
|
|
|
27
27
|
*/
|
|
28
28
|
excludeFromDomainCalculation?: boolean;
|
|
29
29
|
}
|
|
30
|
-
export declare
|
|
31
|
-
x: any;
|
|
32
|
-
y: any;
|
|
33
|
-
id: (d: Datum, i: number) => string;
|
|
34
|
-
color: (d: Datum | Datum[]) => string;
|
|
35
|
-
xScale: any;
|
|
36
|
-
yScale: any;
|
|
37
|
-
excludeFromDomainCalculation: boolean;
|
|
38
|
-
}
|
|
30
|
+
export declare const XYComponentDefaultConfig: XYComponentConfigInterface<unknown>;
|
|
@@ -1,20 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ComponentDefaultConfig } from '../component/config.js';
|
|
2
2
|
|
|
3
3
|
// Config
|
|
4
|
-
|
|
5
|
-
constructor() {
|
|
6
|
-
super(...arguments);
|
|
7
|
-
this.x = undefined;
|
|
8
|
-
this.y = undefined;
|
|
9
|
-
// eslint-disable-next-line dot-notation
|
|
10
|
-
this.id = (d, i) => { var _a; return (_a = d['id']) !== null && _a !== void 0 ? _a : `${i}`; };
|
|
11
|
-
// eslint-disable-next-line dot-notation
|
|
12
|
-
this.color = (d) => d['color'];
|
|
13
|
-
this.xScale = undefined;
|
|
14
|
-
this.yScale = undefined;
|
|
15
|
-
this.excludeFromDomainCalculation = false;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
4
|
+
const XYComponentDefaultConfig = Object.assign(Object.assign({}, ComponentDefaultConfig), { x: undefined, y: undefined, id: (d, i) => { var _a; return (_a = d.id) !== null && _a !== void 0 ? _a : `${i}`; }, color: (d) => d.color, xScale: undefined, yScale: undefined, excludeFromDomainCalculation: false });
|
|
18
5
|
|
|
19
|
-
export {
|
|
6
|
+
export { XYComponentDefaultConfig };
|
|
20
7
|
//# sourceMappingURL=config.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sources":["../../../src/core/xy-component/config.ts"],"sourcesContent":["import { ContinuousScale } from 'types/scale'\n\n// Types\nimport { ColorAccessor, NumericAccessor } from 'types/accessor'\n\n// Config\nimport {
|
|
1
|
+
{"version":3,"file":"config.js","sources":["../../../src/core/xy-component/config.ts"],"sourcesContent":["import { ContinuousScale } from 'types/scale'\n\n// Types\nimport { ColorAccessor, NumericAccessor } from 'types/accessor'\n\n// Config\nimport { ComponentDefaultConfig, ComponentConfigInterface } from '../component/config'\n\nexport interface XYComponentConfigInterface<Datum> extends ComponentConfigInterface {\n /** Accessor function for getting the values along the X axis. Default: `undefined` */\n x: NumericAccessor<Datum>;\n /** A single of multiple accessor functions for getting the values along the Y axis. Default: `undefined` */\n y: NumericAccessor<Datum> | NumericAccessor<Datum>[];\n /** Accessor function for getting the unique data record id. Used for more persistent data updates. Default: `(d, i) => d.id ?? i` */\n id?: ((d: Datum, i: number, ...any: any[]) => string);\n /** Component color accessor function. Default: `d => d.color` */\n color?: ColorAccessor<Datum> | ColorAccessor<Datum[]>;\n /** Scale for X dimension, e.g. Scale.scaleLinear(). If you set xScale you'll be responsible for setting it's `domain` and `range` as well.\n * Only continuous scales are supported.\n * Default: `undefined`\n */\n xScale?: ContinuousScale;\n /** Scale for Y dimension, e.g. Scale.scaleLinear(). If you set yScale you'll be responsible for setting it's `domain` and `range` as well.\n * Only continuous scales are supported.\n * Default: `undefined`\n */\n yScale?: ContinuousScale;\n /** Identifies whether the component should be excluded from overall X and Y domain calculations or not.\n * This property can be useful when you want pass individual data to a component and you don't want it to affect\n * the scales of the chart.\n * Default: `false`\n */\n excludeFromDomainCalculation?: boolean;\n}\n\nexport const XYComponentDefaultConfig: XYComponentConfigInterface<unknown> = {\n ...ComponentDefaultConfig,\n x: undefined,\n y: undefined,\n id: (d: unknown, i: number): string => (d as { id: string }).id ?? `${i}`,\n color: (d: unknown | unknown[]): string => (d as { color: string }).color,\n xScale: undefined,\n yScale: undefined,\n excludeFromDomainCalculation: false,\n}\n"],"names":[],"mappings":";;AAKA;AA8Ba,MAAA,wBAAwB,GAChC,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EAAA,sBAAsB,CACzB,EAAA,EAAA,CAAC,EAAE,SAAS,EACZ,CAAC,EAAE,SAAS,EACZ,EAAE,EAAE,CAAC,CAAU,EAAE,CAAS,KAAY,EAAA,IAAA,EAAA,CAAA,CAAC,OAAA,CAAA,EAAA,GAAC,CAAoB,CAAC,EAAE,MAAA,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,EAAA,GAAI,GAAG,CAAC,CAAA,CAAE,CAAA,EAAA,EACzE,KAAK,EAAE,CAAC,CAAsB,KAAc,CAAuB,CAAC,KAAK,EACzE,MAAM,EAAE,SAAS,EACjB,MAAM,EAAE,SAAS,EACjB,4BAA4B,EAAE,KAAK,EAAA;;;;"}
|
|
@@ -2,17 +2,18 @@ import { Selection } from 'd3-selection';
|
|
|
2
2
|
import { ComponentCore } from "../component";
|
|
3
3
|
import { SeriesDataModel } from "../../data-models/series";
|
|
4
4
|
import { ContinuousScale, ScaleDimension } from "../../types/scale";
|
|
5
|
-
import {
|
|
6
|
-
export declare class XYComponentCore<Datum,
|
|
5
|
+
import { XYComponentConfigInterface } from './config';
|
|
6
|
+
export declare class XYComponentCore<Datum, ConfigInterface extends Partial<XYComponentConfigInterface<Datum>> = Partial<XYComponentConfigInterface<Datum>>> extends ComponentCore<Datum[], ConfigInterface> {
|
|
7
7
|
element: SVGGraphicsElement;
|
|
8
8
|
g: Selection<SVGGElement, unknown, null, undefined>;
|
|
9
|
-
config:
|
|
10
|
-
prevConfig:
|
|
9
|
+
config: ConfigInterface;
|
|
10
|
+
prevConfig: ConfigInterface;
|
|
11
11
|
datamodel: SeriesDataModel<Datum>;
|
|
12
12
|
/** Clippable components can be affected by a clipping path (set up in the container) */
|
|
13
13
|
clippable: boolean;
|
|
14
14
|
/** Identifies whether the component displayed stacked data (eg StackedBar, Area) */
|
|
15
15
|
stacked: boolean;
|
|
16
|
+
protected _defaultConfig: ConfigInterface;
|
|
16
17
|
private _xScale;
|
|
17
18
|
private _yScale;
|
|
18
19
|
get xScale(): ContinuousScale;
|
|
@@ -2,6 +2,7 @@ import { ComponentCore } from '../component/index.js';
|
|
|
2
2
|
import { SeriesDataModel } from '../../data-models/series.js';
|
|
3
3
|
import { getExtent, filterDataByRange, isArray } from '../../utils/data.js';
|
|
4
4
|
import { Scale, ScaleDimension } from '../../types/scale.js';
|
|
5
|
+
import { XYComponentDefaultConfig } from './config.js';
|
|
5
6
|
|
|
6
7
|
// Core
|
|
7
8
|
class XYComponentCore extends ComponentCore {
|
|
@@ -12,6 +13,7 @@ class XYComponentCore extends ComponentCore {
|
|
|
12
13
|
this.clippable = true;
|
|
13
14
|
/** Identifies whether the component displayed stacked data (eg StackedBar, Area) */
|
|
14
15
|
this.stacked = false;
|
|
16
|
+
this._defaultConfig = XYComponentDefaultConfig;
|
|
15
17
|
this._xScale = Scale.scaleLinear();
|
|
16
18
|
this._yScale = Scale.scaleLinear();
|
|
17
19
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/core/xy-component/index.ts"],"sourcesContent":["import { Selection } from 'd3-selection'\n\n// Core\nimport { ComponentCore } from 'core/component'\nimport { SeriesDataModel } from 'data-models/series'\n\n// Utils\nimport { filterDataByRange, getExtent, isArray } from 'utils/data'\n\n// Types\nimport { NumericAccessor } from 'types/accessor'\nimport { ContinuousScale, Scale, ScaleDimension } from 'types/scale'\n\n// Config\nimport {
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/core/xy-component/index.ts"],"sourcesContent":["import { Selection } from 'd3-selection'\n\n// Core\nimport { ComponentCore } from 'core/component'\nimport { SeriesDataModel } from 'data-models/series'\n\n// Utils\nimport { filterDataByRange, getExtent, isArray } from 'utils/data'\n\n// Types\nimport { NumericAccessor } from 'types/accessor'\nimport { ContinuousScale, Scale, ScaleDimension } from 'types/scale'\n\n// Config\nimport { XYComponentDefaultConfig, XYComponentConfigInterface } from './config'\n\nexport class XYComponentCore<\n Datum,\n ConfigInterface extends Partial<XYComponentConfigInterface<Datum>> = Partial<XYComponentConfigInterface<Datum>>,\n> extends ComponentCore<Datum[], ConfigInterface> {\n public element: SVGGraphicsElement\n public g: Selection<SVGGElement, unknown, null, undefined>\n public config: ConfigInterface\n public prevConfig: ConfigInterface\n public datamodel: SeriesDataModel<Datum> = new SeriesDataModel()\n\n /** Clippable components can be affected by a clipping path (set up in the container) */\n public clippable = true\n\n /** Identifies whether the component displayed stacked data (eg StackedBar, Area) */\n public stacked = false\n\n protected _defaultConfig: ConfigInterface = XYComponentDefaultConfig as ConfigInterface\n\n private _xScale: ContinuousScale = Scale.scaleLinear()\n private _yScale: ContinuousScale = Scale.scaleLinear()\n\n get xScale (): ContinuousScale {\n return this.config.xScale || this._xScale\n }\n\n get yScale (): ContinuousScale {\n return this.config.yScale || this._yScale\n }\n\n setConfig (config: ConfigInterface): void {\n // We don't allow changing scales after the component has been initialized\n if (this.config?.xScale) config.xScale = this.config.xScale\n if (this.config?.yScale) config.yScale = this.config.yScale\n\n super.setConfig(config)\n }\n\n setScaleDomain (dimension: ScaleDimension, domain: number[]): void {\n if (dimension === ScaleDimension.X) this._xScale?.domain(domain)\n if (dimension === ScaleDimension.Y) this._yScale?.domain(domain)\n }\n\n setScaleRange (dimension: ScaleDimension, range: number[]): void {\n if (dimension === ScaleDimension.X) this._xScale?.range(range)\n if (dimension === ScaleDimension.Y) this._yScale?.range(range)\n }\n\n setScale (dimension: ScaleDimension, scale: ContinuousScale): void {\n if (scale && (dimension === ScaleDimension.X)) this._xScale = scale\n if (scale && (dimension === ScaleDimension.Y)) this._yScale = scale\n }\n\n getDataExtent (dimension: ScaleDimension, scaleByVisibleData: boolean): number[] {\n const { config, datamodel } = this\n\n switch (dimension) {\n case ScaleDimension.X: return this.getXDataExtent()\n case ScaleDimension.Y: return this.getYDataExtent(scaleByVisibleData)\n default: return getExtent(datamodel.data, config[dimension])\n }\n }\n\n getXDataExtent (): number[] {\n const { config, datamodel } = this\n return getExtent(datamodel.data, config.x)\n }\n\n getYDataExtent (scaleByVisibleData: boolean): number[] {\n const { config, datamodel } = this\n\n const data = scaleByVisibleData ? filterDataByRange(datamodel.data, this.xScale.domain() as [number, number], config.x) : datamodel.data\n const yAccessors = (isArray(config.y) ? config.y : [config.y]) as NumericAccessor<Datum>[]\n return getExtent(data, ...yAccessors)\n }\n}\n"],"names":[],"mappings":";;;;;;AAEA;AAcM,MAAO,eAGX,SAAQ,aAAuC,CAAA;AAHjD,IAAA,WAAA,GAAA;;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AAS,CAAC,CAAC,CAAA;AAC7D,SAAA;KACF;IAED,cAAc,GAAA;AACZ,QAAA,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,IAAI,CAAA;QAClC,OAAO,SAAS,CAAC,SAAS,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,CAAA;KAC3C;AAED,IAAA,cAAc,CAAE,kBAA2B,EAAA;AACzC,QAAA,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,IAAI,CAAA;AAElC,QAAA,MAAM,IAAI,GAAG,kBAAkB,GAAG,iBAAiB,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,EAAsB,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,IAAI,CAAA;QACxI,MAAM,UAAU,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAA6B,CAAA;AAC1F,QAAA,OAAO,SAAS,CAAC,IAAI,EAAE,GAAG,UAAU,CAAC,CAAA;KACtC;AACF;;;;"}
|
|
@@ -9,7 +9,7 @@ export declare class MapGraphDataModel<AreaDatum, PointDatum, LinkDatum> extends
|
|
|
9
9
|
private _areas;
|
|
10
10
|
private _points;
|
|
11
11
|
private _links;
|
|
12
|
-
pointId: ((n: PointDatum) => string);
|
|
12
|
+
pointId: ((n: PointDatum, i: number) => string);
|
|
13
13
|
linkSource: ((l: LinkDatum) => number | string | PointDatum);
|
|
14
14
|
linkTarget: ((l: LinkDatum) => number | string | PointDatum);
|
|
15
15
|
get data(): MapGraphData<AreaDatum, PointDatum, LinkDatum>;
|
package/data-models/map-graph.js
CHANGED
|
@@ -9,12 +9,9 @@ class MapGraphDataModel extends CoreDataModel {
|
|
|
9
9
|
this._points = [];
|
|
10
10
|
this._links = [];
|
|
11
11
|
// Model configuration
|
|
12
|
-
|
|
13
|
-
this.
|
|
14
|
-
|
|
15
|
-
this.linkSource = l => l['source'];
|
|
16
|
-
/* eslint-disable-next-line dot-notation */
|
|
17
|
-
this.linkTarget = l => l['target'];
|
|
12
|
+
this.pointId = n => n.id;
|
|
13
|
+
this.linkSource = l => l.source;
|
|
14
|
+
this.linkTarget = l => l.target;
|
|
18
15
|
}
|
|
19
16
|
get data() {
|
|
20
17
|
return this._data;
|
|
@@ -48,7 +45,7 @@ class MapGraphDataModel extends CoreDataModel {
|
|
|
48
45
|
if (isNumber(pointIdentifier))
|
|
49
46
|
foundPoint = points[pointIdentifier];
|
|
50
47
|
else if (isString(pointIdentifier))
|
|
51
|
-
foundPoint = points.find(node => this.pointId(node) === pointIdentifier);
|
|
48
|
+
foundPoint = points.find((node, i) => this.pointId(node, i) === pointIdentifier);
|
|
52
49
|
else if (isObject(pointIdentifier))
|
|
53
50
|
foundPoint = points.find(node => node === pointIdentifier);
|
|
54
51
|
if (!foundPoint) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"map-graph.js","sources":["../../src/data-models/map-graph.ts"],"sourcesContent":["// Utils\nimport { cloneDeep, isNumber, isObject, isString } from 'utils/data'\n\n// Core Data Model\nimport { CoreDataModel } from 'data-models/core'\n\n// Types\nimport { MapLink } from 'types/map'\n\nexport type MapGraphData<AreaDatum, PointDatum, LinkDatum> = {\n areas?: AreaDatum[];\n points?: PointDatum[];\n links?: LinkDatum[];\n}\n\nexport class MapGraphDataModel<AreaDatum, PointDatum, LinkDatum> extends CoreDataModel<MapGraphData<AreaDatum, PointDatum, LinkDatum>> {\n private _areas: AreaDatum[] = []\n private _points: PointDatum[] = []\n private _links: MapLink<PointDatum, LinkDatum>[] = []\n\n // Model configuration\n
|
|
1
|
+
{"version":3,"file":"map-graph.js","sources":["../../src/data-models/map-graph.ts"],"sourcesContent":["// Utils\nimport { cloneDeep, isNumber, isObject, isString } from 'utils/data'\n\n// Core Data Model\nimport { CoreDataModel } from 'data-models/core'\n\n// Types\nimport { MapLink } from 'types/map'\n\nexport type MapGraphData<AreaDatum, PointDatum, LinkDatum> = {\n areas?: AreaDatum[];\n points?: PointDatum[];\n links?: LinkDatum[];\n}\n\nexport class MapGraphDataModel<AreaDatum, PointDatum, LinkDatum> extends CoreDataModel<MapGraphData<AreaDatum, PointDatum, LinkDatum>> {\n private _areas: AreaDatum[] = []\n private _points: PointDatum[] = []\n private _links: MapLink<PointDatum, LinkDatum>[] = []\n\n // Model configuration\n public pointId: ((n: PointDatum, i: number) => string) = n => (n as unknown as {id: string}).id\n public linkSource: ((l: LinkDatum) => number | string | PointDatum) = l => (l as unknown as {source: string}).source\n public linkTarget: ((l: LinkDatum) => number | string | PointDatum) = l => (l as unknown as {target: string}).target\n\n get data (): MapGraphData<AreaDatum, PointDatum, LinkDatum> {\n return this._data\n }\n\n set data (data: MapGraphData<AreaDatum, PointDatum, LinkDatum>) {\n if (!data) return\n this._data = data\n\n this._areas = cloneDeep(data?.areas ?? [])\n this._points = cloneDeep(data?.points ?? [])\n\n this._links = cloneDeep(data?.links ?? []).reduce((arr, link) => {\n const source = this.findPoint(this.points, this.linkSource(link))\n const target = this.findPoint(this.points, this.linkTarget(link))\n if (source && target) arr.push({ source, target })\n return arr\n }, [])\n }\n\n get areas (): AreaDatum[] {\n return this._areas\n }\n\n get points (): PointDatum[] {\n return this._points\n }\n\n get links (): MapLink<PointDatum, LinkDatum>[] {\n return this._links\n }\n\n private findPoint (points: PointDatum[], pointIdentifier: number | string | PointDatum): PointDatum | undefined {\n let foundPoint: PointDatum | undefined\n if (isNumber(pointIdentifier)) foundPoint = points[pointIdentifier as number]\n else if (isString(pointIdentifier)) foundPoint = points.find((node, i) => this.pointId(node, i) === pointIdentifier)\n else if (isObject(pointIdentifier)) foundPoint = points.find(node => node === pointIdentifier)\n\n if (!foundPoint) {\n console.warn(`Point ${pointIdentifier} is missing from the points list`)\n }\n\n return foundPoint\n }\n}\n"],"names":[],"mappings":";;;AAAA;AAeM,MAAO,iBAAoD,SAAQ,aAA6D,CAA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AC,SAAS,eAAe,CAAA,gCAAA,CAAkC,CAAC,CAAA;AACzE,SAAA;AAED,QAAA,OAAO,UAAU,CAAA;KAClB;AACF;;;;"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unovis/ts",
|
|
3
3
|
"description": "Modular data visualization framework for React, Angular, Svelte, and vanilla TypeScript or JavaScript",
|
|
4
|
-
"version": "1.3.
|
|
4
|
+
"version": "1.3.1",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/f5/unovis.git",
|
|
@@ -39,6 +39,7 @@
|
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@rollup/plugin-json": "^4.1.0",
|
|
42
|
+
"@types/to-px": "^1.1.2",
|
|
42
43
|
"@zerollup/ts-transform-paths": "^1.7.18",
|
|
43
44
|
"rimraf": "^3.0.2",
|
|
44
45
|
"rollup": "^2.61.1",
|
|
@@ -56,6 +57,7 @@
|
|
|
56
57
|
"@types/d3": "^7.4.0",
|
|
57
58
|
"@types/d3-collection": "^1.0.10",
|
|
58
59
|
"@types/d3-sankey": "^0.11.2",
|
|
60
|
+
"@types/dagre": "^0.7.50",
|
|
59
61
|
"@types/geojson": "^7946.0.8",
|
|
60
62
|
"@types/leaflet": "1.7.6",
|
|
61
63
|
"@types/supercluster": "^5.0.2",
|
package/styles/colors.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** Array of default colors */
|
|
2
|
-
export declare const colors:
|
|
3
|
-
export declare const colorsDark:
|
|
2
|
+
export declare const colors: string[];
|
|
3
|
+
export declare const colorsDark: string[];
|
|
4
4
|
/** Return a CSS Variable name for a given color index or string */
|
|
5
5
|
export declare const getCSSColorVariable: (suffix: string | number) => string;
|
|
6
6
|
export declare function getLighterColor(hex: string, percentage?: number): string;
|
package/styles/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { UnovisText } from "../types/text";
|
|
2
|
-
export declare const UNOVIS_ICON_FONT_FAMILY_DEFAULT:
|
|
2
|
+
export declare const UNOVIS_ICON_FONT_FAMILY_DEFAULT: string;
|
|
3
3
|
export declare const UNOVIS_FONT_WH_RATIO_DEFAULT: number;
|
|
4
4
|
export declare const UNOVIS_TEXT_SEPARATOR_DEFAULT: string[];
|
|
5
5
|
export declare const UNOVIS_TEXT_HYPHEN_CHARACTER_DEFAULT: string;
|
package/styles/patterns.js
CHANGED
|
@@ -42,7 +42,8 @@ function injectSVGDefs() {
|
|
|
42
42
|
const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
|
|
43
43
|
svg.setAttribute('height', '100%');
|
|
44
44
|
svg.setAttribute('width', '100%');
|
|
45
|
-
svg.
|
|
45
|
+
svg.style.position = 'fixed';
|
|
46
|
+
svg.style.zIndex = '-99999999';
|
|
46
47
|
svg.innerHTML = `<defs>${svgDefs}</defs>`;
|
|
47
48
|
document.body.appendChild(svg);
|
|
48
49
|
}
|