@fluentui/react-charting 5.17.1 → 5.17.3
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 +64 -4
- package/CHANGELOG.md +28 -5
- package/dist/react-charting.js +1 -1
- package/dist/react-charting.min.js +1 -1
- package/docs/TestPlans/VerticalStackedBarChart/ComponentTests.md +73 -0
- package/lib/components/HorizontalBarChart/HorizontalBarChart.base.d.ts +9 -0
- package/lib/components/HorizontalBarChart/HorizontalBarChart.base.js +34 -3
- package/lib/components/HorizontalBarChart/HorizontalBarChart.base.js.map +1 -1
- package/lib/components/HorizontalBarChart/HorizontalBarChart.styles.js +1 -4
- package/lib/components/HorizontalBarChart/HorizontalBarChart.styles.js.map +1 -1
- package/lib/components/PieChart/Arc/Arc.d.ts +8 -3
- package/lib/components/PieChart/Arc/Arc.js +50 -19
- package/lib/components/PieChart/Arc/Arc.js.map +1 -1
- package/lib/components/PieChart/Arc/Arc.styles.d.ts +2 -1
- package/lib/components/PieChart/Arc/Arc.styles.js +5 -2
- package/lib/components/PieChart/Arc/Arc.styles.js.map +1 -1
- package/lib/components/PieChart/Arc/Arc.types.d.ts +15 -2
- package/lib/components/PieChart/Arc/Arc.types.js.map +1 -1
- package/lib/components/PieChart/Pie/Pie.js +16 -5
- package/lib/components/PieChart/Pie/Pie.js.map +1 -1
- package/lib/components/PieChart/Pie/Pie.types.d.ts +2 -1
- package/lib/components/PieChart/Pie/Pie.types.js.map +1 -1
- package/lib/components/PieChart/PieChart.base.js +9 -3
- package/lib/components/PieChart/PieChart.base.js.map +1 -1
- package/lib/components/StackedBarChart/MultiStackedBarChart.base.d.ts +9 -0
- package/lib/components/StackedBarChart/MultiStackedBarChart.base.js +38 -6
- package/lib/components/StackedBarChart/MultiStackedBarChart.base.js.map +1 -1
- package/lib/components/StackedBarChart/MultiStackedBarChart.styles.js +0 -4
- package/lib/components/StackedBarChart/MultiStackedBarChart.styles.js.map +1 -1
- package/lib/components/StackedBarChart/StackedBarChart.base.d.ts +10 -0
- package/lib/components/StackedBarChart/StackedBarChart.base.js +36 -4
- package/lib/components/StackedBarChart/StackedBarChart.base.js.map +1 -1
- package/lib/components/StackedBarChart/StackedBarChart.styles.js +1 -2
- package/lib/components/StackedBarChart/StackedBarChart.styles.js.map +1 -1
- package/lib/utilities/SVGTooltipText.d.ts +14 -0
- package/lib/utilities/SVGTooltipText.js +3 -3
- package/lib/utilities/SVGTooltipText.js.map +1 -1
- package/lib/version.js +1 -1
- package/lib/version.js.map +1 -1
- package/lib-amd/components/HorizontalBarChart/HorizontalBarChart.base.d.ts +9 -0
- package/lib-amd/components/HorizontalBarChart/HorizontalBarChart.base.js +34 -3
- package/lib-amd/components/HorizontalBarChart/HorizontalBarChart.base.js.map +1 -1
- package/lib-amd/components/HorizontalBarChart/HorizontalBarChart.styles.js +1 -4
- package/lib-amd/components/HorizontalBarChart/HorizontalBarChart.styles.js.map +1 -1
- package/lib-amd/components/PieChart/Arc/Arc.d.ts +8 -3
- package/lib-amd/components/PieChart/Arc/Arc.js +47 -17
- package/lib-amd/components/PieChart/Arc/Arc.js.map +1 -1
- package/lib-amd/components/PieChart/Arc/Arc.styles.d.ts +2 -1
- package/lib-amd/components/PieChart/Arc/Arc.styles.js +5 -2
- package/lib-amd/components/PieChart/Arc/Arc.styles.js.map +1 -1
- package/lib-amd/components/PieChart/Arc/Arc.types.d.ts +15 -2
- package/lib-amd/components/PieChart/Arc/Arc.types.js.map +1 -1
- package/lib-amd/components/PieChart/Pie/Pie.js +15 -6
- package/lib-amd/components/PieChart/Pie/Pie.js.map +1 -1
- package/lib-amd/components/PieChart/Pie/Pie.types.d.ts +2 -1
- package/lib-amd/components/PieChart/Pie/Pie.types.js.map +1 -1
- package/lib-amd/components/PieChart/PieChart.base.js +9 -3
- package/lib-amd/components/PieChart/PieChart.base.js.map +1 -1
- package/lib-amd/components/StackedBarChart/MultiStackedBarChart.base.d.ts +9 -0
- package/lib-amd/components/StackedBarChart/MultiStackedBarChart.base.js +38 -6
- package/lib-amd/components/StackedBarChart/MultiStackedBarChart.base.js.map +1 -1
- package/lib-amd/components/StackedBarChart/MultiStackedBarChart.styles.js +0 -4
- package/lib-amd/components/StackedBarChart/MultiStackedBarChart.styles.js.map +1 -1
- package/lib-amd/components/StackedBarChart/StackedBarChart.base.d.ts +10 -0
- package/lib-amd/components/StackedBarChart/StackedBarChart.base.js +35 -3
- package/lib-amd/components/StackedBarChart/StackedBarChart.base.js.map +1 -1
- package/lib-amd/components/StackedBarChart/StackedBarChart.styles.js +1 -2
- package/lib-amd/components/StackedBarChart/StackedBarChart.styles.js.map +1 -1
- package/lib-amd/utilities/SVGTooltipText.d.ts +14 -0
- package/lib-amd/utilities/SVGTooltipText.js +3 -3
- package/lib-amd/utilities/SVGTooltipText.js.map +1 -1
- package/lib-amd/version.js +1 -1
- package/lib-amd/version.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChart/HorizontalBarChart.base.d.ts +9 -0
- package/lib-commonjs/components/HorizontalBarChart/HorizontalBarChart.base.js +34 -3
- package/lib-commonjs/components/HorizontalBarChart/HorizontalBarChart.base.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChart/HorizontalBarChart.styles.js +1 -4
- package/lib-commonjs/components/HorizontalBarChart/HorizontalBarChart.styles.js.map +1 -1
- package/lib-commonjs/components/PieChart/Arc/Arc.d.ts +8 -3
- package/lib-commonjs/components/PieChart/Arc/Arc.js +47 -16
- package/lib-commonjs/components/PieChart/Arc/Arc.js.map +1 -1
- package/lib-commonjs/components/PieChart/Arc/Arc.styles.d.ts +2 -1
- package/lib-commonjs/components/PieChart/Arc/Arc.styles.js +5 -2
- package/lib-commonjs/components/PieChart/Arc/Arc.styles.js.map +1 -1
- package/lib-commonjs/components/PieChart/Arc/Arc.types.d.ts +15 -2
- package/lib-commonjs/components/PieChart/Arc/Arc.types.js.map +1 -1
- package/lib-commonjs/components/PieChart/Pie/Pie.js +16 -5
- package/lib-commonjs/components/PieChart/Pie/Pie.js.map +1 -1
- package/lib-commonjs/components/PieChart/Pie/Pie.types.d.ts +2 -1
- package/lib-commonjs/components/PieChart/Pie/Pie.types.js.map +1 -1
- package/lib-commonjs/components/PieChart/PieChart.base.js +9 -3
- package/lib-commonjs/components/PieChart/PieChart.base.js.map +1 -1
- package/lib-commonjs/components/StackedBarChart/MultiStackedBarChart.base.d.ts +9 -0
- package/lib-commonjs/components/StackedBarChart/MultiStackedBarChart.base.js +38 -6
- package/lib-commonjs/components/StackedBarChart/MultiStackedBarChart.base.js.map +1 -1
- package/lib-commonjs/components/StackedBarChart/MultiStackedBarChart.styles.js +0 -4
- package/lib-commonjs/components/StackedBarChart/MultiStackedBarChart.styles.js.map +1 -1
- package/lib-commonjs/components/StackedBarChart/StackedBarChart.base.d.ts +10 -0
- package/lib-commonjs/components/StackedBarChart/StackedBarChart.base.js +35 -3
- package/lib-commonjs/components/StackedBarChart/StackedBarChart.base.js.map +1 -1
- package/lib-commonjs/components/StackedBarChart/StackedBarChart.styles.js +1 -2
- package/lib-commonjs/components/StackedBarChart/StackedBarChart.styles.js.map +1 -1
- package/lib-commonjs/utilities/SVGTooltipText.d.ts +14 -0
- package/lib-commonjs/utilities/SVGTooltipText.js +3 -3
- package/lib-commonjs/utilities/SVGTooltipText.js.map +1 -1
- package/lib-commonjs/version.js +1 -1
- package/lib-commonjs/version.js.map +1 -1
- package/package.json +3 -3
- package/src/components/PieChart/Arc/Arc.types.ts +19 -2
- package/src/components/PieChart/Pie/Pie.types.ts +3 -1
|
@@ -25,10 +25,7 @@ var getHorizontalBarChartStyles = function (props) {
|
|
|
25
25
|
display: 'block',
|
|
26
26
|
overflow: 'visible',
|
|
27
27
|
},
|
|
28
|
-
barWrapper: {
|
|
29
|
-
stroke: theme.palette.white,
|
|
30
|
-
strokeWidth: 2,
|
|
31
|
-
},
|
|
28
|
+
barWrapper: {},
|
|
32
29
|
chartTitle: tslib_1.__assign(tslib_1.__assign({}, theme.fonts.small), { display: 'flex', justifyContent: 'space-between' }),
|
|
33
30
|
chartTitleLeft: {
|
|
34
31
|
textOverflow: 'ellipsis',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HorizontalBarChart.styles.js","sourceRoot":"../src/","sources":["components/HorizontalBarChart/HorizontalBarChart.styles.ts"],"names":[],"mappings":";;;;AAAA,uDAAqE;AACrE,uEAIoC;AAE7B,IAAM,2BAA2B,GAAG,UAAC,KAAoC;IACtE,IAAA,SAAS,GAAiE,KAAK,UAAtE,EAAE,KAAK,GAA0D,KAAK,MAA/D,EAAE,KAAK,GAAmD,KAAK,MAAxD,EAAE,SAAS,GAAwC,KAAK,UAA7C,EAAE,YAAY,GAA0B,KAAK,aAA/B,EAAE,OAAO,GAAiB,KAAK,QAAtB,EAAE,UAAU,GAAK,KAAK,WAAV,CAAW;IAChF,IAAA,OAAO,GAAK,KAAM,QAAX,CAAY;IAE3B,OAAO;QACL,IAAI,EAAE;YACJ;gBACE,OAAO,EAAE,MAAM;gBACf,aAAa,EAAE,QAAQ;gBACvB,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM;aAC9B;YACD,SAAS;SACV;QACD,KAAK,EAAE;YACL,YAAY,EAAE,YAAY,IAAI,OAAO,KAAK,oDAAyB,CAAC,aAAa,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM;SACpG;QACD,KAAK,EAAE;YACL,KAAK,EAAE,MAAM;YACb,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE;YAClC,OAAO,EAAE,OAAO;YAChB,QAAQ,EAAE,SAAS;SACpB;QACD,UAAU,EAAE
|
|
1
|
+
{"version":3,"file":"HorizontalBarChart.styles.js","sourceRoot":"../src/","sources":["components/HorizontalBarChart/HorizontalBarChart.styles.ts"],"names":[],"mappings":";;;;AAAA,uDAAqE;AACrE,uEAIoC;AAE7B,IAAM,2BAA2B,GAAG,UAAC,K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AAW,CAAC,QAAQ;YAChC,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,cAAc;SACpC;QACD,wBAAwB,EAAE;YACxB,QAAQ,EAAE,mBAAS,CAAC,MAAM;YAC1B,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,cAAc;SACpC;QACD,kBAAkB,EAAE;YAClB,QAAQ,EAAE,UAAU;YACpB,MAAM,EAAE,KAAK;YACb,SAAS,EAAE,MAAM;YACjB,YAAY,EAAE,MAAM;SACrB;QACD,QAAQ,EAAE;YACR,KAAK,EAAE,GAAG;YACV,MAAM,EAAE,GAAG;YACX,UAAU,EAAE,uBAAuB;YACnC,WAAW,EAAE,uBAAuB;YACpC,SAAS,EAAE,WAAW;YACtB,cAAc,EAAE,OAAO,CAAC,IAAI;YAC5B,YAAY,EAAE,KAAK;YACnB,QAAQ,EAAE,UAAU;SACrB;QACD,QAAQ,wCACH,KAAK,CAAC,KAAK,CAAC,KAAK,KACpB,UAAU,EAAE,qBAAW,CAAC,QAAQ,EAChC,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,cAAc,GACnC;QACD,YAAY,EAAE;YACZ,YAAY,EAAE,OAAO,KAAK,oDAAyB,CAAC,aAAa,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;SAC1F;KACF,CAAC;AACJ,CAAC,CAAC;AAtEW,QAAA,2BAA2B,+BAsEtC","sourcesContent":["import { FontSizes, FontWeights } from '@fluentui/react/lib/Styling';\nimport {\n HorizontalBarChartVariant,\n IHorizontalBarChartStyleProps,\n IHorizontalBarChartStyles,\n} from './HorizontalBarChart.types';\n\nexport const getHorizontalBarChartStyles = (props: IHorizontalBarChartStyleProps): IHorizontalBarChartStyles => {\n const { className, theme, width, barHeight, showTriangle, variant, hideLabels } = props;\n const { palette } = theme!;\n\n return {\n root: [\n {\n display: 'flex',\n flexDirection: 'column',\n width: width ? width : '100%',\n },\n className,\n ],\n items: {\n marginBottom: showTriangle || variant === HorizontalBarChartVariant.AbsoluteScale ? '16px' : '10px',\n },\n chart: {\n width: '100%',\n height: barHeight ? barHeight : 12,\n display: 'block',\n overflow: 'visible',\n },\n barWrapper: {},\n chartTitle: {\n ...theme.fonts.small,\n display: 'flex',\n justifyContent: 'space-between',\n },\n chartTitleLeft: {\n textOverflow: 'ellipsis',\n overflow: 'hidden',\n whiteSpace: 'nowrap',\n display: 'block',\n color: theme.palette.neutralPrimary,\n marginBottom: variant === HorizontalBarChartVariant.AbsoluteScale ? '4px' : '5px',\n },\n chartTitleRight: {\n fontSize: FontSizes.medium,\n fontWeight: FontWeights.semibold,\n color: theme.palette.neutralPrimary,\n },\n chartDataTextDenominator: {\n fontSize: FontSizes.medium,\n color: theme.palette.neutralPrimary,\n },\n benchmarkContainer: {\n position: 'relative',\n height: '7px',\n marginTop: '-3px',\n marginBottom: '-1px',\n },\n triangle: {\n width: '0',\n height: '0',\n borderLeft: '4px solid transparent',\n borderRight: '4px solid transparent',\n borderTop: '7px solid',\n borderTopColor: palette.blue,\n marginBottom: '4px',\n position: 'absolute',\n },\n barLabel: {\n ...theme.fonts.small,\n fontWeight: FontWeights.semibold,\n fill: theme.palette.neutralPrimary,\n },\n chartWrapper: {\n paddingRight: variant === HorizontalBarChartVariant.AbsoluteScale && !hideLabels ? 40 : 0,\n },\n };\n};\n"]}
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { IArcProps } from './Arc.types';
|
|
3
|
-
export declare class Arc extends React.Component<IArcProps,
|
|
2
|
+
import { IArcProps, IArcState } from './Arc.types';
|
|
3
|
+
export declare class Arc extends React.Component<IArcProps, IArcState> {
|
|
4
4
|
static defaultProps: Partial<IArcProps>;
|
|
5
|
-
|
|
5
|
+
protected _arcId: string;
|
|
6
6
|
static getDerivedStateFromProps(nextProps: Readonly<IArcProps>): null;
|
|
7
|
+
constructor(props: IArcProps);
|
|
7
8
|
updateChart: (newProps: IArcProps) => void;
|
|
8
9
|
render(): JSX.Element;
|
|
10
|
+
protected _onFocus: () => void;
|
|
11
|
+
protected _onBlur: () => void;
|
|
9
12
|
}
|
|
10
13
|
export declare class LabeledArc extends Arc {
|
|
14
|
+
private _isRTL;
|
|
15
|
+
constructor(props: IArcProps);
|
|
11
16
|
render(): JSX.Element;
|
|
12
17
|
}
|
|
@@ -7,14 +7,24 @@ var shape = require("d3-shape");
|
|
|
7
7
|
var Utilities_1 = require("@fluentui/react/lib/Utilities");
|
|
8
8
|
var Arc_styles_1 = require("./Arc.styles");
|
|
9
9
|
var utilities_1 = require("../../../utilities/utilities");
|
|
10
|
+
var SVGTooltipText_1 = require("../../../utilities/SVGTooltipText");
|
|
10
11
|
var Arc = /** @class */ (function (_super) {
|
|
11
12
|
tslib_1.__extends(Arc, _super);
|
|
12
|
-
function Arc() {
|
|
13
|
-
var _this = _super
|
|
14
|
-
_this.state = {};
|
|
13
|
+
function Arc(props) {
|
|
14
|
+
var _this = _super.call(this, props) || this;
|
|
15
15
|
_this.updateChart = function (newProps) {
|
|
16
16
|
_updateChart(newProps);
|
|
17
17
|
};
|
|
18
|
+
_this._onFocus = function () {
|
|
19
|
+
_this.setState({ isArcFocused: true });
|
|
20
|
+
};
|
|
21
|
+
_this._onBlur = function () {
|
|
22
|
+
_this.setState({ isArcFocused: false });
|
|
23
|
+
};
|
|
24
|
+
_this.state = {
|
|
25
|
+
isArcFocused: false,
|
|
26
|
+
};
|
|
27
|
+
_this._arcId = (0, Utilities_1.getId)('piechart_arc');
|
|
18
28
|
return _this;
|
|
19
29
|
}
|
|
20
30
|
Arc.getDerivedStateFromProps = function (nextProps) {
|
|
@@ -22,11 +32,12 @@ var Arc = /** @class */ (function (_super) {
|
|
|
22
32
|
return null;
|
|
23
33
|
};
|
|
24
34
|
Arc.prototype.render = function () {
|
|
35
|
+
var _this = this;
|
|
25
36
|
var _a;
|
|
26
|
-
var
|
|
37
|
+
var arc = this.props.arc;
|
|
27
38
|
var getClassNames = (0, Utilities_1.classNamesFunction)();
|
|
28
|
-
var classNames = getClassNames(Arc_styles_1.getStyles,
|
|
29
|
-
return React.createElement("path", { d: arc(this.props.data), className: classNames.
|
|
39
|
+
var classNames = getClassNames(function (props) { return (0, Arc_styles_1.getStyles)(props, _this.props.theme); }, tslib_1.__assign({}, this.props));
|
|
40
|
+
return (React.createElement("path", { d: arc(this.props.data), className: "".concat(this.state.isArcFocused ? classNames.arcRootFocussed : classNames.arcRoot), onClick: (_a = this.props.data) === null || _a === void 0 ? void 0 : _a.data.onClick }));
|
|
30
41
|
};
|
|
31
42
|
Arc.defaultProps = {
|
|
32
43
|
arc: shape.arc(),
|
|
@@ -36,19 +47,39 @@ var Arc = /** @class */ (function (_super) {
|
|
|
36
47
|
exports.Arc = Arc;
|
|
37
48
|
var LabeledArc = /** @class */ (function (_super) {
|
|
38
49
|
tslib_1.__extends(LabeledArc, _super);
|
|
39
|
-
function LabeledArc() {
|
|
40
|
-
|
|
50
|
+
function LabeledArc(props) {
|
|
51
|
+
var _this = _super.call(this, props) || this;
|
|
52
|
+
_this._isRTL = (0, Utilities_1.getRTL)();
|
|
53
|
+
_this._arcId = (0, Utilities_1.getId)('piechart_arc');
|
|
54
|
+
return _this;
|
|
41
55
|
}
|
|
42
56
|
LabeledArc.prototype.render = function () {
|
|
43
|
-
var
|
|
44
|
-
var
|
|
45
|
-
var
|
|
46
|
-
|
|
57
|
+
var _this = this;
|
|
58
|
+
var _a, _b;
|
|
59
|
+
var _c = this.props, data = _c.data, culture = _c.culture;
|
|
60
|
+
var gap = 4;
|
|
61
|
+
// placing the labels on the outside arc
|
|
62
|
+
var _d = shape.arc().centroid({
|
|
63
|
+
endAngle: (data === null || data === void 0 ? void 0 : data.endAngle) || 0,
|
|
64
|
+
startAngle: (data === null || data === void 0 ? void 0 : data.startAngle) || 0,
|
|
65
|
+
padAngle: data === null || data === void 0 ? void 0 : data.padAngle,
|
|
66
|
+
innerRadius: ((_a = this.props) === null || _a === void 0 ? void 0 : _a.outerRadius) || 0,
|
|
67
|
+
outerRadius: ((_b = this.props) === null || _b === void 0 ? void 0 : _b.outerRadius) || 0 + gap,
|
|
68
|
+
}), labelX = _d[0], labelY = _d[1];
|
|
69
|
+
var getClassNames = (0, Utilities_1.classNamesFunction)();
|
|
70
|
+
var classNames = getClassNames(function (props) { return (0, Arc_styles_1.getStyles)(props, _this.props.theme); });
|
|
71
|
+
var angle = (((data === null || data === void 0 ? void 0 : data.startAngle) || 0) + ((data === null || data === void 0 ? void 0 : data.endAngle) || 0)) / 2;
|
|
72
|
+
var content = "".concat(data === null || data === void 0 ? void 0 : data.data.x, "-").concat((0, utilities_1.convertToLocaleString)(data === null || data === void 0 ? void 0 : data.data.y, culture));
|
|
73
|
+
return (React.createElement("g", { className: "".concat(classNames.arc, " arc"), "data-is-focusable": true, id: this._arcId, onFocus: this._onFocus, onBlur: this._onBlur, "aria-label": content, role: "img" },
|
|
47
74
|
_super.prototype.render.call(this),
|
|
48
|
-
React.createElement(
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
75
|
+
React.createElement(SVGTooltipText_1.SVGTooltipText, { content: content, textProps: {
|
|
76
|
+
x: labelX,
|
|
77
|
+
y: labelY,
|
|
78
|
+
dominantBaseline: angle > Math.PI / 2 && angle < (3 * Math.PI) / 2 ? 'hanging' : 'auto',
|
|
79
|
+
textAnchor: (!this._isRTL && angle > Math.PI) || (this._isRTL && angle < Math.PI) ? 'end' : 'start',
|
|
80
|
+
'aria-label': "".concat(data === null || data === void 0 ? void 0 : data.data.x, "-").concat((0, utilities_1.convertToLocaleString)(data === null || data === void 0 ? void 0 : data.data.y, culture)),
|
|
81
|
+
className: classNames.arcText,
|
|
82
|
+
}, isTooltipVisibleProp: this.state.isArcFocused, shouldReceiveFocus: false, maxWidth: 40, wrapContent: utilities_1.wrapContent })));
|
|
52
83
|
};
|
|
53
84
|
return LabeledArc;
|
|
54
85
|
}(Arc));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Arc.js","sourceRoot":"../src/","sources":["components/PieChart/Arc/Arc.tsx"],"names":[],"mappings":";;;;AAAA,6BAA+B;AAC/B,gCAAkC;AAElC,
|
|
1
|
+
{"version":3,"file":"Arc.js","sourceRoot":"../src/","sources":["components/PieChart/Arc/Arc.tsx"],"names":[],"mappings":";;;;AAAA,6BAA+B;AAC/B,gCAAkC;AAElC,2DAAkF;AAClF,2CAAyC;AACzC,0DAAkF;AAClF,oEAAmE;AAEnE;IAAyB,+BAAqC;IAY5D,aAAmB,KAAgB;QAAnC,YACE,kBAAM,KAAK,CAAC,SAMb;QAEM,iBAAW,GAAG,UAAC,QAAmB;YACvC,YAAY,CAAC,QAAQ,CAAC,CAAC;QACzB,CAAC,CAAC;QAgBQ,cAAQ,GAAG;YACnB,KAAI,CAAC,QAAQ,CAAC,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC;QACxC,CAAC,CAAC;QAEQ,aAAO,GAAG;YAClB,KAAI,CAAC,QAAQ,CAAC,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC,CAAC;QACzC,CAAC,CAAC;QA/BA,KAAI,CAAC,KAAK,GAAG;YACX,YAAY,EAAE,KAAK;SACpB,CAAC;QAEF,KAAI,CAAC,MAAM,GAAG,IAAA,iBAAK,EAAC,cAAc,CAAC,CAAC;;IACtC,CAAC;IAZa,4BAAwB,GAAtC,UAAuC,SAA8B;QACnE,YAAY,CAAC,SAAS,CAAC,CAAC;QACxB,OAAO,IAAI,CAAC;IACd,CAAC;IAeM,oBAAM,GAAb;QAAA,iBAYC;;QAXS,IAAA,GAAG,GAAK,IAAI,CAAC,KAAK,IAAf,CAAgB;QAC3B,IAAM,aAAa,GAAG,IAAA,8BAAkB,GAAyB,CAAC;QAClE,IAAM,UAAU,GAAG,aAAa,CAAC,UAAA,KAAK,IAAI,OAAA,IAAA,sBAAS,EAAC,KAAK,EAAE,KAAI,CAAC,KAAK,CAAC,KAAK,CAAC,EAAlC,CAAkC,uBAAO,IAAI,CAAC,KAAK,E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CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM;oBACvF,UAAU,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,IAAI,KAAK,GAAG,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,IAAI,KAAK,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO;oBACnG,YAAY,EAAE,UAAG,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,IAAI,CAAC,CAAC,cAAI,IAAA,iCAAqB,EAAC,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,IAAI,CAAC,CAAC,EAAE,OAAO,CAAC,CAAE;oBAC/E,SAAS,EAAE,UAAU,CAAC,OAAO;iBAC9B,EACD,oBAAoB,EAAE,IAAI,CAAC,KAAK,CAAC,YAAY,EAC7C,kBAAkB,EAAE,KAAK,EACzB,QAAQ,EAAE,EAAE,EACZ,WAAW,EAAE,uBAAW,GACxB,CACA,CACL,CAAC;IACJ,CAAC;IACH,iBAAC;AAAD,CAAC,AAxDD,CAAgC,GAAG,GAwDlC;AAxDY,gCAAU;AA0DvB,SAAS,YAAY,CAAC,QAAmB;IACvC,QAAQ,CAAC,GAAG,CAAC,WAAW,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;IAC/C,QAAQ,CAAC,GAAG,CAAC,WAAW,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;AACjD,CAAC","sourcesContent":["import * as React from 'react';\nimport * as shape from 'd3-shape';\nimport { IArcProps, IArcState, IArcStyles } from './Arc.types';\nimport { classNamesFunction, getId, getRTL } from '@fluentui/react/lib/Utilities';\nimport { getStyles } from './Arc.styles';\nimport { wrapContent, convertToLocaleString } from '../../../utilities/utilities';\nimport { SVGTooltipText } from '../../../utilities/SVGTooltipText';\n\nexport class Arc extends React.Component<IArcProps, IArcState> {\n public static defaultProps: Partial<IArcProps> = {\n arc: shape.arc(),\n };\n\n protected _arcId: string;\n\n public static getDerivedStateFromProps(nextProps: Readonly<IArcProps>): null {\n _updateChart(nextProps);\n return null;\n }\n\n public constructor(props: IArcProps) {\n super(props);\n this.state = {\n isArcFocused: false,\n };\n\n this._arcId = getId('piechart_arc');\n }\n\n public updateChart = (newProps: IArcProps) => {\n _updateChart(newProps);\n };\n\n public render(): JSX.Element {\n const { arc } = this.props;\n const getClassNames = classNamesFunction<IArcProps, IArcStyles>();\n const classNames = getClassNames(props => getStyles(props, this.props.theme), { ...this.props });\n\n return (\n <path\n d={arc(this.props.data)}\n className={`${this.state.isArcFocused ? classNames.arcRootFocussed : classNames.arcRoot}`}\n onClick={this.props.data?.data.onClick}\n />\n );\n }\n\n protected _onFocus = () => {\n this.setState({ isArcFocused: true });\n };\n\n protected _onBlur = () => {\n this.setState({ isArcFocused: false });\n };\n}\n\nexport class LabeledArc extends Arc {\n private _isRTL = getRTL();\n\n public constructor(props: IArcProps) {\n super(props);\n this._arcId = getId('piechart_arc');\n }\n\n public render(): JSX.Element {\n const { data, culture } = this.props;\n const gap = 4;\n // placing the labels on the outside arc\n const [labelX, labelY] = shape.arc().centroid({\n endAngle: data?.endAngle || 0,\n startAngle: data?.startAngle || 0,\n padAngle: data?.padAngle,\n innerRadius: this.props?.outerRadius || 0,\n outerRadius: this.props?.outerRadius || 0 + gap,\n });\n\n const getClassNames = classNamesFunction<IArcProps, IArcStyles>();\n const classNames = getClassNames(props => getStyles(props, this.props.theme));\n\n const angle = ((data?.startAngle || 0) + (data?.endAngle || 0)) / 2;\n\n const content = `${data?.data.x}-${convertToLocaleString(data?.data.y, culture)}`;\n\n return (\n <g\n className={`${classNames.arc} arc`}\n data-is-focusable={true}\n id={this._arcId}\n onFocus={this._onFocus}\n onBlur={this._onBlur}\n aria-label={content}\n role=\"img\"\n >\n {super.render()}\n <SVGTooltipText\n content={content}\n textProps={{\n x: labelX,\n y: labelY,\n dominantBaseline: angle > Math.PI / 2 && angle < (3 * Math.PI) / 2 ? 'hanging' : 'auto',\n textAnchor: (!this._isRTL && angle > Math.PI) || (this._isRTL && angle < Math.PI) ? 'end' : 'start',\n 'aria-label': `${data?.data.x}-${convertToLocaleString(data?.data.y, culture)}`,\n className: classNames.arcText,\n }}\n isTooltipVisibleProp={this.state.isArcFocused}\n shouldReceiveFocus={false}\n maxWidth={40}\n wrapContent={wrapContent}\n />\n </g>\n );\n }\n}\n\nfunction _updateChart(newProps: IArcProps): void {\n newProps.arc.innerRadius(newProps.innerRadius);\n newProps.arc.outerRadius(newProps.outerRadius);\n}\n"]}
|
|
@@ -2,10 +2,13 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getStyles = void 0;
|
|
4
4
|
var Styling_1 = require("@fluentui/react/lib/Styling");
|
|
5
|
-
var getStyles = function (props) {
|
|
5
|
+
var getStyles = function (props, theme) {
|
|
6
6
|
var color = props.color;
|
|
7
7
|
return {
|
|
8
|
-
|
|
8
|
+
arcRoot: { fill: color },
|
|
9
|
+
arcRootFocussed: { fill: color, stroke: (theme === null || theme === void 0 ? void 0 : theme.palette.black) || Styling_1.DefaultPalette.black, strokeWidth: 2 },
|
|
10
|
+
arc: { outline: 'none' },
|
|
11
|
+
arcText: { fill: (theme === null || theme === void 0 ? void 0 : theme.palette.black) || Styling_1.DefaultPalette.black, outline: 'none' },
|
|
9
12
|
};
|
|
10
13
|
};
|
|
11
14
|
exports.getStyles = getStyles;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Arc.styles.js","sourceRoot":"../src/","sources":["components/PieChart/Arc/Arc.styles.ts"],"names":[],"mappings":";;;AACA,
|
|
1
|
+
{"version":3,"file":"Arc.styles.js","sourceRoot":"../src/","sources":["components/PieChart/Arc/Arc.styles.ts"],"names":[],"mappings":";;;AACA,uDAAqE;AAC9D,IAAM,SAAS,GAAG,UAAC,KAAgB,EAAE,KAAyB;IAC3D,IAAA,KAAK,GAAK,KAAK,MAAV,CAAW;IACxB,OAAO;QACL,OAAO,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE;QACxB,eAAe,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,OAAO,CAAC,KAAK,KAAI,wBAAc,CAAC,KAAK,EAAE,WAAW,EAAE,CAAC,EAAE;QACtG,GAAG,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE;QACxB,OAAO,EAAE,EAAE,IAAI,EAAE,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,OAAO,CAAC,KAAK,KAAI,wBAAc,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE;KACjF,CAAC;AACJ,CAAC,CAAC;AARW,QAAA,SAAS,aAQpB","sourcesContent":["import { IArcProps, IArcStyles } from './Arc.types';\nimport { DefaultPalette, ITheme } from '@fluentui/react/lib/Styling';\nexport const getStyles = (props: IArcProps, theme: ITheme | undefined): IArcStyles => {\n const { color } = props;\n return {\n arcRoot: { fill: color },\n arcRootFocussed: { fill: color, stroke: theme?.palette.black || DefaultPalette.black, strokeWidth: 2 },\n arc: { outline: 'none' },\n arcText: { fill: theme?.palette.black || DefaultPalette.black, outline: 'none' },\n };\n};\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IStyle } from '@fluentui/react/lib/Styling';
|
|
1
|
+
import { IStyle, ITheme } from '@fluentui/react/lib/Styling';
|
|
2
2
|
import { IDataPoint } from '../PieChart.types';
|
|
3
3
|
export interface IArcProps {
|
|
4
4
|
/**
|
|
@@ -25,6 +25,16 @@ export interface IArcProps {
|
|
|
25
25
|
* The prop used to define the culture to localized the numbers
|
|
26
26
|
*/
|
|
27
27
|
culture?: string;
|
|
28
|
+
/**
|
|
29
|
+
* to pass the theme
|
|
30
|
+
*/
|
|
31
|
+
theme?: ITheme;
|
|
32
|
+
}
|
|
33
|
+
export interface IArcState {
|
|
34
|
+
/**
|
|
35
|
+
* The state controls, whether the arc needs to be focused or not
|
|
36
|
+
*/
|
|
37
|
+
isArcFocused?: boolean;
|
|
28
38
|
}
|
|
29
39
|
export interface IArcData {
|
|
30
40
|
/**
|
|
@@ -56,5 +66,8 @@ export interface IArcStyles {
|
|
|
56
66
|
/**
|
|
57
67
|
* Style set for the card header component root
|
|
58
68
|
*/
|
|
59
|
-
|
|
69
|
+
arcRoot: IStyle;
|
|
70
|
+
arc: IStyle;
|
|
71
|
+
arcRootFocussed: IStyle;
|
|
72
|
+
arcText: IStyle;
|
|
60
73
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Arc.types.js","sourceRoot":"../src/","sources":["components/PieChart/Arc/Arc.types.ts"],"names":[],"mappings":"","sourcesContent":["import { IStyle } from '@fluentui/react/lib/Styling';\nimport { IDataPoint } from '../PieChart.types';\n\nexport interface IArcProps {\n /**\n * Data to render in the Arc.\n */\n data?: IArcData;\n\n /**\n * shape for Arc.\n */\n /* eslint-disable @typescript-eslint/no-explicit-any */\n arc?: any;\n\n /**\n * innerRadius of the Arc.\n */\n innerRadius?: number;\n /**\n * outerRadius of the Arc.\n */\n outerRadius?: number;\n /**\n * Color for the Arc.\n */\n color: string;\n\n /**\n * The prop used to define the culture to localized the numbers\n */\n culture?: string;\n}\n\nexport interface IArcData {\n /**\n * Data to render in the chart for individual arc.\n */\n data: IDataPoint;\n /**\n * endAngle of the Arc\n */\n endAngle: number;\n /**\n * index of the Arc\n */\n index: number;\n /**\n * padAngle of the Arc\n */\n padAngle: number;\n /**\n * startAngle of the Arc\n */\n startAngle: number;\n /**\n * value of the Arc\n */\n value: number;\n}\n\nexport interface IArcStyles {\n /**\n * Style set for the card header component root\n */\n
|
|
1
|
+
{"version":3,"file":"Arc.types.js","sourceRoot":"../src/","sources":["components/PieChart/Arc/Arc.types.ts"],"names":[],"mappings":"","sourcesContent":["import { IStyle, ITheme } from '@fluentui/react/lib/Styling';\nimport { IDataPoint } from '../PieChart.types';\n\nexport interface IArcProps {\n /**\n * Data to render in the Arc.\n */\n data?: IArcData;\n\n /**\n * shape for Arc.\n */\n /* eslint-disable @typescript-eslint/no-explicit-any */\n arc?: any;\n\n /**\n * innerRadius of the Arc.\n */\n innerRadius?: number;\n /**\n * outerRadius of the Arc.\n */\n outerRadius?: number;\n /**\n * Color for the Arc.\n */\n color: string;\n\n /**\n * The prop used to define the culture to localized the numbers\n */\n culture?: string;\n /**\n * to pass the theme\n */\n theme?: ITheme;\n}\n\nexport interface IArcState {\n /**\n * The state controls, whether the arc needs to be focused or not\n */\n isArcFocused?: boolean;\n}\n\nexport interface IArcData {\n /**\n * Data to render in the chart for individual arc.\n */\n data: IDataPoint;\n /**\n * endAngle of the Arc\n */\n endAngle: number;\n /**\n * index of the Arc\n */\n index: number;\n /**\n * padAngle of the Arc\n */\n padAngle: number;\n /**\n * startAngle of the Arc\n */\n startAngle: number;\n /**\n * value of the Arc\n */\n value: number;\n}\n\nexport interface IArcStyles {\n /**\n * Style set for the card header component root\n */\n arcRoot: IStyle;\n\n arc: IStyle;\n\n arcRootFocussed: IStyle;\n\n arcText: IStyle;\n}\n"]}
|
|
@@ -6,28 +6,39 @@ var React = require("react");
|
|
|
6
6
|
var shape = require("d3-shape");
|
|
7
7
|
var scale = require("d3-scale");
|
|
8
8
|
var Arc_1 = require("../Arc/Arc");
|
|
9
|
+
var react_focus_1 = require("@fluentui/react-focus");
|
|
10
|
+
var colors_1 = require("../../../utilities/colors");
|
|
9
11
|
var Pie = /** @class */ (function (_super) {
|
|
10
12
|
tslib_1.__extends(Pie, _super);
|
|
11
13
|
function Pie(props) {
|
|
12
14
|
var _this = _super.call(this, props) || this;
|
|
13
15
|
_this.arcGenerator = function (d, i) {
|
|
14
|
-
return (React.createElement(Arc_1.LabeledArc, { culture: _this.props.culture, key: i, data: d, innerRadius: _this.props.innerRadius, outerRadius: _this.props.outerRadius, color: "".concat(_this.colors(i)) }));
|
|
16
|
+
return (React.createElement(Arc_1.LabeledArc, { culture: _this.props.culture, key: i, data: d, innerRadius: _this.props.innerRadius, outerRadius: _this.props.outerRadius, color: "".concat(_this.colors(i)), theme: _this.props.theme }));
|
|
15
17
|
};
|
|
16
18
|
return _this;
|
|
17
19
|
}
|
|
18
20
|
Pie.prototype.render = function () {
|
|
19
21
|
var _this = this;
|
|
20
22
|
// const getClassNames = classNamesFunction<IPieProps, IPieStyles>();
|
|
21
|
-
var _a = this.props, pie = _a.pie,
|
|
22
|
-
|
|
23
|
+
var _a = this.props, pie = _a.pie, data = _a.data, width = _a.width, height = _a.height, chartTitle = _a.chartTitle, theme = _a.theme;
|
|
24
|
+
var defaultColors = [];
|
|
25
|
+
if (data && !this.props.colors) {
|
|
26
|
+
for (var i = 0; i < data.length; i++) {
|
|
27
|
+
defaultColors.push((0, colors_1.getNextColor)(i, 0, theme === null || theme === void 0 ? void 0 : theme.isInverted));
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
var _b = this.props.colors, colors = _b === void 0 ? defaultColors : _b;
|
|
31
|
+
this.colors = scale.scaleOrdinal().range(colors.map(function (color) { return (0, colors_1.getColorFromToken)(color); }));
|
|
23
32
|
var piechart = pie(data);
|
|
24
33
|
var translate = "translate(".concat(width / 2, ", ").concat(height / 2, ")");
|
|
25
|
-
return (React.createElement(
|
|
26
|
-
React.createElement("
|
|
34
|
+
return (React.createElement(react_focus_1.FocusZone, { direction: react_focus_1.FocusZoneDirection.domOrder },
|
|
35
|
+
React.createElement("svg", { width: width, height: height, "aria-label": chartTitle },
|
|
36
|
+
React.createElement("g", { className: "pie", transform: translate }, piechart.map(function (d, i) { return _this.arcGenerator(d, i); })))));
|
|
27
37
|
};
|
|
28
38
|
Pie.defaultProps = {
|
|
29
39
|
pie: shape
|
|
30
40
|
.pie()
|
|
41
|
+
.padAngle(0.01)
|
|
31
42
|
.sort(null)
|
|
32
43
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
33
44
|
.value(function (d) { return d.y; }),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Pie.js","sourceRoot":"../src/","sources":["components/PieChart/Pie/Pie.tsx"],"names":[],"mappings":";;;;AAAA,6BAA+B;AAC/B,gCAAkC;AAClC,gCAAkC;AAElC,kCAAwC;
|
|
1
|
+
{"version":3,"file":"Pie.js","sourceRoot":"../src/","sources":["components/PieChart/Pie/Pie.tsx"],"names":[],"mappings":";;;;AAAA,6BAA+B;AAC/B,gCAAkC;AAClC,gCAAkC;AAElC,kCAAwC;AAExC,qDAAsE;AACtE,oDAA4E;AAE5E;IAAyB,+BAA8B;IAWrD,aAAY,KAAgB;QAA5B,YACE,kBAAM,KAAK,CAAC,SACb;QAEM,kBAAY,GAAG,UAAC,CAAW,EAAE,CAAS;YAC3C,OAAO,CACL,oBAAC,gBAAU,IACT,OAAO,EAAE,KAAI,CAAC,KAAK,CAAC,OAAO,EAC3B,GAAG,EAAE,CAAC,EACN,IAAI,EAAE,CAAC,EACP,WAAW,EAAE,KAAI,CAAC,KAAK,CAAC,WAAW,EACnC,WAAW,EAAE,KAAI,CAAC,KAAK,CAAC,WAAW,EACnC,KAAK,EAAE,UAAG,KAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAE,EAC1B,KAAK,EAAE,KAAI,CAAC,KAAK,CAAC,KAAK,GACvB,CACH,CAAC;QACJ,CAAC,CAAC;;IAdF,CAAC;IAgBM,oBAAM,GAAb;QAAA,iBA0BC;QAzBC,qEAAqE;QAC/D,IAAA,KAAkD,IAAI,CAAC,KAAK,EAA1D,GAAG,SAAA,EAAE,IAAI,UAAA,EAAE,KAAK,WAAA,EAAE,MAAM,YAAA,EAAE,UAAU,gBAAA,EAAE,KAAK,WAAe,CAAC;QAEnE,IAAM,aAAa,GAAkB,EAAE,CAAC;QACxC,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE;YAC9B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CA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vC;AAxDY,kBAAG","sourcesContent":["import * as React from 'react';\nimport * as shape from 'd3-shape';\nimport * as scale from 'd3-scale';\nimport { IPieProps } from './Pie.types';\nimport { LabeledArc } from '../Arc/Arc';\nimport { IArcData } from '../Arc/Arc.types';\nimport { FocusZone, FocusZoneDirection } from '@fluentui/react-focus';\nimport { getColorFromToken, getNextColor } from '../../../utilities/colors';\n\nexport class Pie extends React.Component<IPieProps, {}> {\n public static defaultProps: Partial<IPieProps> = {\n pie: shape\n .pie()\n .padAngle(0.01)\n .sort(null)\n /* eslint-disable @typescript-eslint/no-explicit-any */\n .value((d: any) => d.y),\n };\n private colors: scale.ScaleOrdinal<string | number, any>;\n\n constructor(props: IPieProps) {\n super(props);\n }\n\n public arcGenerator = (d: IArcData, i: number): JSX.Element => {\n return (\n <LabeledArc\n culture={this.props.culture}\n key={i}\n data={d}\n innerRadius={this.props.innerRadius}\n outerRadius={this.props.outerRadius}\n color={`${this.colors(i)}`}\n theme={this.props.theme}\n />\n );\n };\n\n public render(): JSX.Element {\n // const getClassNames = classNamesFunction<IPieProps, IPieStyles>();\n const { pie, data, width, height, chartTitle, theme } = this.props;\n\n const defaultColors: Array<string> = [];\n if (data && !this.props.colors) {\n for (let i = 0; i < data.length; i++) {\n defaultColors.push(getNextColor(i, 0, theme?.isInverted));\n }\n }\n const { colors = defaultColors } = this.props;\n\n this.colors = scale.scaleOrdinal().range(colors.map(color => getColorFromToken(color)));\n\n const piechart = pie(data);\n const translate = `translate(${width / 2}, ${height / 2})`;\n\n return (\n <FocusZone direction={FocusZoneDirection.domOrder}>\n <svg width={width} height={height} aria-label={chartTitle}>\n <g className=\"pie\" transform={translate}>\n {piechart.map((d: IArcData, i: number) => this.arcGenerator(d, i))}\n </g>\n </svg>\n </FocusZone>\n );\n }\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IStyle } from '@fluentui/react/lib/Styling';
|
|
1
|
+
import { IStyle, ITheme } from '@fluentui/react/lib/Styling';
|
|
2
2
|
import { IDataPoint } from '../PieChart.types';
|
|
3
3
|
export interface IPieProps {
|
|
4
4
|
/**
|
|
@@ -37,6 +37,7 @@ export interface IPieProps {
|
|
|
37
37
|
* The prop used to define the culture to localized the numbers
|
|
38
38
|
*/
|
|
39
39
|
culture?: string;
|
|
40
|
+
theme?: ITheme;
|
|
40
41
|
}
|
|
41
42
|
export interface IPieStyles {
|
|
42
43
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Pie.types.js","sourceRoot":"../src/","sources":["components/PieChart/Pie/Pie.types.ts"],"names":[],"mappings":"","sourcesContent":["import { IStyle } from '@fluentui/react/lib/Styling';\nimport { IDataPoint } from '../PieChart.types';\n\nexport interface IPieProps {\n /**\n * Width of the Pie.\n */\n width: number;\n /**\n * Height of the Pie.\n */\n height: number;\n /**\n * outerRadius of the Pie.\n */\n outerRadius: number;\n /**\n * innerRadius of the Pie.\n */\n innerRadius: number;\n /**\n * Data to render in the Pie.\n */\n data: IDataPoint[];\n /**\n * colors to render in the Pie.\n */\n colors?: string[];\n /**\n * Title to apply to the whole chart.\n */\n chartTitle?: string;\n /**\n * shape for pie.\n */\n /* eslint-disable @typescript-eslint/no-explicit-any */\n pie?: any;\n\n /**\n * The prop used to define the culture to localized the numbers\n */\n culture?: string;\n}\n\nexport interface IPieStyles {\n /**\n * Style set for the card header component root\n */\n root: IStyle;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Pie.types.js","sourceRoot":"../src/","sources":["components/PieChart/Pie/Pie.types.ts"],"names":[],"mappings":"","sourcesContent":["import { IStyle, ITheme } from '@fluentui/react/lib/Styling';\nimport { IDataPoint } from '../PieChart.types';\n\nexport interface IPieProps {\n /**\n * Width of the Pie.\n */\n width: number;\n /**\n * Height of the Pie.\n */\n height: number;\n /**\n * outerRadius of the Pie.\n */\n outerRadius: number;\n /**\n * innerRadius of the Pie.\n */\n innerRadius: number;\n /**\n * Data to render in the Pie.\n */\n data: IDataPoint[];\n /**\n * colors to render in the Pie.\n */\n colors?: string[];\n /**\n * Title to apply to the whole chart.\n */\n chartTitle?: string;\n /**\n * shape for pie.\n */\n /* eslint-disable @typescript-eslint/no-explicit-any */\n pie?: any;\n\n /**\n * The prop used to define the culture to localized the numbers\n */\n culture?: string;\n\n theme?: ITheme;\n}\n\nexport interface IPieStyles {\n /**\n * Style set for the card header component root\n */\n root: IStyle;\n}\n"]}
|
|
@@ -22,11 +22,17 @@ var PieChartBase = /** @class */ (function (_super) {
|
|
|
22
22
|
height: height,
|
|
23
23
|
className: className,
|
|
24
24
|
});
|
|
25
|
-
var
|
|
26
|
-
var
|
|
25
|
+
var TEXT_MAX_WIDTH = 40;
|
|
26
|
+
var TEXT_LINE_HEIGHT = 16;
|
|
27
|
+
/**
|
|
28
|
+
* The radius for the pie chart is computed based on the space available inside the svg
|
|
29
|
+
* after subtracting the max amount of space that can be used by the text in pie chart
|
|
30
|
+
*/
|
|
31
|
+
var radius = Math.min(width - 2 * TEXT_MAX_WIDTH, height - 2 * TEXT_LINE_HEIGHT) / 2;
|
|
32
|
+
var outerRadius = radius;
|
|
27
33
|
return !this._isChartEmpty() ? (React.createElement("div", { className: this._classNames.root },
|
|
28
34
|
this.props.chartTitle && React.createElement("p", { className: this._classNames.chartTitle }, this.props.chartTitle),
|
|
29
|
-
React.createElement(Pie_1.Pie, { culture: culture, width: width, height: height, outerRadius: outerRadius, innerRadius:
|
|
35
|
+
React.createElement(Pie_1.Pie, { culture: culture, width: width, height: height, outerRadius: outerRadius, innerRadius: 1, data: data, colors: colors, chartTitle: chartTitle, theme: theme }))) : (React.createElement("div", { id: this._emptyChartId, role: 'alert', style: { opacity: '0' }, "aria-label": 'Graph has no data to display' }));
|
|
30
36
|
};
|
|
31
37
|
PieChartBase.prototype._isChartEmpty = function () {
|
|
32
38
|
return !(this.props.data && this.props.data.length > 0 && this.props.data.filter(function (item) { return item.y > 0; }).length > 0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PieChart.base.js","sourceRoot":"../src/","sources":["components/PieChart/PieChart.base.tsx"],"names":[],"mappings":";;;;AAAA,6BAA+B;AAC/B,2DAA0E;AAE1E,iCAAgC;AAGhC,IAAM,aAAa,GAAG,IAAA,8BAAkB,GAAwC,CAAC;AAEjF;IAAkC,wCAAmC;IASnE,sBAAmB,KAAqB;QAAxC,YACE,kBAAM,KAAK,CAAC,SAEb;QADC,KAAI,CAAC,aAAa,GAAG,IAAA,iBAAK,EAAC,iBAAiB,CAAC,CAAC;;IAChD,CAAC;IAEM,6BAAM,GAAb;QACQ,IAAA,KAA8C,IAAI,CAAC,KAAK,EAAtD,IAAI,UAAA,EAAE,KAAK,WAAA,EAAE,MAAM,YAAA,EAAE,MAAM,YAAA,EAAE,UAAU,gBAAe,CAAC;QAEzD,IAAA,KAAwC,IAAI,CAAC,KAAK,EAAhD,KAAK,WAAA,EAAE,SAAS,eAAA,EAAE,MAAM,YAAA,EAAE,OAAO,aAAe,CAAC;QACzD,IAAI,CAAC,WAAW,GAAG,aAAa,CAAC,MAAO,EAAE;YACxC,KAAK,EAAE,KAAM;YACb,KAAK,EAAE,KAAM;YACb,MAAM,EAAE,MAAO;YACf,SAAS,WAAA;SACV,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"PieChart.base.js","sourceRoot":"../src/","sources":["components/PieChart/PieChart.base.tsx"],"names":[],"mappings":";;;;AAAA,6BAA+B;AAC/B,2DAA0E;AAE1E,iCAAgC;AAGhC,IAAM,aAAa,GAAG,IAAA,8BAAkB,GAAwC,CAAC;AAEjF;IAAkC,wCAAmC;IASnE,sBAAmB,KAAqB;QAAxC,YACE,kBAAM,KAAK,CAAC,SAEb;QADC,KAAI,CAAC,aAAa,GAAG,IAAA,iBAAK,EAAC,iBAAiB,CAAC,CAAC;;IAChD,CAAC;IAEM,6BAAM,GAAb;QACQ,IAAA,KAA8C,IAAI,CAAC,KAAK,EAAtD,IAAI,UAAA,EAAE,KAAK,WAAA,EAAE,MAAM,YAAA,E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,CACH,CAAC;IACJ,CAAC;IAEO,oCAAa,GAArB;QACE,OAAO,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,UAAA,IAAI,IAAI,OAAA,IAAI,CAAC,CAAC,GAAG,CAAC,EAAV,CAAU,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACnH,CAAC;IA9Da,yBAAY,GAA4B;QACpD,IAAI,EAAE,EAAE;QACR,KAAK,EAAE,GAAG;QACV,MAAM,EAAE,GAAG;KACZ,CAAC;IA2DJ,mBAAC;CAAA,AAhED,CAAkC,KAAK,CAAC,SAAS,GAgEhD;AAhEY,oCAAY","sourcesContent":["import * as React from 'react';\nimport { classNamesFunction, getId } from '@fluentui/react/lib/Utilities';\nimport { IPieChartProps, IPieChartStyleProps, IPieChartStyles } from './PieChart.types';\nimport { Pie } from './Pie/Pie';\nimport { IProcessedStyleSet } from '@fluentui/react/lib/Styling';\n\nconst getClassNames = classNamesFunction<IPieChartStyleProps, IPieChartStyles>();\n\nexport class PieChartBase extends React.Component<IPieChartProps, {}> {\n public static defaultProps: Partial<IPieChartProps> = {\n data: [],\n width: 600,\n height: 350,\n };\n private _classNames: IProcessedStyleSet<IPieChartStyles>;\n private _emptyChartId: string;\n\n public constructor(props: IPieChartProps) {\n super(props);\n this._emptyChartId = getId('_PieChart_empty');\n }\n\n public render(): JSX.Element {\n const { data, width, height, colors, chartTitle } = this.props;\n\n const { theme, className, styles, culture } = this.props;\n this._classNames = getClassNames(styles!, {\n theme: theme!,\n width: width!,\n height: height!,\n className,\n });\n\n const TEXT_MAX_WIDTH = 40;\n const TEXT_LINE_HEIGHT = 16;\n\n /**\n * The radius for the pie chart is computed based on the space available inside the svg\n * after subtracting the max amount of space that can be used by the text in pie chart\n */\n\n const radius = Math.min(width! - 2 * TEXT_MAX_WIDTH, height! - 2 * TEXT_LINE_HEIGHT) / 2;\n const outerRadius = radius;\n\n return !this._isChartEmpty() ? (\n <div className={this._classNames.root}>\n {this.props.chartTitle && <p className={this._classNames.chartTitle}>{this.props.chartTitle}</p>}\n <Pie\n culture={culture}\n width={width!}\n height={height!}\n outerRadius={outerRadius}\n innerRadius={1}\n data={data!}\n colors={colors!}\n chartTitle={chartTitle!}\n theme={theme}\n />\n </div>\n ) : (\n <div\n id={this._emptyChartId}\n role={'alert'}\n style={{ opacity: '0' }}\n aria-label={'Graph has no data to display'}\n />\n );\n }\n\n private _isChartEmpty(): boolean {\n return !(this.props.data && this.props.data.length > 0 && this.props.data.filter(item => item.y > 0).length > 0);\n }\n}\n"]}
|
|
@@ -17,6 +17,7 @@ export interface IMultiStackedBarChartState {
|
|
|
17
17
|
dataPointCalloutProps?: IChartDataPoint;
|
|
18
18
|
callOutAccessibilityData?: IAccessibilityProps;
|
|
19
19
|
calloutLegend: string;
|
|
20
|
+
barSpacingInPercent: number;
|
|
20
21
|
}
|
|
21
22
|
export declare class MultiStackedBarChartBase extends React.Component<IMultiStackedBarChartProps, IMultiStackedBarChartState> {
|
|
22
23
|
static defaultProps: Partial<IMultiStackedBarChartProps>;
|
|
@@ -25,12 +26,20 @@ export declare class MultiStackedBarChartBase extends React.Component<IMultiStac
|
|
|
25
26
|
private _calloutAnchorPoint;
|
|
26
27
|
private _longestBarTotalValue;
|
|
27
28
|
private _isRTL;
|
|
29
|
+
private barChartSvgRef;
|
|
28
30
|
private _emptyChartId;
|
|
29
31
|
private _barId;
|
|
30
32
|
private _barIdPlaceholderPartToWhole;
|
|
31
33
|
private _barIdEmpty;
|
|
32
34
|
constructor(props: IMultiStackedBarChartProps);
|
|
35
|
+
componentDidMount(): void;
|
|
33
36
|
render(): JSX.Element;
|
|
37
|
+
/**
|
|
38
|
+
* The Create bar functions returns an array of <rect> elements, which form the bars
|
|
39
|
+
* For each bar an x value, and a width needs to be specified
|
|
40
|
+
* The computations are done based on percentages
|
|
41
|
+
* Extra margin is also provided, in the x value to provide some spacing
|
|
42
|
+
*/
|
|
34
43
|
private _createBarsAndLegends;
|
|
35
44
|
private _onBarFocus;
|
|
36
45
|
private _refCallback;
|
|
@@ -139,16 +139,27 @@ var MultiStackedBarChartBase = /** @class */ (function (_super) {
|
|
|
139
139
|
xCalloutValue: '',
|
|
140
140
|
yCalloutValue: '',
|
|
141
141
|
calloutLegend: '',
|
|
142
|
+
barSpacingInPercent: 0,
|
|
142
143
|
};
|
|
143
144
|
_this._onLeave = _this._onLeave.bind(_this);
|
|
144
145
|
_this._onBarLeave = _this._onBarLeave.bind(_this);
|
|
145
146
|
_this._calloutId = (0, Utilities_1.getId)('callout');
|
|
147
|
+
_this.barChartSvgRef = React.createRef();
|
|
146
148
|
_this._emptyChartId = (0, Utilities_1.getId)('_MSBC_empty');
|
|
147
149
|
_this._barId = (0, Utilities_1.getId)('_MSBC_rect_');
|
|
148
150
|
_this._barIdPlaceholderPartToWhole = (0, Utilities_1.getId)('_MSBC_rect_partToWhole_');
|
|
149
151
|
_this._barIdEmpty = (0, Utilities_1.getId)('_MSBC_rect_empty');
|
|
150
152
|
return _this;
|
|
151
153
|
}
|
|
154
|
+
MultiStackedBarChartBase.prototype.componentDidMount = function () {
|
|
155
|
+
var _a;
|
|
156
|
+
var svgWidth = ((_a = this.barChartSvgRef.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect().width) || 0;
|
|
157
|
+
var MARGIN_WIDTH_IN_PX = 3;
|
|
158
|
+
if (svgWidth) {
|
|
159
|
+
var currentBarSpacing = (MARGIN_WIDTH_IN_PX / svgWidth) * 100;
|
|
160
|
+
this.setState({ barSpacingInPercent: currentBarSpacing });
|
|
161
|
+
}
|
|
162
|
+
};
|
|
152
163
|
MultiStackedBarChartBase.prototype.render = function () {
|
|
153
164
|
var _this = this;
|
|
154
165
|
if (!this._isChartEmpty()) {
|
|
@@ -180,8 +191,18 @@ var MultiStackedBarChartBase = /** @class */ (function (_super) {
|
|
|
180
191
|
}
|
|
181
192
|
return (React.createElement("div", { id: this._emptyChartId, role: 'alert', style: { opacity: '0' }, "aria-label": 'Graph has no data to display' }));
|
|
182
193
|
};
|
|
194
|
+
/**
|
|
195
|
+
* The Create bar functions returns an array of <rect> elements, which form the bars
|
|
196
|
+
* For each bar an x value, and a width needs to be specified
|
|
197
|
+
* The computations are done based on percentages
|
|
198
|
+
* Extra margin is also provided, in the x value to provide some spacing
|
|
199
|
+
*/
|
|
183
200
|
MultiStackedBarChartBase.prototype._createBarsAndLegends = function (data, barHeight, palette, hideRatio, hideDenominator, href) {
|
|
184
201
|
var _this = this;
|
|
202
|
+
var _a;
|
|
203
|
+
var noOfBars = ((_a = data.chartData) === null || _a === void 0 ? void 0 : _a.reduce(function (count, point) { return (count += (point.data || 0) > 0 ? 1 : 0); }, 0)) ||
|
|
204
|
+
1;
|
|
205
|
+
var totalMarginPercent = this.state.barSpacingInPercent * (noOfBars - 1);
|
|
185
206
|
var culture = this.props.culture;
|
|
186
207
|
var defaultPalette = [palette.blueLight, palette.blue, palette.blueMid, palette.red, palette.black];
|
|
187
208
|
// calculating starting point of each bar and it's range
|
|
@@ -191,7 +212,8 @@ var MultiStackedBarChartBase = /** @class */ (function (_super) {
|
|
|
191
212
|
var sumOfPercent = 0;
|
|
192
213
|
data.chartData.map(function (point, index) {
|
|
193
214
|
var pointData = point.data ? point.data : 0;
|
|
194
|
-
|
|
215
|
+
var currValue = (pointData / total) * 100;
|
|
216
|
+
var value = currValue ? currValue : 0;
|
|
195
217
|
if (value < 1 && value !== 0) {
|
|
196
218
|
value = 1;
|
|
197
219
|
}
|
|
@@ -214,7 +236,15 @@ var MultiStackedBarChartBase = /** @class */ (function (_super) {
|
|
|
214
236
|
}
|
|
215
237
|
sumOfPercent += value_1;
|
|
216
238
|
}
|
|
217
|
-
|
|
239
|
+
/**
|
|
240
|
+
* The %age of the space occupied by the margin needs to subtracted
|
|
241
|
+
* while computing the scaling ratio, since the margins are not being
|
|
242
|
+
* scaled down, only the data is being scaled down from a higher percentage to lower percentage
|
|
243
|
+
* Eg: 95% of the space is taken by the bars, 5% by the margins
|
|
244
|
+
* Now if the sumOfPercent is 120% -> This needs to be scaled down to 95%, not 100%
|
|
245
|
+
* since that's only space available to the bars
|
|
246
|
+
*/
|
|
247
|
+
var scalingRatio = sumOfPercent !== 0 ? sumOfPercent / (100 - totalMarginPercent) : 1;
|
|
218
248
|
var prevPosition = 0;
|
|
219
249
|
var value = 0;
|
|
220
250
|
var bars = data.chartData.map(function (point, index) {
|
|
@@ -250,13 +280,15 @@ var MultiStackedBarChartBase = /** @class */ (function (_super) {
|
|
|
250
280
|
return (React.createElement("g", { key: index, className: point.placeHolder ? _this._classNames.placeHolderOnHover : _this._classNames.opacityChangeOnHover, ref: function (e) {
|
|
251
281
|
_this._refCallback(e, point.legend);
|
|
252
282
|
}, "data-is-focusable": !_this.props.hideTooltip, onFocus: _this._onBarFocus.bind(_this, pointData, color, point), onBlur: _this._onBarLeave, role: "img", "aria-label": _this._getAriaLabel(point), onMouseOver: point.placeHolder ? undefined : _this._onBarHover.bind(_this, pointData, color, point), onMouseMove: point.placeHolder ? undefined : _this._onBarHover.bind(_this, pointData, color, point), onMouseLeave: point.placeHolder ? undefined : _this._onBarLeave, onClick: href ? (point.placeHolder ? undefined : _this._redirectToUrl.bind(_this, href)) : point.onClick },
|
|
253
|
-
React.createElement("rect", { key: index, id: "".concat(_this._barId, "-").concat(index), x: "".concat(_this._isRTL
|
|
283
|
+
React.createElement("rect", { key: index, id: "".concat(_this._barId, "-").concat(index), x: "".concat(_this._isRTL
|
|
284
|
+
? 100 - startingPoint[index] - value - _this.state.barSpacingInPercent * index
|
|
285
|
+
: startingPoint[index] + _this.state.barSpacingInPercent * index, "%"), y: 0, width: value + '%', height: barHeight, fill: color })));
|
|
254
286
|
});
|
|
255
287
|
if (this.props.variant === index_2.MultiStackedBarChartVariant.AbsoluteScale) {
|
|
256
288
|
if (!this.props.hideLabels) {
|
|
257
289
|
bars.push(React.createElement("text", { key: "text", x: "".concat(this._isRTL
|
|
258
|
-
? 100 - (startingPoint[startingPoint.length - 1] || 0) - value
|
|
259
|
-
: (startingPoint[startingPoint.length - 1] || 0) + value, "%"), y: barHeight / 2, dominantBaseline: "central", transform: "translate(".concat(this._isRTL ? -4 : 4, ")"), className: this._classNames.barLabel, "aria-label": "Total: ".concat(barTotalValue), role: "img" }, (0, d3_format_1.formatPrefix)(barTotalValue < 1000 ? '.2~' : '.1', barTotalValue)(barTotalValue)));
|
|
290
|
+
? 100 - (startingPoint[startingPoint.length - 1] || 0) - value - totalMarginPercent
|
|
291
|
+
: (startingPoint[startingPoint.length - 1] || 0) + value + totalMarginPercent, "%"), textAnchor: this._isRTL ? 'end' : 'start', y: barHeight / 2, dominantBaseline: "central", transform: "translate(".concat(this._isRTL ? -4 : 4, ")"), className: this._classNames.barLabel, "aria-label": "Total: ".concat(barTotalValue), role: "img" }, (0, d3_format_1.formatPrefix)(barTotalValue < 1000 ? '.2~' : '.1', barTotalValue)(barTotalValue)));
|
|
260
292
|
}
|
|
261
293
|
}
|
|
262
294
|
else {
|
|
@@ -285,7 +317,7 @@ var MultiStackedBarChartBase = /** @class */ (function (_super) {
|
|
|
285
317
|
showNumber && (React.createElement("div", tslib_1.__assign({ className: this._classNames.ratioNumerator }, (0, index_3.getAccessibleDataObject)(data.chartDataAccessibilityData, 'text', false)), getChartData())))),
|
|
286
318
|
React.createElement(react_focus_1.FocusZone, { direction: react_focus_1.FocusZoneDirection.horizontal },
|
|
287
319
|
React.createElement("div", { className: this._classNames.chartWrapper },
|
|
288
|
-
React.createElement("svg", { className: this._classNames.chart, "aria-label": data === null || data === void 0 ? void 0 : data.chartTitle }, bars)))));
|
|
320
|
+
React.createElement("svg", { ref: this.barChartSvgRef, className: this._classNames.chart, "aria-label": data === null || data === void 0 ? void 0 : data.chartTitle }, bars)))));
|
|
289
321
|
};
|
|
290
322
|
MultiStackedBarChartBase.prototype._onBarFocus = function (pointData, color, point) {
|
|
291
323
|
var _this = this;
|