@unovis/ts 1.3.0-beta.2 → 1.3.0-beta.3
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 +10 -6
- package/components/area/config.js +12 -3
- package/components/area/config.js.map +1 -1
- package/components/area/index.d.ts +6 -5
- package/components/area/index.js +9 -10
- package/components/area/index.js.map +1 -1
- package/components/axis/config.d.ts +27 -3
- package/components/axis/config.js +30 -3
- package/components/axis/config.js.map +1 -1
- package/components/axis/index.d.ts +3 -4
- package/components/axis/index.js +4 -7
- package/components/axis/index.js.map +1 -1
- package/components/brush/config.d.ts +12 -2
- package/components/brush/config.js +20 -11
- package/components/brush/config.js.map +1 -1
- package/components/brush/index.d.ts +3 -4
- package/components/brush/index.js +3 -4
- package/components/brush/index.js.map +1 -1
- package/components/bullet-legend/config.d.ts +10 -1
- package/components/bullet-legend/config.js +14 -11
- package/components/bullet-legend/config.js.map +1 -1
- package/components/bullet-legend/index.d.ts +3 -4
- package/components/bullet-legend/index.js +2 -5
- package/components/bullet-legend/index.js.map +1 -1
- package/components/chord-diagram/config.d.ts +23 -7
- package/components/chord-diagram/config.js +22 -3
- package/components/chord-diagram/config.js.map +1 -1
- package/components/chord-diagram/index.d.ts +3 -4
- package/components/chord-diagram/index.js +6 -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 +2 -3
- package/components/chord-diagram/types.js.map +1 -1
- package/components/crosshair/config.d.ts +14 -4
- package/components/crosshair/config.js +16 -3
- package/components/crosshair/config.js.map +1 -1
- package/components/crosshair/index.d.ts +3 -4
- package/components/crosshair/index.js +3 -4
- package/components/crosshair/index.js.map +1 -1
- package/components/donut/config.d.ts +19 -2
- package/components/donut/config.js +24 -5
- package/components/donut/config.js.map +1 -1
- package/components/donut/index.d.ts +3 -4
- package/components/donut/index.js +4 -5
- 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 +11 -1
- package/components/flow-legend/config.js +16 -11
- package/components/flow-legend/config.js.map +1 -1
- package/components/flow-legend/index.d.ts +3 -4
- package/components/flow-legend/index.js +2 -5
- package/components/flow-legend/index.js.map +1 -1
- package/components/free-brush/config.d.ts +12 -2
- package/components/free-brush/config.js +20 -11
- package/components/free-brush/config.js.map +1 -1
- package/components/free-brush/index.d.ts +3 -4
- package/components/free-brush/index.js +5 -6
- package/components/free-brush/index.js.map +1 -1
- package/components/graph/config.d.ts +75 -3
- package/components/graph/config.js +78 -12
- package/components/graph/config.js.map +1 -1
- package/components/graph/index.d.ts +7 -8
- package/components/graph/index.js +3 -4
- package/components/graph/index.js.map +1 -1
- package/components/graph/modules/layout.d.ts +7 -7
- 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/index.d.ts +6 -6
- package/components/graph/modules/node/index.js +2 -2
- 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/grouped-bar/config.d.ts +13 -5
- package/components/grouped-bar/config.js +16 -5
- package/components/grouped-bar/config.js.map +1 -1
- package/components/grouped-bar/index.d.ts +3 -4
- package/components/grouped-bar/index.js +3 -4
- package/components/grouped-bar/index.js.map +1 -1
- package/components/leaflet-flow-map/config.d.ts +16 -2
- package/components/leaflet-flow-map/config.js +21 -3
- package/components/leaflet-flow-map/config.js.map +1 -1
- package/components/leaflet-flow-map/index.d.ts +3 -4
- package/components/leaflet-flow-map/index.js +2 -3
- package/components/leaflet-flow-map/index.js.map +1 -1
- package/components/leaflet-map/config.d.ts +59 -4
- package/components/leaflet-map/config.js +67 -23
- package/components/leaflet-map/config.js.map +1 -1
- package/components/leaflet-map/index.d.ts +3 -4
- package/components/leaflet-map/index.js +3 -4
- package/components/leaflet-map/index.js.map +1 -1
- package/components/leaflet-map/modules/map.d.ts +3 -3
- package/components/leaflet-map/modules/map.js.map +1 -1
- package/components/leaflet-map/modules/utils.d.ts +4 -4
- package/components/leaflet-map/modules/utils.js +2 -6
- 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/line/config.d.ts +11 -6
- package/components/line/config.js +13 -3
- package/components/line/config.js.map +1 -1
- package/components/line/index.d.ts +3 -4
- package/components/line/index.js +4 -5
- package/components/line/index.js.map +1 -1
- package/components/nested-donut/config.d.ts +21 -2
- package/components/nested-donut/config.js +24 -3
- package/components/nested-donut/config.js.map +1 -1
- package/components/nested-donut/index.d.ts +3 -4
- package/components/nested-donut/index.js +3 -4
- 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/sankey/config.d.ts +47 -2
- package/components/sankey/config.js +57 -10
- package/components/sankey/config.js.map +1 -1
- package/components/sankey/index.d.ts +3 -4
- package/components/sankey/index.js +2 -3
- 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 +2 -2
- 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 +16 -4
- package/components/scatter/config.js +19 -5
- package/components/scatter/config.js.map +1 -1
- package/components/scatter/index.d.ts +3 -4
- package/components/scatter/index.js +5 -5
- 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 +13 -5
- package/components/stacked-bar/config.js +16 -5
- package/components/stacked-bar/config.js.map +1 -1
- package/components/stacked-bar/index.d.ts +3 -4
- package/components/stacked-bar/index.js +3 -4
- package/components/stacked-bar/index.js.map +1 -1
- package/components/timeline/config.d.ts +16 -5
- package/components/timeline/config.js +21 -9
- package/components/timeline/config.js.map +1 -1
- package/components/timeline/index.d.ts +3 -4
- package/components/timeline/index.js +3 -4
- package/components/timeline/index.js.map +1 -1
- package/components/tooltip/config.d.ts +15 -1
- package/components/tooltip/config.js +16 -12
- package/components/tooltip/config.js.map +1 -1
- package/components/tooltip/index.d.ts +3 -4
- package/components/tooltip/index.js +3 -5
- package/components/tooltip/index.js.map +1 -1
- package/components/topojson-map/config.d.ts +36 -4
- package/components/topojson-map/config.js +38 -3
- package/components/topojson-map/config.js.map +1 -1
- package/components/topojson-map/index.d.ts +3 -4
- package/components/topojson-map/index.js +4 -4
- package/components/topojson-map/index.js.map +1 -1
- package/components/vis-controls/config.d.ts +5 -1
- package/components/vis-controls/config.js +9 -6
- package/components/vis-controls/config.js.map +1 -1
- package/components/vis-controls/index.d.ts +2 -3
- package/components/vis-controls/index.js +2 -5
- package/components/vis-controls/index.js.map +1 -1
- package/components/xy-labels/config.d.ts +16 -4
- package/components/xy-labels/config.js +20 -5
- package/components/xy-labels/config.js.map +1 -1
- package/components/xy-labels/index.d.ts +3 -4
- package/components/xy-labels/index.js +2 -3
- 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 +4 -2
- package/containers/single-container/config.js +8 -3
- package/containers/single-container/config.js.map +1 -1
- package/containers/single-container/index.d.ts +3 -4
- package/containers/single-container/index.js +2 -2
- package/containers/single-container/index.js.map +1 -1
- package/containers/xy-container/config.d.ts +22 -2
- package/containers/xy-container/config.js +26 -3
- package/containers/xy-container/config.js.map +1 -1
- package/containers/xy-container/index.d.ts +2 -5
- package/containers/xy-container/index.js +2 -2
- package/containers/xy-container/index.js.map +1 -1
- package/core/component/config.d.ts +6 -1
- package/core/component/config.js +12 -6
- package/core/component/config.js.map +1 -1
- package/core/component/index.d.ts +5 -7
- package/core/component/index.js +7 -8
- package/core/component/index.js.map +1 -1
- package/core/config/index.d.ts +3 -0
- package/core/config/index.js +16 -0
- package/core/config/index.js.map +1 -0
- package/core/container/config.d.ts +21 -1
- package/core/container/config.js +25 -21
- package/core/container/config.js.map +1 -1
- package/core/container/index.d.ts +4 -5
- package/core/container/index.js +3 -4
- package/core/container/index.js.map +1 -1
- package/core/xy-component/config.d.ts +10 -2
- package/core/xy-component/config.js +16 -7
- package/core/xy-component/config.js.map +1 -1
- package/core/xy-component/index.d.ts +4 -5
- package/core/xy-component/index.js +0 -2
- package/core/xy-component/index.js.map +1 -1
- package/data-models/map-graph.d.ts +1 -1
- package/data-models/map-graph.js +1 -1
- package/data-models/map-graph.js.map +1 -1
- package/package.json +1 -1
- package/types/accessor.d.ts +1 -1
- package/utils/data.d.ts +1 -1
- package/utils/data.js.map +1 -1
package/core/component/config.js
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
duration: 600,
|
|
3
|
-
events: {},
|
|
4
|
-
attributes: {},
|
|
5
|
-
};
|
|
1
|
+
import { Config } from '../config/index.js';
|
|
6
2
|
|
|
7
|
-
|
|
3
|
+
/* eslint-disable no-irregular-whitespace */
|
|
4
|
+
class ComponentConfig extends Config {
|
|
5
|
+
constructor() {
|
|
6
|
+
super(...arguments);
|
|
7
|
+
this.duration = 600;
|
|
8
|
+
this.events = {};
|
|
9
|
+
this.attributes = {};
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export { ComponentConfig };
|
|
8
14
|
//# sourceMappingURL=config.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sources":["../../../src/core/component/config.ts"],"sourcesContent":["/* eslint-disable no-irregular-whitespace */\nimport { VisEventCallback, VisEventType } from 'core/component/types'\n\nexport interface ComponentConfigInterface {\n /** Animation duration of the data update transitions in milliseconds. Default: `600` */\n duration?: number;\n /** Events configuration. An object containing properties in the following format:\n *\n * ```\n * {\n * [selectorString]: {\n * [eventType]: callbackFunction\n * }\n * }\n * ```\n * e.g.:\n * ```\n * {\n * [Area.selectors.area]: {\n * click: (d) => console.log(\"Clicked Area\", d)\n * }\n * }\n * ```\n */\n events?: {\n [selector: string]: {\n [eventType in VisEventType]?: VisEventCallback;\n };\n };\n /** You can set every SVG and HTML visualization object to have a custom DOM attributes, which is useful\n * when you want to do unit or end-to-end testing. Attributes configuration object has the following structure:\n *\n * ```\n * {\n * [selectorString]: {\n * [attributeName]: attribute constant value or accessor function\n * }\n * }\n * ```\n * e.g.:\n * ```\n * {\n * [Area.selectors.area]: {\n * \"test-value\": d => d.value\n * }\n * }\n * ```\n */\n attributes?: {\n [selector: string]: {\n [attr: string]: string | number | boolean | ((datum: any) => string | number | boolean);\n };\n };\n}\n\nexport
|
|
1
|
+
{"version":3,"file":"config.js","sources":["../../../src/core/component/config.ts"],"sourcesContent":["/* eslint-disable no-irregular-whitespace */\nimport { Config } from 'core/config'\nimport { VisEventCallback, VisEventType } from 'core/component/types'\n\nexport interface ComponentConfigInterface {\n /** Animation duration of the data update transitions in milliseconds. Default: `600` */\n duration?: number;\n /** Events configuration. An object containing properties in the following format:\n *\n * ```\n * {\n * [selectorString]: {\n * [eventType]: callbackFunction\n * }\n * }\n * ```\n * e.g.:\n * ```\n * {\n * [Area.selectors.area]: {\n * click: (d) => console.log(\"Clicked Area\", d)\n * }\n * }\n * ```\n */\n events?: {\n [selector: string]: {\n [eventType in VisEventType]?: VisEventCallback;\n };\n };\n /** You can set every SVG and HTML visualization object to have a custom DOM attributes, which is useful\n * when you want to do unit or end-to-end testing. Attributes configuration object has the following structure:\n *\n * ```\n * {\n * [selectorString]: {\n * [attributeName]: attribute constant value or accessor function\n * }\n * }\n * ```\n * e.g.:\n * ```\n * {\n * [Area.selectors.area]: {\n * \"test-value\": d => d.value\n * }\n * }\n * ```\n */\n attributes?: {\n [selector: string]: {\n [attr: string]: string | number | boolean | ((datum: any) => string | number | boolean);\n };\n };\n}\n\nexport class ComponentConfig extends Config implements ComponentConfigInterface {\n duration = 600\n events = {}\n attributes = {}\n}\n"],"names":[],"mappings":";;AAAA;AAwDM,MAAO,eAAgB,SAAQ,MAAM,CAAA;AAA3C,IAAA,WAAA,GAAA;;QACE,IAAQ,CAAA,QAAA,GAAG,GAAG,CAAA;QACd,IAAM,CAAA,MAAA,GAAG,EAAE,CAAA;QACX,IAAU,CAAA,UAAA,GAAG,EAAE,CAAA;KAChB;AAAA;;;;"}
|
|
@@ -3,23 +3,21 @@ import { CoreDataModel } from "../../data-models/core";
|
|
|
3
3
|
import { ComponentType, Sizing } from "../../types/component";
|
|
4
4
|
import { Spacing } from "../../types/spacing";
|
|
5
5
|
import { VisEventCallback, VisEventType } from './types';
|
|
6
|
-
import { ComponentConfigInterface } from './config';
|
|
7
|
-
export declare class ComponentCore<CoreDatum, ConfigInterface extends ComponentConfigInterface = ComponentConfigInterface> {
|
|
6
|
+
import { ComponentConfig, ComponentConfigInterface } from './config';
|
|
7
|
+
export declare class ComponentCore<CoreDatum, ConfigClass extends ComponentConfig = ComponentConfig, ConfigInterface extends ComponentConfigInterface = ComponentConfigInterface> {
|
|
8
8
|
element: SVGGElement | HTMLElement;
|
|
9
9
|
type: ComponentType;
|
|
10
10
|
g: Selection<SVGGElement, unknown, null, undefined> | Selection<HTMLElement, unknown, null, undefined>;
|
|
11
|
-
config:
|
|
12
|
-
prevConfig:
|
|
11
|
+
config: ConfigClass;
|
|
12
|
+
prevConfig: ConfigClass;
|
|
13
13
|
datamodel: CoreDataModel<CoreDatum>;
|
|
14
14
|
sizing: Sizing | string;
|
|
15
15
|
uid: string;
|
|
16
|
-
|
|
16
|
+
events: {
|
|
17
17
|
[selector: string]: {
|
|
18
18
|
[eventType in VisEventType]?: VisEventCallback;
|
|
19
19
|
};
|
|
20
20
|
};
|
|
21
|
-
/** Default configuration */
|
|
22
|
-
protected _defaultConfig: ComponentConfigInterface;
|
|
23
21
|
/** Component width in pixels. This property is set automatically by the container. */
|
|
24
22
|
protected _width: number;
|
|
25
23
|
/** Component height in pixels. This property is set automatically by the container. */
|
package/core/component/index.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { select } from 'd3-selection';
|
|
2
2
|
import { CoreDataModel } from '../../data-models/core.js';
|
|
3
|
-
import { throttle
|
|
3
|
+
import { throttle } 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';
|
|
7
6
|
|
|
8
7
|
class ComponentCore {
|
|
9
8
|
constructor(type = ComponentType.SVG) {
|
|
@@ -12,8 +11,6 @@ class ComponentCore {
|
|
|
12
11
|
this.datamodel = new CoreDataModel();
|
|
13
12
|
this.sizing = Sizing.Fit; // Supported by SingleContainer and a subset of components only (Sankey)
|
|
14
13
|
this.events = {};
|
|
15
|
-
/** Default configuration */
|
|
16
|
-
this._defaultConfig = ComponentDefaultConfig;
|
|
17
14
|
/** Component width in pixels. This property is set automatically by the container. */
|
|
18
15
|
this._width = 400;
|
|
19
16
|
/** Component height in pixels. This property is set automatically by the container. */
|
|
@@ -39,8 +36,10 @@ class ComponentCore {
|
|
|
39
36
|
this.g.attr('class', rootClass);
|
|
40
37
|
}
|
|
41
38
|
setConfig(config) {
|
|
39
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
40
|
+
const ConfigModel = this.config.constructor;
|
|
42
41
|
this.prevConfig = this.config; // Store the previous config instance
|
|
43
|
-
this.config =
|
|
42
|
+
this.config = new ConfigModel().init(config);
|
|
44
43
|
}
|
|
45
44
|
setData(data) {
|
|
46
45
|
this.datamodel.data = data;
|
|
@@ -81,9 +80,9 @@ class ComponentCore {
|
|
|
81
80
|
const attributeMap = this.config.attributes;
|
|
82
81
|
Object.keys(attributeMap).forEach(className => {
|
|
83
82
|
Object.keys(attributeMap[className]).forEach(attr => {
|
|
84
|
-
|
|
85
|
-
.selectAll(`.${className}`)
|
|
86
|
-
|
|
83
|
+
this.g
|
|
84
|
+
.selectAll(`.${className}`)
|
|
85
|
+
.attr(attr, attributeMap[className][attr]);
|
|
87
86
|
});
|
|
88
87
|
});
|
|
89
88
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/core/component/index.ts"],"sourcesContent":["import { select, Selection
|
|
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;AAC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AC,SAAS,IAAG;AACtC,YAAA,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,SAAS,IAAG;AACjD,gBAAA,MAAM,SAAS,GAAI,IAAI,CAAC,CAAoE,CAAC,SAAS,CAAC,CAAI,CAAA,EAAA,SAAS,CAAE,CAAA,CAAC,CAAA;AACvH,gBAAA,SAAS,CAAC,EAAE,CAAC,SAAS,GAAG,MAAM,EAAE,CAAC,KAAY,EAAE,CAAC,KAAI;AACnD,oBAAA,MAAM,GAAG,GAAG,SAAS,CAAC,KAAK,EAAE,CAAA;oBAC7B,MAAM,CAAC,GAAG,GAAG,CAAC,OAAO,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;;;;"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { isPlainObject, merge } from '../../utils/data.js';
|
|
2
|
+
|
|
3
|
+
class Config {
|
|
4
|
+
init(config) {
|
|
5
|
+
Object.keys(config).forEach(key => {
|
|
6
|
+
if (isPlainObject(this[key]) && isPlainObject(config[key]))
|
|
7
|
+
this[key] = merge(this[key], config[key]);
|
|
8
|
+
else
|
|
9
|
+
this[key] = config[key];
|
|
10
|
+
});
|
|
11
|
+
return this;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export { Config };
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/core/config/index.ts"],"sourcesContent":["import { isPlainObject, merge } from 'utils/data'\n\nexport class Config {\n init<T> (config: T): this {\n Object.keys(config).forEach(key => {\n if (isPlainObject(this[key]) && isPlainObject(config[key])) this[key] = merge(this[key], config[key])\n else this[key] = config[key]\n })\n\n return this\n }\n}\n"],"names":[],"mappings":";;MAEa,MAAM,CAAA;AACjB,IAAA,IAAI,CAAK,MAAS,EAAA;QAChB,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,GAAG,IAAG;AAChC,YAAA,IAAI,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,aAAa,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;AAAE,gBAAA,IAAI,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAA;;gBAChG,IAAI,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,CAAA;AAC9B,SAAC,CAAC,CAAA;AAEF,QAAA,OAAO,IAAI,CAAA;KACZ;AACF;;;;"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Config } from "../config";
|
|
1
2
|
import { Sizing } from "../../types/component";
|
|
2
3
|
import { Spacing } from "../../types/spacing";
|
|
3
4
|
export interface ContainerConfigInterface {
|
|
@@ -30,4 +31,23 @@ export interface ContainerConfigInterface {
|
|
|
30
31
|
*/
|
|
31
32
|
ariaLabel?: string | null | undefined;
|
|
32
33
|
}
|
|
33
|
-
export declare
|
|
34
|
+
export declare class ContainerConfig extends Config implements ContainerConfigInterface {
|
|
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
|
+
}
|
package/core/container/config.js
CHANGED
|
@@ -1,26 +1,30 @@
|
|
|
1
|
+
import { Config } from '../config/index.js';
|
|
1
2
|
import { Sizing } from '../../types/component.js';
|
|
2
3
|
|
|
3
4
|
// Core
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
5
|
+
class ContainerConfig extends Config {
|
|
6
|
+
constructor() {
|
|
7
|
+
super(...arguments);
|
|
8
|
+
this.duration = undefined;
|
|
9
|
+
this.margin = {
|
|
10
|
+
top: 0,
|
|
11
|
+
bottom: 0,
|
|
12
|
+
left: 0,
|
|
13
|
+
right: 0,
|
|
14
|
+
};
|
|
15
|
+
this.padding = {
|
|
16
|
+
top: 0,
|
|
17
|
+
bottom: 0,
|
|
18
|
+
left: 0,
|
|
19
|
+
right: 0,
|
|
20
|
+
};
|
|
21
|
+
this.sizing = Sizing.Fit;
|
|
22
|
+
this.width = undefined;
|
|
23
|
+
this.height = undefined;
|
|
24
|
+
this.svgDefs = undefined;
|
|
25
|
+
this.ariaLabel = undefined;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
24
28
|
|
|
25
|
-
export {
|
|
29
|
+
export { ContainerConfig };
|
|
26
30
|
//# sourceMappingURL=config.js.map
|
|
@@ -1 +1 @@
|
|
|
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
|
|
1
|
+
{"version":3,"file":"config.js","sources":["../../../src/core/container/config.ts"],"sourcesContent":["// Core\nimport { Config } from 'core/config'\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 class ContainerConfig extends Config implements 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;AAsCM,MAAO,eAAgB,SAAQ,MAAM,CAAA;AAA3C,IAAA,WAAA,GAAA;;QACE,IAAQ,CAAA,QAAA,GAAG,SAAS,CAAA;AACpB,QAAA,IAAA,CAAA,MAAM,GAAG;AACP,YAAA,GAAG,EAAE,CAAC;AACN,YAAA,MAAM,EAAE,CAAC;AACT,YAAA,IAAI,EAAE,CAAC;AACP,YAAA,KAAK,EAAE,CAAC;SACT,CAAA;AAED,QAAA,IAAA,CAAA,OAAO,GAAG;AACR,YAAA,GAAG,EAAE,CAAC;AACN,YAAA,MAAM,EAAE,CAAC;AACT,YAAA,IAAI,EAAE,CAAC;AACP,YAAA,KAAK,EAAE,CAAC;SACT,CAAA;AAED,QAAA,IAAA,CAAA,MAAM,GAAG,MAAM,CAAC,GAAG,CAAA;QACnB,IAAK,CAAA,KAAA,GAAG,SAAS,CAAA;QACjB,IAAM,CAAA,MAAA,GAAG,SAAS,CAAA;QAElB,IAAO,CAAA,OAAA,GAAG,SAAS,CAAA;QACnB,IAAS,CAAA,SAAA,GAAG,SAAS,CAAA;KACtB;AAAA;;;;"}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { Selection } from 'd3-selection';
|
|
2
|
-
import { ContainerConfigInterface } from './config';
|
|
2
|
+
import { ContainerConfig, 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:
|
|
8
|
-
protected _defaultConfig: ContainerConfigInterface;
|
|
6
|
+
prevConfig: ContainerConfig;
|
|
7
|
+
config: ContainerConfig;
|
|
9
8
|
protected _container: HTMLElement;
|
|
10
9
|
protected _requestedAnimationFrame: number;
|
|
11
10
|
protected _isFirstRender: boolean;
|
|
@@ -17,7 +16,7 @@ export declare class ContainerCore {
|
|
|
17
16
|
updateContainer<T extends ContainerConfigInterface>(config: T): void;
|
|
18
17
|
protected _preRender(): void;
|
|
19
18
|
protected _render(duration?: number): void;
|
|
20
|
-
render(duration?:
|
|
19
|
+
render(duration?: any): void;
|
|
21
20
|
get containerWidth(): number;
|
|
22
21
|
get containerHeight(): number;
|
|
23
22
|
get width(): number;
|
package/core/container/index.js
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { select } from 'd3-selection';
|
|
2
2
|
import { Sizing } from '../../types/component.js';
|
|
3
|
-
import {
|
|
3
|
+
import { clamp, isEqual } from '../../utils/data.js';
|
|
4
4
|
import { ResizeObserver } from '../../utils/resize-observer.js';
|
|
5
|
-
import { ContainerDefaultConfig } from './config.js';
|
|
6
5
|
|
|
7
6
|
class ContainerCore {
|
|
8
7
|
constructor(element) {
|
|
9
|
-
this._defaultConfig = ContainerDefaultConfig;
|
|
10
8
|
this._isFirstRender = true;
|
|
11
9
|
this._requestedAnimationFrame = null;
|
|
12
10
|
this._container = element;
|
|
@@ -26,8 +24,9 @@ class ContainerCore {
|
|
|
26
24
|
}
|
|
27
25
|
updateContainer(config) {
|
|
28
26
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
27
|
+
const ConfigModel = this.config.constructor;
|
|
29
28
|
this.prevConfig = this.config;
|
|
30
|
-
this.config =
|
|
29
|
+
this.config = new ConfigModel().init(config);
|
|
31
30
|
}
|
|
32
31
|
// The `_preRender` step should be used to perform some actions before rendering.
|
|
33
32
|
// 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, 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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9D,MAAM,oBAAoB,GAAG,IAAI,CAAC,UAAU,CAAC,qBAAqB,EAAE,CAAA;AACpE,YAAA,MAAM,oBAAoB,GAAG,EAAE,KAAK,EAAE,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,oBAAoB,CAAC,MAAM,EAAE,CAAA;YACvG,MAAM,cAAc,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,cAAc,EAAE,oBAAoB,CAAC,CAAA;;;YAG1E,IAAI,cAAc,IAAI,oBAAoB,CAAC,KAAK,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
|
+
{"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?.disconnect()\n this.svg.remove()\n }\n}\n"],"names":[],"mappings":";;;;;MAYa,aAAa,CAAA;AAgBxB,IAAA,WAAA,CAAa,OAAoB,EAAA;QARvB,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;QAE5B,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;QACvC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAA;KAC/B;AAEM,IAAA,eAAe,CAAsC,MAAS,EAAA;;AAEnE,QAAA,MAAM,WAAW,GAAI,IAAI,CAAC,MAAM,CAAC,WAAsC,CAAA;AACvE,QAAA,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,MAAM,CAAA;QAC7B,IAAI,CAAC,MAAM,GAAG,IAAI,WAAW,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;KAC7C;;;;AAKS,IAAA,UAAU,MAAY;;AAGtB,IAAA,OAAO,CAAE,QAAiB,EAAA;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,GAAA,EAAA,CAAA,UAAU,EAAE,CAAA;AAClC,QAAA,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,CAAA;KAClB;;AArID;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 { ComponentConfigInterface } from '../component/config';
|
|
3
|
+
import { ComponentConfig, 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,4 +27,12 @@ export interface XYComponentConfigInterface<Datum> extends ComponentConfigInterf
|
|
|
27
27
|
*/
|
|
28
28
|
excludeFromDomainCalculation?: boolean;
|
|
29
29
|
}
|
|
30
|
-
export declare
|
|
30
|
+
export declare class XYComponentConfig<Datum> extends ComponentConfig implements XYComponentConfigInterface<Datum> {
|
|
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
|
+
}
|
|
@@ -1,11 +1,20 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ComponentConfig } from '../component/config.js';
|
|
2
2
|
|
|
3
3
|
// Config
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
class XYComponentConfig extends ComponentConfig {
|
|
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
|
+
}
|
|
9
18
|
|
|
10
|
-
export {
|
|
19
|
+
export { XYComponentConfig };
|
|
11
20
|
//# 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 { ComponentConfig, 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 class XYComponentConfig<Datum> extends ComponentConfig implements XYComponentConfigInterface<Datum> {\n x = undefined\n y = undefined\n // eslint-disable-next-line dot-notation\n id = (d: Datum, i: number): string => d['id'] ?? `${i}`\n // eslint-disable-next-line dot-notation\n color = (d: Datum | Datum[]): string => d['color']\n xScale = undefined\n yScale = undefined\n excludeFromDomainCalculation = false\n}\n"],"names":[],"mappings":";;AAKA;AA8BM,MAAO,iBAAyB,SAAQ,eAAe,CAAA;AAA7D,IAAA,WAAA,GAAA;;QACE,IAAC,CAAA,CAAA,GAAG,SAAS,CAAA;QACb,IAAC,CAAA,CAAA,GAAG,SAAS,CAAA;;QAEb,IAAE,CAAA,EAAA,GAAG,CAAC,CAAQ,EAAE,CAAS,eAAa,OAAA,CAAA,EAAA,GAAA,CAAC,CAAC,IAAI,CAAC,MAAI,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,EAAA,GAAA,CAAA,EAAG,CAAC,CAAE,CAAA,CAAA,EAAA,CAAA;;QAEvD,IAAK,CAAA,KAAA,GAAG,CAAC,CAAkB,KAAa,CAAC,CAAC,OAAO,CAAC,CAAA;QAClD,IAAM,CAAA,MAAA,GAAG,SAAS,CAAA;QAClB,IAAM,CAAA,MAAA,GAAG,SAAS,CAAA;QAClB,IAA4B,CAAA,4BAAA,GAAG,KAAK,CAAA;KACrC;AAAA;;;;"}
|
|
@@ -2,18 +2,17 @@ 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 { XYComponentConfigInterface } from './config';
|
|
6
|
-
export declare class XYComponentCore<Datum, ConfigInterface extends Partial<XYComponentConfigInterface<Datum>> = Partial<XYComponentConfigInterface<Datum>>> extends ComponentCore<Datum[], ConfigInterface> {
|
|
5
|
+
import { XYComponentConfig, XYComponentConfigInterface } from './config';
|
|
6
|
+
export declare class XYComponentCore<Datum, ConfigClass extends XYComponentConfig<Datum> = XYComponentConfig<Datum>, ConfigInterface extends Partial<XYComponentConfigInterface<Datum>> = Partial<XYComponentConfigInterface<Datum>>> extends ComponentCore<Datum[], ConfigClass, ConfigInterface> {
|
|
7
7
|
element: SVGGraphicsElement;
|
|
8
8
|
g: Selection<SVGGElement, unknown, null, undefined>;
|
|
9
|
-
config:
|
|
10
|
-
prevConfig:
|
|
9
|
+
config: ConfigClass;
|
|
10
|
+
prevConfig: ConfigClass;
|
|
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;
|
|
17
16
|
private _xScale;
|
|
18
17
|
private _yScale;
|
|
19
18
|
get xScale(): ContinuousScale;
|
|
@@ -2,7 +2,6 @@ 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';
|
|
6
5
|
|
|
7
6
|
// Core
|
|
8
7
|
class XYComponentCore extends ComponentCore {
|
|
@@ -13,7 +12,6 @@ class XYComponentCore extends ComponentCore {
|
|
|
13
12
|
this.clippable = true;
|
|
14
13
|
/** Identifies whether the component displayed stacked data (eg StackedBar, Area) */
|
|
15
14
|
this.stacked = false;
|
|
16
|
-
this._defaultConfig = XYComponentDefaultConfig;
|
|
17
15
|
this._xScale = Scale.scaleLinear();
|
|
18
16
|
this._yScale = Scale.scaleLinear();
|
|
19
17
|
}
|
|
@@ -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 { XYComponentConfig, XYComponentConfigInterface } from './config'\n\nexport class XYComponentCore<\n Datum,\n ConfigClass extends XYComponentConfig<Datum> = XYComponentConfig<Datum>,\n ConfigInterface extends Partial<XYComponentConfigInterface<Datum>> = Partial<XYComponentConfigInterface<Datum>>,\n> extends ComponentCore<Datum[], ConfigClass, ConfigInterface> {\n element: SVGGraphicsElement\n g: Selection<SVGGElement, unknown, null, undefined>\n config: ConfigClass\n prevConfig: ConfigClass\n datamodel: SeriesDataModel<Datum> = new SeriesDataModel()\n\n /** Clippable components can be affected by a clipping path (set up in the container) */\n clippable = true\n\n /** Identifies whether the component displayed stacked data (eg StackedBar, Area) */\n stacked = false\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,eAIX,SAAQ,aAAoD,CAAA;AAJ9D,IAAA,WAAA,GAAA;;AASE,QAAA,IAAA,CAAA,SAAS,GAA2B,IAAI,eAAe,EAAE,CAAA;;QAGzD,IAAS,CAAA,SAAA,GAAG,IAAI,CAAA;;QAGhB,IAAO,CAAA,OAAA,GAAG,KAAK,CAAA;AAEP,QAAA,IAAA,CAAA,OAAO,GAAoB,KAAK,CAAC,WAAW,EAAE,CAAA;AAC9C,QAAA,IAAA,CAAA,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AE,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
|
|
12
|
+
pointId: ((n: PointDatum) => 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
|
@@ -48,7 +48,7 @@ class MapGraphDataModel extends CoreDataModel {
|
|
|
48
48
|
if (isNumber(pointIdentifier))
|
|
49
49
|
foundPoint = points[pointIdentifier];
|
|
50
50
|
else if (isString(pointIdentifier))
|
|
51
|
-
foundPoint = points.find(
|
|
51
|
+
foundPoint = points.find(node => this.pointId(node) === pointIdentifier);
|
|
52
52
|
else if (isObject(pointIdentifier))
|
|
53
53
|
foundPoint = points.find(node => node === pointIdentifier);
|
|
54
54
|
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 /* eslint-disable-next-line dot-notation */\n public pointId: ((n: PointDatum
|
|
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 /* eslint-disable-next-line dot-notation */\n public pointId: ((n: PointDatum) => string) = n => n['id']\n /* eslint-disable-next-line dot-notation */\n public linkSource: ((l: LinkDatum) => number | string | PointDatum) = l => l['source']\n /* eslint-disable-next-line dot-notation */\n public linkTarget: ((l: LinkDatum) => number | string | PointDatum) = l => l['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 => this.pointId(node) === 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,CAAA;AAAtI,IAAA,WAAA,GAAA;;QACU,IAAM,CAAA,MAAA,GAAgB,EAAE,CAAA;QACxB,IAAO,CAAA,OAAA,GAAiB,EAAE,CAAA;QAC1B,IAAM,CAAA,MAAA,GAAqC,EAAE,CAAA;;;QAI9C,IAAO,CAAA,OAAA,GAAgC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAA;;QAEnD,IAAU,CAAA,UAAA,GAAqD,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,CAAA;;QAE/E,IAAU,CAAA,UAAA,GAAqD,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,CAAA;KA6CvF;AA3CC,IAAA,IAAI,IAAI,GAAA;QACN,OAAO,IAAI,CAAC,KAAK,CAAA;KAClB;IAED,IAAI,IAAI,CAAE,IAAoD,EAAA;;AAC5D,QAAA,IAAI,CAAC,IAAI;YAAE,OAAM;AACjB,QAAA,IAAI,CAAC,KAAK,GAAG,IAAI,CAAA;AAEjB,QAAA,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC,MA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A,IAAI,KAAK,GAAA;QACP,OAAO,IAAI,CAAC,MAAM,CAAA;KACnB;IAEO,SAAS,CAAE,MAAoB,EAAE,eAA6C,EAAA;AACpF,QAAA,IAAI,UAAkC,CAAA;QACtC,IAAI,QAAQ,CAAC,eAAe,CAAC;AAAE,YAAA,UAAU,GAAG,MAAM,CAAC,eAAyB,CAAC,CAAA;aACxE,IAAI,QAAQ,CAAC,eAAe,CAAC;AAAE,YAAA,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,eAAe,CAAC,CAAA;aACvG,IAAI,QAAQ,CAAC,eAAe,CAAC;AAAE,YAAA,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,IAAI,IAAI,KAAK,eAAe,CAAC,CAAA;QAE9F,IAAI,CAAC,UAAU,EAAE;AACf,YAAA,OAAO,CAAC,IAAI,CAAC,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.0-beta.
|
|
4
|
+
"version": "1.3.0-beta.3",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/f5/unovis.git",
|
package/types/accessor.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare type NumericAccessor<Datum> = ((d: Datum, i: number, ...any: any[]) => number | null | undefined) | number | null | undefined;
|
|
2
2
|
export declare type StringAccessor<Datum> = ((d: Datum, i: number, ...any: any[]) => string | null | undefined) | string | null;
|
|
3
|
-
export declare type ColorAccessor<Datum> = ((d: Datum, i: number, ...any: any[]) => string | null | undefined) | string | null | undefined;
|
|
3
|
+
export declare type ColorAccessor<Datum> = ((d: Datum, i: number, ...any: any[]) => string | null | undefined) | string | string[] | null | undefined;
|
|
4
4
|
export declare type BooleanAccessor<Datum> = ((d: Datum, i: number, ...any: any[]) => boolean | null | undefined) | boolean | null | undefined;
|
|
5
5
|
export declare type GenericAccessor<ReturnType, Datum> = ((d: Datum, i: number, ...any: any[]) => ReturnType | null | undefined) | ReturnType | null | undefined;
|