@fluentui/react-charts 0.0.0-nightly-20250603-0406.1 → 0.0.0-nightly-20250604-0406.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.md +15 -15
- 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 +12 -12
- 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
|
@@ -8,6 +8,7 @@ import { timeSecond as d3TimeSecond, timeMinute as d3TimeMinute, timeHour as d3T
|
|
|
8
8
|
import { curveLinear as d3CurveLinear, curveNatural as d3CurveNatural, curveStep as d3CurveStep, curveStepAfter as d3CurveStepAfter, curveStepBefore as d3CurveStepBefore } from 'd3-shape';
|
|
9
9
|
import { formatPrefix as d3FormatPrefix } from 'd3-format';
|
|
10
10
|
import { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';
|
|
11
|
+
import { formatDateToLocaleString, formatToLocaleString, getMultiLevelDateTimeFormatOptions } from '@fluentui/chart-utilities';
|
|
11
12
|
export var ChartTypes;
|
|
12
13
|
(function(ChartTypes) {
|
|
13
14
|
ChartTypes[ChartTypes["AreaChart"] = 0] = "AreaChart";
|
|
@@ -31,6 +32,30 @@ export var YAxisType;
|
|
|
31
32
|
YAxisType[YAxisType["DateAxis"] = 1] = "DateAxis";
|
|
32
33
|
YAxisType[YAxisType["StringAxis"] = 2] = "StringAxis";
|
|
33
34
|
})(YAxisType || (YAxisType = {}));
|
|
35
|
+
function yAxisTickFormatterInternal(value, limitWidth = false) {
|
|
36
|
+
// Use SI format prefix with 2 decimal places without insignificant trailing zeros
|
|
37
|
+
let formatter = d3FormatPrefix('.2~', value);
|
|
38
|
+
if (Math.abs(value) < 1) {
|
|
39
|
+
// Don't use SI notation for small numbers as it is less readable
|
|
40
|
+
formatter = d3Format('.2~g');
|
|
41
|
+
} else if (limitWidth && Math.abs(value) >= 1000) {
|
|
42
|
+
// If width is limited, use SI format prefix with 1 point precision
|
|
43
|
+
formatter = d3FormatPrefix('.1~', value);
|
|
44
|
+
}
|
|
45
|
+
const formattedValue = formatter(value);
|
|
46
|
+
// Replace 'G' with 'B' if the value is greater than 10^9 as it is a more common convention
|
|
47
|
+
if (Math.abs(value) >= 1e9) {
|
|
48
|
+
return formattedValue.replace('G', 'B');
|
|
49
|
+
}
|
|
50
|
+
return formattedValue;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Formatter for y axis ticks.
|
|
54
|
+
* @param value - The number to format.
|
|
55
|
+
* @returns The formatted string .
|
|
56
|
+
*/ export function defaultYAxisTickFormatter(value) {
|
|
57
|
+
return yAxisTickFormatterInternal(value);
|
|
58
|
+
}
|
|
34
59
|
/**
|
|
35
60
|
* Create Numeric X axis
|
|
36
61
|
* @export
|
|
@@ -51,7 +76,7 @@ export var YAxisType;
|
|
|
51
76
|
return d3Format(tickParams.tickFormat)(domainValue);
|
|
52
77
|
}
|
|
53
78
|
const xAxisValue = typeof domainValue === 'number' ? domainValue : domainValue.valueOf();
|
|
54
|
-
return
|
|
79
|
+
return formatToLocaleString(xAxisValue, culture);
|
|
55
80
|
};
|
|
56
81
|
if (hideTickOverlap && typeof xAxisCount === 'undefined') {
|
|
57
82
|
const longestLabelWidth = calculateLongestLabelWidth(xAxisScale.ticks().map(tickFormat), '.fui-cart__xAxis text') + 20;
|
|
@@ -75,16 +100,145 @@ export var YAxisType;
|
|
|
75
100
|
tickValues
|
|
76
101
|
};
|
|
77
102
|
}
|
|
78
|
-
|
|
103
|
+
/**
|
|
104
|
+
* This function returns a multilevel formatter for a given date range.
|
|
105
|
+
* It determines the appropriate date format to accommodate each tick value.
|
|
106
|
+
* The goal is to represent the date label in the smallest possible format without loss of information.
|
|
107
|
+
* The challenge here is to adhere to locale specific formats while ensuring the complete label is shown.
|
|
108
|
+
* There is an exhaustive map of all possible date/time units and their respective formats.
|
|
109
|
+
* Based on the range of formatting granularity levels, a format spanning the range is returned.
|
|
110
|
+
* @param startLevel - The starting level of the date format.
|
|
111
|
+
* @param endLevel - The ending level of the date format.
|
|
112
|
+
* @param locale - The locale object for formatting.
|
|
113
|
+
* @param useUTC
|
|
114
|
+
* @returns
|
|
115
|
+
*/ function getMultiLevelD3DateFormatter(startLevel, endLevel, locale, useUTC) {
|
|
79
116
|
const timeFormat = locale ? useUTC ? locale.utcFormat : locale.format : useUTC ? d3UtcFormat : d3TimeFormat;
|
|
80
|
-
|
|
81
|
-
const
|
|
82
|
-
const
|
|
83
|
-
const
|
|
84
|
-
const
|
|
85
|
-
const
|
|
86
|
-
const
|
|
87
|
-
const
|
|
117
|
+
// Refer to https://d3js.org/d3-time-format#locale_format to see explanation about each format specifier
|
|
118
|
+
const DEFAULT = '%c';
|
|
119
|
+
const MS = '.%L';
|
|
120
|
+
const MS_S = ':%S.%L';
|
|
121
|
+
const MS_S_MIN = '%M:%S.%L';
|
|
122
|
+
const MS_S_MIN_H = '%-I:%M:%S.%L %p';
|
|
123
|
+
const MS_S_MIN_H_D = '%a %d, %X';
|
|
124
|
+
const MS_S_MIN_H_D_W = '%b %d, %X';
|
|
125
|
+
const MS_S_MIN_H_D_W_M = MS_S_MIN_H_D_W;
|
|
126
|
+
const MS_S_MIN_H_D_W_M_Y = DEFAULT;
|
|
127
|
+
const S = ':%S';
|
|
128
|
+
const S_MIN = '%-I:%M:%S';
|
|
129
|
+
const S_MIN_H = '%X';
|
|
130
|
+
const S_MIN_H_D = MS_S_MIN_H_D;
|
|
131
|
+
const S_MIN_H_D_W = MS_S_MIN_H_D_W;
|
|
132
|
+
const S_MIN_H_D_W_M = MS_S_MIN_H_D_W_M;
|
|
133
|
+
const S_MIN_H_D_W_M_Y = DEFAULT;
|
|
134
|
+
const MIN = '%-I:%M %p';
|
|
135
|
+
const MIN_H = MIN;
|
|
136
|
+
const MIN_H_D = '%a %d, %-I:%M %p';
|
|
137
|
+
const MIN_H_D_W = '%b %d, %-I:%M %p';
|
|
138
|
+
const MIN_H_D_W_M = MIN_H_D_W;
|
|
139
|
+
const MIN_H_D_W_M_Y = '%x, %-I:%M %p';
|
|
140
|
+
const H = '%-I %p';
|
|
141
|
+
const H_D = '%a %d, %-I %p';
|
|
142
|
+
const H_D_W = '%b %d, %-I %p';
|
|
143
|
+
const H_D_W_M = H_D_W;
|
|
144
|
+
const H_D_W_M_Y = '%x, %-I %p';
|
|
145
|
+
const D = '%a %d';
|
|
146
|
+
const D_W = '%b %d';
|
|
147
|
+
const D_W_M = D_W;
|
|
148
|
+
const D_W_M_Y = '%x';
|
|
149
|
+
const W = D_W;
|
|
150
|
+
const W_M = W;
|
|
151
|
+
const W_M_Y = D_W_M_Y;
|
|
152
|
+
const M = '%B';
|
|
153
|
+
const M_Y = '%b %Y';
|
|
154
|
+
const Y = '%Y';
|
|
155
|
+
const MULTI_LEVEL_DATE_TIME_FORMATS = [
|
|
156
|
+
// ms, s, min, h, d, w, m, y
|
|
157
|
+
[
|
|
158
|
+
MS,
|
|
159
|
+
MS_S,
|
|
160
|
+
MS_S_MIN,
|
|
161
|
+
MS_S_MIN_H,
|
|
162
|
+
MS_S_MIN_H_D,
|
|
163
|
+
MS_S_MIN_H_D_W,
|
|
164
|
+
MS_S_MIN_H_D_W_M,
|
|
165
|
+
MS_S_MIN_H_D_W_M_Y
|
|
166
|
+
],
|
|
167
|
+
[
|
|
168
|
+
DEFAULT,
|
|
169
|
+
S,
|
|
170
|
+
S_MIN,
|
|
171
|
+
S_MIN_H,
|
|
172
|
+
S_MIN_H_D,
|
|
173
|
+
S_MIN_H_D_W,
|
|
174
|
+
S_MIN_H_D_W_M,
|
|
175
|
+
S_MIN_H_D_W_M_Y
|
|
176
|
+
],
|
|
177
|
+
[
|
|
178
|
+
DEFAULT,
|
|
179
|
+
DEFAULT,
|
|
180
|
+
MIN,
|
|
181
|
+
MIN_H,
|
|
182
|
+
MIN_H_D,
|
|
183
|
+
MIN_H_D_W,
|
|
184
|
+
MIN_H_D_W_M,
|
|
185
|
+
MIN_H_D_W_M_Y
|
|
186
|
+
],
|
|
187
|
+
[
|
|
188
|
+
DEFAULT,
|
|
189
|
+
DEFAULT,
|
|
190
|
+
DEFAULT,
|
|
191
|
+
H,
|
|
192
|
+
H_D,
|
|
193
|
+
H_D_W,
|
|
194
|
+
H_D_W_M,
|
|
195
|
+
H_D_W_M_Y
|
|
196
|
+
],
|
|
197
|
+
[
|
|
198
|
+
DEFAULT,
|
|
199
|
+
DEFAULT,
|
|
200
|
+
DEFAULT,
|
|
201
|
+
DEFAULT,
|
|
202
|
+
D,
|
|
203
|
+
D_W,
|
|
204
|
+
D_W_M,
|
|
205
|
+
D_W_M_Y
|
|
206
|
+
],
|
|
207
|
+
[
|
|
208
|
+
DEFAULT,
|
|
209
|
+
DEFAULT,
|
|
210
|
+
DEFAULT,
|
|
211
|
+
DEFAULT,
|
|
212
|
+
DEFAULT,
|
|
213
|
+
W,
|
|
214
|
+
W_M,
|
|
215
|
+
W_M_Y
|
|
216
|
+
],
|
|
217
|
+
[
|
|
218
|
+
DEFAULT,
|
|
219
|
+
DEFAULT,
|
|
220
|
+
DEFAULT,
|
|
221
|
+
DEFAULT,
|
|
222
|
+
DEFAULT,
|
|
223
|
+
DEFAULT,
|
|
224
|
+
M,
|
|
225
|
+
M_Y
|
|
226
|
+
],
|
|
227
|
+
[
|
|
228
|
+
DEFAULT,
|
|
229
|
+
DEFAULT,
|
|
230
|
+
DEFAULT,
|
|
231
|
+
DEFAULT,
|
|
232
|
+
DEFAULT,
|
|
233
|
+
DEFAULT,
|
|
234
|
+
DEFAULT,
|
|
235
|
+
Y
|
|
236
|
+
]
|
|
237
|
+
];
|
|
238
|
+
const formatter = timeFormat(MULTI_LEVEL_DATE_TIME_FORMATS[startLevel][endLevel]);
|
|
239
|
+
return formatter;
|
|
240
|
+
}
|
|
241
|
+
function getDateFormatLevel(date, useUTC) {
|
|
88
242
|
const timeSecond = useUTC ? d3UtcSecond : d3TimeSecond;
|
|
89
243
|
const timeMinute = useUTC ? d3UtcMinute : d3TimeMinute;
|
|
90
244
|
const timeHour = useUTC ? d3UtcHour : d3TimeHour;
|
|
@@ -92,7 +246,43 @@ function multiFormat(date, locale, useUTC) {
|
|
|
92
246
|
const timeMonth = useUTC ? d3UtcMonth : d3TimeMonth;
|
|
93
247
|
const timeWeek = useUTC ? d3UtcWeek : d3TimeWeek;
|
|
94
248
|
const timeYear = useUTC ? d3UtcYear : d3TimeYear;
|
|
95
|
-
|
|
249
|
+
const formats = [
|
|
250
|
+
{
|
|
251
|
+
formatLevel: 0,
|
|
252
|
+
condition: (d)=>timeSecond(d) < d
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
formatLevel: 1,
|
|
256
|
+
condition: (d)=>timeMinute(d) < d
|
|
257
|
+
},
|
|
258
|
+
{
|
|
259
|
+
formatLevel: 2,
|
|
260
|
+
condition: (d)=>timeHour(d) < d
|
|
261
|
+
},
|
|
262
|
+
{
|
|
263
|
+
formatLevel: 3,
|
|
264
|
+
condition: (d)=>timeDay(d) < d
|
|
265
|
+
},
|
|
266
|
+
{
|
|
267
|
+
formatLevel: 4,
|
|
268
|
+
condition: (d)=>timeMonth(d) < d && timeWeek(d) < d
|
|
269
|
+
},
|
|
270
|
+
{
|
|
271
|
+
formatLevel: 5,
|
|
272
|
+
condition: (d)=>timeMonth(d) < d
|
|
273
|
+
},
|
|
274
|
+
{
|
|
275
|
+
formatLevel: 6,
|
|
276
|
+
condition: (d)=>timeYear(d) < d
|
|
277
|
+
},
|
|
278
|
+
{
|
|
279
|
+
formatLevel: 7,
|
|
280
|
+
condition: ()=>true
|
|
281
|
+
}
|
|
282
|
+
];
|
|
283
|
+
const matchedFormat = formats.find(({ condition })=>condition(date));
|
|
284
|
+
var _matchedFormat_formatLevel;
|
|
285
|
+
return (_matchedFormat_formatLevel = matchedFormat === null || matchedFormat === void 0 ? void 0 : matchedFormat.formatLevel) !== null && _matchedFormat_formatLevel !== void 0 ? _matchedFormat_formatLevel : 7;
|
|
96
286
|
}
|
|
97
287
|
/**
|
|
98
288
|
* Creating Date x axis of the Chart
|
|
@@ -100,26 +290,37 @@ function multiFormat(date, locale, useUTC) {
|
|
|
100
290
|
* @param {IXAxisParams} xAxisParams
|
|
101
291
|
* @param {ITickParams} tickParams
|
|
102
292
|
*/ export function createDateXAxis(xAxisParams, tickParams, culture, options, timeFormatLocale, customDateTimeFormatter, useUTC) {
|
|
103
|
-
const { domainNRangeValues, xAxisElement, tickPadding = 6, xAxistickSize = 6, xAxisCount
|
|
104
|
-
const
|
|
293
|
+
const { domainNRangeValues, xAxisElement, tickPadding = 6, xAxistickSize = 6, xAxisCount } = xAxisParams;
|
|
294
|
+
const isUtcSet = useUTC === true || useUTC === 'utc';
|
|
295
|
+
const xAxisScale = isUtcSet ? d3ScaleUtc() : d3ScaleTime();
|
|
105
296
|
xAxisScale.domain([
|
|
106
297
|
domainNRangeValues.dStartValue,
|
|
107
298
|
domainNRangeValues.dEndValue
|
|
108
299
|
]).range([
|
|
109
300
|
domainNRangeValues.rStartValue,
|
|
110
301
|
domainNRangeValues.rEndValue
|
|
111
|
-
]);
|
|
302
|
+
]).nice();
|
|
112
303
|
let tickCount = xAxisCount !== null && xAxisCount !== void 0 ? xAxisCount : 6;
|
|
304
|
+
let lowestFormatLevel = 100;
|
|
305
|
+
let highestFormatLevel = -1;
|
|
306
|
+
const locale = timeFormatLocale ? d3TimeFormatLocale(timeFormatLocale) : undefined;
|
|
307
|
+
xAxisScale.ticks().forEach((domainValue)=>{
|
|
308
|
+
const formatLevel = getDateFormatLevel(domainValue, isUtcSet);
|
|
309
|
+
if (formatLevel > highestFormatLevel) {
|
|
310
|
+
highestFormatLevel = formatLevel;
|
|
311
|
+
}
|
|
312
|
+
if (formatLevel < lowestFormatLevel) {
|
|
313
|
+
lowestFormatLevel = formatLevel;
|
|
314
|
+
}
|
|
315
|
+
});
|
|
316
|
+
const formatOptions = options !== null && options !== void 0 ? options : getMultiLevelDateTimeFormatOptions(lowestFormatLevel, highestFormatLevel);
|
|
317
|
+
const formatFn = getMultiLevelD3DateFormatter(lowestFormatLevel, highestFormatLevel, locale, isUtcSet);
|
|
113
318
|
const tickFormat = (domainValue, _index)=>{
|
|
114
319
|
if (customDateTimeFormatter) {
|
|
115
320
|
return customDateTimeFormatter(domainValue);
|
|
116
321
|
}
|
|
117
|
-
if (culture && options) {
|
|
118
|
-
return domainValue.toLocaleString(culture, options);
|
|
119
|
-
}
|
|
120
322
|
if (timeFormatLocale) {
|
|
121
|
-
|
|
122
|
-
return multiFormat(domainValue, locale, useUTC);
|
|
323
|
+
return formatFn(domainValue);
|
|
123
324
|
}
|
|
124
325
|
if (culture === undefined && tickParams.tickFormat) {
|
|
125
326
|
if (useUTC) {
|
|
@@ -128,13 +329,12 @@ function multiFormat(date, locale, useUTC) {
|
|
|
128
329
|
return d3TimeFormat(tickParams.tickFormat)(domainValue);
|
|
129
330
|
}
|
|
130
331
|
}
|
|
131
|
-
return
|
|
332
|
+
return formatDateToLocaleString(domainValue, culture, useUTC ? true : false, false, formatOptions);
|
|
132
333
|
};
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
}
|
|
334
|
+
const longestLabelWidth = calculateLongestLabelWidth(xAxisScale.ticks().map(tickFormat), '.fui-cart__xAxis text') + 40;
|
|
335
|
+
const [start, end] = xAxisScale.range();
|
|
336
|
+
const maxPossibleTickCount = Math.max(1, Math.floor(Math.abs(end - start) / longestLabelWidth));
|
|
337
|
+
tickCount = Math.min(maxPossibleTickCount, xAxisCount !== null && xAxisCount !== void 0 ? xAxisCount : tickCount);
|
|
138
338
|
const xAxis = d3AxisBottom(xAxisScale).tickSize(xAxistickSize).tickPadding(tickPadding).ticks(tickCount).tickFormat(tickFormat);
|
|
139
339
|
tickParams.tickValues ? xAxis.tickValues(tickParams.tickValues) : '';
|
|
140
340
|
if (xAxisElement) {
|
|
@@ -164,7 +364,7 @@ function multiFormat(date, locale, useUTC) {
|
|
|
164
364
|
var _tickParams_tickValues;
|
|
165
365
|
let tickValues = (_tickParams_tickValues = tickParams.tickValues) !== null && _tickParams_tickValues !== void 0 ? _tickParams_tickValues : dataset;
|
|
166
366
|
const tickFormat = (domainValue, _index)=>{
|
|
167
|
-
return
|
|
367
|
+
return formatToLocaleString(domainValue, culture);
|
|
168
368
|
};
|
|
169
369
|
if (hideTickOverlap) {
|
|
170
370
|
let nonOverlappingTickValues = [];
|
|
@@ -279,7 +479,7 @@ function handleFloatingPointPrecisionError(num) {
|
|
|
279
479
|
case 6:
|
|
280
480
|
return createYAxisForHorizontalBarChartWithAxis(yAxisParams, isRtl, axisData, barWidth);
|
|
281
481
|
default:
|
|
282
|
-
return
|
|
482
|
+
return createNumericYAxisForOtherCharts(yAxisParams, isRtl, axisData, isIntegralDataset, chartType, useSecondaryYScale, roundedTicks);
|
|
283
483
|
}
|
|
284
484
|
}
|
|
285
485
|
export function createYAxisForHorizontalBarChartWithAxis(yAxisParams, isRtl, axisData, barWidth) {
|
|
@@ -300,11 +500,11 @@ export function createYAxisForHorizontalBarChartWithAxis(yAxisParams, isRtl, axi
|
|
|
300
500
|
]);
|
|
301
501
|
const axis = isRtl ? d3AxisRight(yAxisScale) : d3AxisLeft(yAxisScale);
|
|
302
502
|
const yAxis = axis.tickPadding(tickPadding).ticks(yAxisTickCount);
|
|
303
|
-
yAxisTickFormat ? yAxis.tickFormat(yAxisTickFormat) : yAxis.tickFormat(
|
|
503
|
+
yAxisTickFormat ? yAxis.tickFormat(yAxisTickFormat) : yAxis.tickFormat(defaultYAxisTickFormatter);
|
|
304
504
|
yAxisElement ? d3Select(yAxisElement).call(yAxis).selectAll('text').attr('aria-hidden', 'true') : '';
|
|
305
505
|
return yAxisScale;
|
|
306
506
|
}
|
|
307
|
-
export function
|
|
507
|
+
export function createNumericYAxisForOtherCharts(yAxisParams, isRtl, axisData, isIntegralDataset, chartType, useSecondaryYScale = false, roundedTicks = false) {
|
|
308
508
|
const { yMinMaxValues = {
|
|
309
509
|
startValue: 0,
|
|
310
510
|
endValue: 0
|
|
@@ -330,7 +530,7 @@ export function createYAxisForOtherCharts(yAxisParams, isRtl, axisData, isIntegr
|
|
|
330
530
|
]);
|
|
331
531
|
const axis = !isRtl && useSecondaryYScale || isRtl && !useSecondaryYScale ? d3AxisRight(yAxisScale) : d3AxisLeft(yAxisScale);
|
|
332
532
|
const yAxis = axis.tickPadding(tickPadding).tickValues(domainValues).tickSizeInner(-(containerWidth - margins.left - margins.right));
|
|
333
|
-
yAxisTickFormat ? yAxis.tickFormat(yAxisTickFormat) : yAxis.tickFormat(
|
|
533
|
+
yAxisTickFormat ? yAxis.tickFormat(yAxisTickFormat) : yAxis.tickFormat(defaultYAxisTickFormatter);
|
|
334
534
|
yAxisElement ? d3Select(yAxisElement).call(yAxis).selectAll('text').attr('aria-hidden', 'true') : '';
|
|
335
535
|
axisData.yAxisDomainValues = domainValues;
|
|
336
536
|
return yAxisScale;
|
|
@@ -1214,21 +1414,6 @@ export var CustomPoints;
|
|
|
1214
1414
|
'aria-describedby': accessibleData.ariaDescribedBy
|
|
1215
1415
|
};
|
|
1216
1416
|
};
|
|
1217
|
-
export const convertToLocaleString = (data, culture)=>{
|
|
1218
|
-
if (data === undefined || data === null || Number.isNaN(data)) {
|
|
1219
|
-
return data;
|
|
1220
|
-
}
|
|
1221
|
-
culture = culture || undefined;
|
|
1222
|
-
if (typeof data === 'number') {
|
|
1223
|
-
return data.toLocaleString(culture);
|
|
1224
|
-
} else if (typeof data === 'string' && !isNaN(Number(data))) {
|
|
1225
|
-
const num = Number(data);
|
|
1226
|
-
return num.toLocaleString(culture);
|
|
1227
|
-
} else if (data instanceof Date) {
|
|
1228
|
-
return data.toLocaleDateString(culture);
|
|
1229
|
-
}
|
|
1230
|
-
return data;
|
|
1231
|
-
};
|
|
1232
1417
|
export function rotateXAxisLabels(rotateLabelProps) {
|
|
1233
1418
|
const { node, xAxis } = rotateLabelProps;
|
|
1234
1419
|
if (node === null || xAxis === null) {
|
|
@@ -1286,14 +1471,8 @@ export function wrapTextInsideDonut(selectorClass, maxWidth) {
|
|
|
1286
1471
|
idx += 1;
|
|
1287
1472
|
});
|
|
1288
1473
|
}
|
|
1289
|
-
export function
|
|
1290
|
-
|
|
1291
|
-
if (value < 1000) {
|
|
1292
|
-
specifier = '.2~'; // upto 2 decimal places without insignificant trailing zeros
|
|
1293
|
-
} else {
|
|
1294
|
-
specifier = '.1'; // upto 1 decimal place
|
|
1295
|
-
}
|
|
1296
|
-
return d3FormatPrefix(specifier, value)(value);
|
|
1474
|
+
export function formatScientificLimitWidth(value) {
|
|
1475
|
+
return yAxisTickFormatterInternal(value, true);
|
|
1297
1476
|
}
|
|
1298
1477
|
const DEFAULT_BAR_WIDTH = 16;
|
|
1299
1478
|
const MIN_BAR_WIDTH = 1;
|