@fluentui/react-charts 9.0.5 → 9.0.6
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.md +23 -7
- package/dist/index.d.ts +1 -1
- package/lib/components/CommonComponents/CartesianChart.js +3 -0
- package/lib/components/CommonComponents/CartesianChart.js.map +1 -1
- package/lib/components/CommonComponents/CartesianChart.types.js.map +1 -1
- package/lib/components/CommonComponents/ChartPopover.js +10 -10
- package/lib/components/CommonComponents/ChartPopover.js.map +1 -1
- package/lib/components/DeclarativeChart/DeclarativeChart.js +7 -2
- package/lib/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +7 -4
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib/components/DonutChart/Arc/Arc.js +2 -2
- package/lib/components/DonutChart/Arc/Arc.js.map +1 -1
- package/lib/components/DonutChart/DonutChart.js +2 -2
- package/lib/components/DonutChart/DonutChart.js.map +1 -1
- package/lib/components/GaugeChart/GaugeChart.js +9 -9
- package/lib/components/GaugeChart/GaugeChart.js.map +1 -1
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +2 -2
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
- package/lib/components/HeatMapChart/HeatMapChart.js +3 -2
- package/lib/components/HeatMapChart/HeatMapChart.js.map +1 -1
- package/lib/components/HorizontalBarChart/HorizontalBarChart.js +8 -8
- package/lib/components/HorizontalBarChart/HorizontalBarChart.js.map +1 -1
- package/lib/components/VerticalBarChart/VerticalBarChart.js +2 -2
- package/lib/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js +2 -2
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -1
- package/lib/utilities/utilities.js +232 -53
- package/lib/utilities/utilities.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/CartesianChart.js +3 -0
- package/lib-commonjs/components/CommonComponents/CartesianChart.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/CartesianChart.types.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/ChartPopover.js +10 -10
- package/lib-commonjs/components/CommonComponents/ChartPopover.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js +6 -1
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +6 -3
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib-commonjs/components/DonutChart/Arc/Arc.js +1 -1
- package/lib-commonjs/components/DonutChart/Arc/Arc.js.map +1 -1
- package/lib-commonjs/components/DonutChart/DonutChart.js +2 -2
- package/lib-commonjs/components/DonutChart/DonutChart.js.map +1 -1
- package/lib-commonjs/components/GaugeChart/GaugeChart.js +8 -8
- package/lib-commonjs/components/GaugeChart/GaugeChart.js.map +1 -1
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +1 -1
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
- package/lib-commonjs/components/HeatMapChart/HeatMapChart.js +2 -1
- package/lib-commonjs/components/HeatMapChart/HeatMapChart.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChart/HorizontalBarChart.js +7 -7
- package/lib-commonjs/components/HorizontalBarChart/HorizontalBarChart.js.map +1 -1
- package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js +1 -1
- package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js +1 -1
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -1
- package/lib-commonjs/utilities/utilities.js +236 -61
- package/lib-commonjs/utilities/utilities.js.map +1 -1
- package/package.json +9 -9
- package/lib/utilities/locale-util.js +0 -15
- package/lib/utilities/locale-util.js.map +0 -1
- package/lib-commonjs/utilities/locale-util.js +0 -25
- package/lib-commonjs/utilities/locale-util.js.map +0 -1
|
@@ -42,15 +42,15 @@ _export(exports, {
|
|
|
42
42
|
calloutData: function() {
|
|
43
43
|
return calloutData;
|
|
44
44
|
},
|
|
45
|
-
convertToLocaleString: function() {
|
|
46
|
-
return convertToLocaleString;
|
|
47
|
-
},
|
|
48
45
|
createDateXAxis: function() {
|
|
49
46
|
return createDateXAxis;
|
|
50
47
|
},
|
|
51
48
|
createNumericXAxis: function() {
|
|
52
49
|
return createNumericXAxis;
|
|
53
50
|
},
|
|
51
|
+
createNumericYAxisForOtherCharts: function() {
|
|
52
|
+
return createNumericYAxisForOtherCharts;
|
|
53
|
+
},
|
|
54
54
|
createStringXAxis: function() {
|
|
55
55
|
return createStringXAxis;
|
|
56
56
|
},
|
|
@@ -72,12 +72,12 @@ _export(exports, {
|
|
|
72
72
|
createYAxisForHorizontalBarChartWithAxis: function() {
|
|
73
73
|
return createYAxisForHorizontalBarChartWithAxis;
|
|
74
74
|
},
|
|
75
|
-
createYAxisForOtherCharts: function() {
|
|
76
|
-
return createYAxisForOtherCharts;
|
|
77
|
-
},
|
|
78
75
|
createYAxisLabels: function() {
|
|
79
76
|
return createYAxisLabels;
|
|
80
77
|
},
|
|
78
|
+
defaultYAxisTickFormatter: function() {
|
|
79
|
+
return defaultYAxisTickFormatter;
|
|
80
|
+
},
|
|
81
81
|
domainRageOfVerticalNumeric: function() {
|
|
82
82
|
return domainRageOfVerticalNumeric;
|
|
83
83
|
},
|
|
@@ -123,8 +123,8 @@ _export(exports, {
|
|
|
123
123
|
formatDate: function() {
|
|
124
124
|
return formatDate;
|
|
125
125
|
},
|
|
126
|
-
|
|
127
|
-
return
|
|
126
|
+
formatScientificLimitWidth: function() {
|
|
127
|
+
return formatScientificLimitWidth;
|
|
128
128
|
},
|
|
129
129
|
getAccessibleDataObject: function() {
|
|
130
130
|
return getAccessibleDataObject;
|
|
@@ -196,6 +196,7 @@ const _d3timeformat = require("d3-time-format");
|
|
|
196
196
|
const _d3time = require("d3-time");
|
|
197
197
|
const _d3shape = require("d3-shape");
|
|
198
198
|
const _reactsharedcontexts = require("@fluentui/react-shared-contexts");
|
|
199
|
+
const _chartutilities = require("@fluentui/chart-utilities");
|
|
199
200
|
var ChartTypes;
|
|
200
201
|
(function(ChartTypes) {
|
|
201
202
|
ChartTypes[ChartTypes["AreaChart"] = 0] = "AreaChart";
|
|
@@ -219,6 +220,26 @@ var YAxisType;
|
|
|
219
220
|
YAxisType[YAxisType["DateAxis"] = 1] = "DateAxis";
|
|
220
221
|
YAxisType[YAxisType["StringAxis"] = 2] = "StringAxis";
|
|
221
222
|
})(YAxisType || (YAxisType = {}));
|
|
223
|
+
function yAxisTickFormatterInternal(value, limitWidth = false) {
|
|
224
|
+
// Use SI format prefix with 2 decimal places without insignificant trailing zeros
|
|
225
|
+
let formatter = (0, _d3format.formatPrefix)('.2~', value);
|
|
226
|
+
if (Math.abs(value) < 1) {
|
|
227
|
+
// Don't use SI notation for small numbers as it is less readable
|
|
228
|
+
formatter = (0, _d3format.format)('.2~g');
|
|
229
|
+
} else if (limitWidth && Math.abs(value) >= 1000) {
|
|
230
|
+
// If width is limited, use SI format prefix with 1 point precision
|
|
231
|
+
formatter = (0, _d3format.formatPrefix)('.1~', value);
|
|
232
|
+
}
|
|
233
|
+
const formattedValue = formatter(value);
|
|
234
|
+
// Replace 'G' with 'B' if the value is greater than 10^9 as it is a more common convention
|
|
235
|
+
if (Math.abs(value) >= 1e9) {
|
|
236
|
+
return formattedValue.replace('G', 'B');
|
|
237
|
+
}
|
|
238
|
+
return formattedValue;
|
|
239
|
+
}
|
|
240
|
+
function defaultYAxisTickFormatter(value) {
|
|
241
|
+
return yAxisTickFormatterInternal(value);
|
|
242
|
+
}
|
|
222
243
|
function createNumericXAxis(xAxisParams, tickParams, chartType, culture) {
|
|
223
244
|
const { domainNRangeValues, showRoundOffXTickValues = false, xAxistickSize = 6, tickPadding = 10, xAxisCount, xAxisElement, hideTickOverlap } = xAxisParams;
|
|
224
245
|
const xAxisScale = (0, _d3scale.scaleLinear)().domain([
|
|
@@ -235,7 +256,7 @@ function createNumericXAxis(xAxisParams, tickParams, chartType, culture) {
|
|
|
235
256
|
return (0, _d3format.format)(tickParams.tickFormat)(domainValue);
|
|
236
257
|
}
|
|
237
258
|
const xAxisValue = typeof domainValue === 'number' ? domainValue : domainValue.valueOf();
|
|
238
|
-
return
|
|
259
|
+
return (0, _chartutilities.formatToLocaleString)(xAxisValue, culture);
|
|
239
260
|
};
|
|
240
261
|
if (hideTickOverlap && typeof xAxisCount === 'undefined') {
|
|
241
262
|
const longestLabelWidth = calculateLongestLabelWidth(xAxisScale.ticks().map(tickFormat), '.fui-cart__xAxis text') + 20;
|
|
@@ -259,16 +280,145 @@ function createNumericXAxis(xAxisParams, tickParams, chartType, culture) {
|
|
|
259
280
|
tickValues
|
|
260
281
|
};
|
|
261
282
|
}
|
|
262
|
-
|
|
283
|
+
/**
|
|
284
|
+
* This function returns a multilevel formatter for a given date range.
|
|
285
|
+
* It determines the appropriate date format to accommodate each tick value.
|
|
286
|
+
* The goal is to represent the date label in the smallest possible format without loss of information.
|
|
287
|
+
* The challenge here is to adhere to locale specific formats while ensuring the complete label is shown.
|
|
288
|
+
* There is an exhaustive map of all possible date/time units and their respective formats.
|
|
289
|
+
* Based on the range of formatting granularity levels, a format spanning the range is returned.
|
|
290
|
+
* @param startLevel - The starting level of the date format.
|
|
291
|
+
* @param endLevel - The ending level of the date format.
|
|
292
|
+
* @param locale - The locale object for formatting.
|
|
293
|
+
* @param useUTC
|
|
294
|
+
* @returns
|
|
295
|
+
*/ function getMultiLevelD3DateFormatter(startLevel, endLevel, locale, useUTC) {
|
|
263
296
|
const timeFormat = locale ? useUTC ? locale.utcFormat : locale.format : useUTC ? _d3timeformat.utcFormat : _d3timeformat.timeFormat;
|
|
264
|
-
|
|
265
|
-
const
|
|
266
|
-
const
|
|
267
|
-
const
|
|
268
|
-
const
|
|
269
|
-
const
|
|
270
|
-
const
|
|
271
|
-
const
|
|
297
|
+
// Refer to https://d3js.org/d3-time-format#locale_format to see explanation about each format specifier
|
|
298
|
+
const DEFAULT = '%c';
|
|
299
|
+
const MS = '.%L';
|
|
300
|
+
const MS_S = ':%S.%L';
|
|
301
|
+
const MS_S_MIN = '%M:%S.%L';
|
|
302
|
+
const MS_S_MIN_H = '%-I:%M:%S.%L %p';
|
|
303
|
+
const MS_S_MIN_H_D = '%a %d, %X';
|
|
304
|
+
const MS_S_MIN_H_D_W = '%b %d, %X';
|
|
305
|
+
const MS_S_MIN_H_D_W_M = MS_S_MIN_H_D_W;
|
|
306
|
+
const MS_S_MIN_H_D_W_M_Y = DEFAULT;
|
|
307
|
+
const S = ':%S';
|
|
308
|
+
const S_MIN = '%-I:%M:%S';
|
|
309
|
+
const S_MIN_H = '%X';
|
|
310
|
+
const S_MIN_H_D = MS_S_MIN_H_D;
|
|
311
|
+
const S_MIN_H_D_W = MS_S_MIN_H_D_W;
|
|
312
|
+
const S_MIN_H_D_W_M = MS_S_MIN_H_D_W_M;
|
|
313
|
+
const S_MIN_H_D_W_M_Y = DEFAULT;
|
|
314
|
+
const MIN = '%-I:%M %p';
|
|
315
|
+
const MIN_H = MIN;
|
|
316
|
+
const MIN_H_D = '%a %d, %-I:%M %p';
|
|
317
|
+
const MIN_H_D_W = '%b %d, %-I:%M %p';
|
|
318
|
+
const MIN_H_D_W_M = MIN_H_D_W;
|
|
319
|
+
const MIN_H_D_W_M_Y = '%x, %-I:%M %p';
|
|
320
|
+
const H = '%-I %p';
|
|
321
|
+
const H_D = '%a %d, %-I %p';
|
|
322
|
+
const H_D_W = '%b %d, %-I %p';
|
|
323
|
+
const H_D_W_M = H_D_W;
|
|
324
|
+
const H_D_W_M_Y = '%x, %-I %p';
|
|
325
|
+
const D = '%a %d';
|
|
326
|
+
const D_W = '%b %d';
|
|
327
|
+
const D_W_M = D_W;
|
|
328
|
+
const D_W_M_Y = '%x';
|
|
329
|
+
const W = D_W;
|
|
330
|
+
const W_M = W;
|
|
331
|
+
const W_M_Y = D_W_M_Y;
|
|
332
|
+
const M = '%B';
|
|
333
|
+
const M_Y = '%b %Y';
|
|
334
|
+
const Y = '%Y';
|
|
335
|
+
const MULTI_LEVEL_DATE_TIME_FORMATS = [
|
|
336
|
+
// ms, s, min, h, d, w, m, y
|
|
337
|
+
[
|
|
338
|
+
MS,
|
|
339
|
+
MS_S,
|
|
340
|
+
MS_S_MIN,
|
|
341
|
+
MS_S_MIN_H,
|
|
342
|
+
MS_S_MIN_H_D,
|
|
343
|
+
MS_S_MIN_H_D_W,
|
|
344
|
+
MS_S_MIN_H_D_W_M,
|
|
345
|
+
MS_S_MIN_H_D_W_M_Y
|
|
346
|
+
],
|
|
347
|
+
[
|
|
348
|
+
DEFAULT,
|
|
349
|
+
S,
|
|
350
|
+
S_MIN,
|
|
351
|
+
S_MIN_H,
|
|
352
|
+
S_MIN_H_D,
|
|
353
|
+
S_MIN_H_D_W,
|
|
354
|
+
S_MIN_H_D_W_M,
|
|
355
|
+
S_MIN_H_D_W_M_Y
|
|
356
|
+
],
|
|
357
|
+
[
|
|
358
|
+
DEFAULT,
|
|
359
|
+
DEFAULT,
|
|
360
|
+
MIN,
|
|
361
|
+
MIN_H,
|
|
362
|
+
MIN_H_D,
|
|
363
|
+
MIN_H_D_W,
|
|
364
|
+
MIN_H_D_W_M,
|
|
365
|
+
MIN_H_D_W_M_Y
|
|
366
|
+
],
|
|
367
|
+
[
|
|
368
|
+
DEFAULT,
|
|
369
|
+
DEFAULT,
|
|
370
|
+
DEFAULT,
|
|
371
|
+
H,
|
|
372
|
+
H_D,
|
|
373
|
+
H_D_W,
|
|
374
|
+
H_D_W_M,
|
|
375
|
+
H_D_W_M_Y
|
|
376
|
+
],
|
|
377
|
+
[
|
|
378
|
+
DEFAULT,
|
|
379
|
+
DEFAULT,
|
|
380
|
+
DEFAULT,
|
|
381
|
+
DEFAULT,
|
|
382
|
+
D,
|
|
383
|
+
D_W,
|
|
384
|
+
D_W_M,
|
|
385
|
+
D_W_M_Y
|
|
386
|
+
],
|
|
387
|
+
[
|
|
388
|
+
DEFAULT,
|
|
389
|
+
DEFAULT,
|
|
390
|
+
DEFAULT,
|
|
391
|
+
DEFAULT,
|
|
392
|
+
DEFAULT,
|
|
393
|
+
W,
|
|
394
|
+
W_M,
|
|
395
|
+
W_M_Y
|
|
396
|
+
],
|
|
397
|
+
[
|
|
398
|
+
DEFAULT,
|
|
399
|
+
DEFAULT,
|
|
400
|
+
DEFAULT,
|
|
401
|
+
DEFAULT,
|
|
402
|
+
DEFAULT,
|
|
403
|
+
DEFAULT,
|
|
404
|
+
M,
|
|
405
|
+
M_Y
|
|
406
|
+
],
|
|
407
|
+
[
|
|
408
|
+
DEFAULT,
|
|
409
|
+
DEFAULT,
|
|
410
|
+
DEFAULT,
|
|
411
|
+
DEFAULT,
|
|
412
|
+
DEFAULT,
|
|
413
|
+
DEFAULT,
|
|
414
|
+
DEFAULT,
|
|
415
|
+
Y
|
|
416
|
+
]
|
|
417
|
+
];
|
|
418
|
+
const formatter = timeFormat(MULTI_LEVEL_DATE_TIME_FORMATS[startLevel][endLevel]);
|
|
419
|
+
return formatter;
|
|
420
|
+
}
|
|
421
|
+
function getDateFormatLevel(date, useUTC) {
|
|
272
422
|
const timeSecond = useUTC ? _d3time.utcSecond : _d3time.timeSecond;
|
|
273
423
|
const timeMinute = useUTC ? _d3time.utcMinute : _d3time.timeMinute;
|
|
274
424
|
const timeHour = useUTC ? _d3time.utcHour : _d3time.timeHour;
|
|
@@ -276,29 +426,76 @@ function multiFormat(date, locale, useUTC) {
|
|
|
276
426
|
const timeMonth = useUTC ? _d3time.utcMonth : _d3time.timeMonth;
|
|
277
427
|
const timeWeek = useUTC ? _d3time.utcWeek : _d3time.timeWeek;
|
|
278
428
|
const timeYear = useUTC ? _d3time.utcYear : _d3time.timeYear;
|
|
279
|
-
|
|
429
|
+
const formats = [
|
|
430
|
+
{
|
|
431
|
+
formatLevel: 0,
|
|
432
|
+
condition: (d)=>timeSecond(d) < d
|
|
433
|
+
},
|
|
434
|
+
{
|
|
435
|
+
formatLevel: 1,
|
|
436
|
+
condition: (d)=>timeMinute(d) < d
|
|
437
|
+
},
|
|
438
|
+
{
|
|
439
|
+
formatLevel: 2,
|
|
440
|
+
condition: (d)=>timeHour(d) < d
|
|
441
|
+
},
|
|
442
|
+
{
|
|
443
|
+
formatLevel: 3,
|
|
444
|
+
condition: (d)=>timeDay(d) < d
|
|
445
|
+
},
|
|
446
|
+
{
|
|
447
|
+
formatLevel: 4,
|
|
448
|
+
condition: (d)=>timeMonth(d) < d && timeWeek(d) < d
|
|
449
|
+
},
|
|
450
|
+
{
|
|
451
|
+
formatLevel: 5,
|
|
452
|
+
condition: (d)=>timeMonth(d) < d
|
|
453
|
+
},
|
|
454
|
+
{
|
|
455
|
+
formatLevel: 6,
|
|
456
|
+
condition: (d)=>timeYear(d) < d
|
|
457
|
+
},
|
|
458
|
+
{
|
|
459
|
+
formatLevel: 7,
|
|
460
|
+
condition: ()=>true
|
|
461
|
+
}
|
|
462
|
+
];
|
|
463
|
+
const matchedFormat = formats.find(({ condition })=>condition(date));
|
|
464
|
+
var _matchedFormat_formatLevel;
|
|
465
|
+
return (_matchedFormat_formatLevel = matchedFormat === null || matchedFormat === void 0 ? void 0 : matchedFormat.formatLevel) !== null && _matchedFormat_formatLevel !== void 0 ? _matchedFormat_formatLevel : 7;
|
|
280
466
|
}
|
|
281
467
|
function createDateXAxis(xAxisParams, tickParams, culture, options, timeFormatLocale, customDateTimeFormatter, useUTC) {
|
|
282
|
-
const { domainNRangeValues, xAxisElement, tickPadding = 6, xAxistickSize = 6, xAxisCount
|
|
283
|
-
const
|
|
468
|
+
const { domainNRangeValues, xAxisElement, tickPadding = 6, xAxistickSize = 6, xAxisCount } = xAxisParams;
|
|
469
|
+
const isUtcSet = useUTC === true || useUTC === 'utc';
|
|
470
|
+
const xAxisScale = isUtcSet ? (0, _d3scale.scaleUtc)() : (0, _d3scale.scaleTime)();
|
|
284
471
|
xAxisScale.domain([
|
|
285
472
|
domainNRangeValues.dStartValue,
|
|
286
473
|
domainNRangeValues.dEndValue
|
|
287
474
|
]).range([
|
|
288
475
|
domainNRangeValues.rStartValue,
|
|
289
476
|
domainNRangeValues.rEndValue
|
|
290
|
-
]);
|
|
477
|
+
]).nice();
|
|
291
478
|
let tickCount = xAxisCount !== null && xAxisCount !== void 0 ? xAxisCount : 6;
|
|
479
|
+
let lowestFormatLevel = 100;
|
|
480
|
+
let highestFormatLevel = -1;
|
|
481
|
+
const locale = timeFormatLocale ? (0, _d3timeformat.timeFormatLocale)(timeFormatLocale) : undefined;
|
|
482
|
+
xAxisScale.ticks().forEach((domainValue)=>{
|
|
483
|
+
const formatLevel = getDateFormatLevel(domainValue, isUtcSet);
|
|
484
|
+
if (formatLevel > highestFormatLevel) {
|
|
485
|
+
highestFormatLevel = formatLevel;
|
|
486
|
+
}
|
|
487
|
+
if (formatLevel < lowestFormatLevel) {
|
|
488
|
+
lowestFormatLevel = formatLevel;
|
|
489
|
+
}
|
|
490
|
+
});
|
|
491
|
+
const formatOptions = options !== null && options !== void 0 ? options : (0, _chartutilities.getMultiLevelDateTimeFormatOptions)(lowestFormatLevel, highestFormatLevel);
|
|
492
|
+
const formatFn = getMultiLevelD3DateFormatter(lowestFormatLevel, highestFormatLevel, locale, isUtcSet);
|
|
292
493
|
const tickFormat = (domainValue, _index)=>{
|
|
293
494
|
if (customDateTimeFormatter) {
|
|
294
495
|
return customDateTimeFormatter(domainValue);
|
|
295
496
|
}
|
|
296
|
-
if (culture && options) {
|
|
297
|
-
return domainValue.toLocaleString(culture, options);
|
|
298
|
-
}
|
|
299
497
|
if (timeFormatLocale) {
|
|
300
|
-
|
|
301
|
-
return multiFormat(domainValue, locale, useUTC);
|
|
498
|
+
return formatFn(domainValue);
|
|
302
499
|
}
|
|
303
500
|
if (culture === undefined && tickParams.tickFormat) {
|
|
304
501
|
if (useUTC) {
|
|
@@ -307,13 +504,12 @@ function createDateXAxis(xAxisParams, tickParams, culture, options, timeFormatLo
|
|
|
307
504
|
return (0, _d3timeformat.timeFormat)(tickParams.tickFormat)(domainValue);
|
|
308
505
|
}
|
|
309
506
|
}
|
|
310
|
-
return
|
|
507
|
+
return (0, _chartutilities.formatDateToLocaleString)(domainValue, culture, useUTC ? true : false, false, formatOptions);
|
|
311
508
|
};
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
}
|
|
509
|
+
const longestLabelWidth = calculateLongestLabelWidth(xAxisScale.ticks().map(tickFormat), '.fui-cart__xAxis text') + 40;
|
|
510
|
+
const [start, end] = xAxisScale.range();
|
|
511
|
+
const maxPossibleTickCount = Math.max(1, Math.floor(Math.abs(end - start) / longestLabelWidth));
|
|
512
|
+
tickCount = Math.min(maxPossibleTickCount, xAxisCount !== null && xAxisCount !== void 0 ? xAxisCount : tickCount);
|
|
317
513
|
const xAxis = (0, _d3axis.axisBottom)(xAxisScale).tickSize(xAxistickSize).tickPadding(tickPadding).ticks(tickCount).tickFormat(tickFormat);
|
|
318
514
|
tickParams.tickValues ? xAxis.tickValues(tickParams.tickValues) : '';
|
|
319
515
|
if (xAxisElement) {
|
|
@@ -335,7 +531,7 @@ function createStringXAxis(xAxisParams, tickParams, dataset, culture) {
|
|
|
335
531
|
var _tickParams_tickValues;
|
|
336
532
|
let tickValues = (_tickParams_tickValues = tickParams.tickValues) !== null && _tickParams_tickValues !== void 0 ? _tickParams_tickValues : dataset;
|
|
337
533
|
const tickFormat = (domainValue, _index)=>{
|
|
338
|
-
return
|
|
534
|
+
return (0, _chartutilities.formatToLocaleString)(domainValue, culture);
|
|
339
535
|
};
|
|
340
536
|
if (hideTickOverlap) {
|
|
341
537
|
let nonOverlappingTickValues = [];
|
|
@@ -437,7 +633,7 @@ function createYAxis(yAxisParams, isRtl, axisData, chartType, barWidth, isIntegr
|
|
|
437
633
|
case 6:
|
|
438
634
|
return createYAxisForHorizontalBarChartWithAxis(yAxisParams, isRtl, axisData, barWidth);
|
|
439
635
|
default:
|
|
440
|
-
return
|
|
636
|
+
return createNumericYAxisForOtherCharts(yAxisParams, isRtl, axisData, isIntegralDataset, chartType, useSecondaryYScale, roundedTicks);
|
|
441
637
|
}
|
|
442
638
|
}
|
|
443
639
|
function createYAxisForHorizontalBarChartWithAxis(yAxisParams, isRtl, axisData, barWidth) {
|
|
@@ -458,11 +654,11 @@ function createYAxisForHorizontalBarChartWithAxis(yAxisParams, isRtl, axisData,
|
|
|
458
654
|
]);
|
|
459
655
|
const axis = isRtl ? (0, _d3axis.axisRight)(yAxisScale) : (0, _d3axis.axisLeft)(yAxisScale);
|
|
460
656
|
const yAxis = axis.tickPadding(tickPadding).ticks(yAxisTickCount);
|
|
461
|
-
yAxisTickFormat ? yAxis.tickFormat(yAxisTickFormat) : yAxis.tickFormat(
|
|
657
|
+
yAxisTickFormat ? yAxis.tickFormat(yAxisTickFormat) : yAxis.tickFormat(defaultYAxisTickFormatter);
|
|
462
658
|
yAxisElement ? (0, _d3selection.select)(yAxisElement).call(yAxis).selectAll('text').attr('aria-hidden', 'true') : '';
|
|
463
659
|
return yAxisScale;
|
|
464
660
|
}
|
|
465
|
-
function
|
|
661
|
+
function createNumericYAxisForOtherCharts(yAxisParams, isRtl, axisData, isIntegralDataset, chartType, useSecondaryYScale = false, roundedTicks = false) {
|
|
466
662
|
const { yMinMaxValues = {
|
|
467
663
|
startValue: 0,
|
|
468
664
|
endValue: 0
|
|
@@ -488,7 +684,7 @@ function createYAxisForOtherCharts(yAxisParams, isRtl, axisData, isIntegralDatas
|
|
|
488
684
|
]);
|
|
489
685
|
const axis = !isRtl && useSecondaryYScale || isRtl && !useSecondaryYScale ? (0, _d3axis.axisRight)(yAxisScale) : (0, _d3axis.axisLeft)(yAxisScale);
|
|
490
686
|
const yAxis = axis.tickPadding(tickPadding).tickValues(domainValues).tickSizeInner(-(containerWidth - margins.left - margins.right));
|
|
491
|
-
yAxisTickFormat ? yAxis.tickFormat(yAxisTickFormat) : yAxis.tickFormat(
|
|
687
|
+
yAxisTickFormat ? yAxis.tickFormat(yAxisTickFormat) : yAxis.tickFormat(defaultYAxisTickFormatter);
|
|
492
688
|
yAxisElement ? (0, _d3selection.select)(yAxisElement).call(yAxis).selectAll('text').attr('aria-hidden', 'true') : '';
|
|
493
689
|
axisData.yAxisDomainValues = domainValues;
|
|
494
690
|
return yAxisScale;
|
|
@@ -1195,21 +1391,6 @@ const getAccessibleDataObject = (accessibleData, role = 'text', isDataFocusable
|
|
|
1195
1391
|
'aria-describedby': accessibleData.ariaDescribedBy
|
|
1196
1392
|
};
|
|
1197
1393
|
};
|
|
1198
|
-
const convertToLocaleString = (data, culture)=>{
|
|
1199
|
-
if (data === undefined || data === null || Number.isNaN(data)) {
|
|
1200
|
-
return data;
|
|
1201
|
-
}
|
|
1202
|
-
culture = culture || undefined;
|
|
1203
|
-
if (typeof data === 'number') {
|
|
1204
|
-
return data.toLocaleString(culture);
|
|
1205
|
-
} else if (typeof data === 'string' && !isNaN(Number(data))) {
|
|
1206
|
-
const num = Number(data);
|
|
1207
|
-
return num.toLocaleString(culture);
|
|
1208
|
-
} else if (data instanceof Date) {
|
|
1209
|
-
return data.toLocaleDateString(culture);
|
|
1210
|
-
}
|
|
1211
|
-
return data;
|
|
1212
|
-
};
|
|
1213
1394
|
function rotateXAxisLabels(rotateLabelProps) {
|
|
1214
1395
|
const { node, xAxis } = rotateLabelProps;
|
|
1215
1396
|
if (node === null || xAxis === null) {
|
|
@@ -1267,14 +1448,8 @@ function wrapTextInsideDonut(selectorClass, maxWidth) {
|
|
|
1267
1448
|
idx += 1;
|
|
1268
1449
|
});
|
|
1269
1450
|
}
|
|
1270
|
-
function
|
|
1271
|
-
|
|
1272
|
-
if (value < 1000) {
|
|
1273
|
-
specifier = '.2~'; // upto 2 decimal places without insignificant trailing zeros
|
|
1274
|
-
} else {
|
|
1275
|
-
specifier = '.1'; // upto 1 decimal place
|
|
1276
|
-
}
|
|
1277
|
-
return (0, _d3format.formatPrefix)(specifier, value)(value);
|
|
1451
|
+
function formatScientificLimitWidth(value) {
|
|
1452
|
+
return yAxisTickFormatterInternal(value, true);
|
|
1278
1453
|
}
|
|
1279
1454
|
const DEFAULT_BAR_WIDTH = 16;
|
|
1280
1455
|
const MIN_BAR_WIDTH = 1;
|