@unovis/ts 1.3.0-alpha.4 → 1.3.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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 +7 -4
- 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/bullet-legend/modules/shape.js +7 -6
- package/components/bullet-legend/modules/shape.js.map +1 -1
- package/components/bullet-legend/style.js +4 -0
- package/components/bullet-legend/style.js.map +1 -1
- package/components/chord-diagram/config.d.ts +7 -23
- package/components/chord-diagram/config.js +3 -22
- package/components/chord-diagram/config.js.map +1 -1
- package/components/chord-diagram/index.d.ts +4 -3
- package/components/chord-diagram/index.js +7 -6
- 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 +12 -15
- 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 +2 -19
- package/components/donut/config.js +5 -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 +6 -5
- package/components/free-brush/index.js.map +1 -1
- package/components/graph/config.d.ts +3 -75
- package/components/graph/config.js +12 -78
- package/components/graph/config.js.map +1 -1
- package/components/graph/index.d.ts +8 -7
- package/components/graph/index.js +5 -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 +5 -13
- package/components/grouped-bar/config.js +5 -16
- package/components/grouped-bar/config.js.map +1 -1
- package/components/grouped-bar/index.d.ts +4 -3
- package/components/grouped-bar/index.js +4 -3
- 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 +23 -67
- package/components/leaflet-map/config.js.map +1 -1
- package/components/leaflet-map/index.d.ts +4 -3
- package/components/leaflet-map/index.js +4 -3
- 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 +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/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 +4 -3
- package/components/line/index.js +5 -4
- 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 +4 -3
- 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 +2 -47
- package/components/sankey/config.js +10 -57
- 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 +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 +4 -16
- package/components/scatter/config.js +5 -19
- package/components/scatter/config.js.map +1 -1
- package/components/scatter/index.d.ts +4 -3
- 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 +5 -13
- package/components/stacked-bar/config.js +5 -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 +9 -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 +4 -3
- package/components/tooltip/index.js +5 -3
- package/components/tooltip/index.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 -4
- 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 +5 -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 +4 -2
- package/containers/single-container/index.js.map +1 -1
- package/containers/xy-container/config.d.ts +3 -23
- 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 -3
- package/containers/xy-container/index.js +5 -5
- 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 +8 -7
- 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 +6 -4
- package/core/container/index.js +5 -3
- package/core/container/index.js.map +1 -1
- package/core/xy-component/config.d.ts +2 -10
- package/core/xy-component/config.js +7 -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 +1 -1
- package/data-models/map-graph.js.map +1 -1
- package/package.json +1 -1
- package/styles/index.js +26 -1
- package/styles/index.js.map +1 -1
- package/styles/patterns.d.ts +17 -0
- package/styles/patterns.js +53 -0
- package/styles/patterns.js.map +1 -0
- package/types/accessor.d.ts +1 -1
- package/utils/data.d.ts +1 -1
- package/utils/data.js.map +1 -1
- package/core/config/index.d.ts +0 -3
- package/core/config/index.js +0 -16
- package/core/config/index.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ComponentConfigInterface
|
|
1
|
+
import { ComponentConfigInterface } from "../../core/component/config";
|
|
2
2
|
import { ColorAccessor, NumericAccessor } from "../../types/accessor";
|
|
3
3
|
export interface DonutConfigInterface<Datum> extends ComponentConfigInterface {
|
|
4
4
|
/** Accessor function for getting the unique data record id. Used for more persistent data updates. Default: `(d, i) => d.id ?? i` */
|
|
@@ -39,21 +39,4 @@ export interface DonutConfigInterface<Datum> extends ComponentConfigInterface {
|
|
|
39
39
|
/** Background angle range. When undefined, the value will be taken from `angleRange`. Default: `undefined` */
|
|
40
40
|
backgroundAngleRange?: [number, number];
|
|
41
41
|
}
|
|
42
|
-
export declare
|
|
43
|
-
id: (d: Datum, i: number) => string | number;
|
|
44
|
-
value: any;
|
|
45
|
-
angleRange: [number, number];
|
|
46
|
-
padAngle: number;
|
|
47
|
-
sortFunction: any;
|
|
48
|
-
cornerRadius: number;
|
|
49
|
-
color: any;
|
|
50
|
-
radius: any;
|
|
51
|
-
arcWidth: number;
|
|
52
|
-
centralLabel: any;
|
|
53
|
-
centralSubLabel: any;
|
|
54
|
-
centralSubLabelWrap: boolean;
|
|
55
|
-
showEmptySegments: boolean;
|
|
56
|
-
emptySegmentAngle: number;
|
|
57
|
-
showBackground: boolean;
|
|
58
|
-
backgroundAngleRange: any;
|
|
59
|
-
}
|
|
42
|
+
export declare const DonutDefaultConfig: DonutConfigInterface<unknown>;
|
|
@@ -1,28 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ComponentDefaultConfig } from '../../core/component/config.js';
|
|
2
2
|
|
|
3
3
|
// Core
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
// eslint-disable-next-line dot-notation
|
|
8
|
-
this.id = (d, i) => { var _a; return (_a = d['id']) !== null && _a !== void 0 ? _a : i; };
|
|
9
|
-
this.value = undefined;
|
|
10
|
-
this.angleRange = [0, 2 * Math.PI];
|
|
11
|
-
this.padAngle = 0;
|
|
12
|
-
this.sortFunction = undefined;
|
|
13
|
-
this.cornerRadius = 0;
|
|
14
|
-
this.color = undefined;
|
|
15
|
-
this.radius = undefined;
|
|
16
|
-
this.arcWidth = 20;
|
|
17
|
-
this.centralLabel = undefined;
|
|
18
|
-
this.centralSubLabel = undefined;
|
|
19
|
-
this.centralSubLabelWrap = true;
|
|
20
|
-
this.showEmptySegments = false;
|
|
21
|
-
this.emptySegmentAngle = 0.5 * Math.PI / 180;
|
|
22
|
-
this.showBackground = true;
|
|
23
|
-
this.backgroundAngleRange = undefined;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
4
|
+
const DonutDefaultConfig = Object.assign(Object.assign({}, ComponentDefaultConfig), {
|
|
5
|
+
// eslint-disable-next-line dot-notation
|
|
6
|
+
id: (d, i) => { var _a; return (_a = d['id']) !== null && _a !== void 0 ? _a : i; }, value: undefined, angleRange: [0, 2 * Math.PI], padAngle: 0, sortFunction: undefined, cornerRadius: 0, color: undefined, radius: undefined, arcWidth: 20, centralLabel: undefined, centralSubLabel: undefined, centralSubLabelWrap: true, showEmptySegments: false, emptySegmentAngle: 0.5 * Math.PI / 180, showBackground: true, backgroundAngleRange: undefined });
|
|
26
7
|
|
|
27
|
-
export {
|
|
8
|
+
export { DonutDefaultConfig };
|
|
28
9
|
//# sourceMappingURL=config.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sources":["../../../src/components/donut/config.ts"],"sourcesContent":["// Core\nimport { ComponentConfigInterface,
|
|
1
|
+
{"version":3,"file":"config.js","sources":["../../../src/components/donut/config.ts"],"sourcesContent":["// Core\nimport { ComponentConfigInterface, ComponentDefaultConfig } from 'core/component/config'\n\n// Types\nimport { ColorAccessor, NumericAccessor } from 'types/accessor'\n\nexport interface DonutConfigInterface<Datum> extends ComponentConfigInterface {\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) => string | number);\n /** Value accessor function. Default: `undefined` */\n value: NumericAccessor<Datum>;\n /** Diagram angle range. Default: `[0, 2 * Math.PI]` */\n angleRange?: [number, number];\n /** Pad angle. Default: `0` */\n padAngle?: number;\n /** Custom sort function. Default: `undefined` */\n sortFunction?: (a: Datum, b: Datum) => number;\n /** Corner Radius. Default: `0` */\n cornerRadius?: number;\n /** Color accessor function. Default: `undefined` */\n color?: ColorAccessor<Datum>;\n /** Explicitly set the donut outer radius. Default: `undefined` */\n radius?: number;\n /** Arc width in pixels. Set to `0` if you want to have a pie chart. Default: `20` */\n arcWidth?: number;\n /** Central label accessor function or text. Default: `undefined` */\n centralLabel?: string;\n /** Central sub-label accessor function or text. Default: `undefined` */\n centralSubLabel?: string;\n /** Enables wrapping for the sub-label. Default: `true` */\n centralSubLabelWrap?: boolean;\n /** When true, the component will display empty segments (the ones that have `0` values) as tiny slices.\n * Default: `false`\n */\n showEmptySegments?: boolean;\n /** Angular size for empty segments in radians. Default: `0.5 * Math.PI / 180` */\n emptySegmentAngle?: number;\n /** Show donut background. The color is configurable via\n * the `--vis-donut-background-color` and `--vis-dark-donut-background-color` CSS variables.\n * Default: `true`\n */\n showBackground?: boolean;\n /** Background angle range. When undefined, the value will be taken from `angleRange`. Default: `undefined` */\n backgroundAngleRange?: [number, number];\n}\n\nexport const DonutDefaultConfig: DonutConfigInterface<unknown> = {\n ...ComponentDefaultConfig,\n // eslint-disable-next-line dot-notation\n id: <Datum>(d: Datum, i: number): string | number => d['id'] ?? i,\n value: undefined,\n angleRange: [0, 2 * Math.PI],\n padAngle: 0,\n sortFunction: undefined,\n cornerRadius: 0,\n color: undefined,\n radius: undefined,\n arcWidth: 20,\n centralLabel: undefined,\n centralSubLabel: undefined,\n centralSubLabelWrap: true,\n showEmptySegments: false,\n emptySegmentAngle: 0.5 * Math.PI / 180,\n showBackground: true,\n backgroundAngleRange: undefined,\n}\n"],"names":[],"mappings":";;AAAA;AA8CO,MAAM,kBAAkB,GAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EAC1B,sBAAsB,CAAA,EAAA;;IAEzB,EAAE,EAAE,CAAQ,CAAQ,EAAE,CAAS,eAAsB,OAAA,CAAA,EAAA,GAAA,CAAC,CAAC,IAAI,CAAC,MAAI,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,EAAA,GAAA,CAAC,CAAA,EAAA,EACjE,KAAK,EAAE,SAAS,EAChB,UAAU,EAAE,CAAC,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC,EAC5B,QAAQ,EAAE,CAAC,EACX,YAAY,EAAE,SAAS,EACvB,YAAY,EAAE,CAAC,EACf,KAAK,EAAE,SAAS,EAChB,MAAM,EAAE,SAAS,EACjB,QAAQ,EAAE,EAAE,EACZ,YAAY,EAAE,SAAS,EACvB,eAAe,EAAE,SAAS,EAC1B,mBAAmB,EAAE,IAAI,EACzB,iBAAiB,EAAE,KAAK,EACxB,iBAAiB,EAAE,GAAG,GAAG,IAAI,CAAC,EAAE,GAAG,GAAG,EACtC,cAAc,EAAE,IAAI,EACpB,oBAAoB,EAAE,SAAS,EAAA;;;;"}
|
|
@@ -3,11 +3,12 @@ import { ComponentCore } from "../../core/component";
|
|
|
3
3
|
import { SeriesDataModel } from "../../data-models/series";
|
|
4
4
|
import { Spacing } from "../../types/spacing";
|
|
5
5
|
import { DonutArcAnimState } from './types';
|
|
6
|
-
import {
|
|
6
|
+
import { DonutConfigInterface } from './config';
|
|
7
7
|
import * as s from './style';
|
|
8
|
-
export declare class Donut<Datum> extends ComponentCore<Datum[],
|
|
8
|
+
export declare class Donut<Datum> extends ComponentCore<Datum[], DonutConfigInterface<Datum>> {
|
|
9
9
|
static selectors: typeof s;
|
|
10
|
-
|
|
10
|
+
protected _defaultConfig: DonutConfigInterface<Datum>;
|
|
11
|
+
config: DonutConfigInterface<Datum>;
|
|
11
12
|
datamodel: SeriesDataModel<Datum>;
|
|
12
13
|
arcBackground: Selection<SVGPathElement, unknown, SVGGElement, unknown>;
|
|
13
14
|
arcGroup: Selection<SVGGElement, unknown, SVGGElement, unknown>;
|
|
@@ -4,7 +4,7 @@ import { SeriesDataModel } from '../../data-models/series.js';
|
|
|
4
4
|
import { smartTransition } from '../../utils/d3.js';
|
|
5
5
|
import { getNumber, isNumber, clamp } from '../../utils/data.js';
|
|
6
6
|
import { wrapSVGText } from '../../utils/text.js';
|
|
7
|
-
import {
|
|
7
|
+
import { DonutDefaultConfig } from './config.js';
|
|
8
8
|
import { createArc, updateArc, removeArc } from './modules/arc.js';
|
|
9
9
|
import * as style from './style.js';
|
|
10
10
|
import { centralLabel, centralSubLabel, segment, segmentExit, background } from './style.js';
|
|
@@ -12,12 +12,13 @@ import { centralLabel, centralSubLabel, segment, segmentExit, background } from
|
|
|
12
12
|
class Donut extends ComponentCore {
|
|
13
13
|
constructor(config) {
|
|
14
14
|
super();
|
|
15
|
-
this.
|
|
15
|
+
this._defaultConfig = DonutDefaultConfig;
|
|
16
|
+
this.config = this._defaultConfig;
|
|
16
17
|
this.datamodel = new SeriesDataModel();
|
|
17
18
|
this.arcGen = arc();
|
|
18
19
|
this.events = {};
|
|
19
20
|
if (config)
|
|
20
|
-
this.
|
|
21
|
+
this.setConfig(config);
|
|
21
22
|
this.arcBackground = this.g.append('path');
|
|
22
23
|
this.arcGroup = this.g.append('g');
|
|
23
24
|
this.centralLabel = this.g.append('text')
|
|
@@ -53,7 +54,7 @@ class Donut extends ComponentCore {
|
|
|
53
54
|
.endAngle((_d = (_c = config.angleRange) === null || _c === void 0 ? void 0 : _c[1]) !== null && _d !== void 0 ? _d : 2 * Math.PI)
|
|
54
55
|
.padAngle(config.padAngle)
|
|
55
56
|
.value(d => getNumber(d.datum, config.value, d.index) || 0)
|
|
56
|
-
.sort(config.sortFunction);
|
|
57
|
+
.sort((a, b) => config.sortFunction(a.datum, b.datum));
|
|
57
58
|
this.arcGroup.attr('transform', `translate(${this._width / 2},${this._height / 2})`);
|
|
58
59
|
const arcData = pieGen(data).map(d => {
|
|
59
60
|
const arc = Object.assign(Object.assign({}, d), { data: d.data.datum, index: d.data.index, innerRadius,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/components/donut/index.ts"],"sourcesContent":["import { Selection } from 'd3-selection'\nimport { pie, arc } from 'd3-shape'\n\n// Core\nimport { ComponentCore } from 'core/component'\nimport { SeriesDataModel } from 'data-models/series'\n\n// Utils\nimport { smartTransition } from 'utils/d3'\nimport { isNumber, clamp, getNumber } from 'utils/data'\nimport { wrapSVGText } from 'utils/text'\n\n// Types\nimport { Spacing } from 'types/spacing'\n\n// Local Types\nimport { DonutArcDatum, DonutArcAnimState, DonutDatum } from './types'\n\n// Config\nimport { DonutConfig, DonutConfigInterface } from './config'\n\n// Modules\nimport { createArc, updateArc, removeArc } from './modules/arc'\n\n// Styles\nimport * as s from './style'\n\nexport class Donut<Datum> extends ComponentCore<Datum[], DonutConfig<Datum>, DonutConfigInterface<Datum>> {\n static selectors = s\n config: DonutConfig<Datum> = new DonutConfig()\n datamodel: SeriesDataModel<Datum> = new SeriesDataModel()\n\n arcBackground: Selection<SVGPathElement, unknown, SVGGElement, unknown>\n arcGroup: Selection<SVGGElement, unknown, SVGGElement, unknown>\n centralLabel: Selection<SVGTextElement, unknown, SVGGElement, unknown>\n centralSubLabel: Selection<SVGTextElement, unknown, SVGGElement, unknown>\n arcGen = arc<DonutArcAnimState>()\n\n events = {\n }\n\n constructor (config?: DonutConfigInterface<Datum>) {\n super()\n if (config) this.config.init(config)\n this.arcBackground = this.g.append('path')\n this.arcGroup = this.g.append('g')\n this.centralLabel = this.g.append('text')\n .attr('class', s.centralLabel)\n this.centralSubLabel = this.g.append('text')\n .attr('class', s.centralSubLabel)\n }\n\n get bleed (): Spacing {\n return { top: 0, bottom: 0, left: 0, right: 0 }\n }\n\n _render (customDuration?: number): void {\n const { config, datamodel, bleed } = this\n\n // Wrap data to preserve original indices\n const data: DonutDatum<Datum>[] = datamodel.data\n .map((d, i) => ({\n index: i,\n datum: d,\n }))\n .filter(d => config.showEmptySegments || getNumber(d.datum, config.value, d.index))\n\n const duration = isNumber(customDuration) ? customDuration : config.duration\n const outerRadius = config.radius || Math.min(this._width - bleed.left - bleed.right, this._height - bleed.top - bleed.bottom) / 2\n const innerRadius = config.arcWidth === 0 ? 0 : clamp(outerRadius - config.arcWidth, 0, outerRadius - 1)\n\n this.arcGen\n .startAngle(d => d.startAngle)\n .endAngle(d => d.endAngle)\n .innerRadius(d => d.innerRadius)\n .outerRadius(d => d.outerRadius)\n .padAngle(d => d.padAngle)\n .cornerRadius(config.cornerRadius)\n\n const pieGen = pie<DonutDatum<Datum>>()\n .startAngle(config.angleRange?.[0] ?? 0)\n .endAngle(config.angleRange?.[1] ?? 2 * Math.PI)\n .padAngle(config.padAngle)\n .value(d => getNumber(d.datum, config.value, d.index) || 0)\n .sort(config.sortFunction)\n\n this.arcGroup.attr('transform', `translate(${this._width / 2},${this._height / 2})`)\n\n const arcData: DonutArcDatum<Datum>[] = pieGen(data).map(d => {\n const arc = {\n ...d,\n data: d.data.datum,\n index: d.data.index,\n innerRadius,\n outerRadius,\n }\n\n if (config.showEmptySegments && d.endAngle - d.startAngle - d.padAngle <= Number.EPSILON) {\n arc.endAngle = d.startAngle + Math.max(config.emptySegmentAngle, config.padAngle)\n arc.padAngle = d.padAngle / 2\n }\n return arc\n })\n\n // Arc segments\n const arcsSelection = this.arcGroup\n .selectAll<SVGPathElement, DonutArcDatum<Datum>>(`.${s.segment}`)\n .data(arcData, (d: DonutArcDatum<Datum>) => config.id(d.data, d.index))\n\n const arcsEnter = arcsSelection.enter().append('path')\n .attr('class', s.segment)\n .call(createArc, config)\n\n const arcsMerged = arcsSelection.merge(arcsEnter)\n arcsMerged.call(updateArc, config, this.arcGen, duration)\n arcsMerged.sort((a, b) => b.value - a.value)\n\n arcsSelection.exit<DonutArcDatum<Datum>>()\n .attr('class', s.segmentExit)\n .call(removeArc, duration)\n\n // Label\n this.centralLabel\n .attr('transform', `translate(${this._width / 2},${this._height / 2})`)\n .attr('dy', config.centralSubLabel ? '-0.55em' : null)\n .text(config.centralLabel ?? null)\n\n this.centralSubLabel\n .attr('transform', `translate(${this._width / 2},${this._height / 2})`)\n .attr('dy', config.centralLabel ? '0.55em' : null)\n .text(config.centralSubLabel ?? null)\n\n if (config.centralSubLabelWrap) wrapSVGText(this.centralSubLabel, innerRadius * 1.9)\n\n // Background\n this.arcBackground.attr('class', s.background)\n .attr('visibility', config.showBackground ? null : 'hidden')\n .attr('transform', `translate(${this._width / 2},${this._height / 2})`)\n\n smartTransition(this.arcBackground, duration)\n .attr('d', this.arcGen({\n startAngle: config.backgroundAngleRange?.[0] ?? config.angleRange?.[0] ?? 0,\n endAngle: config.backgroundAngleRange?.[1] ?? config.angleRange?.[1] ?? 2 * Math.PI,\n innerRadius,\n outerRadius,\n }))\n }\n}\n"],"names":["s.centralLabel","s.centralSubLabel","s.segment","s.segmentExit","s.background","s"],"mappings":";;;;;;;;;;;AA2BM,MAAO,KAAa,SAAQ,aAAuE,CAAA;AAcvG,IAAA,WAAA,CAAa,MAAoC,EAAA;AAC/C,QAAA,KAAK,EAAE,CAAA;AAbT,QAAA,IAAA,CAAA,MAAM,GAAuB,IAAI,WAAW,EAAE,CAAA;AAC9C,QAAA,IAAA,CAAA,SAAS,GAA2B,IAAI,eAAe,EAAE,CAAA;QAMzD,IAAM,CAAA,MAAA,GAAG,GAAG,EAAqB,CAAA;QAEjC,IAAM,CAAA,MAAA,GAAG,EACR,CAAA;AAIC,QAAA,IAAI,MAAM;AAAE,YAAA,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;QACpC,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;QAC1C,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,CAAC,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AAA,CAAG,CAAC,CAAC,mCAAI,CAAC,GAAG,IAAI,CAAC,EAAE;YACnF,WAAW;YACX,WAAW;AACZ,SAAA,CAAC,CAAC,CAAA;KACN;;AAtHM,KAAS,CAAA,SAAA,GAAGC,KAAC;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/components/donut/index.ts"],"sourcesContent":["import { Selection } from 'd3-selection'\nimport { pie, arc } from 'd3-shape'\n\n// Core\nimport { ComponentCore } from 'core/component'\nimport { SeriesDataModel } from 'data-models/series'\n\n// Utils\nimport { smartTransition } from 'utils/d3'\nimport { isNumber, clamp, getNumber } from 'utils/data'\nimport { wrapSVGText } from 'utils/text'\n\n// Types\nimport { Spacing } from 'types/spacing'\n\n// Local Types\nimport { DonutArcDatum, DonutArcAnimState, DonutDatum } from './types'\n\n// Config\nimport { DonutDefaultConfig, DonutConfigInterface } from './config'\n\n// Modules\nimport { createArc, updateArc, removeArc } from './modules/arc'\n\n// Styles\nimport * as s from './style'\n\nexport class Donut<Datum> extends ComponentCore<Datum[], DonutConfigInterface<Datum>> {\n static selectors = s\n protected _defaultConfig = DonutDefaultConfig as DonutConfigInterface<Datum>\n public config: DonutConfigInterface<Datum> = this._defaultConfig\n\n datamodel: SeriesDataModel<Datum> = new SeriesDataModel()\n\n arcBackground: Selection<SVGPathElement, unknown, SVGGElement, unknown>\n arcGroup: Selection<SVGGElement, unknown, SVGGElement, unknown>\n centralLabel: Selection<SVGTextElement, unknown, SVGGElement, unknown>\n centralSubLabel: Selection<SVGTextElement, unknown, SVGGElement, unknown>\n arcGen = arc<DonutArcAnimState>()\n\n events = {\n }\n\n constructor (config?: DonutConfigInterface<Datum>) {\n super()\n if (config) this.setConfig(config)\n this.arcBackground = this.g.append('path')\n this.arcGroup = this.g.append('g')\n this.centralLabel = this.g.append('text')\n .attr('class', s.centralLabel)\n this.centralSubLabel = this.g.append('text')\n .attr('class', s.centralSubLabel)\n }\n\n get bleed (): Spacing {\n return { top: 0, bottom: 0, left: 0, right: 0 }\n }\n\n _render (customDuration?: number): void {\n const { config, datamodel, bleed } = this\n\n // Wrap data to preserve original indices\n const data: DonutDatum<Datum>[] = datamodel.data\n .map((d, i) => ({\n index: i,\n datum: d,\n }))\n .filter(d => config.showEmptySegments || getNumber(d.datum, config.value, d.index))\n\n const duration = isNumber(customDuration) ? customDuration : config.duration\n const outerRadius = config.radius || Math.min(this._width - bleed.left - bleed.right, this._height - bleed.top - bleed.bottom) / 2\n const innerRadius = config.arcWidth === 0 ? 0 : clamp(outerRadius - config.arcWidth, 0, outerRadius - 1)\n\n this.arcGen\n .startAngle(d => d.startAngle)\n .endAngle(d => d.endAngle)\n .innerRadius(d => d.innerRadius)\n .outerRadius(d => d.outerRadius)\n .padAngle(d => d.padAngle)\n .cornerRadius(config.cornerRadius)\n\n const pieGen = pie<DonutDatum<Datum>>()\n .startAngle(config.angleRange?.[0] ?? 0)\n .endAngle(config.angleRange?.[1] ?? 2 * Math.PI)\n .padAngle(config.padAngle)\n .value(d => getNumber(d.datum, config.value, d.index) || 0)\n .sort((a, b) => config.sortFunction(a.datum, b.datum))\n\n this.arcGroup.attr('transform', `translate(${this._width / 2},${this._height / 2})`)\n\n const arcData: DonutArcDatum<Datum>[] = pieGen(data).map(d => {\n const arc = {\n ...d,\n data: d.data.datum,\n index: d.data.index,\n innerRadius,\n outerRadius,\n }\n\n if (config.showEmptySegments && d.endAngle - d.startAngle - d.padAngle <= Number.EPSILON) {\n arc.endAngle = d.startAngle + Math.max(config.emptySegmentAngle, config.padAngle)\n arc.padAngle = d.padAngle / 2\n }\n return arc\n })\n\n // Arc segments\n const arcsSelection = this.arcGroup\n .selectAll<SVGPathElement, DonutArcDatum<Datum>>(`.${s.segment}`)\n .data(arcData, (d: DonutArcDatum<Datum>) => config.id(d.data, d.index))\n\n const arcsEnter = arcsSelection.enter().append('path')\n .attr('class', s.segment)\n .call(createArc, config)\n\n const arcsMerged = arcsSelection.merge(arcsEnter)\n arcsMerged.call(updateArc, config, this.arcGen, duration)\n arcsMerged.sort((a, b) => b.value - a.value)\n\n arcsSelection.exit<DonutArcDatum<Datum>>()\n .attr('class', s.segmentExit)\n .call(removeArc, duration)\n\n // Label\n this.centralLabel\n .attr('transform', `translate(${this._width / 2},${this._height / 2})`)\n .attr('dy', config.centralSubLabel ? '-0.55em' : null)\n .text(config.centralLabel ?? null)\n\n this.centralSubLabel\n .attr('transform', `translate(${this._width / 2},${this._height / 2})`)\n .attr('dy', config.centralLabel ? '0.55em' : null)\n .text(config.centralSubLabel ?? null)\n\n if (config.centralSubLabelWrap) wrapSVGText(this.centralSubLabel, innerRadius * 1.9)\n\n // Background\n this.arcBackground.attr('class', s.background)\n .attr('visibility', config.showBackground ? null : 'hidden')\n .attr('transform', `translate(${this._width / 2},${this._height / 2})`)\n\n smartTransition(this.arcBackground, duration)\n .attr('d', this.arcGen({\n startAngle: config.backgroundAngleRange?.[0] ?? config.angleRange?.[0] ?? 0,\n endAngle: config.backgroundAngleRange?.[1] ?? config.angleRange?.[1] ?? 2 * Math.PI,\n innerRadius,\n outerRadius,\n }))\n }\n}\n"],"names":["s.centralLabel","s.centralSubLabel","s.segment","s.segmentExit","s.background","s"],"mappings":";;;;;;;;;;;AA2BM,MAAO,KAAa,SAAQ,aAAmD,CAAA;AAgBnF,IAAA,WAAA,CAAa,MAAoC,EAAA;AAC/C,QAAA,KAAK,EAAE,CAAA;QAfC,IAAc,CAAA,cAAA,GAAG,kBAAiD,CAAA;AACrE,QAAA,IAAA,CAAA,MAAM,GAAgC,IAAI,CAAC,cAAc,CAAA;AAEhE,QAAA,IAAA,CAAA,SAAS,GAA2B,IAAI,eAAe,EAAE,CAAA;QAMzD,IAAM,CAAA,MAAA,GAAG,GAAG,EAAqB,CAAA;QAEjC,IAAM,CAAA,MAAA,GAAG,EACR,CAAA;AAIC,QAAA,IAAI,MAAM;AAAE,YAAA,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAA;QAClC,IAAI,CAAC,aAAa,GAAG,I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AAA,EAAA,CAAA,CAAC,CAAC,MAAA,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,EAAA,GAAI,MAAA,MAAM,CAAC,UAAU,MAAA,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAG,CAAC,CAAC,mCAAI,CAAC,GAAG,IAAI,CAAC,EAAE;YACnF,WAAW;YACX,WAAW;AACZ,SAAA,CAAC,CAAC,CAAA;KACN;;AAxHM,KAAS,CAAA,SAAA,GAAGC,KAAC;;;;"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Selection } from 'd3-selection';
|
|
2
2
|
import { Arc } from 'd3-shape';
|
|
3
3
|
import { DonutArcDatum, DonutArcAnimState } from '../types';
|
|
4
|
-
import {
|
|
4
|
+
import { DonutConfigInterface } from '../config';
|
|
5
5
|
export interface ArcNode extends SVGElement {
|
|
6
6
|
_animState?: DonutArcAnimState;
|
|
7
7
|
}
|
|
8
|
-
export declare function createArc<Datum>(selection: Selection<SVGPathElement, DonutArcDatum<Datum>, SVGGElement, unknown>, config:
|
|
9
|
-
export declare function updateArc<Datum>(selection: Selection<SVGPathElement, DonutArcDatum<Datum>, SVGGElement, unknown>, config:
|
|
8
|
+
export declare function createArc<Datum>(selection: Selection<SVGPathElement, DonutArcDatum<Datum>, SVGGElement, unknown>, config: DonutConfigInterface<Datum>): void;
|
|
9
|
+
export declare function updateArc<Datum>(selection: Selection<SVGPathElement, DonutArcDatum<Datum>, SVGGElement, unknown>, config: DonutConfigInterface<Datum>, arcGen: Arc<any, DonutArcAnimState>, duration: number): void;
|
|
10
10
|
export declare function removeArc<Datum>(selection: Selection<SVGPathElement, DonutArcDatum<Datum>, SVGGElement, unknown>, duration: number): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"arc.js","sources":["../../../../src/components/donut/modules/arc.ts"],"sourcesContent":["import { Selection } from 'd3-selection'\nimport { Transition } from 'd3-transition'\nimport { interpolate } from 'd3-interpolate'\nimport { Arc } from 'd3-shape'\n\n// Utils\nimport { getColor } from 'utils/color'\nimport { smartTransition } from 'utils/d3'\n\n// Local Types\nimport { DonutArcDatum, DonutArcAnimState } from '../types'\n\n// Config\nimport {
|
|
1
|
+
{"version":3,"file":"arc.js","sources":["../../../../src/components/donut/modules/arc.ts"],"sourcesContent":["import { Selection } from 'd3-selection'\nimport { Transition } from 'd3-transition'\nimport { interpolate } from 'd3-interpolate'\nimport { Arc } from 'd3-shape'\n\n// Utils\nimport { getColor } from 'utils/color'\nimport { smartTransition } from 'utils/d3'\n\n// Local Types\nimport { DonutArcDatum, DonutArcAnimState } from '../types'\n\n// Config\nimport { DonutConfigInterface } from '../config'\n\nexport interface ArcNode extends SVGElement {\n _animState?: DonutArcAnimState;\n}\n\nexport function createArc<Datum> (\n selection: Selection<SVGPathElement, DonutArcDatum<Datum>, SVGGElement, unknown>,\n config: DonutConfigInterface<Datum>\n): void {\n selection\n .style('fill', d => getColor(d.data, config.color, d.index))\n .style('opacity', 0)\n .each((d, i, els) => {\n const arcNode: ArcNode = els[i]\n const angleCenter = (d.startAngle + d.endAngle) / 2\n const angleHalfWidth = (d.endAngle - d.startAngle) / 2\n arcNode._animState = {\n startAngle: angleCenter - angleHalfWidth,\n endAngle: angleCenter + angleHalfWidth,\n innerRadius: d.innerRadius,\n outerRadius: d.outerRadius,\n padAngle: d.padAngle,\n }\n })\n}\n\nexport function updateArc<Datum> (\n selection: Selection<SVGPathElement, DonutArcDatum<Datum>, SVGGElement, unknown>,\n config: DonutConfigInterface<Datum>,\n arcGen: Arc<any, DonutArcAnimState>,\n duration: number\n): void {\n selection\n .style('transition', `fill ${duration}ms`) // Animate color with CSS because we're using CSS-variables\n .style('fill', d => getColor(d.data, config.color, d.index))\n\n const setOpacity = (d: DonutArcDatum<Datum>): number => (config.showEmptySegments || d.value) ? 1 : 0\n if (duration) {\n const transition = smartTransition(selection, duration)\n .style('opacity', setOpacity) as Transition<SVGPathElement, DonutArcDatum<Datum>, SVGGElement, unknown>\n\n transition.attrTween('d', (d, i, els) => {\n const arcNode: ArcNode = els[i]\n const nextAnimState: DonutArcAnimState = {\n startAngle: d.startAngle,\n endAngle: d.endAngle,\n innerRadius: d.innerRadius,\n outerRadius: d.outerRadius,\n padAngle: d.padAngle,\n }\n const datum = interpolate(arcNode._animState, nextAnimState)\n\n return (t: number): string => {\n arcNode._animState = datum(t)\n return arcGen(arcNode._animState as DonutArcDatum<Datum>)\n }\n })\n } else {\n selection\n .attr('d', arcGen)\n .style('opacity', setOpacity)\n }\n}\n\nexport function removeArc<Datum> (\n selection: Selection<SVGPathElement, DonutArcDatum<Datum>, SVGGElement, unknown>,\n duration: number\n): void {\n smartTransition(selection, duration)\n .style('opacity', 0)\n .remove()\n}\n"],"names":[],"mappings":";;;;AAmBgB,SAAA,SAAS,CACvB,SAAgF,EAChF,MAAmC,EAAA;IAEnC,SAAS;SACN,KAAK,CAAC,MAAM,EAAE,CAAC,IAAI,QAAQ,CAAC,CAAC,CAAC,IAAI,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC;AAC3D,SAAA,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC;SACnB,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,KAAI;AAClB,QAAA,MAAM,OAAO,GAAY,GAAG,CAAC,CAAC,CAAC,CAAA;AAC/B,QAAA,MAAM,WAAW,GAAG,CAAC,CAAC,CAAC,UAAU,GAAG,CAAC,CAAC,QAAQ,IAAI,CAAC,CAAA;AACnD,QAAA,MAAM,cAAc,GAAG,CAAC,CAAC,CAAC,QAAQ,GAAG,CAAC,CAAC,UAAU,IAAI,CAAC,CAAA;QACtD,OAAO,CAAC,UAAU,GAAG;YACnB,UAAU,EAAE,WAAW,GAAG,cAAc;YACxC,QAAQ,EAAE,WAAW,GAAG,cAAc;YACtC,WAAW,EAAE,CAAC,CAAC,WAAW;YAC1B,WAAW,EAAE,CAA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AAC,CAAC,CAAC,CAAA;AAC7B,gBAAA,OAAO,MAAM,CAAC,OAAO,CAAC,UAAkC,CAAC,CAAA;AAC3D,aAAC,CAAA;AACH,SAAC,CAAC,CAAA;AACH,KAAA;AAAM,SAAA;QACL,SAAS;AACN,aAAA,IAAI,CAAC,GAAG,EAAE,MAAM,CAAC;AACjB,aAAA,KAAK,CAAC,SAAS,EAAE,UAAU,CAAC,CAAA;AAChC,KAAA;AACH,CAAC;AAEe,SAAA,SAAS,CACvB,SAAgF,EAChF,QAAgB,EAAA;AAEhB,IAAA,eAAe,CAAC,SAAS,EAAE,QAAQ,CAAC;AACjC,SAAA,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC;AACnB,SAAA,MAAM,EAAE,CAAA;AACb;;;;"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Config } from "../../core/config";
|
|
2
1
|
export interface FlowLegendConfigInterface {
|
|
3
2
|
/** Custom width of the component. Default: `undefined` */
|
|
4
3
|
customWidth?: number;
|
|
@@ -17,13 +16,4 @@ export interface FlowLegendConfigInterface {
|
|
|
17
16
|
/** Callback function for the legend item click. Default: `undefined` */
|
|
18
17
|
onLegendItemClick?: ((label?: string, i?: number) => void);
|
|
19
18
|
}
|
|
20
|
-
export declare
|
|
21
|
-
customWidth: any;
|
|
22
|
-
items: any[];
|
|
23
|
-
labelFontSize: number;
|
|
24
|
-
lineColor: any;
|
|
25
|
-
labelColor: any;
|
|
26
|
-
arrowSymbol: string;
|
|
27
|
-
arrowColor: any;
|
|
28
|
-
onLegendItemClick: any;
|
|
29
|
-
}
|
|
19
|
+
export declare const FlowLegendDefaultConfig: FlowLegendConfigInterface;
|
|
@@ -1,18 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
const FlowLegendDefaultConfig = {
|
|
2
|
+
customWidth: undefined,
|
|
3
|
+
items: [],
|
|
4
|
+
labelFontSize: 12,
|
|
5
|
+
lineColor: undefined,
|
|
6
|
+
labelColor: undefined,
|
|
7
|
+
arrowSymbol: '▶',
|
|
8
|
+
arrowColor: undefined,
|
|
9
|
+
onLegendItemClick: undefined,
|
|
10
|
+
};
|
|
2
11
|
|
|
3
|
-
|
|
4
|
-
constructor() {
|
|
5
|
-
super(...arguments);
|
|
6
|
-
this.customWidth = undefined;
|
|
7
|
-
this.items = [];
|
|
8
|
-
this.labelFontSize = 12;
|
|
9
|
-
this.lineColor = undefined;
|
|
10
|
-
this.labelColor = undefined;
|
|
11
|
-
this.arrowSymbol = '▶';
|
|
12
|
-
this.arrowColor = undefined;
|
|
13
|
-
this.onLegendItemClick = undefined;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export { FlowLegendConfig };
|
|
12
|
+
export { FlowLegendDefaultConfig };
|
|
18
13
|
//# sourceMappingURL=config.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sources":["../../../src/components/flow-legend/config.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"config.js","sources":["../../../src/components/flow-legend/config.ts"],"sourcesContent":["export interface FlowLegendConfigInterface {\n /** Custom width of the component. Default: `undefined` */\n customWidth?: number;\n /** Legend items array as string[]. Default: `[]` */\n items?: string[];\n /** Color of the flow line. Default: `undefined` */\n lineColor?: string;\n /** Color of the flow label. Default: `undefined` */\n labelColor?: string;\n /** Font size of flow labels in pixels. Default: `12` */\n labelFontSize?: number;\n /** Arrow symbol. Default: `'▶'` */\n arrowSymbol?: string;\n /** Color of the arrow. Default: `undefined` */\n arrowColor?: string;\n /** Callback function for the legend item click. Default: `undefined` */\n onLegendItemClick?: ((label?: string, i?: number) => void);\n}\n\nexport const FlowLegendDefaultConfig: FlowLegendConfigInterface = {\n customWidth: undefined,\n items: [],\n labelFontSize: 12,\n lineColor: undefined,\n labelColor: undefined,\n arrowSymbol: '▶',\n arrowColor: undefined,\n onLegendItemClick: undefined,\n}\n"],"names":[],"mappings":"AAmBa,MAAA,uBAAuB,GAA8B;AAChE,IAAA,WAAW,EAAE,SAAS;AACtB,IAAA,KAAK,EAAE,EAAE;AACT,IAAA,aAAa,EAAE,EAAE;AACjB,IAAA,SAAS,EAAE,SAAS;AACpB,IAAA,UAAU,EAAE,SAAS;AACrB,IAAA,WAAW,EAAE,GAAG;AAChB,IAAA,UAAU,EAAE,SAAS;AACrB,IAAA,iBAAiB,EAAE,SAAS;;;;;"}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { Selection } from 'd3-selection';
|
|
2
|
-
import {
|
|
2
|
+
import { FlowLegendConfigInterface } from './config';
|
|
3
3
|
import { FlowLegendItem } from './types';
|
|
4
4
|
export declare class FlowLegend {
|
|
5
5
|
div: Selection<HTMLDivElement, unknown, null, undefined>;
|
|
6
6
|
element: HTMLElement;
|
|
7
7
|
line: Selection<HTMLDivElement, unknown, null, undefined>;
|
|
8
8
|
labels: Selection<HTMLDivElement, unknown, null, undefined>;
|
|
9
|
-
|
|
10
|
-
config:
|
|
9
|
+
protected _defaultConfig: FlowLegendConfigInterface;
|
|
10
|
+
config: FlowLegendConfigInterface;
|
|
11
|
+
prevConfig: FlowLegendConfigInterface;
|
|
11
12
|
protected _container: HTMLElement;
|
|
12
13
|
constructor(element: HTMLElement, config?: FlowLegendConfigInterface);
|
|
13
14
|
update(config: FlowLegendConfigInterface): void;
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { select } from 'd3-selection';
|
|
2
2
|
import { smartTransition } from '../../utils/d3.js';
|
|
3
|
-
import {
|
|
3
|
+
import { merge } from '../../utils/data.js';
|
|
4
|
+
import { FlowLegendDefaultConfig } from './config.js';
|
|
4
5
|
import { FlowLegendItemType } from './types.js';
|
|
5
6
|
import { root, labels, item, arrow, label, clickable, line } from './style.js';
|
|
6
7
|
|
|
7
8
|
class FlowLegend {
|
|
8
9
|
constructor(element, config) {
|
|
10
|
+
this._defaultConfig = FlowLegendDefaultConfig;
|
|
11
|
+
this.config = this._defaultConfig;
|
|
9
12
|
this._container = element;
|
|
10
13
|
this.div = select(this._container).append('div').attr('class', root);
|
|
11
14
|
this.element = this.div.node();
|
|
@@ -16,7 +19,7 @@ class FlowLegend {
|
|
|
16
19
|
}
|
|
17
20
|
update(config) {
|
|
18
21
|
this.prevConfig = this.config;
|
|
19
|
-
this.config =
|
|
22
|
+
this.config = merge(this._defaultConfig, config);
|
|
20
23
|
this.render();
|
|
21
24
|
}
|
|
22
25
|
render() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/components/flow-legend/index.ts"],"sourcesContent":["import { select, Selection } from 'd3-selection'\n\n// Utils\nimport { smartTransition } from 'utils/d3'\n\n// Config\nimport {
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/components/flow-legend/index.ts"],"sourcesContent":["import { select, Selection } from 'd3-selection'\n\n// Utils\nimport { smartTransition } from 'utils/d3'\nimport { merge } from 'utils/data'\n\n// Config\nimport { FlowLegendDefaultConfig, FlowLegendConfigInterface } from './config'\n\n// Local Types\nimport { FlowLegendItem, FlowLegendItemType } from './types'\n\n// Styles\nimport * as s from './style'\n\nexport class FlowLegend {\n div: Selection<HTMLDivElement, unknown, null, undefined>\n element: HTMLElement\n line: Selection<HTMLDivElement, unknown, null, undefined>\n labels: Selection<HTMLDivElement, unknown, null, undefined>\n protected _defaultConfig = FlowLegendDefaultConfig as FlowLegendConfigInterface\n public config: FlowLegendConfigInterface = this._defaultConfig\n prevConfig: FlowLegendConfigInterface\n protected _container: HTMLElement\n\n constructor (element: HTMLElement, config?: FlowLegendConfigInterface) {\n this._container = element\n\n this.div = select(this._container).append('div').attr('class', s.root)\n this.element = this.div.node()\n\n this.line = this.div.append('div')\n this.labels = this.div.append('div').attr('class', s.labels)\n\n if (config) this.update(config)\n }\n\n update (config: FlowLegendConfigInterface): void {\n this.prevConfig = this.config\n this.config = merge(this._defaultConfig, config)\n this.render()\n }\n\n render (): void {\n const { config } = this\n if (!config.items.length) return\n\n if (config.customWidth) this.div.style('width', `${config.customWidth}px`)\n\n // Prepare Data\n const legendData: FlowLegendItem[] = config.items.reduce((acc, label, i) => {\n acc.push({\n text: label,\n index: i,\n type: FlowLegendItemType.Label,\n })\n\n if (config.arrowSymbol && (acc.length !== config.items.length * 2 - 1)) {\n acc.push({\n text: config.arrowSymbol,\n index: i,\n type: FlowLegendItemType.Symbol,\n })\n }\n return acc\n }, [])\n\n // Draw\n const legendItems = this.labels.selectAll<HTMLDivElement, FlowLegendItem>(`.${s.item}`)\n .data(legendData)\n\n const legendItemsEnter = legendItems.enter()\n .append('div')\n .attr('class', s.item)\n .attr('opacity', 0)\n\n legendItemsEnter.filter(d => d.type === FlowLegendItemType.Label)\n .on('click', this._onItemClick.bind(this))\n\n legendItemsEnter.append('span')\n .attr('class',\n d => d.type === FlowLegendItemType.Symbol\n ? s.arrow(config.arrowColor)\n : s.label(config.labelFontSize, config.labelColor)\n )\n .classed(s.clickable, d => d.type === FlowLegendItemType.Label && !!config.onLegendItemClick)\n\n const legendItemsMerged = legendItemsEnter.merge(legendItems)\n smartTransition(legendItemsMerged, 500)\n .attr('opacity', 1)\n legendItemsMerged.select('span').html(d => d.text)\n\n legendItems.exit().remove()\n\n this.line\n .attr('class', s.line(config.lineColor))\n .style('opacity', config.items.length > 1 ? 1 : 0)\n }\n\n _onItemClick (event: MouseEvent, d: FlowLegendItem): void {\n const { config } = this\n\n if (config.onLegendItemClick) config.onLegendItemClick(d.text, d.index)\n }\n}\n"],"names":["s.root","s.labels","s.item","s.arrow","s.label","s.clickable","s.line"],"mappings":";;;;;;;MAea,UAAU,CAAA;IAUrB,WAAa,CAAA,OAAoB,EAAE,MAAkC,EAAA;QAL3D,IAAc,CAAA,cAAA,GAAG,uBAAoD,CAAA;AACxE,QAAA,IAAA,CAAA,MAAM,GAA8B,IAAI,CAAC,cAAc,CAAA;AAK5D,QAAA,IAAI,CAAC,UAAU,GAAG,OAAO,CAAA;QAEzB,IAAI,CAAC,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,CA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kB,CAAC,KAAK,IAAI,CAAC,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAA;QAE/F,MAAM,iBAAiB,GAAG,gBAAgB,CAAC,KAAK,CAAC,WAAW,CAAC,CAAA;AAC7D,QAAA,eAAe,CAAC,iBAAiB,EAAE,GAAG,CAAC;AACpC,aAAA,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC,CAAA;AACrB,QAAA,iBAAiB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAA;AAElD,QAAA,WAAW,CAAC,IAAI,EAAE,CAAC,MAAM,EAAE,CAAA;AAE3B,QAAA,IAAI,CAAC,IAAI;aACN,IAAI,CAAC,OAAO,EAAEC,IAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;AACvC,aAAA,KAAK,CAAC,SAAS,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAA;KACrD;IAED,YAAY,CAAE,KAAiB,EAAE,CAAiB,EAAA;AAChD,QAAA,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAA;QAEvB,IAAI,MAAM,CAAC,iBAAiB;YAAE,MAAM,CAAC,iBAAiB,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAA;KACxE;AACF;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { D3BrushEvent } from 'd3-brush';
|
|
2
|
-
import { XYComponentConfigInterface
|
|
2
|
+
import { XYComponentConfigInterface } from "../../core/xy-component/config";
|
|
3
3
|
import { FreeBrushMode, FreeBrushSelection } from './types';
|
|
4
4
|
export interface FreeBrushConfigInterface<Datum> extends Partial<XYComponentConfigInterface<Datum>> {
|
|
5
5
|
/** Brush selection mode. X - horizontal, Y - vertical, XY - both. Default: `FreeBrushMode.X` */
|
|
@@ -32,14 +32,4 @@ export interface FreeBrushConfigInterface<Datum> extends Partial<XYComponentConf
|
|
|
32
32
|
/** Automatically hide the brush after selection. Default: `true` */
|
|
33
33
|
autoHide?: boolean;
|
|
34
34
|
}
|
|
35
|
-
export declare
|
|
36
|
-
onBrush: (s: FreeBrushSelection | undefined, e: D3BrushEvent<unknown>, userDriven: boolean) => void;
|
|
37
|
-
onBrushStart: (s: FreeBrushSelection | undefined, e: D3BrushEvent<unknown>, userDriven: boolean) => void;
|
|
38
|
-
onBrushMove: (s: FreeBrushSelection | undefined, e: D3BrushEvent<unknown>, userDriven: boolean) => void;
|
|
39
|
-
onBrushEnd: (s: FreeBrushSelection | undefined, e: D3BrushEvent<unknown>, userDriven: boolean) => void;
|
|
40
|
-
handleWidth: number;
|
|
41
|
-
selection: FreeBrushSelection | null | undefined;
|
|
42
|
-
selectionMinLength: any;
|
|
43
|
-
mode: FreeBrushMode;
|
|
44
|
-
autoHide: boolean;
|
|
45
|
-
}
|
|
35
|
+
export declare const FreeBrushDefaultConfig: FreeBrushConfigInterface<unknown>;
|
|
@@ -1,24 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { XYComponentDefaultConfig } from '../../core/xy-component/config.js';
|
|
2
2
|
import { FreeBrushMode } from './types.js';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
/* eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-function */
|
|
14
|
-
this.onBrushEnd = (s, e, userDriven) => { };
|
|
15
|
-
this.handleWidth = 1;
|
|
16
|
-
this.selection = undefined;
|
|
17
|
-
this.selectionMinLength = undefined;
|
|
18
|
-
this.mode = FreeBrushMode.X;
|
|
19
|
-
this.autoHide = true;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
4
|
+
const FreeBrushDefaultConfig = Object.assign(Object.assign({}, XYComponentDefaultConfig), {
|
|
5
|
+
/* eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-function */
|
|
6
|
+
onBrush: (s, e, userDriven) => { },
|
|
7
|
+
/* eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-function */
|
|
8
|
+
onBrushStart: (s, e, userDriven) => { },
|
|
9
|
+
/* eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-function */
|
|
10
|
+
onBrushMove: (s, e, userDriven) => { },
|
|
11
|
+
/* eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-function */
|
|
12
|
+
onBrushEnd: (s, e, userDriven) => { }, handleWidth: 1, selection: undefined, selectionMinLength: undefined, mode: FreeBrushMode.X, autoHide: true });
|
|
22
13
|
|
|
23
|
-
export {
|
|
14
|
+
export { FreeBrushDefaultConfig };
|
|
24
15
|
//# sourceMappingURL=config.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sources":["../../../src/components/free-brush/config.ts"],"sourcesContent":["import { D3BrushEvent } from 'd3-brush'\nimport { XYComponentConfigInterface,
|
|
1
|
+
{"version":3,"file":"config.js","sources":["../../../src/components/free-brush/config.ts"],"sourcesContent":["import { D3BrushEvent } from 'd3-brush'\nimport { XYComponentConfigInterface, XYComponentDefaultConfig } from 'core/xy-component/config'\n\n// Types\nimport { FreeBrushMode, FreeBrushSelection } from './types'\n\n// We extend partial XY config interface because x and y properties are optional for FreeBrush\nexport interface FreeBrushConfigInterface<Datum> extends Partial<XYComponentConfigInterface<Datum>> {\n /** Brush selection mode. X - horizontal, Y - vertical, XY - both. Default: `FreeBrushMode.X` */\n mode?: FreeBrushMode;\n /** Callback function to be called on any Brush event.\n * Default: `(selection: FreeBrushSelection, event: D3BrushEvent<Datum>, userDriven: boolean): void => {}`\n */\n onBrush?: ((selection: FreeBrushSelection | undefined, event: D3BrushEvent<unknown>, userDriven: boolean) => void);\n /** Callback function to be called on the Brush start event.\n * Default: `(selection: FreeBrushSelection, event: D3BrushEvent<unknown>, userDriven: boolean): void => {}`\n */\n onBrushStart?: ((selection: FreeBrushSelection | undefined, event: D3BrushEvent<unknown>, userDriven: boolean) => void);\n /** Callback function to be called on the Brush move event.\n * Default: `(selection: FreeBrushSelection, event: D3BrushEvent<unknown>, userDriven: boolean): void => {}`\n */\n onBrushMove?: ((selection: FreeBrushSelection | undefined, event: D3BrushEvent<unknown>, userDriven: boolean) => void);\n /** Callback function to be called on the Brush end event.\n * Default: `(selection: FreeBrushSelection, event: D3BrushEvent<unknown>, userDriven: boolean)L void => {}`\n */\n onBrushEnd?: ((selection: FreeBrushSelection | undefined, event: D3BrushEvent<unknown>, userDriven: boolean) => void);\n /** Width of the Brush handle. Default: `1` */\n handleWidth?: number;\n /** Brush selection in data space, can be used to force set the selection from outside.\n * In case of two dimensional mode, the selection has the following format: `[[xMin, xMax], [yMin, yMax]]`.\n * This config property gets updated on internal brush events. Default: `undefined`\n */\n selection?: FreeBrushSelection | null | undefined;\n /** Constraint Brush selection to a minimal length in data units. Default: `undefined` */\n selectionMinLength?: number | [number, number];\n /** Automatically hide the brush after selection. Default: `true` */\n autoHide?: boolean;\n}\n\nexport const FreeBrushDefaultConfig: FreeBrushConfigInterface<unknown> = {\n ...XYComponentDefaultConfig,\n /* eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-function */\n onBrush: (s: FreeBrushSelection | undefined, e: D3BrushEvent<unknown>, userDriven: boolean): void => {},\n /* eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-function */\n onBrushStart: (s: FreeBrushSelection | undefined, e: D3BrushEvent<unknown>, userDriven: boolean): void => {},\n /* eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-function */\n onBrushMove: (s: FreeBrushSelection | undefined, e: D3BrushEvent<unknown>, userDriven: boolean): void => {},\n /* eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-function */\n onBrushEnd: (s: FreeBrushSelection | undefined, e: D3BrushEvent<unknown>, userDriven: boolean): void => {},\n handleWidth: 1,\n selection: undefined,\n selectionMinLength: undefined,\n mode: FreeBrushMode.X,\n autoHide: true,\n}\n"],"names":[],"mappings":";;;AAuCO,MAAM,sBAAsB,GAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EAC9B,wBAAwB,CAAA,EAAA;;IAE3B,OAAO,EAAE,CAAC,CAAiC,EAAE,CAAwB,EAAE,UAAmB,KAAU,GAAG;;IAEvG,YAAY,EAAE,CAAC,CAAiC,EAAE,CAAwB,EAAE,UAAmB,KAAU,GAAG;;IAE5G,WAAW,EAAE,CAAC,CAAiC,EAAE,CAAwB,EAAE,UAAmB,KAAU,GAAG;;AAE3G,IAAA,UAAU,EAAE,CAAC,CAAiC,EAAE,CAAwB,EAAE,UAAmB,QAAa,EAC1G,WAAW,EAAE,CAAC,EACd,SAAS,EAAE,SAAS,EACpB,kBAAkB,EAAE,SAAS,EAC7B,IAAI,EAAE,aAAa,CAAC,CAAC,EACrB,QAAQ,EAAE,IAAI;;;;"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { XYComponentCore } from "../../core/xy-component";
|
|
2
|
-
import {
|
|
2
|
+
import { FreeBrushConfigInterface } from './config';
|
|
3
3
|
import * as s from './style';
|
|
4
|
-
export declare class FreeBrush<Datum> extends XYComponentCore<Datum,
|
|
4
|
+
export declare class FreeBrush<Datum> extends XYComponentCore<Datum, FreeBrushConfigInterface<Datum>> {
|
|
5
5
|
static selectors: typeof s;
|
|
6
|
-
|
|
6
|
+
protected _defaultConfig: FreeBrushConfigInterface<Datum>;
|
|
7
|
+
config: FreeBrushConfigInterface<Datum>;
|
|
7
8
|
private brush;
|
|
8
9
|
private brushBehaviour;
|
|
9
10
|
private _firstRender;
|
|
@@ -3,17 +3,18 @@ import { XYComponentCore } from '../../core/xy-component/index.js';
|
|
|
3
3
|
import { isNumber, clamp } from '../../utils/data.js';
|
|
4
4
|
import { smartTransition } from '../../utils/d3.js';
|
|
5
5
|
import { FreeBrushMode } from './types.js';
|
|
6
|
-
import {
|
|
6
|
+
import { FreeBrushDefaultConfig } from './config.js';
|
|
7
7
|
import * as style from './style.js';
|
|
8
8
|
import { brush, hide } from './style.js';
|
|
9
9
|
|
|
10
10
|
class FreeBrush extends XYComponentCore {
|
|
11
11
|
constructor(config) {
|
|
12
12
|
super();
|
|
13
|
-
this.
|
|
13
|
+
this._defaultConfig = FreeBrushDefaultConfig;
|
|
14
|
+
this.config = this._defaultConfig;
|
|
14
15
|
this._firstRender = true;
|
|
15
16
|
if (config)
|
|
16
|
-
this.
|
|
17
|
+
this.setConfig(config);
|
|
17
18
|
this.brush = this.g
|
|
18
19
|
.append('g')
|
|
19
20
|
.attr('class', brush);
|
|
@@ -97,12 +98,12 @@ class FreeBrush extends XYComponentCore {
|
|
|
97
98
|
break;
|
|
98
99
|
}
|
|
99
100
|
case FreeBrushMode.Y: {
|
|
100
|
-
selectedDomain = this._pixelRangeToDataRange(s, this.yScale, config.selectionMinLength, true);
|
|
101
|
+
selectedDomain = this._pixelRangeToDataRange(s, this.yScale, config.selectionMinLength[0], true);
|
|
101
102
|
break;
|
|
102
103
|
}
|
|
103
104
|
case FreeBrushMode.X:
|
|
104
105
|
default: {
|
|
105
|
-
selectedDomain = this._pixelRangeToDataRange(s, this.xScale, config.selectionMinLength);
|
|
106
|
+
selectedDomain = this._pixelRangeToDataRange(s, this.xScale, config.selectionMinLength[1]);
|
|
106
107
|
break;
|
|
107
108
|
}
|
|
108
109
|
}
|