@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
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var _a;
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.
|
|
5
|
-
exports.getCurveFactory = void 0;
|
|
4
|
+
exports.resolveCSSVariables = exports.areArraysEqual = exports.getSecureProps = exports.formatDate = exports.isScalePaddingDefined = exports.getScalePadding = exports.getBarWidth = exports.formatValueLimitWidth = exports.wrapTextInsideDonut = exports.rotateXAxisLabels = exports.convertToLocaleString = exports.getAccessibleDataObject = exports.pointTypes = exports.CustomPoints = exports.Points = exports.getTypeOfAxis = exports.findHBCWANumericMinMaxOfY = exports.findVerticalNumericMinMaxOfY = exports.findVSBCNumericMinMaxOfY = exports.findNumericMinMaxOfY = exports.domainRageOfVerticalNumeric = exports.domainRangeOfDateForAreaLineVerticalBarChart = exports.domainRangeOfVSBCNumeric = exports.domainRangeOfXStringAxis = exports.domainRangeOfNumericForHorizontalBarChartWithAxis = exports.computeLongestBars = exports.groupChartDataByYValue = exports.domainRangeOfNumericForAreaChart = exports.getXAxisType = exports.tooltipOfXAxislabels = exports.calculateLongestLabelWidth = exports.wrapContent = exports.createYAxisLabels = exports.createWrapOfXLabels = exports.silceOrAppendToArray = exports.getUnique = exports.calloutData = exports.createStringYAxis = exports.createStringYAxisForHorizontalBarChartWithAxis = exports.createNumericYAxis = exports.createYAxisForHorizontalBarChartWithAxis = exports.prepareDatapoints = exports.createStringXAxis = exports.createDateXAxis = exports.createNumericXAxis = exports.defaultYAxisTickFormatter = exports.YAxisType = exports.XAxisTypes = exports.ChartTypes = exports.MIN_DOMAIN_MARGIN = void 0;
|
|
5
|
+
exports.getCurveFactory = exports.createMeasurementSpan = exports.copyStyle = void 0;
|
|
6
6
|
var tslib_1 = require("tslib");
|
|
7
7
|
var d3_axis_1 = require("d3-axis");
|
|
8
8
|
var d3_array_1 = require("d3-array");
|
|
@@ -14,6 +14,7 @@ var d3_time_1 = require("d3-time");
|
|
|
14
14
|
var d3_format_2 = require("d3-format");
|
|
15
15
|
var react_1 = require("@fluentui/react");
|
|
16
16
|
var d3_shape_1 = require("d3-shape");
|
|
17
|
+
exports.MIN_DOMAIN_MARGIN = 8;
|
|
17
18
|
var ChartTypes;
|
|
18
19
|
(function (ChartTypes) {
|
|
19
20
|
ChartTypes[ChartTypes["AreaChart"] = 0] = "AreaChart";
|
|
@@ -36,6 +37,34 @@ var YAxisType;
|
|
|
36
37
|
YAxisType[YAxisType["DateAxis"] = 1] = "DateAxis";
|
|
37
38
|
YAxisType[YAxisType["StringAxis"] = 2] = "StringAxis";
|
|
38
39
|
})(YAxisType || (exports.YAxisType = YAxisType = {}));
|
|
40
|
+
function yAxisTickFormatterInternal(value, limitWidth) {
|
|
41
|
+
if (limitWidth === void 0) { limitWidth = false; }
|
|
42
|
+
// Use SI format prefix with 2 decimal places without insignificant trailing zeros
|
|
43
|
+
var formatter = (0, d3_format_2.formatPrefix)('.2~', value);
|
|
44
|
+
if (Math.abs(value) < 1) {
|
|
45
|
+
// Don't use SI notation for small numbers as it is less readable
|
|
46
|
+
formatter = (0, d3_format_1.format)('.2~g');
|
|
47
|
+
}
|
|
48
|
+
else if (limitWidth && Math.abs(value) >= 1000) {
|
|
49
|
+
// If width is limited, use SI format prefix with 1 point precision
|
|
50
|
+
formatter = (0, d3_format_2.formatPrefix)('.1~', value);
|
|
51
|
+
}
|
|
52
|
+
var formattedValue = formatter(value);
|
|
53
|
+
// Replace 'G' with 'B' if the value is greater than 10^9 as it is a more common convention
|
|
54
|
+
if (Math.abs(value) >= 1e9) {
|
|
55
|
+
return formattedValue.replace('G', 'B');
|
|
56
|
+
}
|
|
57
|
+
return formattedValue;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Formatter for y axis ticks.
|
|
61
|
+
* @param value - The number to format.
|
|
62
|
+
* @returns The formatted string .
|
|
63
|
+
*/
|
|
64
|
+
function defaultYAxisTickFormatter(value) {
|
|
65
|
+
return yAxisTickFormatterInternal(value);
|
|
66
|
+
}
|
|
67
|
+
exports.defaultYAxisTickFormatter = defaultYAxisTickFormatter;
|
|
39
68
|
/**
|
|
40
69
|
* Create Numeric X axis
|
|
41
70
|
* @export
|
|
@@ -43,7 +72,7 @@ var YAxisType;
|
|
|
43
72
|
*/
|
|
44
73
|
function createNumericXAxis(xAxisParams, tickParams, chartType, culture) {
|
|
45
74
|
var _a;
|
|
46
|
-
var domainNRangeValues = xAxisParams.domainNRangeValues, _b = xAxisParams.showRoundOffXTickValues, showRoundOffXTickValues = _b === void 0 ?
|
|
75
|
+
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;
|
|
47
76
|
var xAxisScale = (0, d3_scale_1.scaleLinear)()
|
|
48
77
|
.domain([domainNRangeValues.dStartValue, domainNRangeValues.dEndValue])
|
|
49
78
|
.range([domainNRangeValues.rStartValue, domainNRangeValues.rEndValue]);
|
|
@@ -79,16 +108,75 @@ function createNumericXAxis(xAxisParams, tickParams, chartType, culture) {
|
|
|
79
108
|
return { xScale: xAxisScale, tickValues: tickValues };
|
|
80
109
|
}
|
|
81
110
|
exports.createNumericXAxis = createNumericXAxis;
|
|
82
|
-
|
|
111
|
+
/**
|
|
112
|
+
* This function returns a multilevel formatter for a given date range.
|
|
113
|
+
* It determines the appropriate date format to accommodate each tick value.
|
|
114
|
+
* The goal is to represent the date label in the smallest possible format without loss of information.
|
|
115
|
+
* The challenge here is to adhere to locale specific formats while ensuring the complete label is shown.
|
|
116
|
+
* There is an exhaustive map of all possible date/time units and their respective formats.
|
|
117
|
+
* Based on the range of formatting granularity levels, a format spanning the range is returned.
|
|
118
|
+
* @param startLevel - The starting level of the date format.
|
|
119
|
+
* @param endLevel - The ending level of the date format.
|
|
120
|
+
* @param locale - The locale object for formatting.
|
|
121
|
+
* @param useUTC
|
|
122
|
+
* @returns
|
|
123
|
+
*/
|
|
124
|
+
function getMultiLevelDateFormatter(startLevel, endLevel, locale, useUTC) {
|
|
83
125
|
var timeFormat = locale ? (useUTC ? locale.utcFormat : locale.format) : useUTC ? d3_time_format_1.utcFormat : d3_time_format_1.timeFormat;
|
|
84
|
-
|
|
85
|
-
var
|
|
86
|
-
var
|
|
87
|
-
var
|
|
88
|
-
var
|
|
89
|
-
var
|
|
90
|
-
var
|
|
91
|
-
var
|
|
126
|
+
// Refer to https://d3js.org/d3-time-format#locale_format to see explanation about each format specifier
|
|
127
|
+
var DEFAULT = '%c';
|
|
128
|
+
var MS = '.%L';
|
|
129
|
+
var MS_S = ':%S.%L';
|
|
130
|
+
var MS_S_MIN = '%M:%S.%L';
|
|
131
|
+
var MS_S_MIN_H = '%-I:%M:%S.%L %p';
|
|
132
|
+
var MS_S_MIN_H_D = '%a %d, %X';
|
|
133
|
+
var MS_S_MIN_H_D_W = '%b %d, %X';
|
|
134
|
+
var MS_S_MIN_H_D_W_M = MS_S_MIN_H_D_W;
|
|
135
|
+
var MS_S_MIN_H_D_W_M_Y = DEFAULT;
|
|
136
|
+
var S = ':%S';
|
|
137
|
+
var S_MIN = '%-I:%M:%S';
|
|
138
|
+
var S_MIN_H = '%X';
|
|
139
|
+
var S_MIN_H_D = MS_S_MIN_H_D;
|
|
140
|
+
var S_MIN_H_D_W = MS_S_MIN_H_D_W;
|
|
141
|
+
var S_MIN_H_D_W_M = MS_S_MIN_H_D_W_M;
|
|
142
|
+
var S_MIN_H_D_W_M_Y = DEFAULT;
|
|
143
|
+
var MIN = '%-I:%M %p';
|
|
144
|
+
var MIN_H = MIN;
|
|
145
|
+
var MIN_H_D = '%a %d, %-I:%M %p';
|
|
146
|
+
var MIN_H_D_W = '%b %d, %-I:%M %p';
|
|
147
|
+
var MIN_H_D_W_M = MIN_H_D_W;
|
|
148
|
+
var MIN_H_D_W_M_Y = '%x, %-I:%M %p';
|
|
149
|
+
var H = '%-I %p';
|
|
150
|
+
var H_D = '%a %d, %-I %p';
|
|
151
|
+
var H_D_W = '%b %d, %-I %p';
|
|
152
|
+
var H_D_W_M = H_D_W;
|
|
153
|
+
var H_D_W_M_Y = '%x, %-I %p';
|
|
154
|
+
var D = '%a %d';
|
|
155
|
+
var D_W = '%b %d';
|
|
156
|
+
var D_W_M = D_W;
|
|
157
|
+
var D_W_M_Y = '%x';
|
|
158
|
+
var W = D_W;
|
|
159
|
+
var W_M = W;
|
|
160
|
+
var W_M_Y = D_W_M_Y;
|
|
161
|
+
var M = '%B';
|
|
162
|
+
var M_Y = '%b %Y';
|
|
163
|
+
var Y = '%Y';
|
|
164
|
+
var MULTI_LEVEL_DATE_TIME_FORMATS = [
|
|
165
|
+
// ms, s, min, h, d, w, m, y
|
|
166
|
+
[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
|
|
167
|
+
[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
|
|
168
|
+
[DEFAULT, DEFAULT, MIN, MIN_H, MIN_H_D, MIN_H_D_W, MIN_H_D_W_M, MIN_H_D_W_M_Y], // min
|
|
169
|
+
[DEFAULT, DEFAULT, DEFAULT, H, H_D, H_D_W, H_D_W_M, H_D_W_M_Y], // h
|
|
170
|
+
[DEFAULT, DEFAULT, DEFAULT, DEFAULT, D, D_W, D_W_M, D_W_M_Y], // d
|
|
171
|
+
[DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, W, W_M, W_M_Y], // w
|
|
172
|
+
[DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, M, M_Y], // m
|
|
173
|
+
[DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, Y], // y
|
|
174
|
+
];
|
|
175
|
+
var formatter = timeFormat(MULTI_LEVEL_DATE_TIME_FORMATS[startLevel][endLevel]);
|
|
176
|
+
return formatter;
|
|
177
|
+
}
|
|
178
|
+
function getDateFormatLevel(date, useUTC) {
|
|
179
|
+
var _a;
|
|
92
180
|
var timeSecond = useUTC ? d3_time_1.utcSecond : d3_time_1.timeSecond;
|
|
93
181
|
var timeMinute = useUTC ? d3_time_1.utcMinute : d3_time_1.timeMinute;
|
|
94
182
|
var timeHour = useUTC ? d3_time_1.utcHour : d3_time_1.timeHour;
|
|
@@ -96,21 +184,21 @@ function multiFormat(date, locale, useUTC) {
|
|
|
96
184
|
var timeMonth = useUTC ? d3_time_1.utcMonth : d3_time_1.timeMonth;
|
|
97
185
|
var timeWeek = useUTC ? d3_time_1.utcWeek : d3_time_1.timeWeek;
|
|
98
186
|
var timeYear = useUTC ? d3_time_1.utcYear : d3_time_1.timeYear;
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
: timeMinute(
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
187
|
+
var formats = [
|
|
188
|
+
{ formatLevel: 0, condition: function (d) { return timeSecond(d) < d; } }, // Milliseconds
|
|
189
|
+
{ formatLevel: 1, condition: function (d) { return timeMinute(d) < d; } }, // Seconds
|
|
190
|
+
{ formatLevel: 2, condition: function (d) { return timeHour(d) < d; } }, // Minutes
|
|
191
|
+
{ formatLevel: 3, condition: function (d) { return timeDay(d) < d; } }, // Hours
|
|
192
|
+
{ formatLevel: 4, condition: function (d) { return timeMonth(d) < d && timeWeek(d) < d; } }, // Days
|
|
193
|
+
{ formatLevel: 5, condition: function (d) { return timeMonth(d) < d; } }, // Weeks
|
|
194
|
+
{ formatLevel: 6, condition: function (d) { return timeYear(d) < d; } }, // Months
|
|
195
|
+
{ formatLevel: 7, condition: function () { return true; } }, // Years (default)
|
|
196
|
+
];
|
|
197
|
+
var matchedFormat = formats.find(function (_a) {
|
|
198
|
+
var condition = _a.condition;
|
|
199
|
+
return condition(date);
|
|
200
|
+
});
|
|
201
|
+
return (_a = matchedFormat === null || matchedFormat === void 0 ? void 0 : matchedFormat.formatLevel) !== null && _a !== void 0 ? _a : 7;
|
|
114
202
|
}
|
|
115
203
|
function isPowerOf10(num) {
|
|
116
204
|
var roundedfinalYMax = handleFloatingPointPrecisionError(num);
|
|
@@ -129,12 +217,26 @@ function handleFloatingPointPrecisionError(num) {
|
|
|
129
217
|
*/
|
|
130
218
|
function createDateXAxis(xAxisParams, tickParams, culture, options, timeFormatLocale, customDateTimeFormatter, useUTC) {
|
|
131
219
|
var _a;
|
|
132
|
-
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
|
|
220
|
+
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;
|
|
133
221
|
var xAxisScale = useUTC ? (0, d3_scale_1.scaleUtc)() : (0, d3_scale_1.scaleTime)();
|
|
134
222
|
xAxisScale
|
|
135
223
|
.domain([domainNRangeValues.dStartValue, domainNRangeValues.dEndValue])
|
|
136
|
-
.range([domainNRangeValues.rStartValue, domainNRangeValues.rEndValue])
|
|
224
|
+
.range([domainNRangeValues.rStartValue, domainNRangeValues.rEndValue])
|
|
225
|
+
.nice();
|
|
137
226
|
var tickCount = xAxisCount !== null && xAxisCount !== void 0 ? xAxisCount : 6;
|
|
227
|
+
var lowestFormatLevel = 100;
|
|
228
|
+
var highestFormatLevel = -1;
|
|
229
|
+
var locale = timeFormatLocale ? (0, d3_time_format_1.timeFormatLocale)(timeFormatLocale) : undefined;
|
|
230
|
+
xAxisScale.ticks().forEach(function (domainValue) {
|
|
231
|
+
var formatLevel = getDateFormatLevel(domainValue, useUTC);
|
|
232
|
+
if (formatLevel > highestFormatLevel) {
|
|
233
|
+
highestFormatLevel = formatLevel;
|
|
234
|
+
}
|
|
235
|
+
if (formatLevel < lowestFormatLevel) {
|
|
236
|
+
lowestFormatLevel = formatLevel;
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
var formatFn = getMultiLevelDateFormatter(lowestFormatLevel, highestFormatLevel, locale, useUTC);
|
|
138
240
|
var tickFormat = function (domainValue, _index) {
|
|
139
241
|
if (customDateTimeFormatter) {
|
|
140
242
|
return customDateTimeFormatter(domainValue);
|
|
@@ -143,8 +245,7 @@ function createDateXAxis(xAxisParams, tickParams, culture, options, timeFormatLo
|
|
|
143
245
|
return domainValue.toLocaleString(culture, options);
|
|
144
246
|
}
|
|
145
247
|
if (timeFormatLocale) {
|
|
146
|
-
|
|
147
|
-
return multiFormat(domainValue, locale, useUTC);
|
|
248
|
+
return formatFn(domainValue);
|
|
148
249
|
}
|
|
149
250
|
if (culture === undefined && tickParams.tickFormat) {
|
|
150
251
|
if (useUTC) {
|
|
@@ -154,13 +255,12 @@ function createDateXAxis(xAxisParams, tickParams, culture, options, timeFormatLo
|
|
|
154
255
|
return (0, d3_time_format_1.timeFormat)(tickParams.tickFormat)(domainValue);
|
|
155
256
|
}
|
|
156
257
|
}
|
|
157
|
-
return
|
|
258
|
+
return formatFn(domainValue);
|
|
158
259
|
};
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
}
|
|
260
|
+
var longestLabelWidth = (0, exports.calculateLongestLabelWidth)(xAxisScale.ticks().map(tickFormat), '[class^="xAxis-"] text') + 40;
|
|
261
|
+
var _d = xAxisScale.range(), start = _d[0], end = _d[1];
|
|
262
|
+
tickCount = Math.min(Math.max(1, Math.floor(Math.abs(end - start) / longestLabelWidth)), 10);
|
|
263
|
+
tickCount = Math.min(tickCount, xAxisCount !== null && xAxisCount !== void 0 ? xAxisCount : tickCount);
|
|
164
264
|
var xAxis = (0, d3_axis_1.axisBottom)(xAxisScale)
|
|
165
265
|
.tickSize(xAxistickSize)
|
|
166
266
|
.tickPadding(tickPadding)
|
|
@@ -291,17 +391,16 @@ function prepareDatapoints(maxVal, minVal, splitInto, isIntegralDataset, rounded
|
|
|
291
391
|
exports.prepareDatapoints = prepareDatapoints;
|
|
292
392
|
function createYAxisForHorizontalBarChartWithAxis(yAxisParams, isRtl) {
|
|
293
393
|
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;
|
|
294
|
-
// maxOfYVal coming from
|
|
394
|
+
// maxOfYVal coming from horizontal bar chart with axis (Calculation done at base file)
|
|
295
395
|
var tempVal = maxOfYVal || yMinMaxValues.endValue;
|
|
296
396
|
var finalYmax = tempVal > yMaxValue ? tempVal : yMaxValue;
|
|
297
397
|
var finalYmin = yMinMaxValues.startValue < yMinValue ? Math.min(0, yMinMaxValues.startValue) : yMinValue;
|
|
298
|
-
var yDomainPadding = Math.abs(finalYmax - finalYmin) * 0.1;
|
|
299
398
|
var yAxisScale = (0, d3_scale_1.scaleLinear)()
|
|
300
|
-
.domain([finalYmin
|
|
399
|
+
.domain([finalYmin, finalYmax])
|
|
301
400
|
.range([containerHeight - margins.bottom, margins.top]);
|
|
302
401
|
var axis = isRtl ? (0, d3_axis_1.axisRight)(yAxisScale) : (0, d3_axis_1.axisLeft)(yAxisScale);
|
|
303
402
|
var yAxis = axis.tickPadding(tickPadding).ticks(yAxisTickCount);
|
|
304
|
-
yAxisTickFormat ? yAxis.tickFormat(yAxisTickFormat) : yAxis.tickFormat(
|
|
403
|
+
yAxisTickFormat ? yAxis.tickFormat(yAxisTickFormat) : yAxis.tickFormat(defaultYAxisTickFormatter);
|
|
305
404
|
yAxisElement ? (0, d3_selection_1.select)(yAxisElement).call(yAxis).selectAll('text').attr('aria-hidden', 'true') : '';
|
|
306
405
|
return yAxisScale;
|
|
307
406
|
}
|
|
@@ -328,7 +427,7 @@ function createNumericYAxis(yAxisParams, isRtl, axisData, isIntegralDataset, use
|
|
|
328
427
|
.tickPadding(tickPadding)
|
|
329
428
|
.tickValues(domainValues)
|
|
330
429
|
.tickSizeInner(-(containerWidth - margins.left - margins.right));
|
|
331
|
-
yAxisTickFormat ? yAxis.tickFormat(yAxisTickFormat) : yAxis.tickFormat(
|
|
430
|
+
yAxisTickFormat ? yAxis.tickFormat(yAxisTickFormat) : yAxis.tickFormat(defaultYAxisTickFormatter);
|
|
332
431
|
yAxisElement ? (0, d3_selection_1.select)(yAxisElement).call(yAxis).selectAll('text').attr('aria-hidden', 'true') : '';
|
|
333
432
|
axisData.yAxisDomainValues = domainValues;
|
|
334
433
|
return yAxisScale;
|
|
@@ -341,10 +440,13 @@ exports.createNumericYAxis = createNumericYAxis;
|
|
|
341
440
|
* @param isRtl
|
|
342
441
|
*/
|
|
343
442
|
var createStringYAxisForHorizontalBarChartWithAxis = function (yAxisParams, dataPoints, isRtl, barWidth) {
|
|
344
|
-
var containerHeight = yAxisParams.containerHeight, _a = yAxisParams.tickPadding, tickPadding = _a === void 0 ? 12 : _a, margins = yAxisParams.margins, yAxisTickFormat = yAxisParams.yAxisTickFormat, yAxisElement = yAxisParams.yAxisElement;
|
|
443
|
+
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;
|
|
444
|
+
var yAxisPaddingValue = yAxisPadding !== null && yAxisPadding !== void 0 ? yAxisPadding : 0.5;
|
|
445
|
+
yAxisPaddingValue = yAxisPaddingValue === 1 ? 0.99 : yAxisPaddingValue;
|
|
345
446
|
var yAxisScale = (0, d3_scale_1.scaleBand)()
|
|
346
447
|
.domain(dataPoints)
|
|
347
|
-
.range([containerHeight - margins.bottom
|
|
448
|
+
.range([containerHeight - margins.bottom, margins.top])
|
|
449
|
+
.padding(yAxisPaddingValue);
|
|
348
450
|
var axis = isRtl ? (0, d3_axis_1.axisRight)(yAxisScale) : (0, d3_axis_1.axisLeft)(yAxisScale);
|
|
349
451
|
var yAxis = axis.tickPadding(tickPadding).ticks(dataPoints);
|
|
350
452
|
if (yAxisTickFormat) {
|
|
@@ -1079,10 +1181,16 @@ var convertToLocaleString = function (data, culture) {
|
|
|
1079
1181
|
}
|
|
1080
1182
|
culture = culture || undefined;
|
|
1081
1183
|
if (typeof data === 'number') {
|
|
1184
|
+
if (Math.abs(data) < 10000) {
|
|
1185
|
+
return data.toString();
|
|
1186
|
+
}
|
|
1082
1187
|
return data.toLocaleString(culture);
|
|
1083
1188
|
}
|
|
1084
1189
|
else if (typeof data === 'string' && !window.isNaN(Number(data))) {
|
|
1085
1190
|
var num = Number(data);
|
|
1191
|
+
if (Math.abs(num) < 10000) {
|
|
1192
|
+
return num.toString();
|
|
1193
|
+
}
|
|
1086
1194
|
return num.toLocaleString(culture);
|
|
1087
1195
|
}
|
|
1088
1196
|
else if (data instanceof Date) {
|
|
@@ -1168,17 +1276,10 @@ function wrapTextInsideDonut(selectorClass, maxWidth) {
|
|
|
1168
1276
|
});
|
|
1169
1277
|
}
|
|
1170
1278
|
exports.wrapTextInsideDonut = wrapTextInsideDonut;
|
|
1171
|
-
function
|
|
1172
|
-
|
|
1173
|
-
if (value < 1000) {
|
|
1174
|
-
specifier = '.2~'; // upto 2 decimal places without insignificant trailing zeros
|
|
1175
|
-
}
|
|
1176
|
-
else {
|
|
1177
|
-
specifier = '.1'; // upto 1 decimal place
|
|
1178
|
-
}
|
|
1179
|
-
return (0, d3_format_2.formatPrefix)(specifier, value)(value);
|
|
1279
|
+
function formatValueLimitWidth(value) {
|
|
1280
|
+
return yAxisTickFormatterInternal(value, true);
|
|
1180
1281
|
}
|
|
1181
|
-
exports.
|
|
1282
|
+
exports.formatValueLimitWidth = formatValueLimitWidth;
|
|
1182
1283
|
var DEFAULT_BAR_WIDTH = 16;
|
|
1183
1284
|
var MIN_BAR_WIDTH = 1;
|
|
1184
1285
|
var getBarWidth = function (barWidthProp, maxBarWidthProp, adjustedValue, modeProp) {
|