@fluentui/react-charting 5.24.23 → 5.24.25
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 +37 -1
- package/CHANGELOG.md +21 -2
- package/dist/react-charting.d.ts +59 -1
- package/dist/react-charting.js +1 -1
- package/dist/react-charting.min.js +1 -1
- package/etc/react-charting.api.md +10 -0
- package/lib/components/CommonComponents/CartesianChart.base.js +11 -5
- package/lib/components/CommonComponents/CartesianChart.base.js.map +1 -1
- package/lib/components/CommonComponents/CartesianChart.types.d.ts +16 -1
- package/lib/components/CommonComponents/CartesianChart.types.js.map +1 -1
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.d.ts +1 -1
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +167 -30
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib/components/GaugeChart/GaugeChart.base.d.ts +1 -1
- package/lib/components/ScatterChart/ScatterChart.base.js +66 -13
- package/lib/components/ScatterChart/ScatterChart.base.js.map +1 -1
- package/lib/components/ScatterChart/ScatterChart.types.d.ts +4 -0
- package/lib/components/ScatterChart/ScatterChart.types.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js.map +1 -1
- package/lib/types/IDataPoint.d.ts +37 -0
- package/lib/types/IDataPoint.js.map +1 -1
- package/lib/utilities/utilities.d.ts +17 -13
- package/lib/utilities/utilities.js +131 -17
- package/lib/utilities/utilities.js.map +1 -1
- package/lib-amd/components/CommonComponents/CartesianChart.base.js +11 -5
- package/lib-amd/components/CommonComponents/CartesianChart.base.js.map +1 -1
- package/lib-amd/components/CommonComponents/CartesianChart.types.d.ts +16 -1
- package/lib-amd/components/CommonComponents/CartesianChart.types.js.map +1 -1
- package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.d.ts +1 -1
- package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js +171 -35
- package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib-amd/components/FunnelChart/funnelGeometry.js +5 -6
- package/lib-amd/components/FunnelChart/funnelGeometry.js.map +1 -1
- package/lib-amd/components/GaugeChart/GaugeChart.base.d.ts +1 -1
- package/lib-amd/components/ResponsiveContainer/withResponsiveContainer.js +1 -2
- package/lib-amd/components/ResponsiveContainer/withResponsiveContainer.js.map +1 -1
- package/lib-amd/components/SankeyChart/SankeyChart.base.js +4 -4
- package/lib-amd/components/SankeyChart/SankeyChart.base.js.map +1 -1
- package/lib-amd/components/ScatterChart/ScatterChart.base.js +64 -11
- package/lib-amd/components/ScatterChart/ScatterChart.base.js.map +1 -1
- package/lib-amd/components/ScatterChart/ScatterChart.types.d.ts +4 -0
- package/lib-amd/components/ScatterChart/ScatterChart.types.js.map +1 -1
- package/lib-amd/index.d.ts +1 -1
- package/lib-amd/index.js.map +1 -1
- package/lib-amd/types/IDataPoint.d.ts +37 -0
- package/lib-amd/types/IDataPoint.js.map +1 -1
- package/lib-amd/utilities/image-export-utils.js +2 -3
- package/lib-amd/utilities/image-export-utils.js.map +1 -1
- package/lib-amd/utilities/scatterpolar-utils.js +2 -3
- package/lib-amd/utilities/scatterpolar-utils.js.map +1 -1
- package/lib-amd/utilities/utilities.d.ts +17 -13
- package/lib-amd/utilities/utilities.js +170 -54
- package/lib-amd/utilities/utilities.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/CartesianChart.base.js +11 -5
- package/lib-commonjs/components/CommonComponents/CartesianChart.base.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/CartesianChart.types.d.ts +16 -1
- package/lib-commonjs/components/CommonComponents/CartesianChart.types.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.d.ts +1 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +171 -34
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib-commonjs/components/FunnelChart/funnelGeometry.js +5 -6
- package/lib-commonjs/components/FunnelChart/funnelGeometry.js.map +1 -1
- package/lib-commonjs/components/GaugeChart/GaugeChart.base.d.ts +1 -1
- package/lib-commonjs/components/ResponsiveContainer/withResponsiveContainer.js +1 -2
- package/lib-commonjs/components/ResponsiveContainer/withResponsiveContainer.js.map +1 -1
- package/lib-commonjs/components/SankeyChart/SankeyChart.base.js +4 -4
- package/lib-commonjs/components/SankeyChart/SankeyChart.base.js.map +1 -1
- package/lib-commonjs/components/ScatterChart/ScatterChart.base.js +64 -11
- package/lib-commonjs/components/ScatterChart/ScatterChart.base.js.map +1 -1
- package/lib-commonjs/components/ScatterChart/ScatterChart.types.d.ts +4 -0
- package/lib-commonjs/components/ScatterChart/ScatterChart.types.js.map +1 -1
- package/lib-commonjs/index.d.ts +1 -1
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/types/IDataPoint.d.ts +37 -0
- package/lib-commonjs/types/IDataPoint.js.map +1 -1
- package/lib-commonjs/utilities/image-export-utils.js +2 -3
- package/lib-commonjs/utilities/image-export-utils.js.map +1 -1
- package/lib-commonjs/utilities/scatterpolar-utils.js +2 -3
- package/lib-commonjs/utilities/scatterpolar-utils.js.map +1 -1
- package/lib-commonjs/utilities/utilities.d.ts +17 -13
- package/lib-commonjs/utilities/utilities.js +170 -55
- package/lib-commonjs/utilities/utilities.js.map +1 -1
- package/package.json +2 -2
- package/src/components/CommonComponents/CartesianChart.types.ts +19 -0
- package/src/components/ScatterChart/ScatterChart.types.ts +5 -0
|
@@ -1,8 +1,45 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var _a;
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.
|
|
5
|
-
exports.
|
|
4
|
+
exports.generateMonthlyTicks = exports.generateLinearTicks = exports.getRangeForScatterMarkerSize = exports.getScatterXDomainExtent = exports.isPlottable = exports.isValidDomainValue = exports.getDomainPaddingForMarkers = exports.getInvertedTextColor = exports.sortAxisCategories = exports.truncateString = exports.createMeasurementSpan = exports.isScalePaddingDefined = exports.getScalePadding = exports.getBarWidth = exports.getAccessibleDataObject = exports.pointTypes = exports.CustomPoints = exports.Points = exports.getTypeOfAxis = exports.calculateLongestLabelWidth = exports.wrapContent = exports.DEFAULT_WRAP_WIDTH = exports.createStringYAxis = exports.createStringYAxisForHorizontalBarChartWithAxis = exports.YAxisType = exports.XAxisTypes = exports.ChartTypes = exports.DEFAULT_DATE_STRING = exports.MIN_DONUT_RADIUS = exports.MIN_DOMAIN_MARGIN = void 0;
|
|
5
|
+
exports.defaultYAxisTickFormatter = defaultYAxisTickFormatter;
|
|
6
|
+
exports.createNumericXAxis = createNumericXAxis;
|
|
7
|
+
exports.getDateFormatLevel = getDateFormatLevel;
|
|
8
|
+
exports.createDateXAxis = createDateXAxis;
|
|
9
|
+
exports.createStringXAxis = createStringXAxis;
|
|
10
|
+
exports.prepareDatapoints = prepareDatapoints;
|
|
11
|
+
exports.createYAxisForHorizontalBarChartWithAxis = createYAxisForHorizontalBarChartWithAxis;
|
|
12
|
+
exports.createNumericYAxis = createNumericYAxis;
|
|
13
|
+
exports.calloutData = calloutData;
|
|
14
|
+
exports.getUnique = getUnique;
|
|
15
|
+
exports.silceOrAppendToArray = silceOrAppendToArray;
|
|
16
|
+
exports.createWrapOfXLabels = createWrapOfXLabels;
|
|
17
|
+
exports.createYAxisLabels = createYAxisLabels;
|
|
18
|
+
exports.tooltipOfAxislabels = tooltipOfAxislabels;
|
|
19
|
+
exports.getXAxisType = getXAxisType;
|
|
20
|
+
exports.domainRangeOfNumericForAreaLineScatterCharts = domainRangeOfNumericForAreaLineScatterCharts;
|
|
21
|
+
exports.groupChartDataByYValue = groupChartDataByYValue;
|
|
22
|
+
exports.computeLongestBars = computeLongestBars;
|
|
23
|
+
exports.domainRangeOfNumericForHorizontalBarChartWithAxis = domainRangeOfNumericForHorizontalBarChartWithAxis;
|
|
24
|
+
exports.domainRangeOfXStringAxis = domainRangeOfXStringAxis;
|
|
25
|
+
exports.domainRangeOfVSBCNumeric = domainRangeOfVSBCNumeric;
|
|
26
|
+
exports.domainRangeOfDateForAreaLineScatterVerticalBarCharts = domainRangeOfDateForAreaLineScatterVerticalBarCharts;
|
|
27
|
+
exports.domainRageOfVerticalNumeric = domainRageOfVerticalNumeric;
|
|
28
|
+
exports.findNumericMinMaxOfY = findNumericMinMaxOfY;
|
|
29
|
+
exports.findVSBCNumericMinMaxOfY = findVSBCNumericMinMaxOfY;
|
|
30
|
+
exports.findVerticalNumericMinMaxOfY = findVerticalNumericMinMaxOfY;
|
|
31
|
+
exports.findHBCWANumericMinMaxOfY = findHBCWANumericMinMaxOfY;
|
|
32
|
+
exports.rotateXAxisLabels = rotateXAxisLabels;
|
|
33
|
+
exports.wrapTextInsideDonut = wrapTextInsideDonut;
|
|
34
|
+
exports.formatScientificLimitWidth = formatScientificLimitWidth;
|
|
35
|
+
exports.getSecureProps = getSecureProps;
|
|
36
|
+
exports.areArraysEqual = areArraysEqual;
|
|
37
|
+
exports.resolveCSSVariables = resolveCSSVariables;
|
|
38
|
+
exports.copyStyle = copyStyle;
|
|
39
|
+
exports.getCurveFactory = getCurveFactory;
|
|
40
|
+
exports.getContrastTextColor = getContrastTextColor;
|
|
41
|
+
exports.isScatterPolarSeries = isScatterPolarSeries;
|
|
42
|
+
exports.isTextMode = isTextMode;
|
|
6
43
|
var tslib_1 = require("tslib");
|
|
7
44
|
var d3_axis_1 = require("d3-axis");
|
|
8
45
|
var d3_array_1 = require("d3-array");
|
|
@@ -18,6 +55,7 @@ var chart_utilities_1 = require("@fluentui/chart-utilities");
|
|
|
18
55
|
var colors_1 = require("./colors");
|
|
19
56
|
exports.MIN_DOMAIN_MARGIN = 8;
|
|
20
57
|
exports.MIN_DONUT_RADIUS = 1;
|
|
58
|
+
exports.DEFAULT_DATE_STRING = '2000-01-01';
|
|
21
59
|
var ChartTypes;
|
|
22
60
|
(function (ChartTypes) {
|
|
23
61
|
ChartTypes[ChartTypes["AreaChart"] = 0] = "AreaChart";
|
|
@@ -69,15 +107,13 @@ function yAxisTickFormatterInternal(value, limitWidth) {
|
|
|
69
107
|
function defaultYAxisTickFormatter(value) {
|
|
70
108
|
return yAxisTickFormatterInternal(value);
|
|
71
109
|
}
|
|
72
|
-
exports.defaultYAxisTickFormatter = defaultYAxisTickFormatter;
|
|
73
110
|
/**
|
|
74
111
|
* Create Numeric X axis
|
|
75
112
|
* @export
|
|
76
113
|
* @param {IXAxisParams} xAxisParams
|
|
77
114
|
*/
|
|
78
115
|
function createNumericXAxis(xAxisParams, tickParams, chartType, culture, scaleType) {
|
|
79
|
-
var _a;
|
|
80
|
-
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, calcMaxLabelWidth = xAxisParams.calcMaxLabelWidth;
|
|
116
|
+
var domainNRangeValues = xAxisParams.domainNRangeValues, _a = xAxisParams.showRoundOffXTickValues, showRoundOffXTickValues = _a === void 0 ? true : _a, _b = xAxisParams.xAxistickSize, xAxistickSize = _b === void 0 ? 6 : _b, _c = xAxisParams.tickPadding, tickPadding = _c === void 0 ? 10 : _c, xAxisCount = xAxisParams.xAxisCount, xAxisElement = xAxisParams.xAxisElement, hideTickOverlap = xAxisParams.hideTickOverlap, calcMaxLabelWidth = xAxisParams.calcMaxLabelWidth, tickStep = xAxisParams.tickStep, tick0 = xAxisParams.tick0;
|
|
81
117
|
var xAxisScale = createNumericScale(scaleType)
|
|
82
118
|
.domain([domainNRangeValues.dStartValue, domainNRangeValues.dEndValue])
|
|
83
119
|
.range([domainNRangeValues.rStartValue, domainNRangeValues.rEndValue]);
|
|
@@ -92,7 +128,7 @@ function createNumericXAxis(xAxisParams, tickParams, chartType, culture, scaleTy
|
|
|
92
128
|
};
|
|
93
129
|
if (hideTickOverlap && typeof xAxisCount === 'undefined') {
|
|
94
130
|
var longestLabelWidth = calcMaxLabelWidth(xAxisScale.ticks().map(function (v, i) { return tickFormat(v, i); })) + 20;
|
|
95
|
-
var
|
|
131
|
+
var _d = xAxisScale.range(), start = _d[0], end = _d[1];
|
|
96
132
|
tickCount = Math.min(Math.max(1, Math.floor(Math.abs(end - start) / longestLabelWidth)), 10);
|
|
97
133
|
}
|
|
98
134
|
var xAxis = (0, d3_axis_1.axisBottom)(xAxisScale)
|
|
@@ -103,16 +139,22 @@ function createNumericXAxis(xAxisParams, tickParams, chartType, culture, scaleTy
|
|
|
103
139
|
if ([ChartTypes.HorizontalBarChartWithAxis, ChartTypes.GanttChart].includes(chartType)) {
|
|
104
140
|
xAxis.tickSizeInner(-(xAxisParams.containerHeight - xAxisParams.margins.top));
|
|
105
141
|
}
|
|
142
|
+
var customTickValues;
|
|
106
143
|
if (tickParams.tickValues) {
|
|
107
|
-
|
|
144
|
+
customTickValues = tickParams.tickValues;
|
|
145
|
+
}
|
|
146
|
+
else if (tickStep) {
|
|
147
|
+
customTickValues = generateNumericTicks(scaleType, tickStep, tick0, xAxisScale.domain());
|
|
148
|
+
}
|
|
149
|
+
if (customTickValues) {
|
|
150
|
+
xAxis.tickValues(customTickValues);
|
|
108
151
|
}
|
|
109
152
|
if (xAxisElement) {
|
|
110
153
|
(0, d3_selection_1.select)(xAxisElement).call(xAxis).selectAll('text').attr('aria-hidden', 'true');
|
|
111
154
|
}
|
|
112
|
-
var tickValues = (
|
|
155
|
+
var tickValues = (customTickValues !== null && customTickValues !== void 0 ? customTickValues : xAxisScale.ticks(tickCount)).map(xAxis.tickFormat());
|
|
113
156
|
return { xScale: xAxisScale, tickValues: tickValues };
|
|
114
157
|
}
|
|
115
|
-
exports.createNumericXAxis = createNumericXAxis;
|
|
116
158
|
/**
|
|
117
159
|
* This function returns a multilevel formatter for a given date range.
|
|
118
160
|
* It determines the appropriate date format to accommodate each tick value.
|
|
@@ -205,7 +247,6 @@ function getDateFormatLevel(date, useUTC) {
|
|
|
205
247
|
});
|
|
206
248
|
return (_a = matchedFormat === null || matchedFormat === void 0 ? void 0 : matchedFormat.formatLevel) !== null && _a !== void 0 ? _a : 7;
|
|
207
249
|
}
|
|
208
|
-
exports.getDateFormatLevel = getDateFormatLevel;
|
|
209
250
|
function isPowerOf10(num) {
|
|
210
251
|
var roundedfinalYMax = (0, chart_utilities_1.handleFloatingPointPrecisionError)(num);
|
|
211
252
|
return Math.log10(roundedfinalYMax) % 1 === 0;
|
|
@@ -217,8 +258,7 @@ function isPowerOf10(num) {
|
|
|
217
258
|
* @param {ITickParams} tickParams
|
|
218
259
|
*/
|
|
219
260
|
function createDateXAxis(xAxisParams, tickParams, culture, options, timeFormatLocale, customDateTimeFormatter, useUTC, chartType) {
|
|
220
|
-
var _a;
|
|
221
|
-
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, calcMaxLabelWidth = xAxisParams.calcMaxLabelWidth;
|
|
261
|
+
var domainNRangeValues = xAxisParams.domainNRangeValues, xAxisElement = xAxisParams.xAxisElement, _a = xAxisParams.tickPadding, tickPadding = _a === void 0 ? 6 : _a, _b = xAxisParams.xAxistickSize, xAxistickSize = _b === void 0 ? 6 : _b, xAxisCount = xAxisParams.xAxisCount, calcMaxLabelWidth = xAxisParams.calcMaxLabelWidth, tickStep = xAxisParams.tickStep, tick0 = xAxisParams.tick0;
|
|
222
262
|
var xAxisScale = useUTC ? (0, d3_scale_1.scaleUtc)() : (0, d3_scale_1.scaleTime)();
|
|
223
263
|
xAxisScale
|
|
224
264
|
.domain([domainNRangeValues.dStartValue, domainNRangeValues.dEndValue])
|
|
@@ -257,7 +297,7 @@ function createDateXAxis(xAxisParams, tickParams, culture, options, timeFormatLo
|
|
|
257
297
|
return (0, chart_utilities_1.formatDateToLocaleString)(domainValue, culture, useUTC, false, formatOptions);
|
|
258
298
|
};
|
|
259
299
|
var longestLabelWidth = calcMaxLabelWidth(xAxisScale.ticks().map(tickFormat)) + 40;
|
|
260
|
-
var
|
|
300
|
+
var _c = xAxisScale.range(), start = _c[0], end = _c[1];
|
|
261
301
|
var maxPossibleTickCount = Math.min(Math.max(1, Math.floor(Math.abs(end - start) / longestLabelWidth)), 10);
|
|
262
302
|
tickCount = Math.min(maxPossibleTickCount, xAxisCount !== null && xAxisCount !== void 0 ? xAxisCount : tickCount);
|
|
263
303
|
var xAxis = (0, d3_axis_1.axisBottom)(xAxisScale)
|
|
@@ -268,14 +308,22 @@ function createDateXAxis(xAxisParams, tickParams, culture, options, timeFormatLo
|
|
|
268
308
|
if ([ChartTypes.GanttChart].includes(chartType)) {
|
|
269
309
|
xAxis.tickSizeInner(-(xAxisParams.containerHeight - xAxisParams.margins.top));
|
|
270
310
|
}
|
|
271
|
-
|
|
311
|
+
var customTickValues;
|
|
312
|
+
if (tickParams.tickValues) {
|
|
313
|
+
customTickValues = tickParams.tickValues;
|
|
314
|
+
}
|
|
315
|
+
else if (tickStep) {
|
|
316
|
+
customTickValues = generateDateTicks(tickStep, tick0, xAxisScale.domain(), useUTC);
|
|
317
|
+
}
|
|
318
|
+
if (customTickValues) {
|
|
319
|
+
xAxis.tickValues(customTickValues);
|
|
320
|
+
}
|
|
272
321
|
if (xAxisElement) {
|
|
273
322
|
(0, d3_selection_1.select)(xAxisElement).call(xAxis).selectAll('text').attr('aria-hidden', 'true');
|
|
274
323
|
}
|
|
275
|
-
var tickValues = (
|
|
324
|
+
var tickValues = (customTickValues !== null && customTickValues !== void 0 ? customTickValues : xAxisScale.ticks(tickCount)).map(xAxis.tickFormat());
|
|
276
325
|
return { xScale: xAxisScale, tickValues: tickValues };
|
|
277
326
|
}
|
|
278
|
-
exports.createDateXAxis = createDateXAxis;
|
|
279
327
|
/**
|
|
280
328
|
* Create String X axis
|
|
281
329
|
* Currently using for only Vetical stacked bar chart and grouped vertical bar chart
|
|
@@ -328,7 +376,6 @@ function createStringXAxis(xAxisParams, tickParams, dataset, culture) {
|
|
|
328
376
|
}
|
|
329
377
|
return { xScale: xAxisScale, tickValues: tickValues };
|
|
330
378
|
}
|
|
331
|
-
exports.createStringXAxis = createStringXAxis;
|
|
332
379
|
/**
|
|
333
380
|
* This method is used to calculate the rounded tick values for the y-axis
|
|
334
381
|
* @param {number} minVal
|
|
@@ -390,9 +437,8 @@ function prepareDatapoints(maxVal, minVal, splitInto, isIntegralDataset, rounded
|
|
|
390
437
|
}
|
|
391
438
|
return dataPointsArray;
|
|
392
439
|
}
|
|
393
|
-
exports.prepareDatapoints = prepareDatapoints;
|
|
394
440
|
function createYAxisForHorizontalBarChartWithAxis(yAxisParams, isRtl) {
|
|
395
|
-
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;
|
|
441
|
+
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, tickValues = yAxisParams.tickValues, tickStep = yAxisParams.tickStep, tick0 = yAxisParams.tick0;
|
|
396
442
|
// maxOfYVal coming from horizontal bar chart with axis (Calculation done at base file)
|
|
397
443
|
var tempVal = maxOfYVal || yMinMaxValues.endValue;
|
|
398
444
|
var finalYmax = tempVal > yMaxValue ? tempVal : yMaxValue;
|
|
@@ -403,15 +449,24 @@ function createYAxisForHorizontalBarChartWithAxis(yAxisParams, isRtl) {
|
|
|
403
449
|
var axis = isRtl ? (0, d3_axis_1.axisRight)(yAxisScale) : (0, d3_axis_1.axisLeft)(yAxisScale);
|
|
404
450
|
var yAxis = axis.tickPadding(tickPadding).ticks(yAxisTickCount);
|
|
405
451
|
yAxisTickFormat ? yAxis.tickFormat(yAxisTickFormat) : yAxis.tickFormat(defaultYAxisTickFormatter);
|
|
452
|
+
var customTickValues;
|
|
453
|
+
if (tickValues) {
|
|
454
|
+
customTickValues = tickValues;
|
|
455
|
+
}
|
|
456
|
+
else if (tickStep) {
|
|
457
|
+
customTickValues = generateNumericTicks(undefined, tickStep, tick0, yAxisScale.domain());
|
|
458
|
+
}
|
|
459
|
+
if (customTickValues) {
|
|
460
|
+
yAxis.tickValues(customTickValues);
|
|
461
|
+
}
|
|
406
462
|
yAxisElement ? (0, d3_selection_1.select)(yAxisElement).call(yAxis).selectAll('text').attr('aria-hidden', 'true') : '';
|
|
407
463
|
return yAxisScale;
|
|
408
464
|
}
|
|
409
|
-
exports.createYAxisForHorizontalBarChartWithAxis = createYAxisForHorizontalBarChartWithAxis;
|
|
410
465
|
function createNumericYAxis(yAxisParams, isRtl, axisData, isIntegralDataset, useSecondaryYScale, supportNegativeData, roundedTicks, scaleType) {
|
|
411
466
|
if (useSecondaryYScale === void 0) { useSecondaryYScale = false; }
|
|
412
467
|
if (supportNegativeData === void 0) { supportNegativeData = false; }
|
|
413
468
|
if (roundedTicks === void 0) { roundedTicks = false; }
|
|
414
|
-
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, containerWidth = yAxisParams.containerWidth, 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, eventAnnotationProps = yAxisParams.eventAnnotationProps, eventLabelHeight = yAxisParams.eventLabelHeight;
|
|
469
|
+
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, containerWidth = yAxisParams.containerWidth, 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, eventAnnotationProps = yAxisParams.eventAnnotationProps, eventLabelHeight = yAxisParams.eventLabelHeight, tickValues = yAxisParams.tickValues, tickStep = yAxisParams.tickStep, tick0 = yAxisParams.tick0;
|
|
415
470
|
// maxOfYVal coming from only area chart and Grouped vertical bar chart(Calculation done at base file)
|
|
416
471
|
var tempVal = maxOfYVal || yMinMaxValues.endValue || 0;
|
|
417
472
|
var finalYmax = tempVal > yMaxValue ? tempVal : yMaxValue;
|
|
@@ -438,8 +493,25 @@ function createNumericYAxis(yAxisParams, isRtl, axisData, isIntegralDataset, use
|
|
|
438
493
|
.range([containerHeight - margins.bottom, margins.top + (eventAnnotationProps ? eventLabelHeight : 0)]);
|
|
439
494
|
var axis = (!isRtl && useSecondaryYScale) || (isRtl && !useSecondaryYScale) ? (0, d3_axis_1.axisRight)(yAxisScale) : (0, d3_axis_1.axisLeft)(yAxisScale);
|
|
440
495
|
var yAxis = axis.tickPadding(tickPadding).tickSizeInner(-(containerWidth - margins.left - margins.right));
|
|
441
|
-
|
|
442
|
-
|
|
496
|
+
var customTickValues;
|
|
497
|
+
if (tickValues) {
|
|
498
|
+
customTickValues = tickValues;
|
|
499
|
+
}
|
|
500
|
+
else if (tickStep) {
|
|
501
|
+
customTickValues = generateNumericTicks(scaleType, tickStep, tick0, yAxisScale.domain());
|
|
502
|
+
}
|
|
503
|
+
if (customTickValues) {
|
|
504
|
+
yAxis.tickValues(customTickValues);
|
|
505
|
+
axisData.yAxisDomainValues = customTickValues;
|
|
506
|
+
}
|
|
507
|
+
else {
|
|
508
|
+
if (scaleType === 'log') {
|
|
509
|
+
axisData.yAxisDomainValues = yAxisScale.ticks();
|
|
510
|
+
}
|
|
511
|
+
else {
|
|
512
|
+
yAxis.tickValues(domainValues);
|
|
513
|
+
axisData.yAxisDomainValues = domainValues;
|
|
514
|
+
}
|
|
443
515
|
}
|
|
444
516
|
var tickFormat = function (domainValue, index, defaultFormat) {
|
|
445
517
|
var value = typeof domainValue === 'number' ? domainValue : domainValue.valueOf();
|
|
@@ -449,10 +521,8 @@ function createNumericYAxis(yAxisParams, isRtl, axisData, isIntegralDataset, use
|
|
|
449
521
|
? yAxis.tickFormat(yAxisTickFormat)
|
|
450
522
|
: yAxis.tickFormat(function (v, i) { return tickFormat(v, i, yAxisScale.tickFormat(yAxisTickCount)); });
|
|
451
523
|
yAxisElement ? (0, d3_selection_1.select)(yAxisElement).call(yAxis).selectAll('text').attr('aria-hidden', 'true') : '';
|
|
452
|
-
axisData.yAxisDomainValues = domainValues;
|
|
453
524
|
return yAxisScale;
|
|
454
525
|
}
|
|
455
|
-
exports.createNumericYAxis = createNumericYAxis;
|
|
456
526
|
/**
|
|
457
527
|
* Creating String Y axis of the chart for Horizontal Bar Chart With Axis
|
|
458
528
|
* @param yAxisParams
|
|
@@ -555,7 +625,6 @@ function calloutData(values) {
|
|
|
555
625
|
});
|
|
556
626
|
return result;
|
|
557
627
|
}
|
|
558
|
-
exports.calloutData = calloutData;
|
|
559
628
|
function getUnique(arr, comp) {
|
|
560
629
|
var unique = arr
|
|
561
630
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -567,7 +636,6 @@ function getUnique(arr, comp) {
|
|
|
567
636
|
.map(function (e) { return arr[e]; });
|
|
568
637
|
return unique;
|
|
569
638
|
}
|
|
570
|
-
exports.getUnique = getUnique;
|
|
571
639
|
/**
|
|
572
640
|
* This function takes two paramerter
|
|
573
641
|
* 1. an array of strings
|
|
@@ -589,7 +657,6 @@ function silceOrAppendToArray(array, value) {
|
|
|
589
657
|
return array.slice(0, pos).concat(array.slice(pos + 1));
|
|
590
658
|
}
|
|
591
659
|
}
|
|
592
|
-
exports.silceOrAppendToArray = silceOrAppendToArray;
|
|
593
660
|
exports.DEFAULT_WRAP_WIDTH = 10;
|
|
594
661
|
/**
|
|
595
662
|
* This method used for wrapping of x axis labels (tick values).
|
|
@@ -679,7 +746,6 @@ function createWrapOfXLabels(wrapLabelProps) {
|
|
|
679
746
|
}
|
|
680
747
|
return removeVal > 0 ? removeVal : 0;
|
|
681
748
|
}
|
|
682
|
-
exports.createWrapOfXLabels = createWrapOfXLabels;
|
|
683
749
|
/**
|
|
684
750
|
* This method used for wrapping of y axis labels (tick values).
|
|
685
751
|
*/
|
|
@@ -732,7 +798,6 @@ yAxis, noOfCharsToTruncate, truncateLabel, isRtl) {
|
|
|
732
798
|
}
|
|
733
799
|
});
|
|
734
800
|
}
|
|
735
|
-
exports.createYAxisLabels = createYAxisLabels;
|
|
736
801
|
var wrapContent = function (content, id, maxWidth) {
|
|
737
802
|
var textElement = (0, d3_selection_1.select)("#".concat(id));
|
|
738
803
|
textElement.text(content);
|
|
@@ -817,7 +882,6 @@ function tooltipOfAxislabels(axistooltipProps) {
|
|
|
817
882
|
_loop_1(i);
|
|
818
883
|
}
|
|
819
884
|
}
|
|
820
|
-
exports.tooltipOfAxislabels = tooltipOfAxislabels;
|
|
821
885
|
/**
|
|
822
886
|
* Find the axis type of line chart and area chart from given data
|
|
823
887
|
* @param points
|
|
@@ -834,7 +898,6 @@ function getXAxisType(points) {
|
|
|
834
898
|
}
|
|
835
899
|
return isXAxisDateType;
|
|
836
900
|
}
|
|
837
|
-
exports.getXAxisType = getXAxisType;
|
|
838
901
|
/**
|
|
839
902
|
* Calculates Domain and range values for Numeric X axis.
|
|
840
903
|
* This method calculates Area cart and line chart.
|
|
@@ -859,7 +922,6 @@ function domainRangeOfNumericForAreaLineScatterCharts(points, margins, width, is
|
|
|
859
922
|
? { dStartValue: isScatterPolar ? 1 : xMax, dEndValue: isScatterPolar ? -1 : xMin, rStartValue: rStartValue, rEndValue: rEndValue }
|
|
860
923
|
: { dStartValue: isScatterPolar ? -1 : xMin, dEndValue: isScatterPolar ? 1 : xMax, rStartValue: rStartValue, rEndValue: rEndValue };
|
|
861
924
|
}
|
|
862
|
-
exports.domainRangeOfNumericForAreaLineScatterCharts = domainRangeOfNumericForAreaLineScatterCharts;
|
|
863
925
|
/**
|
|
864
926
|
* Groups HorizontalBarChart With Axis data based on YValue
|
|
865
927
|
* Used for stacked case
|
|
@@ -877,7 +939,6 @@ function groupChartDataByYValue(chartData) {
|
|
|
877
939
|
});
|
|
878
940
|
return Object.values(map);
|
|
879
941
|
}
|
|
880
|
-
exports.groupChartDataByYValue = groupChartDataByYValue;
|
|
881
942
|
/**
|
|
882
943
|
* Calculates maximum domain values for Numeric x axis for both positive and negative values
|
|
883
944
|
* works for Horizontal Bar Chart With axis
|
|
@@ -895,7 +956,6 @@ function computeLongestBars(stackedChartData, X_ORIGIN) {
|
|
|
895
956
|
});
|
|
896
957
|
return { longestPositiveBar: longestPositiveBar, longestNegativeBar: longestNegativeBar };
|
|
897
958
|
}
|
|
898
|
-
exports.computeLongestBars = computeLongestBars;
|
|
899
959
|
/**
|
|
900
960
|
* Calculates Domain and range values for Numeric X axis.
|
|
901
961
|
* This method calculates Horizontal Chart with Axis
|
|
@@ -916,7 +976,6 @@ function domainRangeOfNumericForHorizontalBarChartWithAxis(points, margins, cont
|
|
|
916
976
|
? { dStartValue: xMax, dEndValue: Math.min(xMin, X_ORIGIN), rStartValue: rMin, rEndValue: rMax }
|
|
917
977
|
: { dStartValue: Math.min(xMin, X_ORIGIN), dEndValue: xMax, rStartValue: rMin, rEndValue: rMax };
|
|
918
978
|
}
|
|
919
|
-
exports.domainRangeOfNumericForHorizontalBarChartWithAxis = domainRangeOfNumericForHorizontalBarChartWithAxis;
|
|
920
979
|
/**
|
|
921
980
|
* Calculates Range values of x Axis string axis
|
|
922
981
|
* For String axis, we need to give domain values (Not start and end array values)
|
|
@@ -935,7 +994,6 @@ function domainRangeOfXStringAxis(margins, width, isRTL) {
|
|
|
935
994
|
? { dStartValue: 0, dEndValue: 0, rStartValue: rMax, rEndValue: rMin }
|
|
936
995
|
: { dStartValue: 0, dEndValue: 0, rStartValue: rMin, rEndValue: rMax };
|
|
937
996
|
}
|
|
938
|
-
exports.domainRangeOfXStringAxis = domainRangeOfXStringAxis;
|
|
939
997
|
/**
|
|
940
998
|
* Calculate domain and range values to the Vertical stacked bar chart - For Numeric axis
|
|
941
999
|
* @export
|
|
@@ -955,7 +1013,6 @@ function domainRangeOfVSBCNumeric(points, margins, width, isRTL, barWidth) {
|
|
|
955
1013
|
? { dStartValue: xMax, dEndValue: xMin, rStartValue: rMax, rEndValue: rMin }
|
|
956
1014
|
: { dStartValue: xMin, dEndValue: xMax, rStartValue: rMax, rEndValue: rMin };
|
|
957
1015
|
}
|
|
958
|
-
exports.domainRangeOfVSBCNumeric = domainRangeOfVSBCNumeric;
|
|
959
1016
|
/**
|
|
960
1017
|
* Calculates Domain and range values for Date X axis.
|
|
961
1018
|
* This method calculates Bar chart.
|
|
@@ -998,7 +1055,6 @@ function domainRangeOfDateForAreaLineScatterVerticalBarCharts(points, margins, w
|
|
|
998
1055
|
? { dStartValue: lDate, dEndValue: sDate, rStartValue: rStartValue, rEndValue: rEndValue }
|
|
999
1056
|
: { dStartValue: sDate, dEndValue: lDate, rStartValue: rStartValue, rEndValue: rEndValue };
|
|
1000
1057
|
}
|
|
1001
|
-
exports.domainRangeOfDateForAreaLineScatterVerticalBarCharts = domainRangeOfDateForAreaLineScatterVerticalBarCharts;
|
|
1002
1058
|
/**
|
|
1003
1059
|
* Calculate domain and range values to the Vertical bar chart - For Numeric axis
|
|
1004
1060
|
* @export
|
|
@@ -1018,7 +1074,6 @@ function domainRageOfVerticalNumeric(points, margins, containerWidth, isRTL, bar
|
|
|
1018
1074
|
? { dStartValue: xMax, dEndValue: xMin, rStartValue: rMin, rEndValue: rMax }
|
|
1019
1075
|
: { dStartValue: xMin, dEndValue: xMax, rStartValue: rMin, rEndValue: rMax };
|
|
1020
1076
|
}
|
|
1021
|
-
exports.domainRageOfVerticalNumeric = domainRageOfVerticalNumeric;
|
|
1022
1077
|
/**
|
|
1023
1078
|
* Calculating start and ending values of the Area chart and LineChart
|
|
1024
1079
|
* @export
|
|
@@ -1041,7 +1096,6 @@ function findNumericMinMaxOfY(points, yAxisType, useSecondaryYScale, scaleType)
|
|
|
1041
1096
|
endValue: (0, d3_array_1.max)(values),
|
|
1042
1097
|
};
|
|
1043
1098
|
}
|
|
1044
|
-
exports.findNumericMinMaxOfY = findNumericMinMaxOfY;
|
|
1045
1099
|
/**
|
|
1046
1100
|
* Find the minimum and maximum values of the vertical stacked bar chart y axis data point. Used for create y axis.
|
|
1047
1101
|
* @export
|
|
@@ -1053,7 +1107,6 @@ function findVSBCNumericMinMaxOfY(dataset) {
|
|
|
1053
1107
|
var yMin = (0, d3_array_1.min)(dataset, function (point) { return point.y; });
|
|
1054
1108
|
return { startValue: yMin, endValue: yMax };
|
|
1055
1109
|
}
|
|
1056
|
-
exports.findVSBCNumericMinMaxOfY = findVSBCNumericMinMaxOfY;
|
|
1057
1110
|
/**
|
|
1058
1111
|
* Fins the min and max values of the vertical bar chart y axis data point.
|
|
1059
1112
|
* @export
|
|
@@ -1074,7 +1127,6 @@ function findVerticalNumericMinMaxOfY(points, yAxisType, useSecondaryYScale) {
|
|
|
1074
1127
|
});
|
|
1075
1128
|
return { startValue: (0, d3_array_1.min)(values), endValue: (0, d3_array_1.max)(values) };
|
|
1076
1129
|
}
|
|
1077
|
-
exports.findVerticalNumericMinMaxOfY = findVerticalNumericMinMaxOfY;
|
|
1078
1130
|
/**
|
|
1079
1131
|
* Fins the min and max values of the horizontal bar chart y axis data point.
|
|
1080
1132
|
* @export
|
|
@@ -1089,7 +1141,6 @@ function findHBCWANumericMinMaxOfY(points, yAxisType) {
|
|
|
1089
1141
|
}
|
|
1090
1142
|
return { startValue: 0, endValue: 0 };
|
|
1091
1143
|
}
|
|
1092
|
-
exports.findHBCWANumericMinMaxOfY = findHBCWANumericMinMaxOfY;
|
|
1093
1144
|
/**
|
|
1094
1145
|
* @param p string or number or Date
|
|
1095
1146
|
*
|
|
@@ -1226,7 +1277,6 @@ function rotateXAxisLabels(rotateLabelProps) {
|
|
|
1226
1277
|
});
|
|
1227
1278
|
return Math.floor(maxHeight / 1.414); // Compute maxHeight/tanInverse(45) to get the vertical height of labels.
|
|
1228
1279
|
}
|
|
1229
|
-
exports.rotateXAxisLabels = rotateXAxisLabels;
|
|
1230
1280
|
function wrapTextInsideDonut(selectorClass, maxWidth) {
|
|
1231
1281
|
var idx = 0;
|
|
1232
1282
|
(0, d3_selection_1.selectAll)(".".concat(selectorClass)).each(function () {
|
|
@@ -1263,11 +1313,9 @@ function wrapTextInsideDonut(selectorClass, maxWidth) {
|
|
|
1263
1313
|
idx += 1;
|
|
1264
1314
|
});
|
|
1265
1315
|
}
|
|
1266
|
-
exports.wrapTextInsideDonut = wrapTextInsideDonut;
|
|
1267
1316
|
function formatScientificLimitWidth(value) {
|
|
1268
1317
|
return yAxisTickFormatterInternal(value, true);
|
|
1269
1318
|
}
|
|
1270
|
-
exports.formatScientificLimitWidth = formatScientificLimitWidth;
|
|
1271
1319
|
var DEFAULT_BAR_WIDTH = 16;
|
|
1272
1320
|
var MIN_BAR_WIDTH = 1;
|
|
1273
1321
|
var getBarWidth = function (barWidthProp, maxBarWidthProp, adjustedValue, modeProp) {
|
|
@@ -1306,7 +1354,6 @@ function getSecureProps(props) {
|
|
|
1306
1354
|
var dangerouslySetInnerHTML = props.dangerouslySetInnerHTML, result = tslib_1.__rest(props, ["dangerouslySetInnerHTML"]);
|
|
1307
1355
|
return result;
|
|
1308
1356
|
}
|
|
1309
|
-
exports.getSecureProps = getSecureProps;
|
|
1310
1357
|
function areArraysEqual(arr1, arr2) {
|
|
1311
1358
|
if (arr1 === arr2) {
|
|
1312
1359
|
return true;
|
|
@@ -1324,7 +1371,6 @@ function areArraysEqual(arr1, arr2) {
|
|
|
1324
1371
|
}
|
|
1325
1372
|
return true;
|
|
1326
1373
|
}
|
|
1327
|
-
exports.areArraysEqual = areArraysEqual;
|
|
1328
1374
|
var cssVarRegExp = /var\((--[a-zA-Z0-9\-]+)\)/g;
|
|
1329
1375
|
function resolveCSSVariables(chartContainer, styleRules) {
|
|
1330
1376
|
var containerStyles = getComputedStyle(chartContainer);
|
|
@@ -1332,7 +1378,6 @@ function resolveCSSVariables(chartContainer, styleRules) {
|
|
|
1332
1378
|
return containerStyles.getPropertyValue(group1);
|
|
1333
1379
|
});
|
|
1334
1380
|
}
|
|
1335
|
-
exports.resolveCSSVariables = resolveCSSVariables;
|
|
1336
1381
|
function copyStyle(properties, fromEl, toEl) {
|
|
1337
1382
|
var styles = getComputedStyle(fromEl);
|
|
1338
1383
|
if (Array.isArray(properties)) {
|
|
@@ -1347,7 +1392,6 @@ function copyStyle(properties, fromEl, toEl) {
|
|
|
1347
1392
|
});
|
|
1348
1393
|
}
|
|
1349
1394
|
}
|
|
1350
|
-
exports.copyStyle = copyStyle;
|
|
1351
1395
|
var MEASUREMENT_SPAN_STYLE = {
|
|
1352
1396
|
position: 'absolute',
|
|
1353
1397
|
visibility: 'hidden',
|
|
@@ -1398,7 +1442,6 @@ function getCurveFactory(curve, defaultFactory) {
|
|
|
1398
1442
|
return defaultFactory;
|
|
1399
1443
|
}
|
|
1400
1444
|
}
|
|
1401
|
-
exports.getCurveFactory = getCurveFactory;
|
|
1402
1445
|
var truncateString = function (str, maxLength, ellipsis) {
|
|
1403
1446
|
if (ellipsis === void 0) { ellipsis = '...'; }
|
|
1404
1447
|
if (str.length <= maxLength) {
|
|
@@ -1479,7 +1522,6 @@ function getContrastTextColor(backgroundColor, theme) {
|
|
|
1479
1522
|
}
|
|
1480
1523
|
return textColor;
|
|
1481
1524
|
}
|
|
1482
|
-
exports.getContrastTextColor = getContrastTextColor;
|
|
1483
1525
|
/**
|
|
1484
1526
|
* Utility function to check if an array of points is scatterpolar
|
|
1485
1527
|
* @param points - Array of chart points
|
|
@@ -1490,7 +1532,6 @@ function isScatterPolarSeries(points) {
|
|
|
1490
1532
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1491
1533
|
function (item) { var _a; return typeof ((_a = item.lineOptions) === null || _a === void 0 ? void 0 : _a.mode) === 'string' && item.lineOptions.mode === 'scatterpolar'; });
|
|
1492
1534
|
}
|
|
1493
|
-
exports.isScatterPolarSeries = isScatterPolarSeries;
|
|
1494
1535
|
/**
|
|
1495
1536
|
* Utility function to check if an array of points contains mode as 'text' only
|
|
1496
1537
|
* @param points - Array of chart points
|
|
@@ -1501,7 +1542,6 @@ function isTextMode(points) {
|
|
|
1501
1542
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1502
1543
|
function (item) { var _a; return typeof ((_a = item.lineOptions) === null || _a === void 0 ? void 0 : _a.mode) === 'string' && item.lineOptions.mode === 'text'; });
|
|
1503
1544
|
}
|
|
1504
|
-
exports.isTextMode = isTextMode;
|
|
1505
1545
|
// TODO: Refactor to encapsulate the complete numeric scale creation logic here, including setting domain and range.
|
|
1506
1546
|
var createNumericScale = function (scaleType) {
|
|
1507
1547
|
if (scaleType === 'log') {
|
|
@@ -1580,4 +1620,79 @@ var getRangeForScatterMarkerSize = function (_a) {
|
|
|
1580
1620
|
return Math.min(extraXPixels, extraYPixels);
|
|
1581
1621
|
};
|
|
1582
1622
|
exports.getRangeForScatterMarkerSize = getRangeForScatterMarkerSize;
|
|
1623
|
+
var generateLinearTicks = function (tick0, tickStep, scaleDomain) {
|
|
1624
|
+
var domainMin = (0, d3_array_1.min)(scaleDomain);
|
|
1625
|
+
var domainMax = (0, d3_array_1.max)(scaleDomain);
|
|
1626
|
+
var precision = Math.max((0, react_1.calculatePrecision)(tick0), (0, react_1.calculatePrecision)(tickStep));
|
|
1627
|
+
var start = Math.ceil((0, react_1.precisionRound)((domainMin - tick0) / tickStep, precision));
|
|
1628
|
+
var end = Math.floor((0, react_1.precisionRound)((domainMax - tick0) / tickStep, precision));
|
|
1629
|
+
var ticks = [];
|
|
1630
|
+
for (var i = start; i <= end; i++) {
|
|
1631
|
+
ticks.push((0, react_1.precisionRound)(tick0 + i * tickStep, precision));
|
|
1632
|
+
}
|
|
1633
|
+
return ticks;
|
|
1634
|
+
};
|
|
1635
|
+
exports.generateLinearTicks = generateLinearTicks;
|
|
1636
|
+
var generateMonthlyTicks = function (tick0, tickStepInMonths, scaleDomain, useUTC) {
|
|
1637
|
+
var domainMin = +(0, d3_array_1.min)(scaleDomain);
|
|
1638
|
+
var domainMax = +(0, d3_array_1.max)(scaleDomain);
|
|
1639
|
+
var getMonth = function (d) { return (useUTC ? d.getUTCMonth() : d.getMonth()); };
|
|
1640
|
+
var setMonth = function (d, month) { return (useUTC ? new Date(d.setUTCMonth(month)) : new Date(d.setMonth(month))); };
|
|
1641
|
+
// Find the earliest tick <= domainMin
|
|
1642
|
+
var start = 0;
|
|
1643
|
+
for (var firstTick = new Date(+tick0); +firstTick > domainMin;) {
|
|
1644
|
+
firstTick = setMonth(firstTick, getMonth(firstTick) - tickStepInMonths);
|
|
1645
|
+
start -= tickStepInMonths;
|
|
1646
|
+
}
|
|
1647
|
+
var baseMonth = getMonth(tick0);
|
|
1648
|
+
var ticks = [];
|
|
1649
|
+
// Generate ticks forward until domainMax
|
|
1650
|
+
for (var i = start;; i += tickStepInMonths) {
|
|
1651
|
+
var tickDate = setMonth(new Date(+tick0), baseMonth + i);
|
|
1652
|
+
// Handle month rollover (e.g., Jan 31 + 1 month → Mar 3 instead of Feb)
|
|
1653
|
+
if (getMonth(tickDate) !== (((baseMonth + i) % 12) + 12) % 12) {
|
|
1654
|
+
tickDate = useUTC ? new Date(tickDate.setUTCDate(0)) : new Date(tickDate.setDate(0));
|
|
1655
|
+
}
|
|
1656
|
+
if (+tickDate > domainMax) {
|
|
1657
|
+
break;
|
|
1658
|
+
}
|
|
1659
|
+
if (+tickDate >= domainMin) {
|
|
1660
|
+
ticks.push(tickDate);
|
|
1661
|
+
}
|
|
1662
|
+
}
|
|
1663
|
+
return ticks;
|
|
1664
|
+
};
|
|
1665
|
+
exports.generateMonthlyTicks = generateMonthlyTicks;
|
|
1666
|
+
var generateNumericTicks = function (scaleType, tickStep, tick0, scaleDomain) {
|
|
1667
|
+
var refTick = typeof tick0 === 'number' ? tick0 : 0;
|
|
1668
|
+
if (scaleType === 'log') {
|
|
1669
|
+
if (typeof tickStep === 'number' && tickStep > 0) {
|
|
1670
|
+
return (0, exports.generateLinearTicks)(refTick, tickStep, scaleDomain.map(function (d) { return Math.log10(d); })).map(function (t) { return Math.pow(10, t); });
|
|
1671
|
+
}
|
|
1672
|
+
if (typeof tickStep === 'string') {
|
|
1673
|
+
var prefix = tickStep[0];
|
|
1674
|
+
var num = (0, chart_utilities_1.isNumber)(tickStep.slice(1)) ? Number(tickStep.slice(1)) : 0;
|
|
1675
|
+
if (prefix === 'L' && num > 0) {
|
|
1676
|
+
return (0, exports.generateLinearTicks)(refTick, num, scaleDomain);
|
|
1677
|
+
}
|
|
1678
|
+
}
|
|
1679
|
+
return;
|
|
1680
|
+
}
|
|
1681
|
+
if (typeof tickStep === 'number' && tickStep > 0) {
|
|
1682
|
+
return (0, exports.generateLinearTicks)(refTick, tickStep, scaleDomain);
|
|
1683
|
+
}
|
|
1684
|
+
};
|
|
1685
|
+
var generateDateTicks = function (tickStep, tick0, scaleDomain, useUTC) {
|
|
1686
|
+
var refTick = tick0 instanceof Date ? tick0 : new Date(exports.DEFAULT_DATE_STRING);
|
|
1687
|
+
if (typeof tickStep === 'number' && tickStep > 0) {
|
|
1688
|
+
return (0, exports.generateLinearTicks)(+refTick, tickStep, scaleDomain.map(function (d) { return +d; })).map(function (t) { return new Date(t); });
|
|
1689
|
+
}
|
|
1690
|
+
if (typeof tickStep === 'string') {
|
|
1691
|
+
var prefix = tickStep[0];
|
|
1692
|
+
var num = (0, chart_utilities_1.isNumber)(tickStep.slice(1)) ? Number(tickStep.slice(1)) : 0;
|
|
1693
|
+
if (prefix === 'M' && num > 0 && num === Math.round(num)) {
|
|
1694
|
+
return (0, exports.generateMonthlyTicks)(refTick, num, scaleDomain, useUTC);
|
|
1695
|
+
}
|
|
1696
|
+
}
|
|
1697
|
+
};
|
|
1583
1698
|
//# sourceMappingURL=utilities.js.map
|