@fluentui/react-charting 5.19.26 → 5.19.28
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 +31 -1
- package/CHANGELOG.md +20 -2
- package/dist/react-charting.d.ts +40 -0
- package/dist/react-charting.js +1 -1
- package/dist/react-charting.min.js +1 -1
- package/etc/react-charting.api.md +14 -0
- package/lib/components/SankeyChart/SankeyChart.base.d.ts +2 -0
- package/lib/components/SankeyChart/SankeyChart.base.js +64 -40
- package/lib/components/SankeyChart/SankeyChart.base.js.map +1 -1
- package/lib/components/SankeyChart/SankeyChart.types.d.ts +39 -1
- package/lib/components/SankeyChart/SankeyChart.types.js.map +1 -1
- package/lib/version.js +1 -1
- package/lib/version.js.map +1 -1
- package/lib-amd/components/SankeyChart/SankeyChart.base.d.ts +2 -0
- package/lib-amd/components/SankeyChart/SankeyChart.base.js +63 -39
- package/lib-amd/components/SankeyChart/SankeyChart.base.js.map +1 -1
- package/lib-amd/components/SankeyChart/SankeyChart.types.d.ts +39 -1
- package/lib-amd/components/SankeyChart/SankeyChart.types.js.map +1 -1
- package/lib-amd/version.js +1 -1
- package/lib-amd/version.js.map +1 -1
- package/lib-commonjs/components/SankeyChart/SankeyChart.base.d.ts +2 -0
- package/lib-commonjs/components/SankeyChart/SankeyChart.base.js +63 -39
- package/lib-commonjs/components/SankeyChart/SankeyChart.base.js.map +1 -1
- package/lib-commonjs/components/SankeyChart/SankeyChart.types.d.ts +39 -1
- package/lib-commonjs/components/SankeyChart/SankeyChart.types.js.map +1 -1
- package/lib-commonjs/version.js +1 -1
- package/lib-commonjs/version.js.map +1 -1
- package/package.json +1 -1
- package/src/components/SankeyChart/SankeyChart.types.ts +43 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IStyle, ITheme } from '@fluentui/react/lib/Styling';
|
|
2
2
|
import { IStyleFunctionOrObject } from '@fluentui/react/lib/Utilities';
|
|
3
3
|
import { IChartProps } from '../../types/IDataPoint';
|
|
4
4
|
export type { IChartProps, IDataPoint, ISankeyChartData } from '../../types/IDataPoint';
|
|
@@ -51,6 +51,14 @@ export interface ISankeyChartProps {
|
|
|
51
51
|
* Colors for nodes border
|
|
52
52
|
*/
|
|
53
53
|
borderColorsForNodes?: string[];
|
|
54
|
+
/**
|
|
55
|
+
* Localized strings to show in the UX.
|
|
56
|
+
*/
|
|
57
|
+
strings?: ISankeyChartStrings;
|
|
58
|
+
/**
|
|
59
|
+
* Localized strings to use for the chart's accessibility features.
|
|
60
|
+
*/
|
|
61
|
+
accessibility?: ISankeyChartAccessibilityProps;
|
|
54
62
|
}
|
|
55
63
|
/**
|
|
56
64
|
* Sankey Chart style properties
|
|
@@ -93,3 +101,33 @@ export interface ISankeyChartStyles {
|
|
|
93
101
|
*/
|
|
94
102
|
calloutContentRoot?: IStyle;
|
|
95
103
|
}
|
|
104
|
+
/**
|
|
105
|
+
* Set of strings which are used when rendering the chart.
|
|
106
|
+
*/
|
|
107
|
+
export interface ISankeyChartStrings {
|
|
108
|
+
/**
|
|
109
|
+
* A value similar to "from \{0\}" where \{0\} is the name of the source node for a link.
|
|
110
|
+
* This is shown in the `ChartHoverCard` when the user hovers the mouse over a link.
|
|
111
|
+
*/
|
|
112
|
+
linkFrom?: string;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Set of strings which are used when rendering accessibility information within the chart.
|
|
116
|
+
*/
|
|
117
|
+
export interface ISankeyChartAccessibilityProps {
|
|
118
|
+
/**
|
|
119
|
+
* Aria label for when the chart is empty.
|
|
120
|
+
*/
|
|
121
|
+
emptyAriaLabel?: string;
|
|
122
|
+
/**
|
|
123
|
+
* A value similar to "node \{0\} with weight \{1\}".
|
|
124
|
+
* \{0\} is the name of the node.
|
|
125
|
+
* \{1\} is the weight of the node (as computed by the sankey layout engine via the links to or from this node).
|
|
126
|
+
*/
|
|
127
|
+
nodeAriaLabel?: string;
|
|
128
|
+
/**
|
|
129
|
+
* A value similar to "link from \{0\} to $\{1\} with weight $\{2\}".
|
|
130
|
+
* \{0\} is the source node, \{1\} is the target node, and \{2\} is the value of the link.
|
|
131
|
+
*/
|
|
132
|
+
linkAriaLabel?: string;
|
|
133
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SankeyChart.types.js","sourceRoot":"../src/","sources":["components/SankeyChart/SankeyChart.types.ts"],"names":[],"mappings":"","sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"SankeyChart.types.js","sourceRoot":"../src/","sources":["components/SankeyChart/SankeyChart.types.ts"],"names":[],"mappings":"","sourcesContent":["import { IStyle, ITheme } from '@fluentui/react/lib/Styling';\nimport { IStyleFunctionOrObject } from '@fluentui/react/lib/Utilities';\nimport { IChartProps } from '../../types/IDataPoint';\n\nexport type { IChartProps, IDataPoint, ISankeyChartData } from '../../types/IDataPoint';\n\n/**\n * Sankey Chart properties\n * {@docCategory SankeyChart}\n */\nexport interface ISankeyChartProps {\n /**\n * Data to render in the chart.\n */\n data: IChartProps;\n\n /**\n * Width of the chart.\n */\n width?: number;\n\n /**\n * Height of the chart.\n */\n height?: number;\n\n /**\n * Additional CSS class(es) to apply to the SankeyChart.\n */\n className?: string;\n\n /**\n * Theme (provided through customization.)\n */\n theme?: ITheme;\n\n /**\n * Call to provide customized styling that will layer on top of the variant rules.\n */\n styles?: IStyleFunctionOrObject<ISankeyChartStyleProps, ISankeyChartStyles>;\n\n /**\n * this prop takes its parent as a HTML element to define the width and height of the Sankey chart\n */\n parentRef?: HTMLElement | null;\n\n /**\n * should chart resize when parent resize.\n */\n shouldResize?: number;\n\n /**\n * Color for path\n */\n pathColor?: string;\n\n /**\n * Colors for nodes\n */\n colorsForNodes?: string[];\n\n /**\n * Colors for nodes border\n */\n borderColorsForNodes?: string[];\n\n /**\n * Localized strings to show in the UX.\n */\n strings?: ISankeyChartStrings;\n\n /**\n * Localized strings to use for the chart's accessibility features.\n */\n accessibility?: ISankeyChartAccessibilityProps;\n}\n\n/**\n * Sankey Chart style properties\n * {@docCategory SankeyChart}\n */\nexport interface ISankeyChartStyleProps {\n theme: ITheme;\n className?: string;\n width: number;\n height: number;\n pathColor?: string;\n}\n\n/**\n * Sankey Chart styles\n * {@docCategory SankeyChart}\n */\nexport interface ISankeyChartStyles {\n /**\n * Style for the root element.\n */\n root?: IStyle;\n\n /**\n * Style for the nodes.\n */\n nodes?: IStyle;\n\n /**\n * Style for the links.\n */\n links?: IStyle;\n\n /**\n * Style for the text inside node.\n */\n nodeTextContainer?: IStyle;\n\n /**\n * Style for the tooltip ,when user hover over the truncated node detail.\n */\n toolTip?: IStyle;\n\n /**\n * Style for the tooltip ,when user hover over the truncated node detail.\n */\n\n calloutContentRoot?: IStyle;\n}\n\n/**\n * Set of strings which are used when rendering the chart.\n */\nexport interface ISankeyChartStrings {\n /**\n * A value similar to \"from \\{0\\}\" where \\{0\\} is the name of the source node for a link.\n * This is shown in the `ChartHoverCard` when the user hovers the mouse over a link.\n */\n linkFrom?: string;\n}\n\n/**\n * Set of strings which are used when rendering accessibility information within the chart.\n */\nexport interface ISankeyChartAccessibilityProps {\n /**\n * Aria label for when the chart is empty.\n */\n emptyAriaLabel?: string;\n /**\n * A value similar to \"node \\{0\\} with weight \\{1\\}\".\n * \\{0\\} is the name of the node.\n * \\{1\\} is the weight of the node (as computed by the sankey layout engine via the links to or from this node).\n */\n nodeAriaLabel?: string;\n /**\n * A value similar to \"link from \\{0\\} to $\\{1\\} with weight $\\{2\\}\".\n * \\{0\\} is the source node, \\{1\\} is the target node, and \\{2\\} is the value of the link.\n */\n linkAriaLabel?: string;\n}\n"]}
|
package/lib-amd/version.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
define(["require", "exports", "@fluentui/set-version"], function (require, exports, set_version_1) {
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
(0, set_version_1.setVersion)('@fluentui/react-charting', '5.19.
|
|
4
|
+
(0, set_version_1.setVersion)('@fluentui/react-charting', '5.19.28');
|
|
5
5
|
});
|
|
6
6
|
//# sourceMappingURL=version.js.map
|
package/lib-amd/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"../src/","sources":["version.ts"],"names":[],"mappings":";;;IAGA,IAAA,wBAAU,EAAC,0BAA0B,EAAE,SAAS,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.19.
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"../src/","sources":["version.ts"],"names":[],"mappings":";;;IAGA,IAAA,wBAAU,EAAC,0BAA0B,EAAE,SAAS,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.19.28');"]}
|
|
@@ -52,6 +52,8 @@ export declare class SankeyChartBase extends React.Component<ISankeyChartProps,
|
|
|
52
52
|
private readonly _linkAttributes;
|
|
53
53
|
private readonly _fetchNodes;
|
|
54
54
|
private readonly _fetchLinks;
|
|
55
|
+
private readonly _strings;
|
|
56
|
+
private readonly _accessibility;
|
|
55
57
|
constructor(props: ISankeyChartProps);
|
|
56
58
|
componentDidMount(): void;
|
|
57
59
|
componentDidUpdate(prevProps: ISankeyChartProps): void;
|
|
@@ -364,7 +364,7 @@ function computeElipsisLength(tspan) {
|
|
|
364
364
|
var measurement = measureText(tspan, elipsis);
|
|
365
365
|
return measurement === undefined ? 0 : measurement;
|
|
366
366
|
}
|
|
367
|
-
function computeNodeAttributes(nodes) {
|
|
367
|
+
function computeNodeAttributes(nodes, nodeAriaLabel) {
|
|
368
368
|
var result = {};
|
|
369
369
|
var weightSpan = (0, d3_selection_1.select)('.nodeName').append('text').attr('class', 'tempText').append('tspan').text(null);
|
|
370
370
|
var nameSpan = (0, d3_selection_1.select)('.nodeName')
|
|
@@ -377,13 +377,14 @@ function computeNodeAttributes(nodes) {
|
|
|
377
377
|
var height = Math.max(singleNode.y1 - singleNode.y0, 0);
|
|
378
378
|
var padding = 8;
|
|
379
379
|
var textLengthForNodeWeight = 0;
|
|
380
|
+
var nodeValue = singleNode.actualValue;
|
|
380
381
|
// If the nodeWeight is in the same line as node description an extra padding
|
|
381
382
|
// of 6 px is required between node description and node weight.
|
|
382
383
|
if (height < MIN_HEIGHT_FOR_DOUBLINE_TYPE) {
|
|
383
384
|
padding = padding + 6;
|
|
384
385
|
// The following `select` statement injects a `tempText` element into the DOM. This injection
|
|
385
386
|
// (and subsequent removal) is causing a layout recalculation. This is a performance issue.
|
|
386
|
-
var measurement = measureText(weightSpan,
|
|
387
|
+
var measurement = measureText(weightSpan, nodeValue);
|
|
387
388
|
if (measurement !== undefined) {
|
|
388
389
|
textLengthForNodeWeight = measurement;
|
|
389
390
|
padding = padding + textLengthForNodeWeight;
|
|
@@ -397,6 +398,7 @@ function computeNodeAttributes(nodes) {
|
|
|
397
398
|
reactId: (0, Utilities_1.getId)('nodeBar'),
|
|
398
399
|
gElementId: (0, Utilities_1.getId)('nodeGElement'),
|
|
399
400
|
name: truncatedname,
|
|
401
|
+
aria: nodeAriaLabel(singleNode, nodeValue),
|
|
400
402
|
trimmed: isTruncated,
|
|
401
403
|
height: height,
|
|
402
404
|
weightOffset: textLengthForNodeWeight,
|
|
@@ -405,7 +407,7 @@ function computeNodeAttributes(nodes) {
|
|
|
405
407
|
(0, d3_selection_1.selectAll)('.tempText').remove();
|
|
406
408
|
return result;
|
|
407
409
|
}
|
|
408
|
-
function computeLinkAttributes(links) {
|
|
410
|
+
function computeLinkAttributes(links, linkFrom, linkAriaLabel) {
|
|
409
411
|
var result = {};
|
|
410
412
|
links.forEach(function (link) {
|
|
411
413
|
var sourceId = idFromNumberOrSNode(link.source);
|
|
@@ -414,7 +416,11 @@ function computeLinkAttributes(links) {
|
|
|
414
416
|
sourceToTarget = {};
|
|
415
417
|
result[sourceId] = sourceToTarget;
|
|
416
418
|
}
|
|
417
|
-
sourceToTarget[idFromNumberOrSNode(link.target)] = {
|
|
419
|
+
sourceToTarget[idFromNumberOrSNode(link.target)] = {
|
|
420
|
+
reactId: (0, Utilities_1.getId)('link'),
|
|
421
|
+
from: linkFrom(link.source),
|
|
422
|
+
aria: linkAriaLabel(link),
|
|
423
|
+
};
|
|
418
424
|
});
|
|
419
425
|
return result;
|
|
420
426
|
}
|
|
@@ -439,6 +445,16 @@ function nodeTextColor(state, singleNode) {
|
|
|
439
445
|
? DEFAULT_TEXT_COLOR
|
|
440
446
|
: NON_SELECTED_TEXT_COLOR;
|
|
441
447
|
}
|
|
448
|
+
function linkCalloutAttributes(singleLink, from) {
|
|
449
|
+
return {
|
|
450
|
+
selectedLink: singleLink,
|
|
451
|
+
isCalloutVisible: true,
|
|
452
|
+
color: singleLink.source.color,
|
|
453
|
+
xCalloutValue: singleLink.target.name,
|
|
454
|
+
yCalloutValue: singleLink.unnormalizedValue.toString(),
|
|
455
|
+
descriptionMessage: from,
|
|
456
|
+
};
|
|
457
|
+
}
|
|
442
458
|
// NOTE: To start employing React.useMemo properly, we need to convert this code from a React.Component
|
|
443
459
|
// to a function component. This will require a significant refactor of the code in this file.
|
|
444
460
|
// https://stackoverflow.com/questions/60223362/fast-way-to-convert-react-class-component-to-functional-component
|
|
@@ -517,11 +533,36 @@ var SankeyChartBase = /** @class */ (function (_super) {
|
|
|
517
533
|
_this._fetchTooltip = (0, Utilities_1.memoizeFunction)(function (classNames) {
|
|
518
534
|
return _this._labelTooltipDiv(classNames);
|
|
519
535
|
});
|
|
520
|
-
//
|
|
521
|
-
|
|
522
|
-
|
|
536
|
+
// Prepare the localization utilities
|
|
537
|
+
_this._strings = (0, Utilities_1.memoizeFunction)(function (strings) {
|
|
538
|
+
var fromString = (strings === null || strings === void 0 ? void 0 : strings.linkFrom) || 'From {0}';
|
|
539
|
+
// NOTE: The `node` parameter is the sankey-generated node on the link, and not the original `node` supplied
|
|
540
|
+
// by the caller.
|
|
541
|
+
return {
|
|
542
|
+
linkFrom: function (node) { return (0, Utilities_1.format)(fromString, node.name); },
|
|
543
|
+
};
|
|
544
|
+
})(props.strings);
|
|
545
|
+
_this._accessibility = (0, Utilities_1.memoizeFunction)(function (accessibility) {
|
|
546
|
+
var linkString = (accessibility === null || accessibility === void 0 ? void 0 : accessibility.linkAriaLabel) || 'link from {0} to {1} with weight {2}';
|
|
547
|
+
var nodeString = (accessibility === null || accessibility === void 0 ? void 0 : accessibility.nodeAriaLabel) || 'node {0} with weight {1}';
|
|
548
|
+
return {
|
|
549
|
+
emptyAriaLabel: (accessibility === null || accessibility === void 0 ? void 0 : accessibility.emptyAriaLabel) || 'Graph has no data to display',
|
|
550
|
+
linkAriaLabel: function (link) {
|
|
551
|
+
return (0, Utilities_1.format)(linkString, link.source.name, link.target.name, link.unnormalizedValue);
|
|
552
|
+
},
|
|
553
|
+
nodeAriaLabel: function (node, weight) { return (0, Utilities_1.format)(nodeString, node.name, weight); },
|
|
554
|
+
};
|
|
555
|
+
})(props.accessibility);
|
|
556
|
+
// NOTE: Memoizing the `_createNodes` and `_createLinks` methods would break the hoverability of the chart
|
|
557
|
+
// because the nodes are currently created differently based on the layout information. Hence why we do not
|
|
558
|
+
// memoize these methods (but have stubs for memoizing as the `_fetchNodes` and `_fetchLinks` methods).
|
|
559
|
+
_this._nodeAttributes = (0, Utilities_1.memoizeFunction)(function (nodes, nodeAriaLabel) {
|
|
560
|
+
return computeNodeAttributes(nodes, nodeAriaLabel);
|
|
561
|
+
});
|
|
523
562
|
_this._fetchNodes = function (classNames, nodes, nodeAttributes, tooltipDiv) { return _this._createNodes(classNames, nodes, nodeAttributes, tooltipDiv); };
|
|
524
|
-
_this._linkAttributes = (0, Utilities_1.memoizeFunction)(function (links
|
|
563
|
+
_this._linkAttributes = (0, Utilities_1.memoizeFunction)(function (links, linkFrom, linkAriaLabel) {
|
|
564
|
+
return computeLinkAttributes(links, linkFrom, linkAriaLabel);
|
|
565
|
+
});
|
|
525
566
|
_this._fetchLinks = function (links, linkAttributes) {
|
|
526
567
|
return _this._createLinks(links, linkAttributes);
|
|
527
568
|
};
|
|
@@ -557,10 +598,10 @@ var SankeyChartBase = /** @class */ (function (_super) {
|
|
|
557
598
|
// It might be better to perform this `fetch` within the `_showTooltip` and `_hideTooltip` methods.
|
|
558
599
|
var tooltipDiv = this._fetchTooltip(classNames);
|
|
559
600
|
// Pre-compute some important attributes about nodes, specifically text
|
|
560
|
-
var nodeAttributes = this._nodeAttributes(nodes);
|
|
601
|
+
var nodeAttributes = this._nodeAttributes(nodes, this._accessibility.nodeAriaLabel);
|
|
561
602
|
// Build the nodes and links as rendered in the UX.
|
|
562
603
|
var nodeData = this._fetchNodes(classNames, nodes, nodeAttributes, tooltipDiv);
|
|
563
|
-
var linkAttributes = this._linkAttributes(links);
|
|
604
|
+
var linkAttributes = this._linkAttributes(links, this._strings.linkFrom, this._accessibility.linkAriaLabel);
|
|
564
605
|
var linkData = this._fetchLinks(links, linkAttributes);
|
|
565
606
|
var calloutProps = {
|
|
566
607
|
isCalloutVisible: state.isCalloutVisible,
|
|
@@ -585,7 +626,7 @@ var SankeyChartBase = /** @class */ (function (_super) {
|
|
|
585
626
|
calloutProps.isCalloutVisible && (React.createElement(Callout_1.Callout, tslib_1.__assign({}, calloutProps),
|
|
586
627
|
React.createElement(ChartHoverCard_1.ChartHoverCard, { XValue: calloutProps.XValue, YValue: calloutProps.YValue, color: calloutProps.color, descriptionMessage: calloutProps.descriptionMessage ? calloutProps.descriptionMessage : '' })))))));
|
|
587
628
|
}
|
|
588
|
-
return (React.createElement("div", { id: this._emptyChartId, role: 'alert', style: { opacity: '0' }, "aria-label":
|
|
629
|
+
return (React.createElement("div", { id: this._emptyChartId, role: 'alert', style: { opacity: '0' }, "aria-label": this._accessibility.emptyAriaLabel }));
|
|
589
630
|
};
|
|
590
631
|
SankeyChartBase.prototype._normalizeSankeyData = function (data, containerWidth, containerHeight, colorsForNodes, borderColorsForNodes) {
|
|
591
632
|
var _a = preRenderLayout(this._margins, containerWidth, containerHeight, this._isRtl), sankey = _a.sankey, height = _a.height, width = _a.width;
|
|
@@ -646,7 +687,7 @@ var SankeyChartBase = /** @class */ (function (_super) {
|
|
|
646
687
|
var onMouseOut = function () {
|
|
647
688
|
_this._onStreamLeave(singleLink);
|
|
648
689
|
};
|
|
649
|
-
var
|
|
690
|
+
var _a = linkValue(linkAttributes, singleLink), reactId = _a.reactId, from = _a.from, aria = _a.aria;
|
|
650
691
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
651
692
|
var dataPoints = linkToDataPoints(singleLink);
|
|
652
693
|
var key = "".concat(linkId_1, "-").concat(index);
|
|
@@ -660,7 +701,7 @@ var SankeyChartBase = /** @class */ (function (_super) {
|
|
|
660
701
|
React.createElement("linearGradient", { id: gradientId, x1: "0%", y1: "0%", x2: "100%", y2: "0%" },
|
|
661
702
|
React.createElement("stop", { offset: "0", stopColor: source.color }),
|
|
662
703
|
React.createElement("stop", { offset: "100%", stopColor: target.color }))),
|
|
663
|
-
React.createElement("path", { d: linkArea(dataPoints), id: reactId, fill: _this._fillStreamColors(singleLink, gradientUrl), stroke: _this._fillStreamBorder(singleLink, gradientUrl), strokeWidth: "2", strokeOpacity: _this._getOpacityStreamBorder(singleLink), onMouseOver: _this._onStreamHover
|
|
704
|
+
React.createElement("path", { d: linkArea(dataPoints), id: reactId, fill: _this._fillStreamColors(singleLink, gradientUrl), stroke: _this._fillStreamBorder(singleLink, gradientUrl), strokeWidth: "2", strokeOpacity: _this._getOpacityStreamBorder(singleLink), onMouseOver: function (event) { return _this._onStreamHover(event, singleLink, from); }, onMouseOut: onMouseOut, onFocus: function (event) { return _this._onFocusLink(event, singleLink, from); }, onBlur: _this._onBlur, fillOpacity: _this._getOpacityStream(singleLink), "data-is-focusable": true, "aria-label": aria, role: "img" })));
|
|
664
705
|
});
|
|
665
706
|
}
|
|
666
707
|
return [];
|
|
@@ -674,12 +715,12 @@ var SankeyChartBase = /** @class */ (function (_super) {
|
|
|
674
715
|
var onMouseOut = function () {
|
|
675
716
|
_this._onLeave(singleNode);
|
|
676
717
|
};
|
|
677
|
-
var _a = nodeAttributes[singleNode.nodeId], nodeId = _a.reactId, gElementId = _a.gElementId, height = _a.height, isTruncated = _a.trimmed, truncatedName = _a.name, textLengthForNodeWeight = _a.weightOffset;
|
|
718
|
+
var _a = nodeAttributes[singleNode.nodeId], nodeId = _a.reactId, gElementId = _a.gElementId, height = _a.height, isTruncated = _a.trimmed, truncatedName = _a.name, textLengthForNodeWeight = _a.weightOffset, aria = _a.aria;
|
|
678
719
|
var tooTall = height > MIN_HEIGHT_FOR_DOUBLINE_TYPE;
|
|
679
720
|
var name = singleNode.name, actualValue = singleNode.actualValue, x0 = singleNode.x0, x1 = singleNode.x1, y0 = singleNode.y0;
|
|
680
721
|
var textColor = nodeTextColor(state_1, singleNode);
|
|
681
722
|
return (React.createElement("g", { key: index, id: gElementId },
|
|
682
|
-
React.createElement("rect", { x: x0, y: y0, height: height, width: x1 - x0, fill: _this._fillNodeColors(singleNode), id: nodeId, onMouseOver: _this._onHover.bind(_this, singleNode), onMouseOut: onMouseOut, onFocus: _this._onCloseCallout.bind(_this), stroke: _this._fillNodeBorder(singleNode), strokeWidth: "2", opacity: "1", "data-is-focusable": true, "aria-label":
|
|
723
|
+
React.createElement("rect", { x: x0, y: y0, height: height, width: x1 - x0, fill: _this._fillNodeColors(singleNode), id: nodeId, onMouseOver: _this._onHover.bind(_this, singleNode), onMouseOut: onMouseOut, onFocus: _this._onCloseCallout.bind(_this), stroke: _this._fillNodeBorder(singleNode), strokeWidth: "2", opacity: "1", "data-is-focusable": true, "aria-label": aria, role: "img" }),
|
|
683
724
|
height > MIN_HEIGHT_FOR_TYPE && (React.createElement("g", { className: classNames.nodeTextContainer },
|
|
684
725
|
React.createElement("g", { className: "nodeName" },
|
|
685
726
|
React.createElement("text", { id: "".concat(nodeId, "-name"), x: x0, y: y0, dy: '1.2em', dx: '0.4em', textAnchor: textAnchor_1, fontWeight: "regular", "aria-hidden": "true", fill: textColor, fontSize: 10, onMouseOver: _this._showTooltip.bind(_this, name, isTruncated, tooltipDiv), onMouseOut: _this._hideTooltip.bind(_this, tooltipDiv) }, truncatedName)),
|
|
@@ -718,23 +759,12 @@ var SankeyChartBase = /** @class */ (function (_super) {
|
|
|
718
759
|
});
|
|
719
760
|
}
|
|
720
761
|
};
|
|
721
|
-
SankeyChartBase.prototype._onStreamHover = function (singleLink,
|
|
762
|
+
SankeyChartBase.prototype._onStreamHover = function (mouseEvent, singleLink, from) {
|
|
722
763
|
mouseEvent.persist();
|
|
723
764
|
this._onCloseCallout();
|
|
724
765
|
if (!this.state.selectedState) {
|
|
725
766
|
var _a = getSelectedLinksforStreamHover(singleLink), selectedLinks = _a.selectedLinks, selectedNodes = _a.selectedNodes;
|
|
726
|
-
this.setState({
|
|
727
|
-
selectedState: true,
|
|
728
|
-
selectedNodes: new Set(Array.from(selectedNodes).map(function (node) { return node.index; })),
|
|
729
|
-
selectedLinks: new Set(Array.from(selectedLinks).map(function (link) { return link.index; })),
|
|
730
|
-
refSelected: mouseEvent,
|
|
731
|
-
selectedLink: singleLink,
|
|
732
|
-
isCalloutVisible: true,
|
|
733
|
-
color: singleLink.source.color,
|
|
734
|
-
xCalloutValue: singleLink.target.name,
|
|
735
|
-
yCalloutValue: singleLink.unnormalizedValue.toString(),
|
|
736
|
-
descriptionMessage: 'from ' + singleLink.source.name, // TODO: Does this need to be localized?
|
|
737
|
-
});
|
|
767
|
+
this.setState(tslib_1.__assign({ selectedState: true, selectedNodes: new Set(Array.from(selectedNodes).map(function (node) { return node.index; })), selectedLinks: new Set(Array.from(selectedLinks).map(function (link) { return link.index; })), refSelected: mouseEvent }, linkCalloutAttributes(singleLink, from)));
|
|
738
768
|
}
|
|
739
769
|
};
|
|
740
770
|
SankeyChartBase.prototype._onStreamLeave = function (singleLink) {
|
|
@@ -747,19 +777,13 @@ var SankeyChartBase = /** @class */ (function (_super) {
|
|
|
747
777
|
});
|
|
748
778
|
}
|
|
749
779
|
};
|
|
750
|
-
SankeyChartBase.prototype._onFocusLink = function (singleLink,
|
|
780
|
+
SankeyChartBase.prototype._onFocusLink = function (element, singleLink, from) {
|
|
781
|
+
// There is a big difference in how "Tab" and the "Arrow keys" are handled in this diagram.
|
|
782
|
+
// In particular, I would expect the "Down" key to be like "Tab", but it jumps a little wildly. I'm not sure
|
|
783
|
+
// if this behavior is an accessiblity violation, but it we might want to investigate it.
|
|
751
784
|
element.persist();
|
|
752
785
|
this._onCloseCallout();
|
|
753
|
-
this.setState({
|
|
754
|
-
refSelected: element.currentTarget,
|
|
755
|
-
selectedLink: singleLink,
|
|
756
|
-
isCalloutVisible: true,
|
|
757
|
-
color: singleLink.source.color,
|
|
758
|
-
xCalloutValue: singleLink.target.name,
|
|
759
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
760
|
-
yCalloutValue: singleLink.source.actualValue,
|
|
761
|
-
descriptionMessage: 'from ' + singleLink.source.name, // TODO: Does this need to be localized?
|
|
762
|
-
});
|
|
786
|
+
this.setState(tslib_1.__assign({ refSelected: element.currentTarget }, linkCalloutAttributes(singleLink, from)));
|
|
763
787
|
};
|
|
764
788
|
SankeyChartBase.prototype._fillStreamColors = function (singleLink, gradientUrl) {
|
|
765
789
|
var state = this.state;
|