@fluentui/react-charting 5.23.83 → 5.23.85
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 +55 -1
- package/CHANGELOG.md +24 -2
- package/dist/react-charting.d.ts +7 -0
- package/dist/react-charting.js +1 -1
- package/dist/react-charting.min.js +1 -1
- package/etc/react-charting.api.md +2 -0
- package/lib/components/CommonComponents/CartesianChart.base.js +1 -1
- package/lib/components/CommonComponents/CartesianChart.base.js.map +1 -1
- package/lib/components/CommonComponents/CartesianChart.types.d.ts +2 -0
- package/lib/components/CommonComponents/CartesianChart.types.js.map +1 -1
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +10 -5
- 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/GaugeChart/GaugeChart.base.js +3 -3
- package/lib/components/GaugeChart/GaugeChart.base.js.map +1 -1
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.d.ts +1 -0
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js +19 -9
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js.map +1 -1
- package/lib/components/HorizontalBarChart/HorizontalBarChart.base.js +2 -2
- package/lib/components/HorizontalBarChart/HorizontalBarChart.base.js.map +1 -1
- package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.d.ts +5 -0
- package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.js +78 -16
- package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.js.map +1 -1
- package/lib/components/StackedBarChart/MultiStackedBarChart.base.js +2 -2
- package/lib/components/StackedBarChart/MultiStackedBarChart.base.js.map +1 -1
- package/lib/components/VerticalBarChart/VerticalBarChart.base.js +2 -2
- package/lib/components/VerticalBarChart/VerticalBarChart.base.js.map +1 -1
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js +2 -2
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js.map +1 -1
- package/lib/types/IDataPoint.d.ts +5 -0
- package/lib/types/IDataPoint.js.map +1 -1
- package/lib/utilities/utilities.d.ts +8 -1
- package/lib/utilities/utilities.js +151 -51
- package/lib/utilities/utilities.js.map +1 -1
- package/lib-amd/components/CommonComponents/CartesianChart.base.js +1 -1
- package/lib-amd/components/CommonComponents/CartesianChart.base.js.map +1 -1
- package/lib-amd/components/CommonComponents/CartesianChart.types.d.ts +2 -0
- package/lib-amd/components/CommonComponents/CartesianChart.types.js.map +1 -1
- package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js +10 -5
- package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib-amd/components/DonutChart/Arc/Arc.js +1 -1
- package/lib-amd/components/DonutChart/Arc/Arc.js.map +1 -1
- package/lib-amd/components/GaugeChart/GaugeChart.base.js +2 -2
- package/lib-amd/components/GaugeChart/GaugeChart.base.js.map +1 -1
- package/lib-amd/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.d.ts +1 -0
- package/lib-amd/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js +18 -8
- package/lib-amd/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js.map +1 -1
- package/lib-amd/components/HorizontalBarChart/HorizontalBarChart.base.js +1 -1
- package/lib-amd/components/HorizontalBarChart/HorizontalBarChart.base.js.map +1 -1
- package/lib-amd/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.d.ts +5 -0
- package/lib-amd/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.js +77 -16
- package/lib-amd/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.js.map +1 -1
- package/lib-amd/components/StackedBarChart/MultiStackedBarChart.base.js +1 -1
- package/lib-amd/components/StackedBarChart/MultiStackedBarChart.base.js.map +1 -1
- package/lib-amd/components/VerticalBarChart/VerticalBarChart.base.js +1 -1
- package/lib-amd/components/VerticalBarChart/VerticalBarChart.base.js.map +1 -1
- package/lib-amd/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js +1 -1
- package/lib-amd/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js.map +1 -1
- package/lib-amd/types/IDataPoint.d.ts +5 -0
- package/lib-amd/types/IDataPoint.js.map +1 -1
- package/lib-amd/utilities/utilities.d.ts +8 -1
- package/lib-amd/utilities/utilities.js +154 -53
- package/lib-amd/utilities/utilities.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/CartesianChart.base.js +1 -1
- package/lib-commonjs/components/CommonComponents/CartesianChart.base.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/CartesianChart.types.d.ts +2 -0
- package/lib-commonjs/components/CommonComponents/CartesianChart.types.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +10 -5
- 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/GaugeChart/GaugeChart.base.js +2 -2
- package/lib-commonjs/components/GaugeChart/GaugeChart.base.js.map +1 -1
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.d.ts +1 -0
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js +18 -8
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChart/HorizontalBarChart.base.js +1 -1
- package/lib-commonjs/components/HorizontalBarChart/HorizontalBarChart.base.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.d.ts +5 -0
- package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.js +77 -15
- package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.js.map +1 -1
- package/lib-commonjs/components/StackedBarChart/MultiStackedBarChart.base.js +1 -1
- package/lib-commonjs/components/StackedBarChart/MultiStackedBarChart.base.js.map +1 -1
- package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.base.js +1 -1
- package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.base.js.map +1 -1
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js +1 -1
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js.map +1 -1
- package/lib-commonjs/types/IDataPoint.d.ts +5 -0
- package/lib-commonjs/types/IDataPoint.js.map +1 -1
- package/lib-commonjs/utilities/utilities.d.ts +8 -1
- package/lib-commonjs/utilities/utilities.js +155 -54
- package/lib-commonjs/utilities/utilities.js.map +1 -1
- package/package.json +2 -2
- package/src/components/CommonComponents/CartesianChart.types.ts +3 -0
|
@@ -10,6 +10,7 @@ import { timeSecond as d3TimeSecond, timeMinute as d3TimeMinute, timeHour as d3T
|
|
|
10
10
|
import { formatPrefix as d3FormatPrefix } from 'd3-format';
|
|
11
11
|
import { getId } from '@fluentui/react';
|
|
12
12
|
import { curveLinear as d3CurveLinear, curveNatural as d3CurveNatural, curveStep as d3CurveStep, curveStepAfter as d3CurveStepAfter, curveStepBefore as d3CurveStepBefore, } from 'd3-shape';
|
|
13
|
+
export var MIN_DOMAIN_MARGIN = 8;
|
|
13
14
|
export var ChartTypes;
|
|
14
15
|
(function (ChartTypes) {
|
|
15
16
|
ChartTypes[ChartTypes["AreaChart"] = 0] = "AreaChart";
|
|
@@ -32,6 +33,33 @@ export var YAxisType;
|
|
|
32
33
|
YAxisType[YAxisType["DateAxis"] = 1] = "DateAxis";
|
|
33
34
|
YAxisType[YAxisType["StringAxis"] = 2] = "StringAxis";
|
|
34
35
|
})(YAxisType || (YAxisType = {}));
|
|
36
|
+
function yAxisTickFormatterInternal(value, limitWidth) {
|
|
37
|
+
if (limitWidth === void 0) { limitWidth = false; }
|
|
38
|
+
// Use SI format prefix with 2 decimal places without insignificant trailing zeros
|
|
39
|
+
var formatter = d3FormatPrefix('.2~', value);
|
|
40
|
+
if (Math.abs(value) < 1) {
|
|
41
|
+
// Don't use SI notation for small numbers as it is less readable
|
|
42
|
+
formatter = d3Format('.2~g');
|
|
43
|
+
}
|
|
44
|
+
else if (limitWidth && Math.abs(value) >= 1000) {
|
|
45
|
+
// If width is limited, use SI format prefix with 1 point precision
|
|
46
|
+
formatter = d3FormatPrefix('.1~', value);
|
|
47
|
+
}
|
|
48
|
+
var formattedValue = formatter(value);
|
|
49
|
+
// Replace 'G' with 'B' if the value is greater than 10^9 as it is a more common convention
|
|
50
|
+
if (Math.abs(value) >= 1e9) {
|
|
51
|
+
return formattedValue.replace('G', 'B');
|
|
52
|
+
}
|
|
53
|
+
return formattedValue;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Formatter for y axis ticks.
|
|
57
|
+
* @param value - The number to format.
|
|
58
|
+
* @returns The formatted string .
|
|
59
|
+
*/
|
|
60
|
+
export function defaultYAxisTickFormatter(value) {
|
|
61
|
+
return yAxisTickFormatterInternal(value);
|
|
62
|
+
}
|
|
35
63
|
/**
|
|
36
64
|
* Create Numeric X axis
|
|
37
65
|
* @export
|
|
@@ -39,7 +67,7 @@ export var YAxisType;
|
|
|
39
67
|
*/
|
|
40
68
|
export function createNumericXAxis(xAxisParams, tickParams, chartType, culture) {
|
|
41
69
|
var _a;
|
|
42
|
-
var domainNRangeValues = xAxisParams.domainNRangeValues, _b = xAxisParams.showRoundOffXTickValues, showRoundOffXTickValues = _b === void 0 ?
|
|
70
|
+
var domainNRangeValues = xAxisParams.domainNRangeValues, _b = xAxisParams.showRoundOffXTickValues, showRoundOffXTickValues = _b === void 0 ? true : _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;
|
|
43
71
|
var xAxisScale = d3ScaleLinear()
|
|
44
72
|
.domain([domainNRangeValues.dStartValue, domainNRangeValues.dEndValue])
|
|
45
73
|
.range([domainNRangeValues.rStartValue, domainNRangeValues.rEndValue]);
|
|
@@ -74,16 +102,75 @@ export function createNumericXAxis(xAxisParams, tickParams, chartType, culture)
|
|
|
74
102
|
var tickValues = ((_a = tickParams.tickValues) !== null && _a !== void 0 ? _a : xAxisScale.ticks(tickCount)).map(xAxis.tickFormat());
|
|
75
103
|
return { xScale: xAxisScale, tickValues: tickValues };
|
|
76
104
|
}
|
|
77
|
-
|
|
105
|
+
/**
|
|
106
|
+
* This function returns a multilevel formatter for a given date range.
|
|
107
|
+
* It determines the appropriate date format to accommodate each tick value.
|
|
108
|
+
* The goal is to represent the date label in the smallest possible format without loss of information.
|
|
109
|
+
* The challenge here is to adhere to locale specific formats while ensuring the complete label is shown.
|
|
110
|
+
* There is an exhaustive map of all possible date/time units and their respective formats.
|
|
111
|
+
* Based on the range of formatting granularity levels, a format spanning the range is returned.
|
|
112
|
+
* @param startLevel - The starting level of the date format.
|
|
113
|
+
* @param endLevel - The ending level of the date format.
|
|
114
|
+
* @param locale - The locale object for formatting.
|
|
115
|
+
* @param useUTC
|
|
116
|
+
* @returns
|
|
117
|
+
*/
|
|
118
|
+
function getMultiLevelDateFormatter(startLevel, endLevel, locale, useUTC) {
|
|
78
119
|
var timeFormat = locale ? (useUTC ? locale.utcFormat : locale.format) : useUTC ? d3UtcFormat : d3TimeFormat;
|
|
79
|
-
|
|
80
|
-
var
|
|
81
|
-
var
|
|
82
|
-
var
|
|
83
|
-
var
|
|
84
|
-
var
|
|
85
|
-
var
|
|
86
|
-
var
|
|
120
|
+
// Refer to https://d3js.org/d3-time-format#locale_format to see explanation about each format specifier
|
|
121
|
+
var DEFAULT = '%c';
|
|
122
|
+
var MS = '.%L';
|
|
123
|
+
var MS_S = ':%S.%L';
|
|
124
|
+
var MS_S_MIN = '%M:%S.%L';
|
|
125
|
+
var MS_S_MIN_H = '%-I:%M:%S.%L %p';
|
|
126
|
+
var MS_S_MIN_H_D = '%a %d, %X';
|
|
127
|
+
var MS_S_MIN_H_D_W = '%b %d, %X';
|
|
128
|
+
var MS_S_MIN_H_D_W_M = MS_S_MIN_H_D_W;
|
|
129
|
+
var MS_S_MIN_H_D_W_M_Y = DEFAULT;
|
|
130
|
+
var S = ':%S';
|
|
131
|
+
var S_MIN = '%-I:%M:%S';
|
|
132
|
+
var S_MIN_H = '%X';
|
|
133
|
+
var S_MIN_H_D = MS_S_MIN_H_D;
|
|
134
|
+
var S_MIN_H_D_W = MS_S_MIN_H_D_W;
|
|
135
|
+
var S_MIN_H_D_W_M = MS_S_MIN_H_D_W_M;
|
|
136
|
+
var S_MIN_H_D_W_M_Y = DEFAULT;
|
|
137
|
+
var MIN = '%-I:%M %p';
|
|
138
|
+
var MIN_H = MIN;
|
|
139
|
+
var MIN_H_D = '%a %d, %-I:%M %p';
|
|
140
|
+
var MIN_H_D_W = '%b %d, %-I:%M %p';
|
|
141
|
+
var MIN_H_D_W_M = MIN_H_D_W;
|
|
142
|
+
var MIN_H_D_W_M_Y = '%x, %-I:%M %p';
|
|
143
|
+
var H = '%-I %p';
|
|
144
|
+
var H_D = '%a %d, %-I %p';
|
|
145
|
+
var H_D_W = '%b %d, %-I %p';
|
|
146
|
+
var H_D_W_M = H_D_W;
|
|
147
|
+
var H_D_W_M_Y = '%x, %-I %p';
|
|
148
|
+
var D = '%a %d';
|
|
149
|
+
var D_W = '%b %d';
|
|
150
|
+
var D_W_M = D_W;
|
|
151
|
+
var D_W_M_Y = '%x';
|
|
152
|
+
var W = D_W;
|
|
153
|
+
var W_M = W;
|
|
154
|
+
var W_M_Y = D_W_M_Y;
|
|
155
|
+
var M = '%B';
|
|
156
|
+
var M_Y = '%b %Y';
|
|
157
|
+
var Y = '%Y';
|
|
158
|
+
var MULTI_LEVEL_DATE_TIME_FORMATS = [
|
|
159
|
+
// ms, s, min, h, d, w, m, y
|
|
160
|
+
[MS, MS_S, MS_S_MIN, MS_S_MIN_H, MS_S_MIN_H_D, MS_S_MIN_H_D_W, MS_S_MIN_H_D_W_M, MS_S_MIN_H_D_W_M_Y], // ms
|
|
161
|
+
[DEFAULT, S, S_MIN, S_MIN_H, S_MIN_H_D, S_MIN_H_D_W, S_MIN_H_D_W_M, S_MIN_H_D_W_M_Y], // s
|
|
162
|
+
[DEFAULT, DEFAULT, MIN, MIN_H, MIN_H_D, MIN_H_D_W, MIN_H_D_W_M, MIN_H_D_W_M_Y], // min
|
|
163
|
+
[DEFAULT, DEFAULT, DEFAULT, H, H_D, H_D_W, H_D_W_M, H_D_W_M_Y], // h
|
|
164
|
+
[DEFAULT, DEFAULT, DEFAULT, DEFAULT, D, D_W, D_W_M, D_W_M_Y], // d
|
|
165
|
+
[DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, W, W_M, W_M_Y], // w
|
|
166
|
+
[DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, M, M_Y], // m
|
|
167
|
+
[DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, Y], // y
|
|
168
|
+
];
|
|
169
|
+
var formatter = timeFormat(MULTI_LEVEL_DATE_TIME_FORMATS[startLevel][endLevel]);
|
|
170
|
+
return formatter;
|
|
171
|
+
}
|
|
172
|
+
function getDateFormatLevel(date, useUTC) {
|
|
173
|
+
var _a;
|
|
87
174
|
var timeSecond = useUTC ? d3UtcSecond : d3TimeSecond;
|
|
88
175
|
var timeMinute = useUTC ? d3UtcMinute : d3TimeMinute;
|
|
89
176
|
var timeHour = useUTC ? d3UtcHour : d3TimeHour;
|
|
@@ -91,21 +178,21 @@ function multiFormat(date, locale, useUTC) {
|
|
|
91
178
|
var timeMonth = useUTC ? d3UtcMonth : d3TimeMonth;
|
|
92
179
|
var timeWeek = useUTC ? d3UtcWeek : d3TimeWeek;
|
|
93
180
|
var timeYear = useUTC ? d3UtcYear : d3TimeYear;
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
: timeMinute(
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
181
|
+
var formats = [
|
|
182
|
+
{ formatLevel: 0, condition: function (d) { return timeSecond(d) < d; } }, // Milliseconds
|
|
183
|
+
{ formatLevel: 1, condition: function (d) { return timeMinute(d) < d; } }, // Seconds
|
|
184
|
+
{ formatLevel: 2, condition: function (d) { return timeHour(d) < d; } }, // Minutes
|
|
185
|
+
{ formatLevel: 3, condition: function (d) { return timeDay(d) < d; } }, // Hours
|
|
186
|
+
{ formatLevel: 4, condition: function (d) { return timeMonth(d) < d && timeWeek(d) < d; } }, // Days
|
|
187
|
+
{ formatLevel: 5, condition: function (d) { return timeMonth(d) < d; } }, // Weeks
|
|
188
|
+
{ formatLevel: 6, condition: function (d) { return timeYear(d) < d; } }, // Months
|
|
189
|
+
{ formatLevel: 7, condition: function () { return true; } }, // Years (default)
|
|
190
|
+
];
|
|
191
|
+
var matchedFormat = formats.find(function (_a) {
|
|
192
|
+
var condition = _a.condition;
|
|
193
|
+
return condition(date);
|
|
194
|
+
});
|
|
195
|
+
return (_a = matchedFormat === null || matchedFormat === void 0 ? void 0 : matchedFormat.formatLevel) !== null && _a !== void 0 ? _a : 7;
|
|
109
196
|
}
|
|
110
197
|
function isPowerOf10(num) {
|
|
111
198
|
var roundedfinalYMax = handleFloatingPointPrecisionError(num);
|
|
@@ -124,12 +211,26 @@ function handleFloatingPointPrecisionError(num) {
|
|
|
124
211
|
*/
|
|
125
212
|
export function createDateXAxis(xAxisParams, tickParams, culture, options, timeFormatLocale, customDateTimeFormatter, useUTC) {
|
|
126
213
|
var _a;
|
|
127
|
-
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
|
|
214
|
+
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;
|
|
128
215
|
var xAxisScale = useUTC ? d3ScaleUtc() : d3ScaleTime();
|
|
129
216
|
xAxisScale
|
|
130
217
|
.domain([domainNRangeValues.dStartValue, domainNRangeValues.dEndValue])
|
|
131
|
-
.range([domainNRangeValues.rStartValue, domainNRangeValues.rEndValue])
|
|
218
|
+
.range([domainNRangeValues.rStartValue, domainNRangeValues.rEndValue])
|
|
219
|
+
.nice();
|
|
132
220
|
var tickCount = xAxisCount !== null && xAxisCount !== void 0 ? xAxisCount : 6;
|
|
221
|
+
var lowestFormatLevel = 100;
|
|
222
|
+
var highestFormatLevel = -1;
|
|
223
|
+
var locale = timeFormatLocale ? d3TimeFormatLocale(timeFormatLocale) : undefined;
|
|
224
|
+
xAxisScale.ticks().forEach(function (domainValue) {
|
|
225
|
+
var formatLevel = getDateFormatLevel(domainValue, useUTC);
|
|
226
|
+
if (formatLevel > highestFormatLevel) {
|
|
227
|
+
highestFormatLevel = formatLevel;
|
|
228
|
+
}
|
|
229
|
+
if (formatLevel < lowestFormatLevel) {
|
|
230
|
+
lowestFormatLevel = formatLevel;
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
var formatFn = getMultiLevelDateFormatter(lowestFormatLevel, highestFormatLevel, locale, useUTC);
|
|
133
234
|
var tickFormat = function (domainValue, _index) {
|
|
134
235
|
if (customDateTimeFormatter) {
|
|
135
236
|
return customDateTimeFormatter(domainValue);
|
|
@@ -138,8 +239,7 @@ export function createDateXAxis(xAxisParams, tickParams, culture, options, timeF
|
|
|
138
239
|
return domainValue.toLocaleString(culture, options);
|
|
139
240
|
}
|
|
140
241
|
if (timeFormatLocale) {
|
|
141
|
-
|
|
142
|
-
return multiFormat(domainValue, locale, useUTC);
|
|
242
|
+
return formatFn(domainValue);
|
|
143
243
|
}
|
|
144
244
|
if (culture === undefined && tickParams.tickFormat) {
|
|
145
245
|
if (useUTC) {
|
|
@@ -149,13 +249,12 @@ export function createDateXAxis(xAxisParams, tickParams, culture, options, timeF
|
|
|
149
249
|
return d3TimeFormat(tickParams.tickFormat)(domainValue);
|
|
150
250
|
}
|
|
151
251
|
}
|
|
152
|
-
return
|
|
252
|
+
return formatFn(domainValue);
|
|
153
253
|
};
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
}
|
|
254
|
+
var longestLabelWidth = calculateLongestLabelWidth(xAxisScale.ticks().map(tickFormat), '[class^="xAxis-"] text') + 40;
|
|
255
|
+
var _d = xAxisScale.range(), start = _d[0], end = _d[1];
|
|
256
|
+
tickCount = Math.min(Math.max(1, Math.floor(Math.abs(end - start) / longestLabelWidth)), 10);
|
|
257
|
+
tickCount = Math.min(tickCount, xAxisCount !== null && xAxisCount !== void 0 ? xAxisCount : tickCount);
|
|
159
258
|
var xAxis = d3AxisBottom(xAxisScale)
|
|
160
259
|
.tickSize(xAxistickSize)
|
|
161
260
|
.tickPadding(tickPadding)
|
|
@@ -283,17 +382,16 @@ export function prepareDatapoints(maxVal, minVal, splitInto, isIntegralDataset,
|
|
|
283
382
|
}
|
|
284
383
|
export function createYAxisForHorizontalBarChartWithAxis(yAxisParams, isRtl) {
|
|
285
384
|
var _a = yAxisParams.yMinMaxValues, yMinMaxValues = _a === void 0 ? { startValue: 0, endValue: 0 } : _a, _b = yAxisParams.yAxisElement, yAxisElement = _b === void 0 ? null : _b, _c = yAxisParams.yMaxValue, yMaxValue = _c === void 0 ? 0 : _c, _d = yAxisParams.yMinValue, yMinValue = _d === void 0 ? 0 : _d, containerHeight = yAxisParams.containerHeight, margins = yAxisParams.margins, _e = yAxisParams.tickPadding, tickPadding = _e === void 0 ? 12 : _e, _f = yAxisParams.maxOfYVal, maxOfYVal = _f === void 0 ? 0 : _f, yAxisTickFormat = yAxisParams.yAxisTickFormat, _g = yAxisParams.yAxisTickCount, yAxisTickCount = _g === void 0 ? 4 : _g;
|
|
286
|
-
// maxOfYVal coming from
|
|
385
|
+
// maxOfYVal coming from horizontal bar chart with axis (Calculation done at base file)
|
|
287
386
|
var tempVal = maxOfYVal || yMinMaxValues.endValue;
|
|
288
387
|
var finalYmax = tempVal > yMaxValue ? tempVal : yMaxValue;
|
|
289
388
|
var finalYmin = yMinMaxValues.startValue < yMinValue ? Math.min(0, yMinMaxValues.startValue) : yMinValue;
|
|
290
|
-
var yDomainPadding = Math.abs(finalYmax - finalYmin) * 0.1;
|
|
291
389
|
var yAxisScale = d3ScaleLinear()
|
|
292
|
-
.domain([finalYmin
|
|
390
|
+
.domain([finalYmin, finalYmax])
|
|
293
391
|
.range([containerHeight - margins.bottom, margins.top]);
|
|
294
392
|
var axis = isRtl ? d3AxisRight(yAxisScale) : d3AxisLeft(yAxisScale);
|
|
295
393
|
var yAxis = axis.tickPadding(tickPadding).ticks(yAxisTickCount);
|
|
296
|
-
yAxisTickFormat ? yAxis.tickFormat(yAxisTickFormat) : yAxis.tickFormat(
|
|
394
|
+
yAxisTickFormat ? yAxis.tickFormat(yAxisTickFormat) : yAxis.tickFormat(defaultYAxisTickFormatter);
|
|
297
395
|
yAxisElement ? d3Select(yAxisElement).call(yAxis).selectAll('text').attr('aria-hidden', 'true') : '';
|
|
298
396
|
return yAxisScale;
|
|
299
397
|
}
|
|
@@ -319,7 +417,7 @@ export function createNumericYAxis(yAxisParams, isRtl, axisData, isIntegralDatas
|
|
|
319
417
|
.tickPadding(tickPadding)
|
|
320
418
|
.tickValues(domainValues)
|
|
321
419
|
.tickSizeInner(-(containerWidth - margins.left - margins.right));
|
|
322
|
-
yAxisTickFormat ? yAxis.tickFormat(yAxisTickFormat) : yAxis.tickFormat(
|
|
420
|
+
yAxisTickFormat ? yAxis.tickFormat(yAxisTickFormat) : yAxis.tickFormat(defaultYAxisTickFormatter);
|
|
323
421
|
yAxisElement ? d3Select(yAxisElement).call(yAxis).selectAll('text').attr('aria-hidden', 'true') : '';
|
|
324
422
|
axisData.yAxisDomainValues = domainValues;
|
|
325
423
|
return yAxisScale;
|
|
@@ -331,10 +429,13 @@ export function createNumericYAxis(yAxisParams, isRtl, axisData, isIntegralDatas
|
|
|
331
429
|
* @param isRtl
|
|
332
430
|
*/
|
|
333
431
|
export var createStringYAxisForHorizontalBarChartWithAxis = function (yAxisParams, dataPoints, isRtl, barWidth) {
|
|
334
|
-
var containerHeight = yAxisParams.containerHeight, _a = yAxisParams.tickPadding, tickPadding = _a === void 0 ? 12 : _a, margins = yAxisParams.margins, yAxisTickFormat = yAxisParams.yAxisTickFormat, yAxisElement = yAxisParams.yAxisElement;
|
|
432
|
+
var containerHeight = yAxisParams.containerHeight, _a = yAxisParams.tickPadding, tickPadding = _a === void 0 ? 12 : _a, margins = yAxisParams.margins, yAxisTickFormat = yAxisParams.yAxisTickFormat, yAxisElement = yAxisParams.yAxisElement, yAxisPadding = yAxisParams.yAxisPadding;
|
|
433
|
+
var yAxisPaddingValue = yAxisPadding !== null && yAxisPadding !== void 0 ? yAxisPadding : 0.5;
|
|
434
|
+
yAxisPaddingValue = yAxisPaddingValue === 1 ? 0.99 : yAxisPaddingValue;
|
|
335
435
|
var yAxisScale = d3ScaleBand()
|
|
336
436
|
.domain(dataPoints)
|
|
337
|
-
.range([containerHeight - margins.bottom
|
|
437
|
+
.range([containerHeight - margins.bottom, margins.top])
|
|
438
|
+
.padding(yAxisPaddingValue);
|
|
338
439
|
var axis = isRtl ? d3AxisRight(yAxisScale) : d3AxisLeft(yAxisScale);
|
|
339
440
|
var yAxis = axis.tickPadding(tickPadding).ticks(dataPoints);
|
|
340
441
|
if (yAxisTickFormat) {
|
|
@@ -1044,10 +1145,16 @@ export var convertToLocaleString = function (data, culture) {
|
|
|
1044
1145
|
}
|
|
1045
1146
|
culture = culture || undefined;
|
|
1046
1147
|
if (typeof data === 'number') {
|
|
1148
|
+
if (Math.abs(data) < 10000) {
|
|
1149
|
+
return data.toString();
|
|
1150
|
+
}
|
|
1047
1151
|
return data.toLocaleString(culture);
|
|
1048
1152
|
}
|
|
1049
1153
|
else if (typeof data === 'string' && !window.isNaN(Number(data))) {
|
|
1050
1154
|
var num = Number(data);
|
|
1155
|
+
if (Math.abs(num) < 10000) {
|
|
1156
|
+
return num.toString();
|
|
1157
|
+
}
|
|
1051
1158
|
return num.toLocaleString(culture);
|
|
1052
1159
|
}
|
|
1053
1160
|
else if (data instanceof Date) {
|
|
@@ -1130,15 +1237,8 @@ export function wrapTextInsideDonut(selectorClass, maxWidth) {
|
|
|
1130
1237
|
idx += 1;
|
|
1131
1238
|
});
|
|
1132
1239
|
}
|
|
1133
|
-
export function
|
|
1134
|
-
|
|
1135
|
-
if (value < 1000) {
|
|
1136
|
-
specifier = '.2~'; // upto 2 decimal places without insignificant trailing zeros
|
|
1137
|
-
}
|
|
1138
|
-
else {
|
|
1139
|
-
specifier = '.1'; // upto 1 decimal place
|
|
1140
|
-
}
|
|
1141
|
-
return d3FormatPrefix(specifier, value)(value);
|
|
1240
|
+
export function formatValueLimitWidth(value) {
|
|
1241
|
+
return yAxisTickFormatterInternal(value, true);
|
|
1142
1242
|
}
|
|
1143
1243
|
var DEFAULT_BAR_WIDTH = 16;
|
|
1144
1244
|
var MIN_BAR_WIDTH = 1;
|