@fluentui/react-charting 5.24.39 → 5.25.0

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.
Files changed (111) hide show
  1. package/CHANGELOG.json +60 -1
  2. package/CHANGELOG.md +21 -2
  3. package/dist/react-charting.d.ts +127 -0
  4. package/dist/react-charting.js +1 -1
  5. package/dist/react-charting.min.js +1 -1
  6. package/etc/react-charting.api.md +74 -0
  7. package/lib/components/CommonComponents/Annotations/ChartAnnotationLayer.d.ts +3 -0
  8. package/lib/components/CommonComponents/Annotations/ChartAnnotationLayer.js +343 -0
  9. package/lib/components/CommonComponents/Annotations/ChartAnnotationLayer.js.map +1 -0
  10. package/lib/components/CommonComponents/Annotations/ChartAnnotationLayer.styles.d.ts +28 -0
  11. package/lib/components/CommonComponents/Annotations/ChartAnnotationLayer.styles.js +111 -0
  12. package/lib/components/CommonComponents/Annotations/ChartAnnotationLayer.styles.js.map +1 -0
  13. package/lib/components/CommonComponents/Annotations/ChartAnnotationLayer.types.d.ts +52 -0
  14. package/lib/components/CommonComponents/Annotations/ChartAnnotationLayer.types.js +2 -0
  15. package/lib/components/CommonComponents/Annotations/ChartAnnotationLayer.types.js.map +1 -0
  16. package/lib/components/CommonComponents/CartesianChart.base.js +38 -46
  17. package/lib/components/CommonComponents/CartesianChart.base.js.map +1 -1
  18. package/lib/components/CommonComponents/CartesianChart.styles.js +9 -1
  19. package/lib/components/CommonComponents/CartesianChart.styles.js.map +1 -1
  20. package/lib/components/CommonComponents/CartesianChart.types.d.ts +17 -1
  21. package/lib/components/CommonComponents/CartesianChart.types.js.map +1 -1
  22. package/lib/components/CommonComponents/index.d.ts +2 -0
  23. package/lib/components/CommonComponents/index.js +2 -0
  24. package/lib/components/CommonComponents/index.js.map +1 -1
  25. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +641 -76
  26. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  27. package/lib/index.d.ts +1 -1
  28. package/lib/index.js.map +1 -1
  29. package/lib/types/IChartAnnotation.d.ts +99 -0
  30. package/lib/types/IChartAnnotation.js +2 -0
  31. package/lib/types/IChartAnnotation.js.map +1 -0
  32. package/lib/types/IDataPoint.d.ts +4 -0
  33. package/lib/types/IDataPoint.js.map +1 -1
  34. package/lib/types/index.d.ts +1 -0
  35. package/lib/types/index.js +1 -0
  36. package/lib/types/index.js.map +1 -1
  37. package/lib/utilities/image-export-utils.js +55 -0
  38. package/lib/utilities/image-export-utils.js.map +1 -1
  39. package/lib/utilities/utilities.js +72 -20
  40. package/lib/utilities/utilities.js.map +1 -1
  41. package/lib-amd/components/CommonComponents/Annotations/ChartAnnotationLayer.d.ts +3 -0
  42. package/lib-amd/components/CommonComponents/Annotations/ChartAnnotationLayer.js +344 -0
  43. package/lib-amd/components/CommonComponents/Annotations/ChartAnnotationLayer.js.map +1 -0
  44. package/lib-amd/components/CommonComponents/Annotations/ChartAnnotationLayer.styles.d.ts +28 -0
  45. package/lib-amd/components/CommonComponents/Annotations/ChartAnnotationLayer.styles.js +119 -0
  46. package/lib-amd/components/CommonComponents/Annotations/ChartAnnotationLayer.styles.js.map +1 -0
  47. package/lib-amd/components/CommonComponents/Annotations/ChartAnnotationLayer.types.d.ts +52 -0
  48. package/lib-amd/components/CommonComponents/Annotations/ChartAnnotationLayer.types.js +5 -0
  49. package/lib-amd/components/CommonComponents/Annotations/ChartAnnotationLayer.types.js.map +1 -0
  50. package/lib-amd/components/CommonComponents/CartesianChart.base.js +38 -47
  51. package/lib-amd/components/CommonComponents/CartesianChart.base.js.map +1 -1
  52. package/lib-amd/components/CommonComponents/CartesianChart.styles.js +9 -1
  53. package/lib-amd/components/CommonComponents/CartesianChart.styles.js.map +1 -1
  54. package/lib-amd/components/CommonComponents/CartesianChart.types.d.ts +17 -1
  55. package/lib-amd/components/CommonComponents/CartesianChart.types.js.map +1 -1
  56. package/lib-amd/components/CommonComponents/index.d.ts +2 -0
  57. package/lib-amd/components/CommonComponents/index.js +3 -1
  58. package/lib-amd/components/CommonComponents/index.js.map +1 -1
  59. package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js +641 -76
  60. package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  61. package/lib-amd/index.d.ts +1 -1
  62. package/lib-amd/index.js.map +1 -1
  63. package/lib-amd/types/IChartAnnotation.d.ts +99 -0
  64. package/lib-amd/types/IChartAnnotation.js +5 -0
  65. package/lib-amd/types/IChartAnnotation.js.map +1 -0
  66. package/lib-amd/types/IDataPoint.d.ts +4 -0
  67. package/lib-amd/types/IDataPoint.js.map +1 -1
  68. package/lib-amd/types/index.d.ts +1 -0
  69. package/lib-amd/types/index.js +2 -1
  70. package/lib-amd/types/index.js.map +1 -1
  71. package/lib-amd/utilities/image-export-utils.js +55 -0
  72. package/lib-amd/utilities/image-export-utils.js.map +1 -1
  73. package/lib-amd/utilities/utilities.js +72 -20
  74. package/lib-amd/utilities/utilities.js.map +1 -1
  75. package/lib-commonjs/components/CommonComponents/Annotations/ChartAnnotationLayer.d.ts +3 -0
  76. package/lib-commonjs/components/CommonComponents/Annotations/ChartAnnotationLayer.js +346 -0
  77. package/lib-commonjs/components/CommonComponents/Annotations/ChartAnnotationLayer.js.map +1 -0
  78. package/lib-commonjs/components/CommonComponents/Annotations/ChartAnnotationLayer.styles.d.ts +28 -0
  79. package/lib-commonjs/components/CommonComponents/Annotations/ChartAnnotationLayer.styles.js +118 -0
  80. package/lib-commonjs/components/CommonComponents/Annotations/ChartAnnotationLayer.styles.js.map +1 -0
  81. package/lib-commonjs/components/CommonComponents/Annotations/ChartAnnotationLayer.types.d.ts +52 -0
  82. package/lib-commonjs/components/CommonComponents/Annotations/ChartAnnotationLayer.types.js +3 -0
  83. package/lib-commonjs/components/CommonComponents/Annotations/ChartAnnotationLayer.types.js.map +1 -0
  84. package/lib-commonjs/components/CommonComponents/CartesianChart.base.js +38 -46
  85. package/lib-commonjs/components/CommonComponents/CartesianChart.base.js.map +1 -1
  86. package/lib-commonjs/components/CommonComponents/CartesianChart.styles.js +9 -1
  87. package/lib-commonjs/components/CommonComponents/CartesianChart.styles.js.map +1 -1
  88. package/lib-commonjs/components/CommonComponents/CartesianChart.types.d.ts +17 -1
  89. package/lib-commonjs/components/CommonComponents/CartesianChart.types.js.map +1 -1
  90. package/lib-commonjs/components/CommonComponents/index.d.ts +2 -0
  91. package/lib-commonjs/components/CommonComponents/index.js +2 -0
  92. package/lib-commonjs/components/CommonComponents/index.js.map +1 -1
  93. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +641 -76
  94. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  95. package/lib-commonjs/index.d.ts +1 -1
  96. package/lib-commonjs/index.js.map +1 -1
  97. package/lib-commonjs/types/IChartAnnotation.d.ts +99 -0
  98. package/lib-commonjs/types/IChartAnnotation.js +3 -0
  99. package/lib-commonjs/types/IChartAnnotation.js.map +1 -0
  100. package/lib-commonjs/types/IDataPoint.d.ts +4 -0
  101. package/lib-commonjs/types/IDataPoint.js.map +1 -1
  102. package/lib-commonjs/types/index.d.ts +1 -0
  103. package/lib-commonjs/types/index.js +1 -0
  104. package/lib-commonjs/types/index.js.map +1 -1
  105. package/lib-commonjs/utilities/image-export-utils.js +55 -0
  106. package/lib-commonjs/utilities/image-export-utils.js.map +1 -1
  107. package/lib-commonjs/utilities/utilities.js +72 -20
  108. package/lib-commonjs/utilities/utilities.js.map +1 -1
  109. package/package.json +9 -9
  110. package/src/components/CommonComponents/Annotations/ChartAnnotationLayer.types.ts +58 -0
  111. package/src/components/CommonComponents/CartesianChart.types.ts +21 -0
@@ -39,6 +39,7 @@ export type AxisCategoryOrder = 'default' | 'data' | string[] | 'category ascend
39
39
  export type AxisProps = {
40
40
  tickStep?: number | string;
41
41
  tick0?: number | Date;
42
+ tickText?: string[];
42
43
  };
43
44
 
44
45
  // @public
@@ -47,6 +48,75 @@ export type AxisScaleType = 'default' | 'log';
47
48
  // @public
48
49
  export const CartesianChart: React_2.FunctionComponent<IModifiedCartesianChartProps>;
49
50
 
51
+ // @public (undocumented)
52
+ export interface ChartAnnotation {
53
+ accessibility?: ChartAnnotationAccessibilityProps;
54
+ connector?: ChartAnnotationConnectorProps;
55
+ coordinates: ChartAnnotationCoordinate;
56
+ data?: Record<string, unknown>;
57
+ id?: string;
58
+ layout?: ChartAnnotationLayoutProps;
59
+ style?: ChartAnnotationStyleProps;
60
+ text: string;
61
+ }
62
+
63
+ // @public (undocumented)
64
+ export interface ChartAnnotationAccessibilityProps {
65
+ ariaDescribedBy?: string;
66
+ ariaLabel?: string;
67
+ role?: string;
68
+ }
69
+
70
+ // @public (undocumented)
71
+ export type ChartAnnotationArrowHead = 'none' | 'start' | 'end' | 'both';
72
+
73
+ // @public (undocumented)
74
+ export interface ChartAnnotationConnectorProps {
75
+ arrow?: ChartAnnotationArrowHead;
76
+ dashArray?: string;
77
+ endPadding?: number;
78
+ startPadding?: number;
79
+ strokeColor?: string;
80
+ strokeWidth?: number;
81
+ }
82
+
83
+ // @public (undocumented)
84
+ export type ChartAnnotationCoordinate = {
85
+ type: 'data' | 'relative' | 'pixel';
86
+ x: number | string | Date;
87
+ y: number | string | Date;
88
+ yAxis?: 'primary' | 'secondary';
89
+ };
90
+
91
+ // @public (undocumented)
92
+ export interface ChartAnnotationLayoutProps {
93
+ // Warning: (ae-forgotten-export) The symbol "ChartAnnotationHorizontalAlign" needs to be exported by the entry point index.d.ts
94
+ align?: ChartAnnotationHorizontalAlign;
95
+ className?: string;
96
+ clipToBounds?: boolean;
97
+ maxWidth?: number;
98
+ offsetX?: number;
99
+ offsetY?: number;
100
+ // Warning: (ae-forgotten-export) The symbol "ChartAnnotationVerticalAlign" needs to be exported by the entry point index.d.ts
101
+ verticalAlign?: ChartAnnotationVerticalAlign;
102
+ }
103
+
104
+ // @public (undocumented)
105
+ export interface ChartAnnotationStyleProps {
106
+ backgroundColor?: string;
107
+ borderColor?: string;
108
+ borderRadius?: number;
109
+ borderStyle?: React_2.CSSProperties['borderStyle'];
110
+ borderWidth?: number;
111
+ boxShadow?: string;
112
+ className?: string;
113
+ fontSize?: string;
114
+ fontWeight?: React_2.CSSProperties['fontWeight'];
115
+ opacity?: number;
116
+ padding?: string;
117
+ textColor?: string;
118
+ }
119
+
50
120
  // @public
51
121
  export type ChartDataMode = 'default' | 'fraction' | 'percentage';
52
122
 
@@ -313,6 +383,7 @@ export interface IBasestate {
313
383
 
314
384
  // @public
315
385
  export interface ICartesianChartProps {
386
+ annotations?: ChartAnnotation[];
316
387
  calloutProps?: Partial<ICalloutProps>;
317
388
  // @deprecated
318
389
  chartLabel?: string;
@@ -395,6 +466,7 @@ export interface ICartesianChartStyleProps {
395
466
 
396
467
  // @public
397
468
  export interface ICartesianChartStyles {
469
+ annotationLayer?: IStyle;
398
470
  axisAnnotation?: IStyle;
399
471
  axisTitle?: IStyle;
400
472
  calloutBlockContainer?: IStyle;
@@ -411,6 +483,7 @@ export interface ICartesianChartStyles {
411
483
  hover?: IStyle;
412
484
  legendContainer?: IStyle;
413
485
  opacityChangeOnHover?: IStyle;
486
+ plotContainer?: IStyle;
414
487
  root?: IStyle;
415
488
  shapeStyles?: IStyle;
416
489
  svgTooltip?: IStyle;
@@ -1286,6 +1359,7 @@ export interface IMargins {
1286
1359
 
1287
1360
  // @public (undocumented)
1288
1361
  export interface IModifiedCartesianChartProps extends ICartesianChartProps {
1362
+ annotations?: ChartAnnotation[];
1289
1363
  barwidth?: number;
1290
1364
  calloutProps: Partial<ICalloutProps> & {
1291
1365
  isCalloutVisible: boolean;
@@ -0,0 +1,3 @@
1
+ import * as React from 'react';
2
+ import { IChartAnnotationLayerProps } from './ChartAnnotationLayer.types';
3
+ export declare const ChartAnnotationLayer: React.FC<IChartAnnotationLayerProps>;
@@ -0,0 +1,343 @@
1
+ import { __assign } from "tslib";
2
+ import * as React from 'react';
3
+ import { classNamesFunction, css, getId } from '@fluentui/react/lib/Utilities';
4
+ import { applyOpacityToColor, DEFAULT_ANNOTATION_BACKGROUND_OPACITY, DEFAULT_CONNECTOR_ARROW, DEFAULT_CONNECTOR_END_PADDING, DEFAULT_CONNECTOR_START_PADDING, DEFAULT_CONNECTOR_STROKE_WIDTH, getDefaultConnectorStrokeColor, getStyles, } from './ChartAnnotationLayer.styles';
5
+ var getClassNames = classNamesFunction();
6
+ var DEFAULT_HORIZONTAL_ALIGN = 'center';
7
+ var DEFAULT_VERTICAL_ALIGN = 'middle';
8
+ var DEFAULT_FOREIGN_OBJECT_WIDTH = 180;
9
+ var DEFAULT_FOREIGN_OBJECT_HEIGHT = 60;
10
+ var MIN_ARROW_SIZE = 6;
11
+ var MAX_ARROW_SIZE = 24;
12
+ var ARROW_SIZE_SCALE = 0.35;
13
+ var getAnnotationKey = function (annotation, index) {
14
+ var _a, _b;
15
+ return (_b = (_a = annotation.id) !== null && _a !== void 0 ? _a : (typeof annotation.text === 'string' || typeof annotation.text === 'number' ? String(annotation.text) : undefined)) !== null && _b !== void 0 ? _b : "annotation-".concat(index);
16
+ };
17
+ var decodeHtmlEntities = function (html, documentRef) {
18
+ var _a, _b;
19
+ if (!html || html.indexOf('&') === -1) {
20
+ return html;
21
+ }
22
+ if (!((_a = documentRef === null || documentRef === void 0 ? void 0 : documentRef.implementation) === null || _a === void 0 ? void 0 : _a.createHTMLDocument)) {
23
+ return html;
24
+ }
25
+ var workingDocument = documentRef.implementation.createHTMLDocument('');
26
+ workingDocument.body.innerHTML = html;
27
+ return (_b = workingDocument.body.textContent) !== null && _b !== void 0 ? _b : '';
28
+ };
29
+ var sanitizeAnnotationHtml = function (html) {
30
+ var _a, _b;
31
+ if (!html) {
32
+ return '';
33
+ }
34
+ if (typeof window === 'undefined' || !((_b = (_a = window.document) === null || _a === void 0 ? void 0 : _a.implementation) === null || _b === void 0 ? void 0 : _b.createHTMLDocument)) {
35
+ return html;
36
+ }
37
+ var workingDocument = window.document.implementation.createHTMLDocument('');
38
+ workingDocument.body.innerHTML = decodeHtmlEntities(html, window.document);
39
+ workingDocument.body.querySelectorAll('script, iframe, object, embed, link').forEach(function (node) { return node.remove(); });
40
+ workingDocument.body.querySelectorAll('*').forEach(function (node) {
41
+ Array.from(node.attributes).forEach(function (attr) {
42
+ if (/^on/i.test(attr.name)) {
43
+ node.removeAttribute(attr.name);
44
+ }
45
+ });
46
+ });
47
+ return workingDocument.body.innerHTML;
48
+ };
49
+ var normalizeBandOffset = function (scale, value) {
50
+ var position = scale === null || scale === void 0 ? void 0 : scale(value);
51
+ if (typeof position !== 'number' || Number.isNaN(position)) {
52
+ return undefined;
53
+ }
54
+ if (scale && typeof scale.bandwidth === 'function') {
55
+ return position + scale.bandwidth() / 2;
56
+ }
57
+ return position;
58
+ };
59
+ var clamp = function (value, min, max) { return Math.max(min, Math.min(max, value)); };
60
+ var createMeasurementSignature = function (annotationHtml, containerStyle, contentStyle, layoutClassName, styleClassName) {
61
+ return JSON.stringify({
62
+ annotationHtml: annotationHtml,
63
+ containerStyle: containerStyle,
64
+ contentStyle: contentStyle,
65
+ layoutClassName: layoutClassName !== null && layoutClassName !== void 0 ? layoutClassName : '',
66
+ styleClassName: styleClassName !== null && styleClassName !== void 0 ? styleClassName : '',
67
+ });
68
+ };
69
+ var resolveCoordinates = function (annotation, context) {
70
+ var _a, _b;
71
+ var coordinates = annotation.coordinates, layout = annotation.layout;
72
+ if (!coordinates) {
73
+ return undefined;
74
+ }
75
+ var offsetX = (_a = layout === null || layout === void 0 ? void 0 : layout.offsetX) !== null && _a !== void 0 ? _a : 0;
76
+ var offsetY = (_b = layout === null || layout === void 0 ? void 0 : layout.offsetY) !== null && _b !== void 0 ? _b : 0;
77
+ var anchor = { x: 0, y: 0 };
78
+ switch (coordinates.type) {
79
+ case 'data': {
80
+ var x = coordinates.x, y = coordinates.y, _c = coordinates.yAxis, yAxis = _c === void 0 ? 'primary' : _c;
81
+ var xScale = context.xScale;
82
+ var yScale = yAxis === 'secondary' ? context.yScaleSecondary : context.yScalePrimary;
83
+ if (!xScale || !yScale) {
84
+ return undefined;
85
+ }
86
+ var xValue = normalizeBandOffset(xScale, x instanceof Date ? x.getTime() : x);
87
+ var yValue = normalizeBandOffset(yScale, y instanceof Date ? y.getTime() : y);
88
+ if (typeof xValue !== 'number' || typeof yValue !== 'number') {
89
+ return undefined;
90
+ }
91
+ anchor.x = xValue;
92
+ anchor.y = yValue;
93
+ break;
94
+ }
95
+ case 'relative': {
96
+ if (typeof coordinates.x !== 'number' || typeof coordinates.y !== 'number') {
97
+ return undefined;
98
+ }
99
+ anchor.x = context.plotRect.x + context.plotRect.width * coordinates.x;
100
+ anchor.y = context.plotRect.y + context.plotRect.height * coordinates.y;
101
+ break;
102
+ }
103
+ case 'pixel': {
104
+ if (typeof coordinates.x !== 'number' || typeof coordinates.y !== 'number') {
105
+ return undefined;
106
+ }
107
+ anchor.x = context.plotRect.x + coordinates.x;
108
+ anchor.y = context.plotRect.y + coordinates.y;
109
+ break;
110
+ }
111
+ default:
112
+ return undefined;
113
+ }
114
+ var left = anchor.x + offsetX;
115
+ var top = anchor.y + offsetY;
116
+ if (layout === null || layout === void 0 ? void 0 : layout.clipToBounds) {
117
+ left = clamp(left, context.plotRect.x, context.plotRect.x + context.plotRect.width);
118
+ top = clamp(top, context.plotRect.y, context.plotRect.y + context.plotRect.height);
119
+ }
120
+ return {
121
+ anchor: anchor,
122
+ point: { x: left, y: top },
123
+ };
124
+ };
125
+ export var ChartAnnotationLayer = React.memo(function (props) {
126
+ var annotationsProp = props.annotations, theme = props.theme, context = props.context, className = props.className;
127
+ var classNames = getClassNames(getStyles, { theme: theme, className: className });
128
+ var idPrefix = React.useMemo(function () { return getId('chart-annotation'); }, []);
129
+ var _a = React.useState({}), measurements = _a[0], setMeasurements = _a[1];
130
+ var resolvedAnnotations = React.useMemo(function () {
131
+ return (annotationsProp !== null && annotationsProp !== void 0 ? annotationsProp : []).map(function (annotation, index) { return ({ annotation: annotation, key: getAnnotationKey(annotation, index) }); });
132
+ }, [annotationsProp]);
133
+ React.useEffect(function () {
134
+ setMeasurements(function (prev) {
135
+ if (resolvedAnnotations.length === 0) {
136
+ if (Object.keys(prev).length === 0) {
137
+ return prev;
138
+ }
139
+ return {};
140
+ }
141
+ var next = {};
142
+ resolvedAnnotations.forEach(function (_a) {
143
+ var key = _a.key;
144
+ if (prev[key]) {
145
+ next[key] = prev[key];
146
+ }
147
+ });
148
+ if (Object.keys(next).length === Object.keys(prev).length) {
149
+ var identical = true;
150
+ for (var _i = 0, _a = Object.keys(next); _i < _a.length; _i++) {
151
+ var key = _a[_i];
152
+ if (next[key] !== prev[key]) {
153
+ identical = false;
154
+ break;
155
+ }
156
+ }
157
+ if (identical) {
158
+ return prev;
159
+ }
160
+ }
161
+ return next;
162
+ });
163
+ }, [resolvedAnnotations]);
164
+ var updateMeasurement = React.useCallback(function (key, width, height, signature) {
165
+ setMeasurements(function (prev) {
166
+ var _a;
167
+ var prevEntry = prev[key];
168
+ if (prevEntry &&
169
+ prevEntry.signature === signature &&
170
+ Math.abs(prevEntry.width - width) < 0.5 &&
171
+ Math.abs(prevEntry.height - height) < 0.5) {
172
+ return prev;
173
+ }
174
+ if (width === 0 && height === 0) {
175
+ return prev;
176
+ }
177
+ return __assign(__assign({}, prev), (_a = {}, _a[key] = { width: width, height: height, signature: signature }, _a));
178
+ });
179
+ }, []);
180
+ var annotationForeignObjects = [];
181
+ var measurementElements = [];
182
+ var connectors = [];
183
+ resolvedAnnotations.forEach(function (_a) {
184
+ var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12;
185
+ var annotation = _a.annotation, key = _a.key;
186
+ var resolved = resolveCoordinates(annotation, context);
187
+ if (!resolved) {
188
+ return;
189
+ }
190
+ var annotationHtml = sanitizeAnnotationHtml((_b = annotation.text) !== null && _b !== void 0 ? _b : '');
191
+ var layout = annotation.layout;
192
+ var horizontalAlign = (_c = layout === null || layout === void 0 ? void 0 : layout.align) !== null && _c !== void 0 ? _c : DEFAULT_HORIZONTAL_ALIGN;
193
+ var verticalAlign = (_d = layout === null || layout === void 0 ? void 0 : layout.verticalAlign) !== null && _d !== void 0 ? _d : DEFAULT_VERTICAL_ALIGN;
194
+ var backgroundOpacity = (_f = (_e = annotation.style) === null || _e === void 0 ? void 0 : _e.opacity) !== null && _f !== void 0 ? _f : DEFAULT_ANNOTATION_BACKGROUND_OPACITY;
195
+ var baseBackgroundColor = (_h = (_g = annotation.style) === null || _g === void 0 ? void 0 : _g.backgroundColor) !== null && _h !== void 0 ? _h : theme.semanticColors.bodyBackground;
196
+ var hasCustomBackground = ((_j = annotation.style) === null || _j === void 0 ? void 0 : _j.backgroundColor) !== undefined || ((_k = annotation.style) === null || _k === void 0 ? void 0 : _k.opacity) !== undefined;
197
+ var containerStyle = __assign(__assign({ maxWidth: layout === null || layout === void 0 ? void 0 : layout.maxWidth }, (hasCustomBackground && {
198
+ backgroundColor: applyOpacityToColor(baseBackgroundColor, backgroundOpacity),
199
+ })), { borderColor: (_l = annotation.style) === null || _l === void 0 ? void 0 : _l.borderColor, borderWidth: (_m = annotation.style) === null || _m === void 0 ? void 0 : _m.borderWidth, borderStyle: (_p = (_o = annotation.style) === null || _o === void 0 ? void 0 : _o.borderStyle) !== null && _p !== void 0 ? _p : (((_q = annotation.style) === null || _q === void 0 ? void 0 : _q.borderColor) ? 'solid' : undefined), borderRadius: (_r = annotation.style) === null || _r === void 0 ? void 0 : _r.borderRadius, padding: (_s = annotation.style) === null || _s === void 0 ? void 0 : _s.padding, boxShadow: (_t = annotation.style) === null || _t === void 0 ? void 0 : _t.boxShadow });
200
+ var contentStyle = {
201
+ color: (_u = annotation.style) === null || _u === void 0 ? void 0 : _u.textColor,
202
+ fontSize: (_v = annotation.style) === null || _v === void 0 ? void 0 : _v.fontSize,
203
+ fontWeight: (_w = annotation.style) === null || _w === void 0 ? void 0 : _w.fontWeight,
204
+ opacity: 1,
205
+ };
206
+ var measurementSignature = createMeasurementSignature(annotationHtml, containerStyle, contentStyle, layout === null || layout === void 0 ? void 0 : layout.className, (_x = annotation.style) === null || _x === void 0 ? void 0 : _x.className);
207
+ var measurementEntry = measurements[key];
208
+ var isMeasurementValid = (measurementEntry === null || measurementEntry === void 0 ? void 0 : measurementEntry.signature) === measurementSignature;
209
+ var measuredSize = isMeasurementValid ? measurementEntry : undefined;
210
+ var width = Math.max((_z = (_y = measuredSize === null || measuredSize === void 0 ? void 0 : measuredSize.width) !== null && _y !== void 0 ? _y : layout === null || layout === void 0 ? void 0 : layout.maxWidth) !== null && _z !== void 0 ? _z : DEFAULT_FOREIGN_OBJECT_WIDTH, 1);
211
+ var height = Math.max((_0 = measuredSize === null || measuredSize === void 0 ? void 0 : measuredSize.height) !== null && _0 !== void 0 ? _0 : DEFAULT_FOREIGN_OBJECT_HEIGHT, 1);
212
+ var offsetX = horizontalAlign === 'center' ? -width / 2 : horizontalAlign === 'end' ? -width : 0;
213
+ var offsetY = verticalAlign === 'middle' ? -height / 2 : verticalAlign === 'bottom' ? -height : 0;
214
+ var baseTopLeftX = resolved.point.x + offsetX;
215
+ var baseTopLeftY = resolved.point.y + offsetY;
216
+ var usePlotBounds = (layout === null || layout === void 0 ? void 0 : layout.clipToBounds) !== false;
217
+ var viewportX = usePlotBounds ? context.plotRect.x : 0;
218
+ var viewportY = usePlotBounds ? context.plotRect.y : 0;
219
+ var viewportWidth = usePlotBounds ? context.plotRect.width : (_1 = context.svgRect.width) !== null && _1 !== void 0 ? _1 : 0;
220
+ var viewportHeight = usePlotBounds ? context.plotRect.height : (_2 = context.svgRect.height) !== null && _2 !== void 0 ? _2 : 0;
221
+ var maxTopLeftX = viewportWidth > 0 ? viewportX + viewportWidth - width : baseTopLeftX;
222
+ var maxTopLeftY = viewportHeight > 0 ? viewportY + viewportHeight - height : baseTopLeftY;
223
+ var topLeftX = viewportWidth > 0 ? clamp(baseTopLeftX, viewportX, Math.max(viewportX, maxTopLeftX)) : baseTopLeftX;
224
+ var topLeftY = viewportHeight > 0 ? clamp(baseTopLeftY, viewportY, Math.max(viewportY, maxTopLeftY)) : baseTopLeftY;
225
+ var displayPoint = {
226
+ x: topLeftX - offsetX,
227
+ y: topLeftY - offsetY,
228
+ };
229
+ if (annotation.connector) {
230
+ var startPadding = (_3 = annotation.connector.startPadding) !== null && _3 !== void 0 ? _3 : 12;
231
+ var endPadding = (_4 = annotation.connector.endPadding) !== null && _4 !== void 0 ? _4 : 0;
232
+ var minArrowClearance = 6;
233
+ var minDistance = Math.max(startPadding + endPadding + minArrowClearance, startPadding);
234
+ var dx = displayPoint.x - resolved.anchor.x;
235
+ var dy = displayPoint.y - resolved.anchor.y;
236
+ var distance = Math.sqrt(dx * dx + dy * dy);
237
+ if (distance < minDistance) {
238
+ var fallbackDirection = { x: 0, y: -1 };
239
+ var ux = distance === 0 ? fallbackDirection.x : dx / distance;
240
+ var uy = distance === 0 ? fallbackDirection.y : dy / distance;
241
+ var desiredDisplayX = resolved.anchor.x + ux * minDistance;
242
+ var desiredDisplayY = resolved.anchor.y + uy * minDistance;
243
+ var desiredTopLeftX = desiredDisplayX + offsetX;
244
+ var desiredTopLeftY = desiredDisplayY + offsetY;
245
+ desiredTopLeftX =
246
+ viewportWidth > 0 ? clamp(desiredTopLeftX, viewportX, Math.max(viewportX, maxTopLeftX)) : desiredTopLeftX;
247
+ desiredTopLeftY =
248
+ viewportHeight > 0 ? clamp(desiredTopLeftY, viewportY, Math.max(viewportY, maxTopLeftY)) : desiredTopLeftY;
249
+ topLeftX = desiredTopLeftX;
250
+ topLeftY = desiredTopLeftY;
251
+ displayPoint = {
252
+ x: topLeftX - offsetX,
253
+ y: topLeftY - offsetY,
254
+ };
255
+ }
256
+ }
257
+ var measurementStyle = __assign({ left: topLeftX, top: topLeftY, pointerEvents: 'none' }, containerStyle);
258
+ if (!isMeasurementValid) {
259
+ measurementElements.push(React.createElement("div", { key: "".concat(key, "-measurement"), ref: function (node) {
260
+ if (node) {
261
+ var rect = node.getBoundingClientRect();
262
+ if (rect.width !== 0 || rect.height !== 0) {
263
+ updateMeasurement(key, rect.width, rect.height, measurementSignature);
264
+ }
265
+ }
266
+ }, className: css(classNames.annotation, classNames.measurement, layout === null || layout === void 0 ? void 0 : layout.className, (_5 = annotation.style) === null || _5 === void 0 ? void 0 : _5.className), style: measurementStyle, "aria-hidden": true, "data-annotation-key": key, "data-chart-annotation-measurement": "true" },
267
+ React.createElement("div", { className: css(classNames.annotationContent, layout === null || layout === void 0 ? void 0 : layout.className, (_6 = annotation.style) === null || _6 === void 0 ? void 0 : _6.className), style: contentStyle, dangerouslySetInnerHTML: { __html: annotationHtml } })));
268
+ }
269
+ annotationForeignObjects.push(React.createElement("foreignObject", { key: "".concat(key, "-annotation"), x: topLeftX, y: topLeftY, width: width, height: height, className: css(classNames.annotationForeignObject), "data-annotation-key": key },
270
+ React.createElement("div", { className: css(classNames.annotation, layout === null || layout === void 0 ? void 0 : layout.className, (_7 = annotation.style) === null || _7 === void 0 ? void 0 : _7.className), style: containerStyle, "data-annotation-key": key },
271
+ React.createElement("div", { className: css(classNames.annotationContent, (_8 = annotation.style) === null || _8 === void 0 ? void 0 : _8.className), style: contentStyle, role: (_10 = (_9 = annotation.accessibility) === null || _9 === void 0 ? void 0 : _9.role) !== null && _10 !== void 0 ? _10 : 'note', "aria-label": (_11 = annotation.accessibility) === null || _11 === void 0 ? void 0 : _11.ariaLabel, "aria-describedby": (_12 = annotation.accessibility) === null || _12 === void 0 ? void 0 : _12.ariaDescribedBy, "data-chart-annotation": "true", "data-annotation-key": key, dangerouslySetInnerHTML: { __html: annotationHtml } }))));
272
+ if (annotation.connector) {
273
+ var _13 = annotation.connector, _14 = _13.startPadding, startPadding = _14 === void 0 ? DEFAULT_CONNECTOR_START_PADDING : _14, _15 = _13.endPadding, endPadding = _15 === void 0 ? DEFAULT_CONNECTOR_END_PADDING : _15, _16 = _13.strokeColor, strokeColor = _16 === void 0 ? getDefaultConnectorStrokeColor(theme) : _16, _17 = _13.strokeWidth, strokeWidth = _17 === void 0 ? DEFAULT_CONNECTOR_STROKE_WIDTH : _17, dashArray = _13.dashArray, _18 = _13.arrow, arrow = _18 === void 0 ? DEFAULT_CONNECTOR_ARROW : _18;
274
+ var dx = resolved.anchor.x - displayPoint.x;
275
+ var dy = resolved.anchor.y - displayPoint.y;
276
+ var distance = Math.sqrt(dx * dx + dy * dy) || 1;
277
+ var ux = dx / distance;
278
+ var uy = dy / distance;
279
+ var sizeBasis = Math.max(1, Math.min(width, height));
280
+ var proportionalSize = sizeBasis * ARROW_SIZE_SCALE;
281
+ var maxByPadding = startPadding > 0 ? startPadding * 1.25 : MAX_ARROW_SIZE;
282
+ var maxByDistance = distance * 0.6;
283
+ var markerSize = clamp(proportionalSize, MIN_ARROW_SIZE, Math.min(MAX_ARROW_SIZE, maxByPadding, maxByDistance));
284
+ var markerStrokeWidth = clamp(strokeWidth, 1, markerSize / 2);
285
+ var start = {
286
+ x: displayPoint.x + ux * startPadding,
287
+ y: displayPoint.y + uy * startPadding,
288
+ };
289
+ var end = {
290
+ x: resolved.anchor.x - ux * endPadding,
291
+ y: resolved.anchor.y - uy * endPadding,
292
+ };
293
+ connectors.push({
294
+ key: "".concat(key, "-connector"),
295
+ start: start,
296
+ end: end,
297
+ strokeColor: strokeColor,
298
+ strokeWidth: strokeWidth,
299
+ dashArray: dashArray,
300
+ arrow: arrow,
301
+ markerSize: markerSize,
302
+ markerStrokeWidth: markerStrokeWidth,
303
+ });
304
+ }
305
+ });
306
+ if (annotationForeignObjects.length === 0 && connectors.length === 0) {
307
+ return null;
308
+ }
309
+ var viewBoxWidth = context.svgRect.width || 1;
310
+ var viewBoxHeight = context.svgRect.height || 1;
311
+ var markerDefs = [];
312
+ var createMarkerId = function (color, position, size, markerStrokeWidth) {
313
+ var id = "".concat(idPrefix, "-").concat(position, "-").concat(markerDefs.length);
314
+ var refY = size / 2;
315
+ var refX = position === 'end' ? size : 0;
316
+ var pathEnd = "M0 0 L ".concat(size, " ").concat(refY, " L0 ").concat(size, " Z");
317
+ var pathStart = "M ".concat(size, " 0 L0 ").concat(refY, " L ").concat(size, " ").concat(size, " Z");
318
+ var path = position === 'end' ? pathEnd : pathStart;
319
+ markerDefs.push(React.createElement("marker", { key: id, id: id, markerWidth: size, markerHeight: size, viewBox: "0 0 ".concat(size, " ").concat(size), refX: refX, refY: refY, orient: "auto", markerUnits: "userSpaceOnUse" },
320
+ React.createElement("path", { d: path, fill: color, stroke: color, strokeWidth: markerStrokeWidth, strokeLinecap: "round", strokeLinejoin: "round" })));
321
+ return id;
322
+ };
323
+ var connectorElements = connectors.map(function (connector) {
324
+ var markerStart;
325
+ var markerEnd;
326
+ if (connector.arrow === 'start' || connector.arrow === 'both') {
327
+ markerStart = createMarkerId(connector.strokeColor, 'start', connector.markerSize, connector.markerStrokeWidth);
328
+ }
329
+ if (connector.arrow === 'end' || connector.arrow === 'both') {
330
+ markerEnd = createMarkerId(connector.strokeColor, 'end', connector.markerSize, connector.markerStrokeWidth);
331
+ }
332
+ return (React.createElement("line", { key: connector.key, x1: connector.start.x, y1: connector.start.y, x2: connector.end.x, y2: connector.end.y, stroke: connector.strokeColor, strokeWidth: connector.strokeWidth, strokeDasharray: connector.dashArray, strokeLinecap: "round", markerStart: markerStart ? "url(#".concat(markerStart, ")") : undefined, markerEnd: markerEnd ? "url(#".concat(markerEnd, ")") : undefined }));
333
+ });
334
+ var shouldRenderSvg = connectors.length > 0 || annotationForeignObjects.length > 0;
335
+ return (React.createElement("div", { className: classNames.root, role: "presentation", "data-chart-annotation-layer": "true" },
336
+ shouldRenderSvg && (React.createElement("svg", { className: classNames.connectorLayer, width: "100%", height: "100%", viewBox: "0 0 ".concat(viewBoxWidth, " ").concat(viewBoxHeight), preserveAspectRatio: "none", "data-chart-annotation-svg": "true" },
337
+ markerDefs.length > 0 && React.createElement("defs", null, markerDefs),
338
+ connectorElements.length > 0 && (React.createElement("g", { "aria-hidden": "true", className: classNames.connectorGroup }, connectorElements)),
339
+ annotationForeignObjects)),
340
+ measurementElements));
341
+ });
342
+ ChartAnnotationLayer.displayName = 'ChartAnnotationLayer';
343
+ //# sourceMappingURL=ChartAnnotationLayer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChartAnnotationLayer.js","sourceRoot":"../src/","sources":["components/CommonComponents/Annotations/ChartAnnotationLayer.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,kBAAkB,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,+BAA+B,CAAC;AAS/E,OAAO,EACL,mBAAmB,EACnB,qCAAqC,EACrC,uBAAuB,EACvB,6BAA6B,EAC7B,+BAA+B,EAC/B,8BAA8B,EAC9B,8BAA8B,EAC9B,SAAS,GAGV,MAAM,+BAA+B,CAAC;AAEvC,IAAM,aAAa,GAAG,kBAAkB,EAAgE,CAAC;AAEzG,IAAM,wBAAwB,GAAG,QAAQ,CAAC;AAC1C,IAAM,sBAAsB,GAAG,QAAQ,CAAC;AACxC,IAAM,4BAA4B,GAAG,GAAG,CAAC;AACzC,IAAM,6BAA6B,GAAG,EAAE,CAAC;AACzC,IAAM,cAAc,GAAG,CAAC,CAAC;AACzB,IAAM,cAAc,GAAG,EAAE,CAAC;AAC1B,IAAM,gBAAgB,GAAG,IAAI,CAAC;AAC9B,IAAM,gBAAgB,GAAG,UAAC,UAA4B,EAAE,KAAa;;IACnE,OAAA,MAAA,MAAA,UAAU,CAAC,EAAE,mCACb,CAAC,OAAO,UAAU,CAAC,IAAI,KAAK,QAAQ,IAAI,OAAO,UAAU,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,mCAClH,qBAAc,KAAK,CAAE,CAAA;CAAA,CAAC;AAExB,IAAM,kBAAkB,GAAG,UAAC,IAAY,EAAE,WAAqB;;IAC7D,IAAI,C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CAAC;IAEH,IAAM,eAAe,GAAG,UAAU,CAAC,MAAM,GAAG,CAAC,IAAI,wBAAwB,CAAC,MAAM,GAAG,CAAC,CAAC;IACrF,OAAO,CACL,6BAAK,SAAS,EAAE,UAAU,CAAC,IAAI,EAAE,IAAI,EAAC,cAAc,iCAA6B,MAAM;QACpF,eAAe,IAAI,CAClB,6BACE,SAAS,EAAE,UAAU,CAAC,cAAc,EACpC,KAAK,EAAC,MAAM,EACZ,MAAM,EAAC,MAAM,EACb,OAAO,EAAE,cAAO,YAAY,cAAI,aAAa,CAAE,EAC/C,mBAAmB,EAAC,MAAM,+BACA,MAAM;YAE/B,UAAU,CAAC,MAAM,GAAG,CAAC,IAAI,kCAAO,UAAU,CAAQ;YAClD,iBAAiB,CAAC,MAAM,GAAG,CAAC,IAAI,CAC/B,0CAAe,MAAM,EAAC,SAAS,EAAE,UAAU,CAAC,cAAc,IACvD,iBAAiB,CAChB,CACL;YACA,wBAAwB,CACrB,CACP;QACA,mBAAmB,CAChB,CACP,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,oBAAoB,CAAC,WAAW,GAAG,sBAAsB,CAAC","sourcesContent":["import * as React from 'react';\nimport { classNamesFunction, css, getId } from '@fluentui/react/lib/Utilities';\nimport { IChartAnnotation } from '../../../types/IChartAnnotation';\nimport {\n IAnnotationPoint,\n IChartAnnotationContext,\n IChartAnnotationLayerProps,\n ConnectorRenderData,\n IResolvedAnnotationPosition,\n} from './ChartAnnotationLayer.types';\nimport {\n applyOpacityToColor,\n DEFAULT_ANNOTATION_BACKGROUND_OPACITY,\n DEFAULT_CONNECTOR_ARROW,\n DEFAULT_CONNECTOR_END_PADDING,\n DEFAULT_CONNECTOR_START_PADDING,\n DEFAULT_CONNECTOR_STROKE_WIDTH,\n getDefaultConnectorStrokeColor,\n getStyles,\n IChartAnnotationLayerStyleProps,\n IChartAnnotationLayerStyles,\n} from './ChartAnnotationLayer.styles';\n\nconst getClassNames = classNamesFunction<IChartAnnotationLayerStyleProps, IChartAnnotationLayerStyles>();\n\nconst DEFAULT_HORIZONTAL_ALIGN = 'center';\nconst DEFAULT_VERTICAL_ALIGN = 'middle';\nconst DEFAULT_FOREIGN_OBJECT_WIDTH = 180;\nconst DEFAULT_FOREIGN_OBJECT_HEIGHT = 60;\nconst MIN_ARROW_SIZE = 6;\nconst MAX_ARROW_SIZE = 24;\nconst ARROW_SIZE_SCALE = 0.35;\nconst getAnnotationKey = (annotation: IChartAnnotation, index: number) =>\n annotation.id ??\n (typeof annotation.text === 'string' || typeof annotation.text === 'number' ? String(annotation.text) : undefined) ??\n `annotation-${index}`;\n\nconst decodeHtmlEntities = (html: string, documentRef: Document): string => {\n if (!html || html.indexOf('&') === -1) {\n return html;\n }\n\n if (!documentRef?.implementation?.createHTMLDocument) {\n return html;\n }\n\n const workingDocument = documentRef.implementation.createHTMLDocument('');\n workingDocument.body.innerHTML = html;\n return workingDocument.body.textContent ?? '';\n};\n\nconst sanitizeAnnotationHtml = (html: string): string => {\n if (!html) {\n return '';\n }\n\n if (typeof window === 'undefined' || !window.document?.implementation?.createHTMLDocument) {\n return html;\n }\n\n const workingDocument = window.document.implementation.createHTMLDocument('');\n workingDocument.body.innerHTML = decodeHtmlEntities(html, window.document);\n\n workingDocument.body.querySelectorAll('script, iframe, object, embed, link').forEach(node => node.remove());\n\n workingDocument.body.querySelectorAll('*').forEach(node => {\n Array.from(node.attributes).forEach(attr => {\n if (/^on/i.test(attr.name)) {\n node.removeAttribute(attr.name);\n }\n });\n });\n\n return workingDocument.body.innerHTML;\n};\n\nconst normalizeBandOffset = (\n scale: (((value: unknown) => number) & { bandwidth?: () => number }) | undefined,\n value: unknown,\n) => {\n const position = scale?.(value as never);\n if (typeof position !== 'number' || Number.isNaN(position)) {\n return undefined;\n }\n if (scale && typeof scale.bandwidth === 'function') {\n return position + scale.bandwidth() / 2;\n }\n return position;\n};\n\nconst clamp = (value: number, min: number, max: number) => Math.max(min, Math.min(max, value));\n\nconst createMeasurementSignature = (\n annotationHtml: string,\n containerStyle: React.CSSProperties,\n contentStyle: React.CSSProperties,\n layoutClassName?: string,\n styleClassName?: string,\n) =>\n JSON.stringify({\n annotationHtml,\n containerStyle,\n contentStyle,\n layoutClassName: layoutClassName ?? '',\n styleClassName: styleClassName ?? '',\n });\n\ntype MeasurementEntry = { width: number; height: number; signature: string };\n\nconst resolveCoordinates = (\n annotation: IChartAnnotation,\n context: IChartAnnotationContext,\n): IResolvedAnnotationPosition | undefined => {\n const { coordinates, layout } = annotation;\n\n if (!coordinates) {\n return undefined;\n }\n\n const offsetX = layout?.offsetX ?? 0;\n const offsetY = layout?.offsetY ?? 0;\n\n const anchor: IAnnotationPoint = { x: 0, y: 0 };\n\n switch (coordinates.type) {\n case 'data': {\n const { x, y, yAxis = 'primary' } = coordinates;\n const xScale = context.xScale;\n const yScale = yAxis === 'secondary' ? context.yScaleSecondary : context.yScalePrimary;\n if (!xScale || !yScale) {\n return undefined;\n }\n const xValue = normalizeBandOffset(xScale, x instanceof Date ? x.getTime() : x);\n const yValue = normalizeBandOffset(yScale, y instanceof Date ? y.getTime() : y);\n if (typeof xValue !== 'number' || typeof yValue !== 'number') {\n return undefined;\n }\n anchor.x = xValue;\n anchor.y = yValue;\n break;\n }\n case 'relative': {\n if (typeof coordinates.x !== 'number' || typeof coordinates.y !== 'number') {\n return undefined;\n }\n anchor.x = context.plotRect.x + context.plotRect.width * coordinates.x;\n anchor.y = context.plotRect.y + context.plotRect.height * coordinates.y;\n break;\n }\n case 'pixel': {\n if (typeof coordinates.x !== 'number' || typeof coordinates.y !== 'number') {\n return undefined;\n }\n anchor.x = context.plotRect.x + coordinates.x;\n anchor.y = context.plotRect.y + coordinates.y;\n break;\n }\n default:\n return undefined;\n }\n\n let left = anchor.x + offsetX;\n let top = anchor.y + offsetY;\n\n if (layout?.clipToBounds) {\n left = clamp(left, context.plotRect.x, context.plotRect.x + context.plotRect.width);\n top = clamp(top, context.plotRect.y, context.plotRect.y + context.plotRect.height);\n }\n\n return {\n anchor,\n point: { x: left, y: top },\n };\n};\n\nexport const ChartAnnotationLayer: React.FC<IChartAnnotationLayerProps> = React.memo(props => {\n const { annotations: annotationsProp, theme, context, className } = props;\n\n const classNames = getClassNames(getStyles, { theme, className });\n const idPrefix = React.useMemo(() => getId('chart-annotation'), []);\n\n const [measurements, setMeasurements] = React.useState<Record<string, MeasurementEntry>>({});\n\n const resolvedAnnotations = React.useMemo(\n () =>\n (annotationsProp ?? []).map((annotation, index) => ({ annotation, key: getAnnotationKey(annotation, index) })),\n [annotationsProp],\n );\n\n React.useEffect(() => {\n setMeasurements(prev => {\n if (resolvedAnnotations.length === 0) {\n if (Object.keys(prev).length === 0) {\n return prev;\n }\n return {} as Record<string, MeasurementEntry>;\n }\n\n const next: Record<string, MeasurementEntry> = {};\n resolvedAnnotations.forEach(({ key }) => {\n if (prev[key]) {\n next[key] = prev[key];\n }\n });\n\n if (Object.keys(next).length === Object.keys(prev).length) {\n let identical = true;\n for (const key of Object.keys(next)) {\n if (next[key] !== prev[key]) {\n identical = false;\n break;\n }\n }\n if (identical) {\n return prev;\n }\n }\n\n return next;\n });\n }, [resolvedAnnotations]);\n\n const updateMeasurement = React.useCallback((key: string, width: number, height: number, signature: string) => {\n setMeasurements(prev => {\n const prevEntry = prev[key];\n if (\n prevEntry &&\n prevEntry.signature === signature &&\n Math.abs(prevEntry.width - width) < 0.5 &&\n Math.abs(prevEntry.height - height) < 0.5\n ) {\n return prev;\n }\n\n if (width === 0 && height === 0) {\n return prev;\n }\n\n return {\n ...prev,\n [key]: { width, height, signature },\n };\n });\n }, []);\n\n const annotationForeignObjects: React.ReactNode[] = [];\n const measurementElements: React.ReactNode[] = [];\n const connectors: ConnectorRenderData[] = [];\n\n resolvedAnnotations.forEach(({ annotation, key }) => {\n const resolved = resolveCoordinates(annotation, context);\n if (!resolved) {\n return;\n }\n\n const annotationHtml = sanitizeAnnotationHtml(annotation.text ?? '');\n\n const layout = annotation.layout;\n const horizontalAlign = layout?.align ?? DEFAULT_HORIZONTAL_ALIGN;\n const verticalAlign = layout?.verticalAlign ?? DEFAULT_VERTICAL_ALIGN;\n const backgroundOpacity = annotation.style?.opacity ?? DEFAULT_ANNOTATION_BACKGROUND_OPACITY;\n const baseBackgroundColor = annotation.style?.backgroundColor ?? theme.semanticColors.bodyBackground;\n const hasCustomBackground =\n annotation.style?.backgroundColor !== undefined || annotation.style?.opacity !== undefined;\n\n const containerStyle: React.CSSProperties = {\n maxWidth: layout?.maxWidth,\n ...(hasCustomBackground && {\n backgroundColor: applyOpacityToColor(baseBackgroundColor, backgroundOpacity),\n }),\n borderColor: annotation.style?.borderColor,\n borderWidth: annotation.style?.borderWidth,\n borderStyle: annotation.style?.borderStyle ?? (annotation.style?.borderColor ? 'solid' : undefined),\n borderRadius: annotation.style?.borderRadius,\n padding: annotation.style?.padding,\n boxShadow: annotation.style?.boxShadow,\n };\n\n const contentStyle: React.CSSProperties = {\n color: annotation.style?.textColor,\n fontSize: annotation.style?.fontSize,\n fontWeight: annotation.style?.fontWeight,\n opacity: 1,\n };\n\n const measurementSignature = createMeasurementSignature(\n annotationHtml,\n containerStyle,\n contentStyle,\n layout?.className,\n annotation.style?.className,\n );\n const measurementEntry = measurements[key];\n const isMeasurementValid = measurementEntry?.signature === measurementSignature;\n const measuredSize = isMeasurementValid ? measurementEntry : undefined;\n const width = Math.max(measuredSize?.width ?? layout?.maxWidth ?? DEFAULT_FOREIGN_OBJECT_WIDTH, 1);\n const height = Math.max(measuredSize?.height ?? DEFAULT_FOREIGN_OBJECT_HEIGHT, 1);\n\n const offsetX = horizontalAlign === 'center' ? -width / 2 : horizontalAlign === 'end' ? -width : 0;\n const offsetY = verticalAlign === 'middle' ? -height / 2 : verticalAlign === 'bottom' ? -height : 0;\n\n const baseTopLeftX = resolved.point.x + offsetX;\n const baseTopLeftY = resolved.point.y + offsetY;\n\n const usePlotBounds = layout?.clipToBounds !== false;\n const viewportX = usePlotBounds ? context.plotRect.x : 0;\n const viewportY = usePlotBounds ? context.plotRect.y : 0;\n const viewportWidth = usePlotBounds ? context.plotRect.width : context.svgRect.width ?? 0;\n const viewportHeight = usePlotBounds ? context.plotRect.height : context.svgRect.height ?? 0;\n\n const maxTopLeftX = viewportWidth > 0 ? viewportX + viewportWidth - width : baseTopLeftX;\n const maxTopLeftY = viewportHeight > 0 ? viewportY + viewportHeight - height : baseTopLeftY;\n\n let topLeftX = viewportWidth > 0 ? clamp(baseTopLeftX, viewportX, Math.max(viewportX, maxTopLeftX)) : baseTopLeftX;\n let topLeftY = viewportHeight > 0 ? clamp(baseTopLeftY, viewportY, Math.max(viewportY, maxTopLeftY)) : baseTopLeftY;\n\n let displayPoint = {\n x: topLeftX - offsetX,\n y: topLeftY - offsetY,\n };\n\n if (annotation.connector) {\n const startPadding = annotation.connector.startPadding ?? 12;\n const endPadding = annotation.connector.endPadding ?? 0;\n const minArrowClearance = 6;\n const minDistance = Math.max(startPadding + endPadding + minArrowClearance, startPadding);\n\n const dx = displayPoint.x - resolved.anchor.x;\n const dy = displayPoint.y - resolved.anchor.y;\n const distance = Math.sqrt(dx * dx + dy * dy);\n\n if (distance < minDistance) {\n const fallbackDirection: IAnnotationPoint = { x: 0, y: -1 };\n const ux = distance === 0 ? fallbackDirection.x : dx / distance;\n const uy = distance === 0 ? fallbackDirection.y : dy / distance;\n\n const desiredDisplayX = resolved.anchor.x + ux * minDistance;\n const desiredDisplayY = resolved.anchor.y + uy * minDistance;\n\n let desiredTopLeftX = desiredDisplayX + offsetX;\n let desiredTopLeftY = desiredDisplayY + offsetY;\n\n desiredTopLeftX =\n viewportWidth > 0 ? clamp(desiredTopLeftX, viewportX, Math.max(viewportX, maxTopLeftX)) : desiredTopLeftX;\n desiredTopLeftY =\n viewportHeight > 0 ? clamp(desiredTopLeftY, viewportY, Math.max(viewportY, maxTopLeftY)) : desiredTopLeftY;\n\n topLeftX = desiredTopLeftX;\n topLeftY = desiredTopLeftY;\n displayPoint = {\n x: topLeftX - offsetX,\n y: topLeftY - offsetY,\n };\n }\n }\n\n const measurementStyle: React.CSSProperties = {\n left: topLeftX,\n top: topLeftY,\n pointerEvents: 'none',\n ...containerStyle,\n };\n\n if (!isMeasurementValid) {\n measurementElements.push(\n <div\n key={`${key}-measurement`}\n ref={node => {\n if (node) {\n const rect = node.getBoundingClientRect();\n if (rect.width !== 0 || rect.height !== 0) {\n updateMeasurement(key, rect.width, rect.height, measurementSignature);\n }\n }\n }}\n className={css(classNames.annotation, classNames.measurement, layout?.className, annotation.style?.className)}\n style={measurementStyle}\n aria-hidden={true}\n data-annotation-key={key}\n data-chart-annotation-measurement=\"true\"\n >\n {/* eslint-disable-next-line react/no-danger -- content sanitized via sanitizeAnnotationHtml */}\n <div\n className={css(classNames.annotationContent, layout?.className, annotation.style?.className)}\n style={contentStyle}\n dangerouslySetInnerHTML={{ __html: annotationHtml }}\n />\n </div>,\n );\n }\n\n annotationForeignObjects.push(\n <foreignObject\n key={`${key}-annotation`}\n x={topLeftX}\n y={topLeftY}\n width={width}\n height={height}\n className={css(classNames.annotationForeignObject)}\n data-annotation-key={key}\n >\n <div\n className={css(classNames.annotation, layout?.className, annotation.style?.className)}\n style={containerStyle}\n data-annotation-key={key}\n >\n {/* eslint-disable-next-line react/no-danger -- content sanitized via sanitizeAnnotationHtml */}\n <div\n className={css(classNames.annotationContent, annotation.style?.className)}\n style={contentStyle}\n role={annotation.accessibility?.role ?? 'note'}\n aria-label={annotation.accessibility?.ariaLabel}\n aria-describedby={annotation.accessibility?.ariaDescribedBy}\n data-chart-annotation=\"true\"\n data-annotation-key={key}\n dangerouslySetInnerHTML={{ __html: annotationHtml }}\n />\n </div>\n </foreignObject>,\n );\n\n if (annotation.connector) {\n const {\n startPadding = DEFAULT_CONNECTOR_START_PADDING,\n endPadding = DEFAULT_CONNECTOR_END_PADDING,\n strokeColor = getDefaultConnectorStrokeColor(theme),\n strokeWidth = DEFAULT_CONNECTOR_STROKE_WIDTH,\n dashArray,\n arrow = DEFAULT_CONNECTOR_ARROW,\n } = annotation.connector;\n\n const dx = resolved.anchor.x - displayPoint.x;\n const dy = resolved.anchor.y - displayPoint.y;\n const distance = Math.sqrt(dx * dx + dy * dy) || 1;\n const ux = dx / distance;\n const uy = dy / distance;\n\n const sizeBasis = Math.max(1, Math.min(width, height));\n const proportionalSize = sizeBasis * ARROW_SIZE_SCALE;\n const maxByPadding = startPadding > 0 ? startPadding * 1.25 : MAX_ARROW_SIZE;\n const maxByDistance = distance * 0.6;\n const markerSize = clamp(proportionalSize, MIN_ARROW_SIZE, Math.min(MAX_ARROW_SIZE, maxByPadding, maxByDistance));\n const markerStrokeWidth = clamp(strokeWidth, 1, markerSize / 2);\n\n const start: IAnnotationPoint = {\n x: displayPoint.x + ux * startPadding,\n y: displayPoint.y + uy * startPadding,\n };\n\n const end: IAnnotationPoint = {\n x: resolved.anchor.x - ux * endPadding,\n y: resolved.anchor.y - uy * endPadding,\n };\n\n connectors.push({\n key: `${key}-connector`,\n start,\n end,\n strokeColor,\n strokeWidth,\n dashArray,\n arrow,\n markerSize,\n markerStrokeWidth,\n });\n }\n });\n\n if (annotationForeignObjects.length === 0 && connectors.length === 0) {\n return null;\n }\n\n const viewBoxWidth = context.svgRect.width || 1;\n const viewBoxHeight = context.svgRect.height || 1;\n\n const markerDefs: React.ReactNode[] = [];\n\n const createMarkerId = (color: string, position: 'start' | 'end', size: number, markerStrokeWidth: number) => {\n const id = `${idPrefix}-${position}-${markerDefs.length}`;\n const refY = size / 2;\n const refX = position === 'end' ? size : 0;\n const pathEnd = `M0 0 L ${size} ${refY} L0 ${size} Z`;\n const pathStart = `M ${size} 0 L0 ${refY} L ${size} ${size} Z`;\n const path = position === 'end' ? pathEnd : pathStart;\n\n markerDefs.push(\n <marker\n key={id}\n id={id}\n markerWidth={size}\n markerHeight={size}\n viewBox={`0 0 ${size} ${size}`}\n refX={refX}\n refY={refY}\n orient=\"auto\"\n markerUnits=\"userSpaceOnUse\"\n >\n <path\n d={path}\n fill={color}\n stroke={color}\n strokeWidth={markerStrokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n </marker>,\n );\n\n return id;\n };\n\n const connectorElements = connectors.map(connector => {\n let markerStart: string | undefined;\n let markerEnd: string | undefined;\n\n if (connector.arrow === 'start' || connector.arrow === 'both') {\n markerStart = createMarkerId(connector.strokeColor, 'start', connector.markerSize, connector.markerStrokeWidth);\n }\n if (connector.arrow === 'end' || connector.arrow === 'both') {\n markerEnd = createMarkerId(connector.strokeColor, 'end', connector.markerSize, connector.markerStrokeWidth);\n }\n\n return (\n <line\n key={connector.key}\n x1={connector.start.x}\n y1={connector.start.y}\n x2={connector.end.x}\n y2={connector.end.y}\n stroke={connector.strokeColor}\n strokeWidth={connector.strokeWidth}\n strokeDasharray={connector.dashArray}\n strokeLinecap=\"round\"\n markerStart={markerStart ? `url(#${markerStart})` : undefined}\n markerEnd={markerEnd ? `url(#${markerEnd})` : undefined}\n />\n );\n });\n\n const shouldRenderSvg = connectors.length > 0 || annotationForeignObjects.length > 0;\n return (\n <div className={classNames.root} role=\"presentation\" data-chart-annotation-layer=\"true\">\n {shouldRenderSvg && (\n <svg\n className={classNames.connectorLayer}\n width=\"100%\"\n height=\"100%\"\n viewBox={`0 0 ${viewBoxWidth} ${viewBoxHeight}`}\n preserveAspectRatio=\"none\"\n data-chart-annotation-svg=\"true\"\n >\n {markerDefs.length > 0 && <defs>{markerDefs}</defs>}\n {connectorElements.length > 0 && (\n <g aria-hidden=\"true\" className={classNames.connectorGroup}>\n {connectorElements}\n </g>\n )}\n {annotationForeignObjects}\n </svg>\n )}\n {measurementElements}\n </div>\n );\n});\n\nChartAnnotationLayer.displayName = 'ChartAnnotationLayer';\n"]}
@@ -0,0 +1,28 @@
1
+ import { ITheme, IStyle } from '@fluentui/react/lib/Styling';
2
+ import { IStyleFunctionOrObject } from '@fluentui/react/lib/Utilities';
3
+ export interface IChartAnnotationLayerStyleProps {
4
+ theme: ITheme;
5
+ className?: string;
6
+ }
7
+ import { ChartAnnotationArrowHead } from '../../../types/IChartAnnotation';
8
+ export interface IChartAnnotationLayerStyles {
9
+ root?: IStyle;
10
+ annotation?: IStyle;
11
+ connectorLayer?: IStyle;
12
+ measurement?: IStyle;
13
+ annotationContent?: IStyle;
14
+ annotationForeignObject?: IStyle;
15
+ annotationContentInteractive?: IStyle;
16
+ annotationForeignObjectInteractive?: IStyle;
17
+ connectorGroup?: IStyle;
18
+ }
19
+ export declare const DEFAULT_ANNOTATION_BACKGROUND_OPACITY = 0.8;
20
+ export declare const DEFAULT_ANNOTATION_PADDING = "4px 8px";
21
+ export declare const DEFAULT_CONNECTOR_START_PADDING = 12;
22
+ export declare const DEFAULT_CONNECTOR_END_PADDING = 0;
23
+ export declare const DEFAULT_CONNECTOR_STROKE_WIDTH = 2;
24
+ export declare const DEFAULT_CONNECTOR_ARROW: ChartAnnotationArrowHead;
25
+ export declare const applyOpacityToColor: (color: string | undefined, opacity: number) => string | undefined;
26
+ export declare const getDefaultAnnotationBackgroundColor: (theme: ITheme) => string | undefined;
27
+ export declare const getDefaultConnectorStrokeColor: (theme: ITheme) => string;
28
+ export declare const getStyles: IStyleFunctionOrObject<IChartAnnotationLayerStyleProps, IChartAnnotationLayerStyles>;