@fluentui/react-charting 5.12.1 → 5.12.4
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/CHANGELOG.json +58 -1
- package/CHANGELOG.md +31 -2
- package/dist/react-charting.js +1 -1
- package/dist/react-charting.min.js +1 -1
- package/lib/components/Sparkline/Sparkline.base.d.ts +2 -0
- package/lib/components/Sparkline/Sparkline.base.js +17 -6
- package/lib/components/Sparkline/Sparkline.base.js.map +1 -1
- package/lib/components/Sparkline/Sparkline.styles.js +1 -1
- package/lib/components/Sparkline/Sparkline.styles.js.map +1 -1
- package/lib/components/Sparkline/Sparkline.types.d.ts +6 -1
- package/lib/components/Sparkline/Sparkline.types.js.map +1 -1
- package/lib/components/TreeChart/TreeChart.base.d.ts +1 -1
- package/lib/components/TreeChart/TreeChart.base.js +86 -28
- package/lib/components/TreeChart/TreeChart.base.js.map +1 -1
- package/lib/components/TreeChart/TreeChart.styles.js +8 -0
- package/lib/components/TreeChart/TreeChart.styles.js.map +1 -1
- package/lib/components/TreeChart/TreeChart.types.d.ts +100 -3
- package/lib/components/TreeChart/TreeChart.types.js +12 -0
- package/lib/components/TreeChart/TreeChart.types.js.map +1 -1
- package/lib/version.js +1 -1
- package/lib/version.js.map +1 -1
- package/lib-amd/components/Sparkline/Sparkline.base.d.ts +2 -0
- package/lib-amd/components/Sparkline/Sparkline.base.js +16 -5
- package/lib-amd/components/Sparkline/Sparkline.base.js.map +1 -1
- package/lib-amd/components/Sparkline/Sparkline.styles.js +1 -1
- package/lib-amd/components/Sparkline/Sparkline.styles.js.map +1 -1
- package/lib-amd/components/Sparkline/Sparkline.types.d.ts +6 -1
- package/lib-amd/components/Sparkline/Sparkline.types.js.map +1 -1
- package/lib-amd/components/TreeChart/TreeChart.base.d.ts +1 -1
- package/lib-amd/components/TreeChart/TreeChart.base.js +86 -28
- package/lib-amd/components/TreeChart/TreeChart.base.js.map +1 -1
- package/lib-amd/components/TreeChart/TreeChart.styles.js +8 -0
- package/lib-amd/components/TreeChart/TreeChart.styles.js.map +1 -1
- package/lib-amd/components/TreeChart/TreeChart.types.d.ts +100 -3
- package/lib-amd/components/TreeChart/TreeChart.types.js +12 -0
- package/lib-amd/components/TreeChart/TreeChart.types.js.map +1 -1
- package/lib-amd/version.js +1 -1
- package/lib-amd/version.js.map +1 -1
- package/lib-commonjs/components/Sparkline/Sparkline.base.d.ts +2 -0
- package/lib-commonjs/components/Sparkline/Sparkline.base.js +16 -5
- package/lib-commonjs/components/Sparkline/Sparkline.base.js.map +1 -1
- package/lib-commonjs/components/Sparkline/Sparkline.styles.js +1 -1
- package/lib-commonjs/components/Sparkline/Sparkline.styles.js.map +1 -1
- package/lib-commonjs/components/Sparkline/Sparkline.types.d.ts +6 -1
- package/lib-commonjs/components/Sparkline/Sparkline.types.js.map +1 -1
- package/lib-commonjs/components/TreeChart/TreeChart.base.d.ts +1 -1
- package/lib-commonjs/components/TreeChart/TreeChart.base.js +86 -28
- package/lib-commonjs/components/TreeChart/TreeChart.base.js.map +1 -1
- package/lib-commonjs/components/TreeChart/TreeChart.styles.js +8 -0
- package/lib-commonjs/components/TreeChart/TreeChart.styles.js.map +1 -1
- package/lib-commonjs/components/TreeChart/TreeChart.types.d.ts +100 -3
- package/lib-commonjs/components/TreeChart/TreeChart.types.js +12 -0
- package/lib-commonjs/components/TreeChart/TreeChart.types.js.map +1 -1
- package/lib-commonjs/version.js +1 -1
- package/lib-commonjs/version.js.map +1 -1
- package/package.json +3 -3
- package/src/components/Sparkline/Sparkline.types.ts +7 -1
- package/src/components/TreeChart/TreeChart.types.ts +100 -3
|
@@ -1,18 +1,45 @@
|
|
|
1
1
|
import { IStyle, ITheme } from '@fluentui/react/lib/Styling';
|
|
2
2
|
import { IStyleFunctionOrObject } from '@fluentui/react/lib/Utilities';
|
|
3
3
|
export interface ITreeChartDataPoint {
|
|
4
|
+
/**
|
|
5
|
+
* Node main text
|
|
6
|
+
*/
|
|
4
7
|
name: string;
|
|
5
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Subtext value (optional)
|
|
10
|
+
*/
|
|
11
|
+
subname?: string | undefined;
|
|
12
|
+
/**
|
|
13
|
+
* Metric text value (optional)
|
|
14
|
+
*/
|
|
6
15
|
metric?: string | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* Color of the rectangular box
|
|
18
|
+
*/
|
|
7
19
|
fill: string;
|
|
20
|
+
/**
|
|
21
|
+
* Recursive datastructure for child node object
|
|
22
|
+
*/
|
|
8
23
|
children?: Array<ITreeChartDataPoint>;
|
|
9
24
|
}
|
|
10
25
|
export declare enum NodesComposition {
|
|
26
|
+
/**
|
|
27
|
+
* NodeComposition enum val for long: number = 1
|
|
28
|
+
*/
|
|
11
29
|
long = 1,
|
|
30
|
+
/**
|
|
31
|
+
* NodeComposition enum val for compact: number = 0
|
|
32
|
+
*/
|
|
12
33
|
compact = 0
|
|
13
34
|
}
|
|
14
35
|
export declare enum TreeTraverse {
|
|
36
|
+
/**
|
|
37
|
+
* TreeTraverse enum val for preOrder: number = 1
|
|
38
|
+
*/
|
|
15
39
|
preOrder = 1,
|
|
40
|
+
/**
|
|
41
|
+
* TreeTraverse enum val for levelOrder: number = 0
|
|
42
|
+
*/
|
|
16
43
|
levelOrder = 0
|
|
17
44
|
}
|
|
18
45
|
export interface ITreeProps {
|
|
@@ -24,13 +51,18 @@ export interface ITreeProps {
|
|
|
24
51
|
* compostion for three layer chart, long: composition = 1; compact: composition = 0
|
|
25
52
|
*/
|
|
26
53
|
composition?: NodesComposition.long | NodesComposition.compact | undefined;
|
|
54
|
+
/**
|
|
55
|
+
* Node Width Size for the Tree Layout
|
|
56
|
+
* * @default 75
|
|
57
|
+
*/
|
|
58
|
+
layoutWidth?: number | undefined;
|
|
27
59
|
/**
|
|
28
60
|
* traversal order for tree chart, preOrder = 1, levelOrder = 0
|
|
29
61
|
*/
|
|
30
62
|
treeTraversal?: TreeTraverse.preOrder | TreeTraverse.levelOrder;
|
|
31
63
|
/**
|
|
32
64
|
* Width of SVG tree chart
|
|
33
|
-
* * @default
|
|
65
|
+
* * @default 1500
|
|
34
66
|
*/
|
|
35
67
|
width?: number;
|
|
36
68
|
/**
|
|
@@ -61,28 +93,93 @@ export interface ITreeProps {
|
|
|
61
93
|
theme?: ITheme;
|
|
62
94
|
}
|
|
63
95
|
export interface ITreeState {
|
|
96
|
+
/**
|
|
97
|
+
* Width of SVG tree chart
|
|
98
|
+
* * @default 1500
|
|
99
|
+
*/
|
|
64
100
|
_width: number;
|
|
101
|
+
/**
|
|
102
|
+
* Height of SVG tree chart
|
|
103
|
+
* * @default 700
|
|
104
|
+
*/
|
|
65
105
|
_height: number;
|
|
106
|
+
/**
|
|
107
|
+
* Layout Width of SVG tree chart
|
|
108
|
+
* * @default 75
|
|
109
|
+
*/
|
|
110
|
+
_layoutWidth?: number;
|
|
66
111
|
}
|
|
67
112
|
export interface ITreeDataStructure {
|
|
113
|
+
/**
|
|
114
|
+
* Node id of each node
|
|
115
|
+
*/
|
|
68
116
|
id: number;
|
|
117
|
+
/**
|
|
118
|
+
* Children node object
|
|
119
|
+
*/
|
|
69
120
|
children: unknown;
|
|
121
|
+
/**
|
|
122
|
+
* Node main text
|
|
123
|
+
*/
|
|
70
124
|
dataName: string;
|
|
71
|
-
|
|
125
|
+
/**
|
|
126
|
+
* Subtext value (optional)
|
|
127
|
+
*/
|
|
128
|
+
subName?: string | undefined;
|
|
129
|
+
/**
|
|
130
|
+
* Metric text value (optional)
|
|
131
|
+
*/
|
|
72
132
|
metricName?: string | undefined;
|
|
133
|
+
/**
|
|
134
|
+
* Color of the rectangular box
|
|
135
|
+
*/
|
|
73
136
|
fill: string;
|
|
137
|
+
/**
|
|
138
|
+
* X-coordindate of node
|
|
139
|
+
*/
|
|
74
140
|
x: number;
|
|
141
|
+
/**
|
|
142
|
+
* Y-coordindate of node
|
|
143
|
+
*/
|
|
75
144
|
y: number;
|
|
145
|
+
/**
|
|
146
|
+
* Node id of each node's parent
|
|
147
|
+
*/
|
|
76
148
|
parentID: number;
|
|
77
149
|
}
|
|
78
150
|
export interface ITreeStyleProps {
|
|
151
|
+
/**
|
|
152
|
+
* Theme (provided through customization.)
|
|
153
|
+
*/
|
|
79
154
|
theme: ITheme;
|
|
155
|
+
/**
|
|
156
|
+
* Additional CSS class(es) to apply to the TreeChart.
|
|
157
|
+
*/
|
|
80
158
|
className?: string;
|
|
81
159
|
}
|
|
82
160
|
export interface ITreeStyles {
|
|
161
|
+
/**
|
|
162
|
+
* Style for the root element.
|
|
163
|
+
*/
|
|
164
|
+
root: IStyle;
|
|
165
|
+
/**
|
|
166
|
+
* Style for the Link/Path element.
|
|
167
|
+
*/
|
|
83
168
|
link: IStyle;
|
|
169
|
+
/**
|
|
170
|
+
* Style for rectangular Node
|
|
171
|
+
*/
|
|
84
172
|
rectNode: IStyle;
|
|
173
|
+
/**
|
|
174
|
+
* Style for the node main Text
|
|
175
|
+
*/
|
|
85
176
|
rectText: IStyle;
|
|
177
|
+
/**
|
|
178
|
+
* Style for the node sub Text
|
|
179
|
+
*/
|
|
86
180
|
rectSubText: IStyle;
|
|
181
|
+
/**
|
|
182
|
+
* Style for the node metric value Text
|
|
183
|
+
*/
|
|
87
184
|
rectMetricText: IStyle;
|
|
88
185
|
}
|
|
@@ -1,11 +1,23 @@
|
|
|
1
1
|
export var NodesComposition;
|
|
2
2
|
(function (NodesComposition) {
|
|
3
|
+
/**
|
|
4
|
+
* NodeComposition enum val for long: number = 1
|
|
5
|
+
*/
|
|
3
6
|
NodesComposition[NodesComposition["long"] = 1] = "long";
|
|
7
|
+
/**
|
|
8
|
+
* NodeComposition enum val for compact: number = 0
|
|
9
|
+
*/
|
|
4
10
|
NodesComposition[NodesComposition["compact"] = 0] = "compact";
|
|
5
11
|
})(NodesComposition || (NodesComposition = {}));
|
|
6
12
|
export var TreeTraverse;
|
|
7
13
|
(function (TreeTraverse) {
|
|
14
|
+
/**
|
|
15
|
+
* TreeTraverse enum val for preOrder: number = 1
|
|
16
|
+
*/
|
|
8
17
|
TreeTraverse[TreeTraverse["preOrder"] = 1] = "preOrder";
|
|
18
|
+
/**
|
|
19
|
+
* TreeTraverse enum val for levelOrder: number = 0
|
|
20
|
+
*/
|
|
9
21
|
TreeTraverse[TreeTraverse["levelOrder"] = 0] = "levelOrder";
|
|
10
22
|
})(TreeTraverse || (TreeTraverse = {}));
|
|
11
23
|
//# sourceMappingURL=TreeChart.types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeChart.types.js","sourceRoot":"../src/","sources":["components/TreeChart/TreeChart.types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"TreeChart.types.js","sourceRoot":"../src/","sources":["components/TreeChart/TreeChart.types.ts"],"names":[],"mappings":"AA0BA,MAAM,CAAN,IAAY,gBASX;AATD,WAAY,gBAAgB;IAC1B;;OAEG;IACH,uDAAQ,CAAA;IACR;;OAEG;IACH,6DAAW,CAAA;AACb,CAAC,EATW,gBAAgB,KAAhB,gBAAgB,QAS3B;AAED,MAAM,CAAN,IAAY,YASX;AATD,WAAY,YAAY;IACtB;;OAEG;IACH,uDAAY,CAAA;IACZ;;OAEG;IACH,2DAAc,CAAA;AAChB,CAAC,EATW,YAAY,KAAZ,YAAY,QASvB","sourcesContent":["import { IStyle, ITheme } from '@fluentui/react/lib/Styling';\nimport { IStyleFunctionOrObject } from '@fluentui/react/lib/Utilities';\n\nexport interface ITreeChartDataPoint {\n /**\n * Node main text\n */\n name: string;\n /**\n * Subtext value (optional)\n */\n subname?: string | undefined;\n /**\n * Metric text value (optional)\n */\n metric?: string | undefined;\n /**\n * Color of the rectangular box\n */\n fill: string;\n /**\n * Recursive datastructure for child node object\n */\n children?: Array<ITreeChartDataPoint>;\n}\n\nexport enum NodesComposition {\n /**\n * NodeComposition enum val for long: number = 1\n */\n long = 1,\n /**\n * NodeComposition enum val for compact: number = 0\n */\n compact = 0,\n}\n\nexport enum TreeTraverse {\n /**\n * TreeTraverse enum val for preOrder: number = 1\n */\n preOrder = 1,\n /**\n * TreeTraverse enum val for levelOrder: number = 0\n */\n levelOrder = 0,\n}\n\nexport interface ITreeProps {\n /**\n * An object of chart data points for the Tree chart\n */\n treeData: ITreeChartDataPoint;\n /**\n * compostion for three layer chart, long: composition = 1; compact: composition = 0\n */\n composition?: NodesComposition.long | NodesComposition.compact | undefined;\n /**\n * Node Width Size for the Tree Layout\n * * @default 75\n */\n layoutWidth?: number | undefined;\n /**\n * traversal order for tree chart, preOrder = 1, levelOrder = 0\n */\n treeTraversal?: TreeTraverse.preOrder | TreeTraverse.levelOrder;\n /**\n * Width of SVG tree chart\n * * @default 1500\n */\n width?: number;\n /**\n * Height of SVG tree chart\n * * @default 700\n */\n height?: number;\n /**\n * Margin for the SVG tree chart\n */\n marign?: { left: number; right: number; top: number; bottom: number };\n /**\n * Call to provide customized styling that will layer on top of the variant rules.\n */\n styles?: IStyleFunctionOrObject<ITreeStyleProps, ITreeStyles>;\n /**\n * Additional CSS class(es) to apply to the TreeChart.\n */\n className?: string;\n /**\n * Theme (provided through customization.)\n */\n theme?: ITheme;\n}\nexport interface ITreeState {\n /**\n * Width of SVG tree chart\n * * @default 1500\n */\n _width: number;\n /**\n * Height of SVG tree chart\n * * @default 700\n */\n _height: number;\n /**\n * Layout Width of SVG tree chart\n * * @default 75\n */\n _layoutWidth?: number;\n}\n\nexport interface ITreeDataStructure {\n /**\n * Node id of each node\n */\n id: number;\n /**\n * Children node object\n */\n children: unknown;\n /**\n * Node main text\n */\n dataName: string;\n /**\n * Subtext value (optional)\n */\n subName?: string | undefined;\n /**\n * Metric text value (optional)\n */\n metricName?: string | undefined;\n /**\n * Color of the rectangular box\n */\n fill: string;\n /**\n * X-coordindate of node\n */\n x: number;\n /**\n * Y-coordindate of node\n */\n y: number;\n /**\n * Node id of each node's parent\n */\n parentID: number;\n}\n\nexport interface ITreeStyleProps {\n /**\n * Theme (provided through customization.)\n */\n theme: ITheme;\n /**\n * Additional CSS class(es) to apply to the TreeChart.\n */\n className?: string;\n}\nexport interface ITreeStyles {\n /**\n * Style for the root element.\n */\n root: IStyle;\n /**\n * Style for the Link/Path element.\n */\n link: IStyle;\n /**\n * Style for rectangular Node\n */\n rectNode: IStyle;\n /**\n * Style for the node main Text\n */\n rectText: IStyle;\n /**\n * Style for the node sub Text\n */\n rectSubText: IStyle;\n /**\n * Style for the node metric value Text\n */\n rectMetricText: IStyle;\n}\n"]}
|
package/lib/version.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Do not modify this file; it is generated as part of publish.
|
|
2
2
|
// The checked in version is a placeholder only and will not be updated.
|
|
3
3
|
import { setVersion } from '@fluentui/set-version';
|
|
4
|
-
setVersion('@fluentui/react-charting', '5.12.
|
|
4
|
+
setVersion('@fluentui/react-charting', '5.12.4');
|
|
5
5
|
//# sourceMappingURL=version.js.map
|
package/lib/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"../src/","sources":["version.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,wEAAwE;AACxE,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,UAAU,CAAC,0BAA0B,EAAE,QAAQ,CAAC,CAAC","sourcesContent":["// Do not modify this file; it is generated as part of publish.\n// The checked in version is a placeholder only and will not be updated.\nimport { setVersion } from '@fluentui/set-version';\nsetVersion('@fluentui/react-charting', '5.12.
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"../src/","sources":["version.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,wEAAwE;AACxE,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,UAAU,CAAC,0BAA0B,EAAE,QAAQ,CAAC,CAAC","sourcesContent":["// Do not modify this file; it is generated as part of publish.\n// The checked in version is a placeholder only and will not be updated.\nimport { setVersion } from '@fluentui/set-version';\nsetVersion('@fluentui/react-charting', '5.12.4');"]}
|
|
@@ -5,12 +5,14 @@ export interface ISparklineState {
|
|
|
5
5
|
_points: ILineChartDataPoint[] | null;
|
|
6
6
|
_width: number;
|
|
7
7
|
_height: number;
|
|
8
|
+
_valueTextWidth: number;
|
|
8
9
|
}
|
|
9
10
|
export declare class SparklineBase extends React.Component<ISparklineProps, ISparklineState> {
|
|
10
11
|
private margin;
|
|
11
12
|
private x;
|
|
12
13
|
private y;
|
|
13
14
|
private area;
|
|
15
|
+
private line;
|
|
14
16
|
constructor(props: ISparklineProps);
|
|
15
17
|
componentDidMount(): void;
|
|
16
18
|
drawSparkline(): JSX.Element;
|
|
@@ -16,7 +16,8 @@ define(["require", "exports", "tslib", "react", "d3-scale", "d3-shape", "d3-arra
|
|
|
16
16
|
_this.state = {
|
|
17
17
|
_points: null,
|
|
18
18
|
_width: _this.props.width || 80,
|
|
19
|
-
_height: _this.props.height || 20
|
|
19
|
+
_height: _this.props.height || 20,
|
|
20
|
+
_valueTextWidth: _this.props.valueTextWidth || 80,
|
|
20
21
|
};
|
|
21
22
|
return _this;
|
|
22
23
|
}
|
|
@@ -28,8 +29,15 @@ define(["require", "exports", "tslib", "react", "d3-scale", "d3-shape", "d3-arra
|
|
|
28
29
|
.y0(this.state._height)
|
|
29
30
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
30
31
|
.y1(function (d) { return _this.y(d.y); })
|
|
31
|
-
.curve(d3_shape_1.
|
|
32
|
+
.curve(d3_shape_1.curveLinear);
|
|
32
33
|
this.area = area;
|
|
34
|
+
var line = d3_shape_1.line()
|
|
35
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
36
|
+
.x(function (d) { return _this.x(d.x); })
|
|
37
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
38
|
+
.y(function (d) { return _this.y(d.y); })
|
|
39
|
+
.curve(d3_shape_1.curveLinear);
|
|
40
|
+
this.line = line;
|
|
33
41
|
var points = this.props.data.lineChartData[0].data;
|
|
34
42
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
35
43
|
var _a = d3_array_1.extent(points, function (d) { return d.x; }), xMin = _a[0], xMax = _a[1];
|
|
@@ -45,7 +53,9 @@ define(["require", "exports", "tslib", "react", "d3-scale", "d3-shape", "d3-arra
|
|
|
45
53
|
});
|
|
46
54
|
};
|
|
47
55
|
SparklineBase.prototype.drawSparkline = function () {
|
|
48
|
-
return (React.createElement(
|
|
56
|
+
return (React.createElement(React.Fragment, null,
|
|
57
|
+
React.createElement("path", { className: "line", d: this.line(this.state._points), fill: 'transparent', opacity: 1, strokeWidth: 2, stroke: this.props.data.lineChartData[0].color }),
|
|
58
|
+
React.createElement("path", { className: "area", d: this.area(this.state._points), opacity: 1, fillOpacity: 0.2, fill: this.props.data.lineChartData[0].color, "aria-label": "Sparkline with label " + this.props.data.lineChartData[0].legend })));
|
|
49
59
|
};
|
|
50
60
|
SparklineBase.prototype.render = function () {
|
|
51
61
|
var classNames = getClassNames(this.props.styles, {
|
|
@@ -53,8 +63,9 @@ define(["require", "exports", "tslib", "react", "d3-scale", "d3-shape", "d3-arra
|
|
|
53
63
|
});
|
|
54
64
|
return (React.createElement(react_focus_1.FocusZone, { direction: react_focus_1.FocusZoneDirection.horizontal, isCircularNavigation: true, className: classNames.inlineBlock },
|
|
55
65
|
React.createElement("div", { className: classNames.inlineBlock },
|
|
56
|
-
this.state._width >= 50 && this.state._height >= 16 ? (React.createElement("svg", { width: this.state._width, height: this.state._height,
|
|
57
|
-
this.props.showLegend && this.props.data.lineChartData[0].legend ? (React.createElement("
|
|
66
|
+
this.state._width >= 50 && this.state._height >= 16 ? (React.createElement("svg", { width: this.state._width, height: this.state._height, "data-is-focusable": true }, this.state._points ? this.drawSparkline() : null)) : (React.createElement(React.Fragment, null)),
|
|
67
|
+
this.props.showLegend && this.props.data.lineChartData[0].legend ? (React.createElement("svg", { width: this.state._valueTextWidth, height: this.state._height, "data-is-focusable": true },
|
|
68
|
+
React.createElement("text", { x: "0%", dx: 8, y: "100%", dy: -5, className: classNames.valueText }, this.props.data.lineChartData[0].legend))) : (React.createElement(React.Fragment, null)))));
|
|
58
69
|
};
|
|
59
70
|
return SparklineBase;
|
|
60
71
|
}(React.Component));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Sparkline.base.js","sourceRoot":"../src/","sources":["components/Sparkline/Sparkline.base.tsx"],"names":[],"mappings":";;;;IAQA,IAAM,aAAa,GAAG,8BAAkB,EAA0C,CAAC;
|
|
1
|
+
{"version":3,"file":"Sparkline.base.js","sourceRoot":"../src/","sources":["components/Sparkline/Sparkline.base.tsx"],"names":[],"mappings":";;;;IAQA,IAAM,aAAa,GAAG,8BAAkB,EAA0C,CAAC;IASnF;QAAmC,yCAAiD;QAgBlF,uBAAY,KAAsB;YAAlC,YACE,kBAAM,KAAK,CAAC,SAOb;YAvBO,YAAM,GAAG;gBACf,GAAG,EAAE,CAAC;gBACN,KAAK,EAAE,CAAC;gBACR,MAAM,EAAE,CAAC;gBACT,IAAI,EAAE,CAAC;aACR,CAAC;YAYA,KAAI,CAAC,KAAK,GAAG;gBACX,OAAO,EAAE,IAAI;gBACb,MAAM,EAAE,KAAI,CAAC,KAAK,CAAC,KAAM,IAAI,EAAE;gBAC/B,OAAO,EAAE,KAAI,CAAC,KAAK,CAAC,MAAO,IAAI,EAAE;gBACjC,eAAe,EAAE,KAAI,CAAC,KAAK,CAAC,cAAe,IAAI,EAAE;aAClD,CAAC;;QACJ,CAAC;QAEM,yCAAiB,GAAxB;YAAA,iBAkCC;YAjCC,IAAM,IAAI,GAAG,eAAM,EAAE;gBACnB,uDAAuD;iBACtD,CAAC,CAAC,UAAC,CAAM,IAAK,OAAA,KAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAX,CAAW,CAAC;iBAC1B,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC;gBACvB,uDAAuD;iBACtD,EAAE,CAAC,UAAC,CAAM,IAAK,OAAA,KAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAX,CAAW,CAAC;iBAC3B,KAAK,CAAC,sBAAa,CAAC,CAAC;YACxB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;YAEjB,IAAM,IAAI,GAAG,eAAM,EAAE;gBACnB,uDAAuD;iBACtD,CAAC,CAAC,UAAC,CAAM,IAAK,OAAA,KAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAX,CAAW,CAAC;gBAC3B,uDAAuD;iBACtD,CAAC,CAAC,UAAC,CAAM,IAAK,OAAA,KAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAX,CAAW,CAAC;iBAC1B,KAAK,CAAC,sBAAa,CAAC,CAAC;YACxB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;YAEjB,IAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAK,CAAC,aAAc,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;YAEvD,uDAAuD;YACjD,IAAA,KAAe,iBAAQ,CAAC,MAAM,EAAE,UAAC,CAAM,IAAK,OAAA,CAAC,CAAC,CAAC,EAAH,CAAG,CAAC,EAA/C,IAAI,QAAA,EAAE,IAAI,QAAqC,CAAC;YAEvD,IAAI,CAAC,CAAC,GAAG,sBAAa,EAAE;iBACrB,MAAM,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;iBACpB,KAAK,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,IAAK,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,KAAM,CAAC,CAAC,CAAC;YACtE,IAAI,CAAC,CAAC,GAAG,sBAAa,EAAE;gBACtB,uDAAuD;iBACtD,MAAM,CAAC,CAAC,CAAC,EAAE,cAAK,CAAC,MAAM,EAAE,UAAC,CAAM,IAAK,OAAA,CAAC,CAAC,CAAC,EAAH,CAAG,CAAC,CAAC,CAAC;iBAC3C,KAAK,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,MAAO,EAAE,IAAI,CAAC,MAAM,CAAC,GAAI,CAAC,CAAC,CAAC;YAEvE,IAAI,CAAC,QAAQ,CAAC;gBACZ,OAAO,EAAE,MAAM;aAChB,CAAC,CAAC;QACL,CAAC;QAEM,qCAAa,GAApB;YACE,OAAO,CACL;gBACE,8BACE,SAAS,EAAC,MAAM,EAChB,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,EAChC,IAAI,EAAE,aAAa,EACnB,OAAO,EAAE,CAAC,EACV,WAAW,EAAE,CAAC,EACd,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,IAAK,CAAC,aAAc,CAAC,CAAC,CAAC,CAAC,KAAM,GACjD;gBACF,8BACE,SAAS,EAAC,MAAM,EAChB,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,EAChC,OAAO,EAAE,CAAC,EACV,WAAW,EAAE,GAAG,EAChB,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,IAAK,CAAC,aAAc,CAAC,CAAC,CAAC,CAAC,KAAM,gBACnC,0BAAwB,IAAI,CAAC,KAAK,CAAC,IAAK,CAAC,aAAc,CAAC,CAAC,CAAC,CAAC,MAAS,GAChF,CACD,CACJ,CAAC;QACJ,CAAC;QAEM,8BAAM,GAAb;YACE,IAAM,UAAU,GAAG,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,MAAO,EAAE;gBACnD,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAM;aACzB,CAAC,CAAC;YACH,OAAO,CACL,oBAAC,uBAAS,IACR,SAAS,EAAE,gCAAkB,CAAC,UAAU,EACxC,oBAAoB,EAAE,IAAI,EAC1B,SAAS,EAAE,UAAU,CAAC,WAAW;gBAEjC,6BAAK,SAAS,EAAE,UAAU,CAAC,WAAW;oBACnC,IAAI,CAAC,KAAK,CAAC,MAAM,IAAI,EAAE,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,CAAC,CACrD,6BAAK,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO,uBAAqB,IAAI,IAC/E,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC,IAAI,CAC7C,CACP,CAAC,CAAC,CAAC,CACF,yCAAK,CACN;oBACA,IAAI,CAAC,KAAK,CAAC,UAAU,IAAI,IAAI,CAAC,KAAK,CAAC,IAAK,CAAC,aAAc,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CACpE,6BAAK,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,eAAe,EAAE,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO,uBAAqB,IAAI;wBACzF,8BAAM,CAAC,EAAC,IAAI,EAAC,EAAE,EAAE,CAAC,EAAE,CAAC,EAAC,MAAM,EAAC,EAAE,EAAE,CAAC,CAAC,EAAE,SAAS,EAAE,UAAU,CAAC,SAAS,IACjE,IAAI,CAAC,KAAK,CAAC,IAAK,CAAC,aAAc,CAAC,CAAC,CAAC,CAAC,MAAO,CACtC,CACH,CACP,CAAC,CAAC,CAAC,CACF,yCAAK,CACN,CACG,CACI,CACb,CAAC;QACJ,CAAC;QACH,oBAAC;IAAD,CAAC,AApHD,CAAmC,KAAK,CAAC,SAAS,GAoHjD;IApHY,sCAAa","sourcesContent":["import * as React from 'react';\nimport { scaleLinear as d3ScaleLinear } from 'd3-scale';\nimport { area as d3Area, line as d3Line, curveLinear as d3curveLinear } from 'd3-shape';\nimport { max as d3Max, extent as d3Extent } from 'd3-array';\nimport { FocusZone, FocusZoneDirection } from '@fluentui/react-focus';\nimport { ILineChartDataPoint } from '../../types/IDataPoint';\nimport { classNamesFunction } from '@fluentui/react/lib/Utilities';\nimport { ISparklineProps, ISparklineStyleProps, ISparklineStyles } from '../../index';\nconst getClassNames = classNamesFunction<ISparklineStyleProps, ISparklineStyles>();\n\nexport interface ISparklineState {\n _points: ILineChartDataPoint[] | null;\n _width: number;\n _height: number;\n _valueTextWidth: number;\n}\n\nexport class SparklineBase extends React.Component<ISparklineProps, ISparklineState> {\n private margin = {\n top: 2,\n right: 0,\n bottom: 0,\n left: 0,\n };\n\n /* eslint-disable @typescript-eslint/no-explicit-any */\n private x: any;\n\n /* eslint-disable @typescript-eslint/no-explicit-any */\n private y: any;\n private area: any;\n private line: any;\n\n constructor(props: ISparklineProps) {\n super(props);\n this.state = {\n _points: null,\n _width: this.props.width! || 80,\n _height: this.props.height! || 20,\n _valueTextWidth: this.props.valueTextWidth! || 80,\n };\n }\n\n public componentDidMount() {\n const area = d3Area()\n /* eslint-disable @typescript-eslint/no-explicit-any */\n .x((d: any) => this.x(d.x))\n .y0(this.state._height)\n /* eslint-disable @typescript-eslint/no-explicit-any */\n .y1((d: any) => this.y(d.y))\n .curve(d3curveLinear);\n this.area = area;\n\n const line = d3Line()\n /* eslint-disable @typescript-eslint/no-explicit-any */\n .x((d: any) => this.x(d.x))\n /* eslint-disable @typescript-eslint/no-explicit-any */\n .y((d: any) => this.y(d.y))\n .curve(d3curveLinear);\n this.line = line;\n\n const points = this.props.data!.lineChartData![0].data;\n\n /* eslint-disable @typescript-eslint/no-explicit-any */\n const [xMin, xMax] = d3Extent(points, (d: any) => d.x);\n\n this.x = d3ScaleLinear()\n .domain([xMin, xMax])\n .range([this.margin.left!, this.state._width - this.margin.right!]);\n this.y = d3ScaleLinear()\n /* eslint-disable @typescript-eslint/no-explicit-any */\n .domain([0, d3Max(points, (d: any) => d.y)])\n .range([this.state._height - this.margin.bottom!, this.margin.top!]);\n\n this.setState({\n _points: points,\n });\n }\n\n public drawSparkline() {\n return (\n <>\n <path\n className=\"line\"\n d={this.line(this.state._points)}\n fill={'transparent'}\n opacity={1}\n strokeWidth={2}\n stroke={this.props.data!.lineChartData![0].color!}\n />\n <path\n className=\"area\"\n d={this.area(this.state._points)}\n opacity={1}\n fillOpacity={0.2}\n fill={this.props.data!.lineChartData![0].color!}\n aria-label={`Sparkline with label ${this.props.data!.lineChartData![0].legend!}`}\n />\n </>\n );\n }\n\n public render() {\n const classNames = getClassNames(this.props.styles!, {\n theme: this.props.theme!,\n });\n return (\n <FocusZone\n direction={FocusZoneDirection.horizontal}\n isCircularNavigation={true}\n className={classNames.inlineBlock}\n >\n <div className={classNames.inlineBlock}>\n {this.state._width >= 50 && this.state._height >= 16 ? (\n <svg width={this.state._width} height={this.state._height} data-is-focusable={true}>\n {this.state._points ? this.drawSparkline() : null}\n </svg>\n ) : (\n <></>\n )}\n {this.props.showLegend && this.props.data!.lineChartData![0].legend ? (\n <svg width={this.state._valueTextWidth} height={this.state._height} data-is-focusable={true}>\n <text x=\"0%\" dx={8} y=\"100%\" dy={-5} className={classNames.valueText}>\n {this.props.data!.lineChartData![0].legend!}\n </text>\n </svg>\n ) : (\n <></>\n )}\n </div>\n </FocusZone>\n );\n }\n}\n"]}
|
|
@@ -7,7 +7,7 @@ define(["require", "exports", "tslib"], function (require, exports, tslib_1) {
|
|
|
7
7
|
inlineBlock: {
|
|
8
8
|
display: 'inline',
|
|
9
9
|
},
|
|
10
|
-
|
|
10
|
+
valueText: tslib_1.__assign({}, props.theme.fonts.smallPlus),
|
|
11
11
|
};
|
|
12
12
|
};
|
|
13
13
|
exports.getStyles = getStyles;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Sparkline.styles.js","sourceRoot":"../src/","sources":["components/Sparkline/Sparkline.styles.ts"],"names":[],"mappings":";;;;IAEO,IAAM,SAAS,GAAG,UAAC,KAA2B;QACnD,OAAO;YACL,WAAW,EAAE;gBACX,OAAO,EAAE,QAAQ;aAClB;YACD,SAAS,
|
|
1
|
+
{"version":3,"file":"Sparkline.styles.js","sourceRoot":"../src/","sources":["components/Sparkline/Sparkline.styles.ts"],"names":[],"mappings":";;;;IAEO,IAAM,SAAS,GAAG,UAAC,KAA2B;QACnD,OAAO;YACL,WAAW,EAAE;gBACX,OAAO,EAAE,QAAQ;aAClB;YACD,SAAS,uBACJ,KAAK,CAAC,KAAM,CAAC,KAAK,CAAC,SAAS,CAChC;SACF,CAAC;IACJ,CAAC,CAAC;IATW,QAAA,SAAS,aASpB","sourcesContent":["import { ISparklineStyleProps, ISparklineStyles } from './Sparkline.types';\n\nexport const getStyles = (props: ISparklineStyleProps): ISparklineStyles => {\n return {\n inlineBlock: {\n display: 'inline',\n },\n valueText: {\n ...props.theme!.fonts.smallPlus,\n },\n };\n};\n"]}
|
|
@@ -19,6 +19,11 @@ export interface ISparklineProps {
|
|
|
19
19
|
* @default 20
|
|
20
20
|
*/
|
|
21
21
|
height?: number;
|
|
22
|
+
/**
|
|
23
|
+
* Width of value text
|
|
24
|
+
* * @default 80
|
|
25
|
+
*/
|
|
26
|
+
valueTextWidth?: number;
|
|
22
27
|
/**
|
|
23
28
|
* Additional CSS class(es) to apply to the SparklineChart.
|
|
24
29
|
*/
|
|
@@ -42,5 +47,5 @@ export interface ISparklineProps {
|
|
|
42
47
|
}
|
|
43
48
|
export interface ISparklineStyles {
|
|
44
49
|
inlineBlock?: IStyle;
|
|
45
|
-
|
|
50
|
+
valueText?: IStyle;
|
|
46
51
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Sparkline.types.js","sourceRoot":"../src/","sources":["components/Sparkline/Sparkline.types.ts"],"names":[],"mappings":"","sourcesContent":["import { ITheme, IStyle } from '@fluentui/react/lib/Styling';\nimport { IStyleFunctionOrObject } from '@fluentui/react/lib/Utilities';\nimport { IChartProps } from '../../types/IDataPoint';\nimport { ICartesianChartStyleProps } from '../CommonComponents/index';\n\nexport interface ISparklineStyleProps extends ICartesianChartStyleProps {}\n\nexport interface ISparklineProps {\n /**\n * An array of chart data points for the Sparkline chart\n */\n data?: IChartProps;\n\n /**\n * Width of chart\n * * @default 80\n */\n width?: number;\n\n /**\n * Height of chart\n * @default 20\n */\n height?: number;\n\n /**\n * Additional CSS class(es) to apply to the SparklineChart.\n */\n className?: string;\n\n /**\n * Theme (provided through customization.)\n */\n theme?: ITheme;\n\n /**\n * The prop used to define the culture to localized the numbers\n */\n culture?: string;\n\n /**\n * Prop used to determine whether to show the legend or not\n */\n showLegend?: boolean;\n\n /**\n * Call to provide customized styling that will layer on top of the variant rules.\n */\n styles?: IStyleFunctionOrObject<ISparklineStyleProps, ISparklineStyles>;\n}\n\nexport interface ISparklineStyles {\n inlineBlock?: IStyle;\n
|
|
1
|
+
{"version":3,"file":"Sparkline.types.js","sourceRoot":"../src/","sources":["components/Sparkline/Sparkline.types.ts"],"names":[],"mappings":"","sourcesContent":["import { ITheme, IStyle } from '@fluentui/react/lib/Styling';\nimport { IStyleFunctionOrObject } from '@fluentui/react/lib/Utilities';\nimport { IChartProps } from '../../types/IDataPoint';\nimport { ICartesianChartStyleProps } from '../CommonComponents/index';\n\nexport interface ISparklineStyleProps extends ICartesianChartStyleProps {}\n\nexport interface ISparklineProps {\n /**\n * An array of chart data points for the Sparkline chart\n */\n data?: IChartProps;\n\n /**\n * Width of chart\n * * @default 80\n */\n width?: number;\n\n /**\n * Height of chart\n * @default 20\n */\n height?: number;\n\n /**\n * Width of value text\n * * @default 80\n */\n valueTextWidth?: number;\n\n /**\n * Additional CSS class(es) to apply to the SparklineChart.\n */\n className?: string;\n\n /**\n * Theme (provided through customization.)\n */\n theme?: ITheme;\n\n /**\n * The prop used to define the culture to localized the numbers\n */\n culture?: string;\n\n /**\n * Prop used to determine whether to show the legend or not\n */\n showLegend?: boolean;\n\n /**\n * Call to provide customized styling that will layer on top of the variant rules.\n */\n styles?: IStyleFunctionOrObject<ISparklineStyleProps, ISparklineStyles>;\n}\n\nexport interface ISparklineStyles {\n inlineBlock?: IStyle;\n valueText?: IStyle;\n}\n"]}
|
|
@@ -6,13 +6,13 @@ export declare class TreeChartBase extends React.Component<ITreeProps, ITreeStat
|
|
|
6
6
|
private _height;
|
|
7
7
|
private _composition;
|
|
8
8
|
private _classNames;
|
|
9
|
-
private _rootElem;
|
|
10
9
|
private _margin;
|
|
11
10
|
private _nodeElements;
|
|
12
11
|
private _linkElements;
|
|
13
12
|
private _treeTraversal;
|
|
14
13
|
constructor(props: ITreeProps);
|
|
15
14
|
componentDidMount(): void;
|
|
15
|
+
componentDidUpdate(prevProps: ITreeProps): void;
|
|
16
16
|
createTreeChart(): void;
|
|
17
17
|
render(): JSX.Element;
|
|
18
18
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
define(["require", "exports", "tslib", "react", "d3-
|
|
1
|
+
define(["require", "exports", "tslib", "react", "d3-hierarchy", "@fluentui/react/lib/Utilities", "d3-selection", "@fluentui/react-focus"], function (require, exports, tslib_1, React, d3_hierarchy_1, Utilities_1, d3_selection_1, react_focus_1) {
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.TreeChartBase = void 0;
|
|
@@ -15,18 +15,56 @@ define(["require", "exports", "tslib", "react", "d3-selection", "d3-hierarchy",
|
|
|
15
15
|
this._nodeElements = _nodeElements;
|
|
16
16
|
this._linkElements = _linkElements;
|
|
17
17
|
}
|
|
18
|
+
StandardTree.prototype.truncateText = function (text, rectangleWidth, padding, styleClass) {
|
|
19
|
+
var truncatedText = '';
|
|
20
|
+
var words = text.split(/\s+/).reverse();
|
|
21
|
+
var word = '';
|
|
22
|
+
var tspan = d3_selection_1.select('.svgTree').append('text').attr('class', 'tempText').append('tspan').text(null);
|
|
23
|
+
if (styleClass !== undefined) {
|
|
24
|
+
tspan.attr('class', styleClass);
|
|
25
|
+
}
|
|
26
|
+
var line = [];
|
|
27
|
+
while ((word = words.pop())) {
|
|
28
|
+
line.push(word);
|
|
29
|
+
tspan.text(line.join(' ') + ' ');
|
|
30
|
+
if (tspan.node() !== null) {
|
|
31
|
+
var w = tspan.node().getComputedTextLength();
|
|
32
|
+
if (w > rectangleWidth - padding) {
|
|
33
|
+
line.pop();
|
|
34
|
+
line.push('...');
|
|
35
|
+
break;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
truncatedText = line.join(' ') + ' ';
|
|
40
|
+
tspan.text(null);
|
|
41
|
+
d3_selection_1.selectAll('.tempText').remove();
|
|
42
|
+
return truncatedText;
|
|
43
|
+
};
|
|
18
44
|
// Append node elements
|
|
19
45
|
// nodeId to create unique key
|
|
20
46
|
StandardTree.prototype.addNodeShapetoSVG = function (name, subname, metricName, xCoordinate, yCoordinate, fillColor, rectangleWidth, rectangleHeight, nodeId, parentInfo) {
|
|
21
47
|
var ariaLabel = "nodeId: " + nodeId + " \nnodeMainText: " + name + "\nsubText " + subname + " " + parentInfo;
|
|
22
48
|
this._nodeElements.push(React.createElement("rect", { width: rectangleWidth, height: rectangleHeight, x: xCoordinate, y: yCoordinate, tabIndex: 0, role: 'text', "data-is-focusable": true, "aria-label": ariaLabel, className: this.styleClassNames.rectNode, stroke: fillColor, key: "" + nodeId + this.styleClassNames.rectNode }));
|
|
49
|
+
if (subname !== undefined) {
|
|
50
|
+
subname = this.truncateText(subname, rectangleWidth, rectangleWidth / 4, this.styleClassNames.rectSubText);
|
|
51
|
+
}
|
|
52
|
+
if (metricName !== undefined) {
|
|
53
|
+
metricName = this.truncateText(metricName, rectangleWidth, rectangleWidth / 4, this.styleClassNames.rectmetricText);
|
|
54
|
+
}
|
|
55
|
+
name = this.truncateText(name, rectangleWidth, rectangleWidth / 4, this.styleClassNames.rectText);
|
|
23
56
|
// Text position y = y + rectHeight/2, 2 is ratio for depth
|
|
24
57
|
// Text position x = x + rectWidth/2, 2 is ratio for length
|
|
25
58
|
// Sub-text position x = x + rectWidth/2, 2 is ratio for length
|
|
26
59
|
var subValue = metricName !== undefined ? (React.createElement("tspan", { className: this.styleClassNames.rectmetricText, dy: "1.4em", x: xCoordinate + rectangleWidth / 2 }, metricName)) : (React.createElement("tspan", { className: this.styleClassNames.rectSubText, dy: "1.4em", x: xCoordinate + rectangleWidth / 2 }, subname));
|
|
27
|
-
|
|
28
|
-
name
|
|
29
|
-
|
|
60
|
+
if (subname === undefined && metricName === undefined) {
|
|
61
|
+
this._nodeElements.push(React.createElement("text", { textAnchor: "middle", className: this.styleClassNames.rectmetricText, dy: yCoordinate + rectangleHeight / 1.6, x: xCoordinate + rectangleWidth / 2, key: "" + nodeId + this.styleClassNames.rectText }, name));
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
this._nodeElements.push(React.createElement("text", { textAnchor: "middle", className: metricName !== undefined ? this.styleClassNames.rectSubText : this.styleClassNames.rectText, dy: metricName !== undefined ? yCoordinate + rectangleHeight / 2.5 : yCoordinate + rectangleHeight / 2, x: xCoordinate + rectangleWidth / 2, key: "" + nodeId + this.styleClassNames.rectText },
|
|
65
|
+
name,
|
|
66
|
+
subValue));
|
|
67
|
+
}
|
|
30
68
|
};
|
|
31
69
|
// Create a rectangular path from parent to the child nodes
|
|
32
70
|
StandardTree.prototype.createPathLink = function (parentX, parentY, childX, childY, leaf, rectWidth, rectHeight, gap) {
|
|
@@ -53,16 +91,25 @@ define(["require", "exports", "tslib", "react", "d3-selection", "d3-hierarchy",
|
|
|
53
91
|
_this._treeTraversal = _treeTraversal;
|
|
54
92
|
return _this;
|
|
55
93
|
}
|
|
56
|
-
LayeredTree.prototype.createTree = function () {
|
|
94
|
+
LayeredTree.prototype.createTree = function (givenLayoutWidth, screenWidth) {
|
|
57
95
|
var _a, _b, _c, _d;
|
|
96
|
+
if (givenLayoutWidth !== undefined) {
|
|
97
|
+
if (givenLayoutWidth < 65) {
|
|
98
|
+
givenLayoutWidth = 65;
|
|
99
|
+
}
|
|
100
|
+
if (givenLayoutWidth > 90) {
|
|
101
|
+
givenLayoutWidth = 90;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
var layoutWidth = givenLayoutWidth || 75;
|
|
58
105
|
var root = d3_hierarchy_1.hierarchy(this.treeData, function (d) {
|
|
59
106
|
return d.children;
|
|
60
107
|
});
|
|
61
108
|
// Find tree Height
|
|
62
109
|
var treeHeight = (root === null || root === void 0 ? void 0 : root.height) + 1;
|
|
63
|
-
// Create tree layout, width:
|
|
110
|
+
// Create tree layout, width: layoutWidth, height: layoutWidth/1.5 and add node separation
|
|
64
111
|
var treemap = d3_hierarchy_1.tree()
|
|
65
|
-
.nodeSize([
|
|
112
|
+
.nodeSize([layoutWidth, layoutWidth / 1.5])
|
|
66
113
|
.separation(function (a, b) {
|
|
67
114
|
return a.parent === root && b.parent === root ? 3.5 : 1;
|
|
68
115
|
});
|
|
@@ -72,10 +119,10 @@ define(["require", "exports", "tslib", "react", "d3-selection", "d3-hierarchy",
|
|
|
72
119
|
var nodes = treeData.descendants();
|
|
73
120
|
// Normalize for fixed-depth and width
|
|
74
121
|
// Normalise y coordinate by depth of each node by a factor of 130
|
|
75
|
-
// Normalise x coordinate by start coordinate 0 with
|
|
122
|
+
// Normalise x coordinate by start coordinate 0 with screenSize/3
|
|
76
123
|
nodes.forEach(function (d) {
|
|
77
124
|
d.y = d.depth === 0 ? 10 : d.depth * 130;
|
|
78
|
-
d.x +=
|
|
125
|
+
d.x += screenWidth / 3;
|
|
79
126
|
});
|
|
80
127
|
// <------------------ Traversal section ------------------>
|
|
81
128
|
// Create tree data structure
|
|
@@ -105,8 +152,8 @@ define(["require", "exports", "tslib", "react", "d3-selection", "d3-hierarchy",
|
|
|
105
152
|
: root.eachBefore(function (d) {
|
|
106
153
|
createTreeDataStructure(d);
|
|
107
154
|
});
|
|
108
|
-
var
|
|
109
|
-
var
|
|
155
|
+
var rectWidth = layoutWidth * 3;
|
|
156
|
+
var rectHeight = rectWidth / 3.45;
|
|
110
157
|
var gap = 20;
|
|
111
158
|
var parentSet = new Set();
|
|
112
159
|
for (var _i = 0, treeDataStructure_1 = treeDataStructure; _i < treeDataStructure_1.length; _i++) {
|
|
@@ -117,7 +164,7 @@ define(["require", "exports", "tslib", "react", "d3-selection", "d3-hierarchy",
|
|
|
117
164
|
// check for leaf nodes
|
|
118
165
|
if (!d.children && !parentSet.has(d.parentID) && treeHeight === 3) {
|
|
119
166
|
var newWidth = (rectWidth - gap) / 2;
|
|
120
|
-
var newHeight =
|
|
167
|
+
var newHeight = rectHeight;
|
|
121
168
|
parentSet.add(d.parentID);
|
|
122
169
|
// <------------------ Links section ------------------>
|
|
123
170
|
this.addLinktoSVG(d.id, treeDataStructure[d.parentID].x, treeDataStructure[d.parentID].y, treeDataStructure[d.id].x, treeDataStructure[d.id].y, true, rectWidth, rectHeight, gap);
|
|
@@ -179,14 +226,14 @@ define(["require", "exports", "tslib", "react", "d3-selection", "d3-hierarchy",
|
|
|
179
226
|
_this._nodeElements = [];
|
|
180
227
|
_this._linkElements = [];
|
|
181
228
|
_this._margin = { top: 30, right: 20, bottom: 30, left: 50 };
|
|
182
|
-
_this._width = _this.props.width ||
|
|
229
|
+
_this._width = _this.props.width || 1500;
|
|
183
230
|
_this._height = _this.props.height || 700;
|
|
184
231
|
_this._treeData = _this.props.treeData;
|
|
185
232
|
_this._composition = (_a = _this.props) === null || _a === void 0 ? void 0 : _a.composition;
|
|
186
233
|
_this._treeTraversal = _this.props.treeTraversal;
|
|
187
234
|
_this.state = {
|
|
188
|
-
_width: _this._width
|
|
189
|
-
_height: _this._height
|
|
235
|
+
_width: _this._width,
|
|
236
|
+
_height: _this._height,
|
|
190
237
|
};
|
|
191
238
|
return _this;
|
|
192
239
|
}
|
|
@@ -199,18 +246,27 @@ define(["require", "exports", "tslib", "react", "d3-selection", "d3-hierarchy",
|
|
|
199
246
|
});
|
|
200
247
|
// Call createTreeChart function in componentDidMount
|
|
201
248
|
this.createTreeChart();
|
|
202
|
-
var reducedHeight = this._rootElem && this._rootElem.offsetHeight / 5;
|
|
203
249
|
this.setState({
|
|
204
|
-
_width:
|
|
205
|
-
_height:
|
|
250
|
+
_width: this.props.width || 1500,
|
|
251
|
+
_height: this.props.height || 700,
|
|
206
252
|
});
|
|
207
253
|
};
|
|
254
|
+
TreeChartBase.prototype.componentDidUpdate = function (prevProps) {
|
|
255
|
+
if (prevProps.layoutWidth !== this.props.layoutWidth) {
|
|
256
|
+
var svgText = d3_selection_1.selectAll('text');
|
|
257
|
+
var svgRect = d3_selection_1.selectAll('rect');
|
|
258
|
+
var svgLink = d3_selection_1.selectAll('path');
|
|
259
|
+
if (this._nodeElements.length === 0 && this._linkElements.length === 0) {
|
|
260
|
+
svgText.remove();
|
|
261
|
+
svgRect.remove();
|
|
262
|
+
svgLink.remove();
|
|
263
|
+
}
|
|
264
|
+
this.createTreeChart();
|
|
265
|
+
}
|
|
266
|
+
};
|
|
208
267
|
TreeChartBase.prototype.createTreeChart = function () {
|
|
209
|
-
var
|
|
210
|
-
|
|
211
|
-
svg
|
|
212
|
-
.attr('width', this.state._width - this._margin.left - this._margin.right)
|
|
213
|
-
.attr('height', this.state._height - this._margin.top - this._margin.bottom);
|
|
268
|
+
var nodeElements = [];
|
|
269
|
+
var linkElements = [];
|
|
214
270
|
// Create styleClass object to access it in parent class
|
|
215
271
|
var styleClassNames = {
|
|
216
272
|
link: this._classNames.link,
|
|
@@ -220,14 +276,16 @@ define(["require", "exports", "tslib", "react", "d3-selection", "d3-hierarchy",
|
|
|
220
276
|
rectmetricText: this._classNames.rectMetricText,
|
|
221
277
|
};
|
|
222
278
|
// Instantiate inherited class and call createTree function for the object
|
|
223
|
-
var treeObject = new LayeredTree(this._treeData, this._composition, styleClassNames,
|
|
224
|
-
treeObject.createTree();
|
|
279
|
+
var treeObject = new LayeredTree(this._treeData, this._composition, styleClassNames, nodeElements, linkElements, this._treeTraversal);
|
|
280
|
+
treeObject.createTree(this.props.layoutWidth, this._width);
|
|
281
|
+
this._nodeElements = nodeElements;
|
|
282
|
+
this._linkElements = linkElements;
|
|
225
283
|
};
|
|
226
284
|
TreeChartBase.prototype.render = function () {
|
|
227
|
-
var
|
|
285
|
+
var _a;
|
|
228
286
|
return (React.createElement(react_focus_1.FocusZone, null,
|
|
229
|
-
React.createElement("div", { className:
|
|
230
|
-
React.createElement("svg", { className: "svgTree" },
|
|
287
|
+
React.createElement("div", { className: (_a = this._classNames) === null || _a === void 0 ? void 0 : _a.root },
|
|
288
|
+
React.createElement("svg", { className: "svgTree", width: this.state._width - this._margin.left - this._margin.right, height: this.state._height - this._margin.top - this._margin.bottom },
|
|
231
289
|
React.createElement("g", { className: "svgNode" }, this._nodeElements.map(function (element) { return element; })),
|
|
232
290
|
React.createElement("g", { className: "svgLink" }, this._linkElements.map(function (element) { return element; }))))));
|
|
233
291
|
};
|