@fluentui/react-charting 5.23.52 → 5.23.54
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 +39 -1
- package/CHANGELOG.md +20 -2
- package/dist/react-charting.d.ts +8 -3
- package/dist/react-charting.js +1 -1
- package/dist/react-charting.min.js +1 -1
- package/etc/react-charting.api.md +4 -3
- package/lib/components/CommonComponents/CartesianChart.base.js +7 -2
- package/lib/components/CommonComponents/CartesianChart.base.js.map +1 -1
- package/lib/components/CommonComponents/CartesianChart.types.d.ts +8 -3
- package/lib/components/CommonComponents/CartesianChart.types.js.map +1 -1
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +7 -0
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib/components/DonutChart/Arc/Arc.js +3 -1
- package/lib/components/DonutChart/Arc/Arc.js.map +1 -1
- package/lib/components/HeatMapChart/HeatMapChart.base.js +5 -1
- package/lib/components/HeatMapChart/HeatMapChart.base.js.map +1 -1
- package/lib/components/LineChart/LineChart.base.js +2 -1
- package/lib/components/LineChart/LineChart.base.js.map +1 -1
- package/lib/utilities/utilities.d.ts +4 -2
- package/lib/utilities/utilities.js +86 -36
- package/lib/utilities/utilities.js.map +1 -1
- package/lib-amd/components/CommonComponents/CartesianChart.base.js +7 -2
- package/lib-amd/components/CommonComponents/CartesianChart.base.js.map +1 -1
- package/lib-amd/components/CommonComponents/CartesianChart.types.d.ts +8 -3
- package/lib-amd/components/CommonComponents/CartesianChart.types.js.map +1 -1
- package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js +7 -0
- package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib-amd/components/DonutChart/Arc/Arc.js +3 -1
- package/lib-amd/components/DonutChart/Arc/Arc.js.map +1 -1
- package/lib-amd/components/HeatMapChart/HeatMapChart.base.js +5 -1
- package/lib-amd/components/HeatMapChart/HeatMapChart.base.js.map +1 -1
- package/lib-amd/components/LineChart/LineChart.base.js +2 -1
- package/lib-amd/components/LineChart/LineChart.base.js.map +1 -1
- package/lib-amd/utilities/utilities.d.ts +4 -2
- package/lib-amd/utilities/utilities.js +86 -36
- package/lib-amd/utilities/utilities.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/CartesianChart.base.js +7 -2
- package/lib-commonjs/components/CommonComponents/CartesianChart.base.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/CartesianChart.types.d.ts +8 -3
- package/lib-commonjs/components/CommonComponents/CartesianChart.types.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +7 -0
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib-commonjs/components/DonutChart/Arc/Arc.js +3 -1
- package/lib-commonjs/components/DonutChart/Arc/Arc.js.map +1 -1
- package/lib-commonjs/components/HeatMapChart/HeatMapChart.base.js +5 -1
- package/lib-commonjs/components/HeatMapChart/HeatMapChart.base.js.map +1 -1
- package/lib-commonjs/components/LineChart/LineChart.base.js +2 -1
- package/lib-commonjs/components/LineChart/LineChart.base.js.map +1 -1
- package/lib-commonjs/utilities/utilities.d.ts +4 -2
- package/lib-commonjs/utilities/utilities.js +86 -36
- package/lib-commonjs/utilities/utilities.js.map +1 -1
- package/package.json +1 -1
- package/project.json +1 -1
- package/src/components/CommonComponents/CartesianChart.types.ts +9 -3
|
@@ -30,27 +30,41 @@ define(["require", "exports", "tslib", "d3-axis", "d3-array", "d3-scale", "d3-se
|
|
|
30
30
|
* @export
|
|
31
31
|
* @param {IXAxisParams} xAxisParams
|
|
32
32
|
*/
|
|
33
|
-
function createNumericXAxis(xAxisParams, chartType, culture) {
|
|
34
|
-
var
|
|
33
|
+
function createNumericXAxis(xAxisParams, tickParams, chartType, culture) {
|
|
34
|
+
var _a;
|
|
35
|
+
var domainNRangeValues = xAxisParams.domainNRangeValues, _b = xAxisParams.showRoundOffXTickValues, showRoundOffXTickValues = _b === void 0 ? false : _b, _c = xAxisParams.xAxistickSize, xAxistickSize = _c === void 0 ? 6 : _c, _d = xAxisParams.tickPadding, tickPadding = _d === void 0 ? 10 : _d, xAxisCount = xAxisParams.xAxisCount, xAxisElement = xAxisParams.xAxisElement, hideTickOverlap = xAxisParams.hideTickOverlap;
|
|
35
36
|
var xAxisScale = (0, d3_scale_1.scaleLinear)()
|
|
36
37
|
.domain([domainNRangeValues.dStartValue, domainNRangeValues.dEndValue])
|
|
37
38
|
.range([domainNRangeValues.rStartValue, domainNRangeValues.rEndValue]);
|
|
38
39
|
showRoundOffXTickValues && xAxisScale.nice();
|
|
40
|
+
var tickCount = xAxisCount !== null && xAxisCount !== void 0 ? xAxisCount : 6;
|
|
41
|
+
var tickFormat = function (domainValue, _index) {
|
|
42
|
+
if (tickParams.tickFormat) {
|
|
43
|
+
return (0, d3_format_1.format)(tickParams.tickFormat)(domainValue);
|
|
44
|
+
}
|
|
45
|
+
var xAxisValue = typeof domainValue === 'number' ? domainValue : domainValue.valueOf();
|
|
46
|
+
return (0, exports.convertToLocaleString)(xAxisValue, culture);
|
|
47
|
+
};
|
|
48
|
+
if (hideTickOverlap && typeof xAxisCount === 'undefined') {
|
|
49
|
+
var longestLabelWidth = (0, exports.calculateLongestLabelWidth)(xAxisScale.ticks().map(tickFormat), '[class^="xAxis-"] text') + 20;
|
|
50
|
+
var _e = xAxisScale.range(), start = _e[0], end = _e[1];
|
|
51
|
+
tickCount = Math.max(1, Math.floor(Math.abs(end - start) / longestLabelWidth));
|
|
52
|
+
}
|
|
39
53
|
var xAxis = (0, d3_axis_1.axisBottom)(xAxisScale)
|
|
40
54
|
.tickSize(xAxistickSize)
|
|
41
55
|
.tickPadding(tickPadding)
|
|
42
|
-
.ticks(
|
|
43
|
-
.tickFormat(
|
|
44
|
-
var xAxisValue = typeof domainValue === 'number' ? domainValue : domainValue.valueOf();
|
|
45
|
-
return (0, exports.convertToLocaleString)(xAxisValue, culture);
|
|
46
|
-
});
|
|
56
|
+
.ticks(tickCount)
|
|
57
|
+
.tickFormat(tickFormat);
|
|
47
58
|
if (chartType === ChartTypes.HorizontalBarChartWithAxis) {
|
|
48
59
|
xAxis.tickSizeInner(-(xAxisParams.containerHeight - xAxisParams.margins.top));
|
|
49
60
|
}
|
|
61
|
+
if (tickParams.tickValues) {
|
|
62
|
+
xAxis.tickValues(tickParams.tickValues);
|
|
63
|
+
}
|
|
50
64
|
if (xAxisElement) {
|
|
51
65
|
(0, d3_selection_1.select)(xAxisElement).call(xAxis).selectAll('text').attr('aria-hidden', 'true');
|
|
52
66
|
}
|
|
53
|
-
var tickValues = xAxisScale.ticks(
|
|
67
|
+
var tickValues = ((_a = tickParams.tickValues) !== null && _a !== void 0 ? _a : xAxisScale.ticks(tickCount)).map(xAxis.tickFormat());
|
|
54
68
|
return { xScale: xAxisScale, tickValues: tickValues };
|
|
55
69
|
}
|
|
56
70
|
exports.createNumericXAxis = createNumericXAxis;
|
|
@@ -95,42 +109,48 @@ define(["require", "exports", "tslib", "d3-axis", "d3-array", "d3-scale", "d3-se
|
|
|
95
109
|
*/
|
|
96
110
|
function createDateXAxis(xAxisParams, tickParams, culture, options, timeFormatLocale, customDateTimeFormatter, useUTC) {
|
|
97
111
|
var _a;
|
|
98
|
-
var domainNRangeValues = xAxisParams.domainNRangeValues, xAxisElement = xAxisParams.xAxisElement, _b = xAxisParams.tickPadding, tickPadding = _b === void 0 ? 6 : _b, _c = xAxisParams.xAxistickSize, xAxistickSize = _c === void 0 ? 6 : _c,
|
|
112
|
+
var domainNRangeValues = xAxisParams.domainNRangeValues, xAxisElement = xAxisParams.xAxisElement, _b = xAxisParams.tickPadding, tickPadding = _b === void 0 ? 6 : _b, _c = xAxisParams.xAxistickSize, xAxistickSize = _c === void 0 ? 6 : _c, xAxisCount = xAxisParams.xAxisCount, hideTickOverlap = xAxisParams.hideTickOverlap;
|
|
99
113
|
var xAxisScale = useUTC ? (0, d3_scale_1.scaleUtc)() : (0, d3_scale_1.scaleTime)();
|
|
100
114
|
xAxisScale
|
|
101
115
|
.domain([domainNRangeValues.dStartValue, domainNRangeValues.dEndValue])
|
|
102
116
|
.range([domainNRangeValues.rStartValue, domainNRangeValues.rEndValue]);
|
|
103
|
-
var
|
|
104
|
-
|
|
105
|
-
|
|
117
|
+
var tickCount = xAxisCount !== null && xAxisCount !== void 0 ? xAxisCount : 6;
|
|
118
|
+
var tickFormat = function (domainValue, _index) {
|
|
119
|
+
if (customDateTimeFormatter) {
|
|
106
120
|
return customDateTimeFormatter(domainValue);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
else if (culture && options) {
|
|
110
|
-
xAxis.tickFormat(function (domainValue, _index) {
|
|
121
|
+
}
|
|
122
|
+
if (culture && options) {
|
|
111
123
|
return domainValue.toLocaleString(culture, options);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
124
|
+
}
|
|
125
|
+
if (timeFormatLocale) {
|
|
126
|
+
var locale = (0, d3_time_format_1.timeFormatLocale)(timeFormatLocale);
|
|
127
|
+
return multiFormat(domainValue, locale, useUTC);
|
|
128
|
+
}
|
|
129
|
+
if (culture === undefined && tickParams.tickFormat) {
|
|
130
|
+
if (useUTC) {
|
|
131
|
+
return (0, d3_time_format_1.utcFormat)(tickParams.tickFormat)(domainValue);
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
return (0, d3_time_format_1.timeFormat)(tickParams.tickFormat)(domainValue);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return multiFormat(domainValue, undefined, useUTC);
|
|
138
|
+
};
|
|
139
|
+
if (hideTickOverlap && typeof xAxisCount === 'undefined') {
|
|
140
|
+
var longestLabelWidth = (0, exports.calculateLongestLabelWidth)(xAxisScale.ticks().map(tickFormat), '[class^="xAxis-"] text') + 40;
|
|
141
|
+
var _d = xAxisScale.range(), start = _d[0], end = _d[1];
|
|
142
|
+
tickCount = Math.max(1, Math.floor(Math.abs(end - start) / longestLabelWidth));
|
|
119
143
|
}
|
|
144
|
+
var xAxis = (0, d3_axis_1.axisBottom)(xAxisScale)
|
|
145
|
+
.tickSize(xAxistickSize)
|
|
146
|
+
.tickPadding(tickPadding)
|
|
147
|
+
.ticks(tickCount)
|
|
148
|
+
.tickFormat(tickFormat);
|
|
120
149
|
tickParams.tickValues ? xAxis.tickValues(tickParams.tickValues) : '';
|
|
121
|
-
if (culture === undefined) {
|
|
122
|
-
tickParams.tickFormat
|
|
123
|
-
? xAxis.tickFormat(useUTC ? (0, d3_time_format_1.utcFormat)(tickParams.tickFormat) : (0, d3_time_format_1.timeFormat)(tickParams.tickFormat))
|
|
124
|
-
: '';
|
|
125
|
-
}
|
|
126
150
|
if (xAxisElement) {
|
|
127
151
|
(0, d3_selection_1.select)(xAxisElement).call(xAxis).selectAll('text').attr('aria-hidden', 'true');
|
|
128
152
|
}
|
|
129
|
-
var tickValues = ((_a = tickParams.tickValues) !== null && _a !== void 0 ? _a : xAxisScale.ticks(
|
|
130
|
-
var tickFormat = xAxis.tickFormat();
|
|
131
|
-
// val is a Date object. So when the tick format is not set, format val as a string to calculate its width
|
|
132
|
-
return tickFormat ? tickFormat(val, idx) : multiFormat(val, undefined, useUTC);
|
|
133
|
-
});
|
|
153
|
+
var tickValues = ((_a = tickParams.tickValues) !== null && _a !== void 0 ? _a : xAxisScale.ticks(tickCount)).map(xAxis.tickFormat());
|
|
134
154
|
return { xScale: xAxisScale, tickValues: tickValues };
|
|
135
155
|
}
|
|
136
156
|
exports.createDateXAxis = createDateXAxis;
|
|
@@ -144,17 +164,47 @@ define(["require", "exports", "tslib", "d3-axis", "d3-array", "d3-scale", "d3-se
|
|
|
144
164
|
* @returns
|
|
145
165
|
*/
|
|
146
166
|
function createStringXAxis(xAxisParams, tickParams, dataset, culture) {
|
|
147
|
-
var
|
|
167
|
+
var _a;
|
|
168
|
+
var domainNRangeValues = xAxisParams.domainNRangeValues, _b = xAxisParams.xAxistickSize, xAxistickSize = _b === void 0 ? 6 : _b, _c = xAxisParams.tickPadding, tickPadding = _c === void 0 ? 10 : _c, _d = xAxisParams.xAxisPadding, xAxisPadding = _d === void 0 ? 0.1 : _d, xAxisInnerPadding = xAxisParams.xAxisInnerPadding, xAxisOuterPadding = xAxisParams.xAxisOuterPadding, containerWidth = xAxisParams.containerWidth, hideTickOverlap = xAxisParams.hideTickOverlap;
|
|
148
169
|
var xAxisScale = (0, d3_scale_1.scaleBand)()
|
|
149
170
|
.domain(dataset)
|
|
150
171
|
.range([domainNRangeValues.rStartValue, domainNRangeValues.rEndValue])
|
|
151
172
|
.paddingInner(typeof xAxisInnerPadding !== 'undefined' ? xAxisInnerPadding : xAxisPadding)
|
|
152
173
|
.paddingOuter(typeof xAxisOuterPadding !== 'undefined' ? xAxisOuterPadding : xAxisPadding);
|
|
153
|
-
var
|
|
174
|
+
var tickValues = (_a = tickParams.tickValues) !== null && _a !== void 0 ? _a : dataset;
|
|
175
|
+
if (hideTickOverlap) {
|
|
176
|
+
var nonOverlappingTickValues = [];
|
|
177
|
+
// Here, we need the width of each individual label to detect overlaps,
|
|
178
|
+
// but calculateLongestLabelWidth returns the maximum pixel width from an array of labels.
|
|
179
|
+
// So call this function separately for each label, instead of the entire array.
|
|
180
|
+
var tickSizes = tickValues.map(function (value) { return (0, exports.calculateLongestLabelWidth)([value], '[class^="xAxis-"] text'); });
|
|
181
|
+
// for LTR
|
|
182
|
+
var start = 0;
|
|
183
|
+
var end = containerWidth;
|
|
184
|
+
var sign = 1;
|
|
185
|
+
var range = xAxisScale.range();
|
|
186
|
+
if (range[1] - range[0] < 0) {
|
|
187
|
+
// for RTL
|
|
188
|
+
start = containerWidth;
|
|
189
|
+
end = 0;
|
|
190
|
+
sign = -1;
|
|
191
|
+
}
|
|
192
|
+
for (var i = tickValues.length - 1; i >= 0; i--) {
|
|
193
|
+
var tickPosition = xAxisScale(tickValues[i]);
|
|
194
|
+
if (sign * (tickPosition - (sign * tickSizes[i]) / 2 - start) >= 0 &&
|
|
195
|
+
sign * (tickPosition + (sign * tickSizes[i]) / 2 - end) <= 0) {
|
|
196
|
+
nonOverlappingTickValues.push(tickValues[i]);
|
|
197
|
+
end = tickPosition - sign * (tickSizes[i] / 2 + 10);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
nonOverlappingTickValues = nonOverlappingTickValues.reverse();
|
|
201
|
+
tickValues = nonOverlappingTickValues;
|
|
202
|
+
}
|
|
203
|
+
var xAxis = (0, d3_axis_1.axisBottom)(xAxisScale).tickSize(xAxistickSize).tickPadding(tickPadding).tickValues(tickValues);
|
|
154
204
|
if (xAxisParams.xAxisElement) {
|
|
155
205
|
(0, d3_selection_1.select)(xAxisParams.xAxisElement).call(xAxis).selectAll('text').attr('aria-hidden', 'true');
|
|
156
206
|
}
|
|
157
|
-
return { xScale: xAxisScale, tickValues:
|
|
207
|
+
return { xScale: xAxisScale, tickValues: tickValues };
|
|
158
208
|
}
|
|
159
209
|
exports.createStringXAxis = createStringXAxis;
|
|
160
210
|
/**
|