@fluentui/react-charting 5.24.39 → 5.25.1
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 +75 -1
- package/CHANGELOG.md +30 -2
- package/dist/react-charting.d.ts +127 -0
- package/dist/react-charting.js +1 -1
- package/dist/react-charting.min.js +1 -1
- package/etc/react-charting.api.md +74 -0
- package/lib/components/CommonComponents/Annotations/ChartAnnotationLayer.d.ts +3 -0
- package/lib/components/CommonComponents/Annotations/ChartAnnotationLayer.js +496 -0
- package/lib/components/CommonComponents/Annotations/ChartAnnotationLayer.js.map +1 -0
- package/lib/components/CommonComponents/Annotations/ChartAnnotationLayer.styles.d.ts +28 -0
- package/lib/components/CommonComponents/Annotations/ChartAnnotationLayer.styles.js +111 -0
- package/lib/components/CommonComponents/Annotations/ChartAnnotationLayer.styles.js.map +1 -0
- package/lib/components/CommonComponents/Annotations/ChartAnnotationLayer.types.d.ts +52 -0
- package/lib/components/CommonComponents/Annotations/ChartAnnotationLayer.types.js +2 -0
- package/lib/components/CommonComponents/Annotations/ChartAnnotationLayer.types.js.map +1 -0
- package/lib/components/CommonComponents/CartesianChart.base.js +38 -46
- package/lib/components/CommonComponents/CartesianChart.base.js.map +1 -1
- package/lib/components/CommonComponents/CartesianChart.styles.js +9 -1
- package/lib/components/CommonComponents/CartesianChart.styles.js.map +1 -1
- package/lib/components/CommonComponents/CartesianChart.types.d.ts +17 -1
- package/lib/components/CommonComponents/CartesianChart.types.js.map +1 -1
- package/lib/components/CommonComponents/index.d.ts +2 -0
- package/lib/components/CommonComponents/index.js +2 -0
- package/lib/components/CommonComponents/index.js.map +1 -1
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +650 -76
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js.map +1 -1
- package/lib/types/IChartAnnotation.d.ts +99 -0
- package/lib/types/IChartAnnotation.js +2 -0
- package/lib/types/IChartAnnotation.js.map +1 -0
- package/lib/types/IDataPoint.d.ts +4 -0
- package/lib/types/IDataPoint.js.map +1 -1
- package/lib/types/index.d.ts +1 -0
- package/lib/types/index.js +1 -0
- package/lib/types/index.js.map +1 -1
- package/lib/utilities/image-export-utils.js +55 -0
- package/lib/utilities/image-export-utils.js.map +1 -1
- package/lib/utilities/utilities.js +72 -20
- package/lib/utilities/utilities.js.map +1 -1
- package/lib-amd/components/CommonComponents/Annotations/ChartAnnotationLayer.d.ts +3 -0
- package/lib-amd/components/CommonComponents/Annotations/ChartAnnotationLayer.js +497 -0
- package/lib-amd/components/CommonComponents/Annotations/ChartAnnotationLayer.js.map +1 -0
- package/lib-amd/components/CommonComponents/Annotations/ChartAnnotationLayer.styles.d.ts +28 -0
- package/lib-amd/components/CommonComponents/Annotations/ChartAnnotationLayer.styles.js +119 -0
- package/lib-amd/components/CommonComponents/Annotations/ChartAnnotationLayer.styles.js.map +1 -0
- package/lib-amd/components/CommonComponents/Annotations/ChartAnnotationLayer.types.d.ts +52 -0
- package/lib-amd/components/CommonComponents/Annotations/ChartAnnotationLayer.types.js +5 -0
- package/lib-amd/components/CommonComponents/Annotations/ChartAnnotationLayer.types.js.map +1 -0
- package/lib-amd/components/CommonComponents/CartesianChart.base.js +38 -47
- package/lib-amd/components/CommonComponents/CartesianChart.base.js.map +1 -1
- package/lib-amd/components/CommonComponents/CartesianChart.styles.js +9 -1
- package/lib-amd/components/CommonComponents/CartesianChart.styles.js.map +1 -1
- package/lib-amd/components/CommonComponents/CartesianChart.types.d.ts +17 -1
- package/lib-amd/components/CommonComponents/CartesianChart.types.js.map +1 -1
- package/lib-amd/components/CommonComponents/index.d.ts +2 -0
- package/lib-amd/components/CommonComponents/index.js +3 -1
- package/lib-amd/components/CommonComponents/index.js.map +1 -1
- package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js +650 -76
- package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib-amd/index.d.ts +1 -1
- package/lib-amd/index.js.map +1 -1
- package/lib-amd/types/IChartAnnotation.d.ts +99 -0
- package/lib-amd/types/IChartAnnotation.js +5 -0
- package/lib-amd/types/IChartAnnotation.js.map +1 -0
- package/lib-amd/types/IDataPoint.d.ts +4 -0
- package/lib-amd/types/IDataPoint.js.map +1 -1
- package/lib-amd/types/index.d.ts +1 -0
- package/lib-amd/types/index.js +2 -1
- package/lib-amd/types/index.js.map +1 -1
- package/lib-amd/utilities/image-export-utils.js +55 -0
- package/lib-amd/utilities/image-export-utils.js.map +1 -1
- package/lib-amd/utilities/utilities.js +72 -20
- package/lib-amd/utilities/utilities.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/Annotations/ChartAnnotationLayer.d.ts +3 -0
- package/lib-commonjs/components/CommonComponents/Annotations/ChartAnnotationLayer.js +499 -0
- package/lib-commonjs/components/CommonComponents/Annotations/ChartAnnotationLayer.js.map +1 -0
- package/lib-commonjs/components/CommonComponents/Annotations/ChartAnnotationLayer.styles.d.ts +28 -0
- package/lib-commonjs/components/CommonComponents/Annotations/ChartAnnotationLayer.styles.js +118 -0
- package/lib-commonjs/components/CommonComponents/Annotations/ChartAnnotationLayer.styles.js.map +1 -0
- package/lib-commonjs/components/CommonComponents/Annotations/ChartAnnotationLayer.types.d.ts +52 -0
- package/lib-commonjs/components/CommonComponents/Annotations/ChartAnnotationLayer.types.js +3 -0
- package/lib-commonjs/components/CommonComponents/Annotations/ChartAnnotationLayer.types.js.map +1 -0
- package/lib-commonjs/components/CommonComponents/CartesianChart.base.js +38 -46
- package/lib-commonjs/components/CommonComponents/CartesianChart.base.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/CartesianChart.styles.js +9 -1
- package/lib-commonjs/components/CommonComponents/CartesianChart.styles.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/CartesianChart.types.d.ts +17 -1
- package/lib-commonjs/components/CommonComponents/CartesianChart.types.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/index.d.ts +2 -0
- package/lib-commonjs/components/CommonComponents/index.js +2 -0
- package/lib-commonjs/components/CommonComponents/index.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +650 -76
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib-commonjs/index.d.ts +1 -1
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/types/IChartAnnotation.d.ts +99 -0
- package/lib-commonjs/types/IChartAnnotation.js +3 -0
- package/lib-commonjs/types/IChartAnnotation.js.map +1 -0
- package/lib-commonjs/types/IDataPoint.d.ts +4 -0
- package/lib-commonjs/types/IDataPoint.js.map +1 -1
- package/lib-commonjs/types/index.d.ts +1 -0
- package/lib-commonjs/types/index.js +1 -0
- package/lib-commonjs/types/index.js.map +1 -1
- package/lib-commonjs/utilities/image-export-utils.js +55 -0
- package/lib-commonjs/utilities/image-export-utils.js.map +1 -1
- package/lib-commonjs/utilities/utilities.js +72 -20
- package/lib-commonjs/utilities/utilities.js.map +1 -1
- package/package.json +9 -9
- package/src/components/CommonComponents/Annotations/ChartAnnotationLayer.types.ts +58 -0
- package/src/components/CommonComponents/CartesianChart.types.ts +21 -0
|
@@ -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>;
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
define(["require", "exports", "d3-color"], function (require, exports, d3_color_1) {
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.getStyles = exports.getDefaultConnectorStrokeColor = exports.getDefaultAnnotationBackgroundColor = exports.applyOpacityToColor = exports.DEFAULT_CONNECTOR_ARROW = exports.DEFAULT_CONNECTOR_STROKE_WIDTH = exports.DEFAULT_CONNECTOR_END_PADDING = exports.DEFAULT_CONNECTOR_START_PADDING = exports.DEFAULT_ANNOTATION_PADDING = exports.DEFAULT_ANNOTATION_BACKGROUND_OPACITY = void 0;
|
|
5
|
+
exports.DEFAULT_ANNOTATION_BACKGROUND_OPACITY = 0.8;
|
|
6
|
+
exports.DEFAULT_ANNOTATION_PADDING = '4px 8px';
|
|
7
|
+
exports.DEFAULT_CONNECTOR_START_PADDING = 12;
|
|
8
|
+
exports.DEFAULT_CONNECTOR_END_PADDING = 0;
|
|
9
|
+
exports.DEFAULT_CONNECTOR_STROKE_WIDTH = 2;
|
|
10
|
+
exports.DEFAULT_CONNECTOR_ARROW = 'end';
|
|
11
|
+
var applyOpacityToColor = function (color, opacity) {
|
|
12
|
+
if (!color) {
|
|
13
|
+
return undefined;
|
|
14
|
+
}
|
|
15
|
+
var parsed = (0, d3_color_1.color)(color);
|
|
16
|
+
if (!parsed) {
|
|
17
|
+
return color;
|
|
18
|
+
}
|
|
19
|
+
parsed.opacity = Math.max(0, Math.min(1, opacity));
|
|
20
|
+
return parsed.toString();
|
|
21
|
+
};
|
|
22
|
+
exports.applyOpacityToColor = applyOpacityToColor;
|
|
23
|
+
var getDefaultAnnotationBackgroundColor = function (theme) {
|
|
24
|
+
return (0, exports.applyOpacityToColor)(theme.semanticColors.bodyBackground, exports.DEFAULT_ANNOTATION_BACKGROUND_OPACITY);
|
|
25
|
+
};
|
|
26
|
+
exports.getDefaultAnnotationBackgroundColor = getDefaultAnnotationBackgroundColor;
|
|
27
|
+
var getDefaultConnectorStrokeColor = function (theme) { return theme.palette.neutralPrimary; };
|
|
28
|
+
exports.getDefaultConnectorStrokeColor = getDefaultConnectorStrokeColor;
|
|
29
|
+
var getStyles = function (props) {
|
|
30
|
+
var theme = props.theme, className = props.className;
|
|
31
|
+
var defaultBackground = (0, exports.getDefaultAnnotationBackgroundColor)(theme);
|
|
32
|
+
var defaultTextColor = theme.semanticColors.bodyText;
|
|
33
|
+
var defaultBorderColor = theme.semanticColors.bodyDivider;
|
|
34
|
+
return {
|
|
35
|
+
root: [
|
|
36
|
+
{
|
|
37
|
+
position: 'absolute',
|
|
38
|
+
top: 0,
|
|
39
|
+
left: 0,
|
|
40
|
+
right: 0,
|
|
41
|
+
bottom: 0,
|
|
42
|
+
width: '100%',
|
|
43
|
+
height: '100%',
|
|
44
|
+
pointerEvents: 'none',
|
|
45
|
+
overflow: 'visible',
|
|
46
|
+
zIndex: 1,
|
|
47
|
+
},
|
|
48
|
+
className,
|
|
49
|
+
],
|
|
50
|
+
annotation: [
|
|
51
|
+
theme.fonts.small,
|
|
52
|
+
{
|
|
53
|
+
position: 'absolute',
|
|
54
|
+
pointerEvents: 'none',
|
|
55
|
+
display: 'flex',
|
|
56
|
+
alignItems: 'center',
|
|
57
|
+
justifyContent: 'center',
|
|
58
|
+
textAlign: 'center',
|
|
59
|
+
backgroundColor: defaultBackground,
|
|
60
|
+
color: defaultTextColor,
|
|
61
|
+
padding: exports.DEFAULT_ANNOTATION_PADDING,
|
|
62
|
+
borderRadius: 4,
|
|
63
|
+
boxShadow: theme.effects.elevation4,
|
|
64
|
+
border: "1px solid ".concat(defaultBorderColor),
|
|
65
|
+
whiteSpace: 'pre-wrap',
|
|
66
|
+
zIndex: 2,
|
|
67
|
+
},
|
|
68
|
+
],
|
|
69
|
+
connectorLayer: [
|
|
70
|
+
{
|
|
71
|
+
position: 'absolute',
|
|
72
|
+
top: 0,
|
|
73
|
+
left: 0,
|
|
74
|
+
width: '100%',
|
|
75
|
+
height: '100%',
|
|
76
|
+
pointerEvents: 'none',
|
|
77
|
+
overflow: 'visible',
|
|
78
|
+
},
|
|
79
|
+
],
|
|
80
|
+
measurement: [
|
|
81
|
+
{
|
|
82
|
+
position: 'absolute',
|
|
83
|
+
visibility: 'hidden',
|
|
84
|
+
pointerEvents: 'none',
|
|
85
|
+
},
|
|
86
|
+
],
|
|
87
|
+
annotationContent: [
|
|
88
|
+
{
|
|
89
|
+
width: '100%',
|
|
90
|
+
height: '100%',
|
|
91
|
+
pointerEvents: 'none',
|
|
92
|
+
},
|
|
93
|
+
],
|
|
94
|
+
annotationForeignObject: [
|
|
95
|
+
{
|
|
96
|
+
overflow: 'visible',
|
|
97
|
+
pointerEvents: 'none',
|
|
98
|
+
},
|
|
99
|
+
],
|
|
100
|
+
annotationContentInteractive: [
|
|
101
|
+
{
|
|
102
|
+
pointerEvents: 'auto',
|
|
103
|
+
},
|
|
104
|
+
],
|
|
105
|
+
annotationForeignObjectInteractive: [
|
|
106
|
+
{
|
|
107
|
+
pointerEvents: 'auto',
|
|
108
|
+
},
|
|
109
|
+
],
|
|
110
|
+
connectorGroup: [
|
|
111
|
+
{
|
|
112
|
+
pointerEvents: 'none',
|
|
113
|
+
},
|
|
114
|
+
],
|
|
115
|
+
};
|
|
116
|
+
};
|
|
117
|
+
exports.getStyles = getStyles;
|
|
118
|
+
});
|
|
119
|
+
//# sourceMappingURL=ChartAnnotationLayer.styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChartAnnotationLayer.styles.js","sourceRoot":"../src/","sources":["components/CommonComponents/Annotations/ChartAnnotationLayer.styles.ts"],"names":[],"mappings":"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","sourcesContent":["import { ITheme, IStyle } from '@fluentui/react/lib/Styling';\nimport { IStyleFunctionOrObject } from '@fluentui/react/lib/Utilities';\n\nexport interface IChartAnnotationLayerStyleProps {\n theme: ITheme;\n className?: string;\n}\nimport { color as d3Color } from 'd3-color';\nimport { ChartAnnotationArrowHead } from '../../../types/IChartAnnotation';\n\nexport interface IChartAnnotationLayerStyles {\n root?: IStyle;\n annotation?: IStyle;\n connectorLayer?: IStyle;\n measurement?: IStyle;\n annotationContent?: IStyle;\n annotationForeignObject?: IStyle;\n annotationContentInteractive?: IStyle;\n annotationForeignObjectInteractive?: IStyle;\n connectorGroup?: IStyle;\n}\n\nexport const DEFAULT_ANNOTATION_BACKGROUND_OPACITY = 0.8;\nexport const DEFAULT_ANNOTATION_PADDING = '4px 8px';\nexport const DEFAULT_CONNECTOR_START_PADDING = 12;\nexport const DEFAULT_CONNECTOR_END_PADDING = 0;\nexport const DEFAULT_CONNECTOR_STROKE_WIDTH = 2;\nexport const DEFAULT_CONNECTOR_ARROW: ChartAnnotationArrowHead = 'end';\n\nexport const applyOpacityToColor = (color: string | undefined, opacity: number): string | undefined => {\n if (!color) {\n return undefined;\n }\n\n const parsed = d3Color(color);\n if (!parsed) {\n return color;\n }\n\n parsed.opacity = Math.max(0, Math.min(1, opacity));\n return parsed.toString();\n};\n\nexport const getDefaultAnnotationBackgroundColor = (theme: ITheme): string | undefined =>\n applyOpacityToColor(theme.semanticColors.bodyBackground, DEFAULT_ANNOTATION_BACKGROUND_OPACITY);\n\nexport const getDefaultConnectorStrokeColor = (theme: ITheme): string => theme.palette.neutralPrimary;\n\nexport const getStyles: IStyleFunctionOrObject<IChartAnnotationLayerStyleProps, IChartAnnotationLayerStyles> = (\n props: IChartAnnotationLayerStyleProps,\n) => {\n const { theme, className } = props;\n const defaultBackground = getDefaultAnnotationBackgroundColor(theme);\n const defaultTextColor = theme.semanticColors.bodyText;\n const defaultBorderColor = theme.semanticColors.bodyDivider;\n\n return {\n root: [\n {\n position: 'absolute',\n top: 0,\n left: 0,\n right: 0,\n bottom: 0,\n width: '100%',\n height: '100%',\n pointerEvents: 'none',\n overflow: 'visible',\n zIndex: 1,\n },\n className,\n ],\n annotation: [\n theme.fonts.small,\n {\n position: 'absolute',\n pointerEvents: 'none',\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n textAlign: 'center',\n backgroundColor: defaultBackground,\n color: defaultTextColor,\n padding: DEFAULT_ANNOTATION_PADDING,\n borderRadius: 4,\n boxShadow: theme.effects.elevation4,\n border: `1px solid ${defaultBorderColor}`,\n whiteSpace: 'pre-wrap',\n zIndex: 2,\n },\n ],\n connectorLayer: [\n {\n position: 'absolute',\n top: 0,\n left: 0,\n width: '100%',\n height: '100%',\n pointerEvents: 'none',\n overflow: 'visible',\n },\n ],\n measurement: [\n {\n position: 'absolute',\n visibility: 'hidden',\n pointerEvents: 'none',\n },\n ],\n annotationContent: [\n {\n width: '100%',\n height: '100%',\n pointerEvents: 'none',\n },\n ],\n annotationForeignObject: [\n {\n overflow: 'visible',\n pointerEvents: 'none',\n },\n ],\n annotationContentInteractive: [\n {\n pointerEvents: 'auto',\n },\n ],\n annotationForeignObjectInteractive: [\n {\n pointerEvents: 'auto',\n },\n ],\n connectorGroup: [\n {\n pointerEvents: 'none',\n },\n ],\n };\n};\n"]}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { ITheme } from '@fluentui/react/lib/Styling';
|
|
2
|
+
import { IChartAnnotation, ChartAnnotationArrowHead } from '../../../types/IChartAnnotation';
|
|
3
|
+
export interface IAnnotationPoint {
|
|
4
|
+
x: number;
|
|
5
|
+
y: number;
|
|
6
|
+
}
|
|
7
|
+
export interface IAnnotationPlotRect {
|
|
8
|
+
x: number;
|
|
9
|
+
y: number;
|
|
10
|
+
width: number;
|
|
11
|
+
height: number;
|
|
12
|
+
}
|
|
13
|
+
export interface IChartAnnotationContext {
|
|
14
|
+
/** Rectangle describing the drawable area of the chart (without margins) */
|
|
15
|
+
plotRect: IAnnotationPlotRect;
|
|
16
|
+
/** Size of the owning SVG element */
|
|
17
|
+
svgRect: {
|
|
18
|
+
width: number;
|
|
19
|
+
height: number;
|
|
20
|
+
};
|
|
21
|
+
/** Indicates if layout should be mirrored */
|
|
22
|
+
isRtl?: boolean;
|
|
23
|
+
/** Primary x scale mapping data domain to pixels */
|
|
24
|
+
xScale?: (value: any) => number;
|
|
25
|
+
/** Primary y scale mapping data domain to pixels */
|
|
26
|
+
yScalePrimary?: (value: any) => number;
|
|
27
|
+
/** Secondary y scale when present */
|
|
28
|
+
yScaleSecondary?: (value: any) => number;
|
|
29
|
+
}
|
|
30
|
+
export interface IChartAnnotationLayerProps {
|
|
31
|
+
annotations?: IChartAnnotation[];
|
|
32
|
+
context: IChartAnnotationContext;
|
|
33
|
+
theme: ITheme;
|
|
34
|
+
className?: string;
|
|
35
|
+
}
|
|
36
|
+
export interface IResolvedAnnotationPosition {
|
|
37
|
+
/** Final absolute position after applying layout and offsets */
|
|
38
|
+
point: IAnnotationPoint;
|
|
39
|
+
/** Raw anchor position before offsets (used for connectors) */
|
|
40
|
+
anchor: IAnnotationPoint;
|
|
41
|
+
}
|
|
42
|
+
export type ConnectorRenderData = {
|
|
43
|
+
key: string;
|
|
44
|
+
start: IAnnotationPoint;
|
|
45
|
+
end: IAnnotationPoint;
|
|
46
|
+
strokeColor: string;
|
|
47
|
+
strokeWidth: number;
|
|
48
|
+
dashArray?: string;
|
|
49
|
+
arrow: ChartAnnotationArrowHead;
|
|
50
|
+
markerSize: number;
|
|
51
|
+
markerStrokeWidth: number;
|
|
52
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChartAnnotationLayer.types.js","sourceRoot":"../src/","sources":["components/CommonComponents/Annotations/ChartAnnotationLayer.types.ts"],"names":[],"mappings":"","sourcesContent":["import { ITheme } from '@fluentui/react/lib/Styling';\nimport { IChartAnnotation, ChartAnnotationArrowHead } from '../../../types/IChartAnnotation';\n\nexport interface IAnnotationPoint {\n x: number;\n y: number;\n}\n\nexport interface IAnnotationPlotRect {\n x: number;\n y: number;\n width: number;\n height: number;\n}\n\nexport interface IChartAnnotationContext {\n /** Rectangle describing the drawable area of the chart (without margins) */\n plotRect: IAnnotationPlotRect;\n /** Size of the owning SVG element */\n svgRect: { width: number; height: number };\n /** Indicates if layout should be mirrored */\n isRtl?: boolean;\n /** Primary x scale mapping data domain to pixels */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n xScale?: (value: any) => number;\n /** Primary y scale mapping data domain to pixels */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n yScalePrimary?: (value: any) => number;\n /** Secondary y scale when present */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n yScaleSecondary?: (value: any) => number;\n}\n\nexport interface IChartAnnotationLayerProps {\n annotations?: IChartAnnotation[];\n context: IChartAnnotationContext;\n theme: ITheme;\n className?: string;\n}\n\nexport interface IResolvedAnnotationPosition {\n /** Final absolute position after applying layout and offsets */\n point: IAnnotationPoint;\n /** Raw anchor position before offsets (used for connectors) */\n anchor: IAnnotationPoint;\n}\n\nexport type ConnectorRenderData = {\n key: string;\n start: IAnnotationPoint;\n end: IAnnotationPoint;\n strokeColor: string;\n strokeWidth: number;\n dashArray?: string;\n arrow: ChartAnnotationArrowHead;\n markerSize: number;\n markerStrokeWidth: number;\n};\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
define(["require", "exports", "tslib", "react", "@fluentui/react/lib/Utilities", "@fluentui/react/lib/Callout", "@fluentui/react-focus", "d3-selection", "@fluentui/chart-utilities", "../../utilities/index", "../Legends/index", "../../utilities/SVGTooltipText"], function (require, exports, tslib_1, React, Utilities_1, Callout_1, react_focus_1, d3_selection_1, chart_utilities_1, index_1, index_2, SVGTooltipText_1) {
|
|
1
|
+
define(["require", "exports", "tslib", "react", "@fluentui/react/lib/Utilities", "@fluentui/react/lib/Callout", "@fluentui/react-focus", "d3-selection", "@fluentui/chart-utilities", "../../utilities/index", "../Legends/index", "../../utilities/SVGTooltipText", "./Annotations/ChartAnnotationLayer"], function (require, exports, tslib_1, React, Utilities_1, Callout_1, react_focus_1, d3_selection_1, chart_utilities_1, index_1, index_2, SVGTooltipText_1, ChartAnnotationLayer_1) {
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.CartesianChartBase = void 0;
|
|
@@ -296,8 +296,8 @@ define(["require", "exports", "tslib", "react", "@fluentui/react/lib/Utilities",
|
|
|
296
296
|
CartesianChartBase.prototype.render = function () {
|
|
297
297
|
var _a, _b, _c, _d;
|
|
298
298
|
var _this = this;
|
|
299
|
-
var _e, _f, _g, _h, _j, _k
|
|
300
|
-
var
|
|
299
|
+
var _e, _f, _g, _h, _j, _k;
|
|
300
|
+
var _l = this.props, calloutProps = _l.calloutProps, points = _l.points, chartType = _l.chartType, chartHoverProps = _l.chartHoverProps, svgFocusZoneProps = _l.svgFocusZoneProps, svgProps = _l.svgProps, culture = _l.culture, dateLocalizeOptions = _l.dateLocalizeOptions, timeFormatLocale = _l.timeFormatLocale, customDateTimeFormatter = _l.customDateTimeFormatter;
|
|
301
301
|
if (this.props.parentRef) {
|
|
302
302
|
this._fitParentContainer();
|
|
303
303
|
}
|
|
@@ -323,36 +323,24 @@ define(["require", "exports", "tslib", "react", "@fluentui/react/lib/Utilities",
|
|
|
323
323
|
});
|
|
324
324
|
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
325
325
|
var callout = null;
|
|
326
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
327
|
+
var yScalePrimary;
|
|
328
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
329
|
+
var yScaleSecondary;
|
|
326
330
|
var children = null;
|
|
327
331
|
if ((this.props.enableFirstRenderOptimization && this.chartContainer) ||
|
|
328
332
|
!this.props.enableFirstRenderOptimization) {
|
|
329
333
|
this._isFirstRender = false;
|
|
330
|
-
var XAxisParams = {
|
|
331
|
-
domainNRangeValues: this.props.getDomainNRangeValues(points, this.props.getDomainMargins ? this.props.getDomainMargins(this.state.containerWidth) : this.margins, this.state.containerWidth, chartType, this._isRtl, this.props.xAxisType, this.props.barwidth, this.props.tickValues,
|
|
334
|
+
var XAxisParams = tslib_1.__assign({ domainNRangeValues: this.props.getDomainNRangeValues(points, this.props.getDomainMargins ? this.props.getDomainMargins(this.state.containerWidth) : this.margins, this.state.containerWidth, chartType, this._isRtl, this.props.xAxisType, this.props.barwidth, this.props.tickValues,
|
|
332
335
|
// This is only used for Horizontal Bar Chart with Axis for y as string axis
|
|
333
|
-
this.state.startFromX),
|
|
336
|
+
this.state.startFromX),
|
|
334
337
|
// FIXME: In XAxisParams, containerHeight is used by HBWA to generate vertical gridlines.
|
|
335
338
|
// Since the x-axis in HBWA is numeric, it typically doesn't require transformation.
|
|
336
339
|
// However, if transformation props are enabled, the updated _removalValueForTextTuncate
|
|
337
340
|
// will only be available in the next render, as it's set after the axis is created.
|
|
338
341
|
// Solution: Delay the creation of gridlines until after the transformation has been applied,
|
|
339
342
|
// or precompute the required height for transformed labels (_removalValueForTextTuncate).
|
|
340
|
-
containerHeight: this.state.containerHeight - this._removalValueForTextTuncate,
|
|
341
|
-
margins: this.margins,
|
|
342
|
-
xAxisElement: this.xAxisElement,
|
|
343
|
-
showRoundOffXTickValues: (_e = this.props.showRoundOffXTickValues) !== null && _e !== void 0 ? _e : true,
|
|
344
|
-
xAxisCount: this.props.xAxisTickCount,
|
|
345
|
-
xAxistickSize: this.props.xAxistickSize,
|
|
346
|
-
tickPadding: this.props.tickPadding || this.props.showXAxisLablesTooltip ? 5 : 10,
|
|
347
|
-
xAxisPadding: this.props.xAxisPadding,
|
|
348
|
-
xAxisInnerPadding: this.props.xAxisInnerPadding,
|
|
349
|
-
xAxisOuterPadding: this.props.xAxisOuterPadding,
|
|
350
|
-
containerWidth: this.state.containerWidth,
|
|
351
|
-
hideTickOverlap: this.props.hideTickOverlap,
|
|
352
|
-
calcMaxLabelWidth: this._calcMaxLabelWidthWithTransform,
|
|
353
|
-
tickStep: (_f = this.props.xAxis) === null || _f === void 0 ? void 0 : _f.tickStep,
|
|
354
|
-
tick0: (_g = this.props.xAxis) === null || _g === void 0 ? void 0 : _g.tick0,
|
|
355
|
-
};
|
|
343
|
+
containerHeight: this.state.containerHeight - this._removalValueForTextTuncate, margins: this.margins, xAxisElement: this.xAxisElement, showRoundOffXTickValues: (_e = this.props.showRoundOffXTickValues) !== null && _e !== void 0 ? _e : true, xAxisCount: this.props.xAxisTickCount, xAxistickSize: this.props.xAxistickSize, tickPadding: this.props.tickPadding || this.props.showXAxisLablesTooltip ? 5 : 10, xAxisPadding: this.props.xAxisPadding, xAxisInnerPadding: this.props.xAxisInnerPadding, xAxisOuterPadding: this.props.xAxisOuterPadding, containerWidth: this.state.containerWidth, hideTickOverlap: this.props.hideTickOverlap, calcMaxLabelWidth: this._calcMaxLabelWidthWithTransform }, this.props.xAxis);
|
|
356
344
|
/**
|
|
357
345
|
* These scales used for 2 purposes.
|
|
358
346
|
* 1. To create x and y axis
|
|
@@ -378,36 +366,17 @@ define(["require", "exports", "tslib", "react", "@fluentui/react/lib/Utilities",
|
|
|
378
366
|
this._xScale = xScale;
|
|
379
367
|
this._tickValues = tickValues;
|
|
380
368
|
this._transformXAxisLabels();
|
|
381
|
-
var YAxisParams = {
|
|
382
|
-
margins: this.props.getYDomainMargins ? this.props.getYDomainMargins(this.state.containerHeight) : this.margins,
|
|
383
|
-
containerWidth: this.state.containerWidth,
|
|
384
|
-
containerHeight: this.state.containerHeight - this._removalValueForTextTuncate,
|
|
385
|
-
yAxisElement: this.yAxisElement,
|
|
386
|
-
yAxisTickFormat: this.props.yAxisTickFormat,
|
|
387
|
-
yAxisTickCount: this.props.yAxisTickCount,
|
|
388
|
-
yMinValue: this.props.yMinValue || 0,
|
|
389
|
-
yMaxValue: this.props.yMaxValue || 0,
|
|
390
|
-
tickPadding: 10,
|
|
391
|
-
maxOfYVal: this.props.maxOfYVal,
|
|
392
|
-
yMinMaxValues: this.props.getMinMaxOfYAxis(points, this.props.yAxisType),
|
|
369
|
+
var YAxisParams = tslib_1.__assign({ margins: this.props.getYDomainMargins ? this.props.getYDomainMargins(this.state.containerHeight) : this.margins, containerWidth: this.state.containerWidth, containerHeight: this.state.containerHeight - this._removalValueForTextTuncate, yAxisElement: this.yAxisElement, yAxisTickFormat: this.props.yAxisTickFormat, yAxisTickCount: this.props.yAxisTickCount, yMinValue: this.props.yMinValue || 0, yMaxValue: this.props.yMaxValue || 0, tickPadding: 10, maxOfYVal: this.props.maxOfYVal, yMinMaxValues: this.props.getMinMaxOfYAxis(points, this.props.yAxisType),
|
|
393
370
|
// please note these padding default values must be consistent in here
|
|
394
371
|
// and the parent chart(HBWA/Vertical etc..) for more details refer example
|
|
395
372
|
// http://using-d3js.com/04_07_ordinal_scales.html
|
|
396
|
-
yAxisPadding: this.props.yAxisPadding || 0,
|
|
397
|
-
tickValues: this.props.yAxisTickValues,
|
|
398
|
-
tickStep: (_h = this.props.yAxis) === null || _h === void 0 ? void 0 : _h.tickStep,
|
|
399
|
-
tick0: (_j = this.props.yAxis) === null || _j === void 0 ? void 0 : _j.tick0,
|
|
400
|
-
};
|
|
373
|
+
yAxisPadding: this.props.yAxisPadding || 0, tickValues: this.props.yAxisTickValues }, this.props.yAxis);
|
|
401
374
|
/**
|
|
402
375
|
* These scales used for 2 purposes.
|
|
403
376
|
* 1. To create x and y axis
|
|
404
377
|
* 2. To draw the graph.
|
|
405
378
|
* For area/line chart using same scales. For other charts, creating their own scales to draw the graph.
|
|
406
379
|
*/
|
|
407
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
408
|
-
var yScalePrimary = void 0;
|
|
409
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
410
|
-
var yScaleSecondary = void 0;
|
|
411
380
|
var axisData = { yAxisDomainValues: [] };
|
|
412
381
|
if (this.props.yAxisType && this.props.yAxisType === index_1.YAxisType.StringAxis) {
|
|
413
382
|
yScalePrimary = this.props.createStringYAxis(YAxisParams, this.props.stringDatasetForYAxisDomain, this._isRtl, this.props.barwidth, this.props.chartType);
|
|
@@ -418,7 +387,7 @@ define(["require", "exports", "tslib", "react", "@fluentui/react/lib/Utilities",
|
|
|
418
387
|
// rendering the secondary y-axis. Therefore, rather than checking the secondaryYScaleOptions
|
|
419
388
|
// prop to determine whether to create a secondary y-axis, it's more appropriate to check if any
|
|
420
389
|
// data points are assigned to use the secondary y-scale.
|
|
421
|
-
if ((
|
|
390
|
+
if ((_f = this.props) === null || _f === void 0 ? void 0 : _f.secondaryYScaleOptions) {
|
|
422
391
|
var YAxisParamsSecondary = {
|
|
423
392
|
margins: this.margins,
|
|
424
393
|
containerWidth: this.state.containerWidth,
|
|
@@ -426,8 +395,8 @@ define(["require", "exports", "tslib", "react", "@fluentui/react/lib/Utilities",
|
|
|
426
395
|
yAxisElement: this.yAxisElementSecondary,
|
|
427
396
|
yAxisTickFormat: this.props.yAxisTickFormat,
|
|
428
397
|
yAxisTickCount: this.props.yAxisTickCount,
|
|
429
|
-
yMinValue: ((
|
|
430
|
-
yMaxValue: (
|
|
398
|
+
yMinValue: ((_g = this.props.secondaryYScaleOptions) === null || _g === void 0 ? void 0 : _g.yMinValue) || 0,
|
|
399
|
+
yMaxValue: (_j = (_h = this.props.secondaryYScaleOptions) === null || _h === void 0 ? void 0 : _h.yMaxValue) !== null && _j !== void 0 ? _j : 100,
|
|
431
400
|
tickPadding: 10,
|
|
432
401
|
yMinMaxValues: this.props.getMinMaxOfYAxis(points, this.props.yAxisType, true),
|
|
433
402
|
yAxisPadding: this.props.yAxisPadding,
|
|
@@ -481,6 +450,27 @@ define(["require", "exports", "tslib", "react", "@fluentui/react/lib/Utilities",
|
|
|
481
450
|
width: this.state.containerWidth,
|
|
482
451
|
height: this.state.containerHeight,
|
|
483
452
|
};
|
|
453
|
+
var startFromX = this.state.startFromX || 0;
|
|
454
|
+
var plotWidth = Math.max(0, svgDimensions.width - this.margins.left - this.margins.right - startFromX);
|
|
455
|
+
var plotHeight = Math.max(0, svgDimensions.height - this.margins.top - this.margins.bottom - this._removalValueForTextTuncate);
|
|
456
|
+
var plotRect = {
|
|
457
|
+
x: this._isRtl ? this.margins.left : this.margins.left + startFromX,
|
|
458
|
+
y: this.margins.top,
|
|
459
|
+
width: plotWidth,
|
|
460
|
+
height: plotHeight,
|
|
461
|
+
};
|
|
462
|
+
var annotations = (_k = this.props.annotations) !== null && _k !== void 0 ? _k : [];
|
|
463
|
+
var hasAnnotations = annotations.length > 0;
|
|
464
|
+
var annotationContext = hasAnnotations
|
|
465
|
+
? {
|
|
466
|
+
plotRect: plotRect,
|
|
467
|
+
svgRect: svgDimensions,
|
|
468
|
+
isRtl: this._isRtl,
|
|
469
|
+
xScale: this._xScale,
|
|
470
|
+
yScalePrimary: yScalePrimary,
|
|
471
|
+
yScaleSecondary: yScaleSecondary,
|
|
472
|
+
}
|
|
473
|
+
: undefined;
|
|
484
474
|
var focusDirection;
|
|
485
475
|
if (this.props.focusZoneDirection === react_focus_1.FocusZoneDirection.vertical) {
|
|
486
476
|
focusDirection = this.props.focusZoneDirection;
|
|
@@ -593,7 +583,8 @@ define(["require", "exports", "tslib", "react", "@fluentui/react/lib/Utilities",
|
|
|
593
583
|
: this.margins.right / 2 + this.titleMargin, ",\n ").concat(svgDimensions.height - this.margins.bottom - this.margins.top - this.titleMargin, ")rotate(-90)"),
|
|
594
584
|
className: this._classNames.axisAnnotation,
|
|
595
585
|
'aria-hidden': true,
|
|
596
|
-
}, maxWidth: yAxisTitleMaximumAllowedHeight }, commonSvgToolTipProps))))
|
|
586
|
+
}, maxWidth: yAxisTitleMaximumAllowedHeight }, commonSvgToolTipProps)))),
|
|
587
|
+
hasAnnotations && annotationContext && (React.createElement(ChartAnnotationLayer_1.ChartAnnotationLayer, { annotations: annotations, context: annotationContext, theme: this.props.theme, className: this._classNames.annotationLayer }))),
|
|
597
588
|
!this.props.hideLegend && (React.createElement("div", { ref: function (e) { return (_this.legendContainer = e); }, className: this._classNames.legendContainer }, this.props.legendBars)),
|
|
598
589
|
callout && React.createElement(React.Suspense, { fallback: React.createElement("div", null, "Loading...") }, callout)));
|
|
599
590
|
};
|