@fluentui/react-charts 9.3.2 → 9.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +47 -2
- package/dist/index.d.ts +151 -1
- package/lib/components/AreaChart/AreaChart.js +208 -60
- package/lib/components/AreaChart/AreaChart.js.map +1 -1
- package/lib/components/ChartTable/ChartTable.js +14 -12
- package/lib/components/ChartTable/ChartTable.js.map +1 -1
- package/lib/components/ChartTable/useChartTableStyles.styles.js +3 -3
- package/lib/components/ChartTable/useChartTableStyles.styles.js.map +1 -1
- package/lib/components/ChartTable/useChartTableStyles.styles.raw.js +2 -2
- package/lib/components/ChartTable/useChartTableStyles.styles.raw.js.map +1 -1
- package/lib/components/CommonComponents/CartesianChart.js +5 -6
- package/lib/components/CommonComponents/CartesianChart.js.map +1 -1
- package/lib/components/CommonComponents/ChartPopover.js +2 -1
- package/lib/components/CommonComponents/ChartPopover.js.map +1 -1
- package/lib/components/CommonComponents/ChartPopover.types.js.map +1 -1
- package/lib/components/CommonComponents/useCartesianChartStyles.styles.js +3 -2
- package/lib/components/CommonComponents/useCartesianChartStyles.styles.js.map +1 -1
- package/lib/components/CommonComponents/useCartesianChartStyles.styles.raw.js +2 -1
- package/lib/components/CommonComponents/useCartesianChartStyles.styles.raw.js.map +1 -1
- package/lib/components/CommonComponents/useChartPopoverStyles.styles.js +3 -2
- package/lib/components/CommonComponents/useChartPopoverStyles.styles.js.map +1 -1
- package/lib/components/CommonComponents/useChartPopoverStyles.styles.raw.js +2 -1
- package/lib/components/CommonComponents/useChartPopoverStyles.styles.raw.js.map +1 -1
- package/lib/components/DeclarativeChart/DeclarativeChart.js +16 -7
- package/lib/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib/components/DeclarativeChart/PlotlyColorAdapter.js +63 -18
- package/lib/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -1
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +471 -207
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib/components/DonutChart/Arc/Arc.js +8 -7
- package/lib/components/DonutChart/Arc/Arc.js.map +1 -1
- package/lib/components/DonutChart/DonutChart.js +16 -32
- package/lib/components/DonutChart/DonutChart.js.map +1 -1
- package/lib/components/DonutChart/DonutChart.types.js.map +1 -1
- package/lib/components/DonutChart/Pie/Pie.js +4 -4
- package/lib/components/DonutChart/Pie/Pie.js.map +1 -1
- package/lib/components/DonutChart/useDonutChartStyles.styles.js +3 -2
- package/lib/components/DonutChart/useDonutChartStyles.styles.js.map +1 -1
- package/lib/components/DonutChart/useDonutChartStyles.styles.raw.js +2 -1
- package/lib/components/DonutChart/useDonutChartStyles.styles.raw.js.map +1 -1
- package/lib/components/FunnelChart/FunnelChart.js +23 -45
- package/lib/components/FunnelChart/FunnelChart.js.map +1 -1
- package/lib/components/FunnelChart/useFunnelChartStyles.styles.js +3 -2
- package/lib/components/FunnelChart/useFunnelChartStyles.styles.js.map +1 -1
- package/lib/components/FunnelChart/useFunnelChartStyles.styles.raw.js +2 -1
- package/lib/components/FunnelChart/useFunnelChartStyles.styles.raw.js.map +1 -1
- package/lib/components/GaugeChart/GaugeChart.js +21 -46
- package/lib/components/GaugeChart/GaugeChart.js.map +1 -1
- package/lib/components/GaugeChart/useGaugeChartStyles.styles.js +3 -2
- package/lib/components/GaugeChart/useGaugeChartStyles.styles.js.map +1 -1
- package/lib/components/GaugeChart/useGaugeChartStyles.styles.raw.js +2 -1
- package/lib/components/GaugeChart/useGaugeChartStyles.styles.raw.js.map +1 -1
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +332 -114
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.types.js.map +1 -1
- package/lib/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.js +3 -2
- package/lib/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.js.map +1 -1
- package/lib/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.raw.js +2 -1
- package/lib/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.raw.js.map +1 -1
- package/lib/components/Legends/Legends.js +1 -1
- package/lib/components/Legends/Legends.js.map +1 -1
- package/lib/components/LineChart/LineChart.js +145 -97
- package/lib/components/LineChart/LineChart.js.map +1 -1
- package/lib/components/SankeyChart/useSankeyChartStyles.styles.js +3 -2
- package/lib/components/SankeyChart/useSankeyChartStyles.styles.js.map +1 -1
- package/lib/components/SankeyChart/useSankeyChartStyles.styles.raw.js +2 -1
- package/lib/components/SankeyChart/useSankeyChartStyles.styles.raw.js.map +1 -1
- package/lib/components/ScatterChart/ScatterChart.js +7 -11
- package/lib/components/ScatterChart/ScatterChart.js.map +1 -1
- package/lib/types/DataPoint.js +1 -3
- package/lib/types/DataPoint.js.map +1 -1
- package/lib/utilities/utilities.js +77 -26
- package/lib/utilities/utilities.js.map +1 -1
- package/lib-commonjs/components/AreaChart/AreaChart.js +207 -59
- package/lib-commonjs/components/AreaChart/AreaChart.js.map +1 -1
- package/lib-commonjs/components/ChartTable/ChartTable.js +13 -12
- package/lib-commonjs/components/ChartTable/ChartTable.js.map +1 -1
- package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.js +3 -3
- package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.js.map +1 -1
- package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.raw.js +2 -2
- package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/CartesianChart.js +5 -6
- package/lib-commonjs/components/CommonComponents/CartesianChart.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/ChartPopover.js +2 -1
- package/lib-commonjs/components/CommonComponents/ChartPopover.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/ChartPopover.types.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.js +7 -1
- package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.raw.js +2 -1
- package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/useChartPopoverStyles.styles.js +7 -1
- package/lib-commonjs/components/CommonComponents/useChartPopoverStyles.styles.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/useChartPopoverStyles.styles.raw.js +2 -1
- package/lib-commonjs/components/CommonComponents/useChartPopoverStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js +16 -7
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.js +65 -18
- package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +470 -206
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib-commonjs/components/DonutChart/Arc/Arc.js +8 -7
- package/lib-commonjs/components/DonutChart/Arc/Arc.js.map +1 -1
- package/lib-commonjs/components/DonutChart/DonutChart.js +16 -32
- package/lib-commonjs/components/DonutChart/DonutChart.js.map +1 -1
- package/lib-commonjs/components/DonutChart/DonutChart.types.js.map +1 -1
- package/lib-commonjs/components/DonutChart/Pie/Pie.js +4 -4
- package/lib-commonjs/components/DonutChart/Pie/Pie.js.map +1 -1
- package/lib-commonjs/components/DonutChart/useDonutChartStyles.styles.js +7 -1
- package/lib-commonjs/components/DonutChart/useDonutChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/DonutChart/useDonutChartStyles.styles.raw.js +2 -1
- package/lib-commonjs/components/DonutChart/useDonutChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/FunnelChart/FunnelChart.js +23 -45
- package/lib-commonjs/components/FunnelChart/FunnelChart.js.map +1 -1
- package/lib-commonjs/components/FunnelChart/useFunnelChartStyles.styles.js +7 -1
- package/lib-commonjs/components/FunnelChart/useFunnelChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/FunnelChart/useFunnelChartStyles.styles.raw.js +2 -1
- package/lib-commonjs/components/FunnelChart/useFunnelChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/GaugeChart/GaugeChart.js +21 -46
- package/lib-commonjs/components/GaugeChart/GaugeChart.js.map +1 -1
- package/lib-commonjs/components/GaugeChart/useGaugeChartStyles.styles.js +7 -1
- package/lib-commonjs/components/GaugeChart/useGaugeChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/GaugeChart/useGaugeChartStyles.styles.raw.js +2 -1
- package/lib-commonjs/components/GaugeChart/useGaugeChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +329 -112
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.types.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.js +7 -1
- package/lib-commonjs/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.raw.js +2 -1
- package/lib-commonjs/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/Legends/Legends.js +1 -1
- package/lib-commonjs/components/Legends/Legends.js.map +1 -1
- package/lib-commonjs/components/LineChart/LineChart.js +144 -96
- package/lib-commonjs/components/LineChart/LineChart.js.map +1 -1
- package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.js +7 -1
- package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.raw.js +2 -1
- package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/ScatterChart/ScatterChart.js +6 -10
- package/lib-commonjs/components/ScatterChart/ScatterChart.js.map +1 -1
- package/lib-commonjs/types/DataPoint.js +1 -3
- package/lib-commonjs/types/DataPoint.js.map +1 -1
- package/lib-commonjs/utilities/utilities.js +80 -26
- package/lib-commonjs/utilities/utilities.js.map +1 -1
- package/package.json +13 -13
|
@@ -66,7 +66,7 @@ function yAxisTickFormatterInternal(value, limitWidth = false) {
|
|
|
66
66
|
* @export
|
|
67
67
|
* @param {IXAxisParams} xAxisParams
|
|
68
68
|
*/ export function createNumericXAxis(xAxisParams, tickParams, chartType, culture, scaleType, _useRtl) {
|
|
69
|
-
const { domainNRangeValues, showRoundOffXTickValues = false, xAxistickSize = 6, tickPadding = 10, xAxisCount, xAxisElement, hideTickOverlap, calcMaxLabelWidth, tickStep, tick0 } = xAxisParams;
|
|
69
|
+
const { domainNRangeValues, showRoundOffXTickValues = false, xAxistickSize = 6, tickPadding = 10, xAxisCount, xAxisElement, hideTickOverlap, calcMaxLabelWidth, tickStep, tick0, tickText } = xAxisParams;
|
|
70
70
|
const xAxisScale = createNumericScale(scaleType).domain([
|
|
71
71
|
domainNRangeValues.dStartValue,
|
|
72
72
|
domainNRangeValues.dEndValue
|
|
@@ -77,6 +77,9 @@ function yAxisTickFormatterInternal(value, limitWidth = false) {
|
|
|
77
77
|
showRoundOffXTickValues && xAxisScale.nice();
|
|
78
78
|
let tickCount = xAxisCount !== null && xAxisCount !== void 0 ? xAxisCount : 6;
|
|
79
79
|
const tickFormat = (domainValue, _index, defaultFormat)=>{
|
|
80
|
+
if (tickParams.tickValues && tickText && typeof tickText[_index] !== 'undefined') {
|
|
81
|
+
return tickText[_index];
|
|
82
|
+
}
|
|
80
83
|
if (tickParams.tickFormat) {
|
|
81
84
|
return d3Format(tickParams.tickFormat)(domainValue);
|
|
82
85
|
}
|
|
@@ -303,7 +306,7 @@ export function getDateFormatLevel(date, useUTC) {
|
|
|
303
306
|
* @param {IXAxisParams} xAxisParams
|
|
304
307
|
* @param {ITickParams} tickParams
|
|
305
308
|
*/ export function createDateXAxis(xAxisParams, tickParams, culture, options, timeFormatLocale, customDateTimeFormatter, useUTC, chartType) {
|
|
306
|
-
const { domainNRangeValues, xAxisElement, tickPadding = 6, xAxistickSize = 6, xAxisCount, calcMaxLabelWidth, tickStep, tick0 } = xAxisParams;
|
|
309
|
+
const { domainNRangeValues, xAxisElement, tickPadding = 6, xAxistickSize = 6, xAxisCount, calcMaxLabelWidth, tickStep, tick0, tickText } = xAxisParams;
|
|
307
310
|
const isUtcSet = useUTC === true || useUTC === 'utc';
|
|
308
311
|
const xAxisScale = isUtcSet ? d3ScaleUtc() : d3ScaleTime();
|
|
309
312
|
xAxisScale.domain([
|
|
@@ -329,6 +332,9 @@ export function getDateFormatLevel(date, useUTC) {
|
|
|
329
332
|
const formatOptions = options !== null && options !== void 0 ? options : getMultiLevelDateTimeFormatOptions(lowestFormatLevel, highestFormatLevel);
|
|
330
333
|
const formatFn = getMultiLevelD3DateFormatter(lowestFormatLevel, highestFormatLevel, locale, isUtcSet);
|
|
331
334
|
const tickFormat = (domainValue, _index)=>{
|
|
335
|
+
if (tickParams.tickValues && tickText && typeof tickText[_index] !== 'undefined') {
|
|
336
|
+
return tickText[_index];
|
|
337
|
+
}
|
|
332
338
|
if (customDateTimeFormatter) {
|
|
333
339
|
return customDateTimeFormatter(domainValue);
|
|
334
340
|
}
|
|
@@ -381,7 +387,7 @@ export function getDateFormatLevel(date, useUTC) {
|
|
|
381
387
|
* @param {string[]} dataset
|
|
382
388
|
* @returns
|
|
383
389
|
*/ export function createStringXAxis(xAxisParams, tickParams, dataset, culture, _useRtl) {
|
|
384
|
-
const { domainNRangeValues, xAxistickSize = 6, tickPadding = 10, xAxisPadding = 0.1, xAxisInnerPadding, xAxisOuterPadding, containerWidth, hideTickOverlap, calcMaxLabelWidth } = xAxisParams;
|
|
390
|
+
const { domainNRangeValues, xAxistickSize = 6, tickPadding = 10, xAxisPadding = 0.1, xAxisInnerPadding, xAxisOuterPadding, containerWidth, hideTickOverlap, calcMaxLabelWidth, tickText } = xAxisParams;
|
|
385
391
|
const xAxisScale = d3ScaleBand().domain(dataset).range([
|
|
386
392
|
domainNRangeValues.rStartValue,
|
|
387
393
|
domainNRangeValues.rEndValue
|
|
@@ -389,7 +395,10 @@ export function getDateFormatLevel(date, useUTC) {
|
|
|
389
395
|
var _tickParams_tickValues;
|
|
390
396
|
let tickValues = (_tickParams_tickValues = tickParams.tickValues) !== null && _tickParams_tickValues !== void 0 ? _tickParams_tickValues : dataset;
|
|
391
397
|
const tickFormat = (domainValue, _index)=>{
|
|
392
|
-
|
|
398
|
+
if (tickParams.tickValues && tickText && typeof tickText[_index] !== 'undefined') {
|
|
399
|
+
return tickText[_index];
|
|
400
|
+
}
|
|
401
|
+
return domainValue;
|
|
393
402
|
};
|
|
394
403
|
if (hideTickOverlap) {
|
|
395
404
|
let nonOverlappingTickValues = [];
|
|
@@ -498,7 +507,7 @@ export function createYAxisForHorizontalBarChartWithAxis(yAxisParams, isRtl) {
|
|
|
498
507
|
const { yMinMaxValues = {
|
|
499
508
|
startValue: 0,
|
|
500
509
|
endValue: 0
|
|
501
|
-
}, yAxisElement = null, yMaxValue = 0, yMinValue = 0, containerHeight, margins, tickPadding = 12, maxOfYVal = 0, yAxisTickFormat, yAxisTickCount = 4, tickValues, tickStep, tick0 } = yAxisParams;
|
|
510
|
+
}, yAxisElement = null, yMaxValue = 0, yMinValue = 0, containerHeight, margins, tickPadding = 12, maxOfYVal = 0, yAxisTickFormat, yAxisTickCount = 4, tickValues, tickStep, tick0, tickText } = yAxisParams;
|
|
502
511
|
// maxOfYVal coming from horizontal bar chart with axis (Calculation done at base file)
|
|
503
512
|
const tempVal = maxOfYVal || yMinMaxValues.endValue;
|
|
504
513
|
const finalYmax = tempVal > yMaxValue ? tempVal : yMaxValue;
|
|
@@ -512,7 +521,20 @@ export function createYAxisForHorizontalBarChartWithAxis(yAxisParams, isRtl) {
|
|
|
512
521
|
]);
|
|
513
522
|
const axis = isRtl ? d3AxisRight(yAxisScale) : d3AxisLeft(yAxisScale);
|
|
514
523
|
const yAxis = axis.tickPadding(tickPadding).ticks(yAxisTickCount);
|
|
515
|
-
|
|
524
|
+
const tickFormat = (domainValue, index)=>{
|
|
525
|
+
if (tickValues && tickText && typeof tickText[index] !== 'undefined') {
|
|
526
|
+
return tickText[index];
|
|
527
|
+
}
|
|
528
|
+
if (typeof yAxisTickFormat === 'function') {
|
|
529
|
+
return yAxisTickFormat(domainValue, index);
|
|
530
|
+
}
|
|
531
|
+
if (typeof yAxisTickFormat === 'string') {
|
|
532
|
+
return d3Format(yAxisTickFormat)(domainValue);
|
|
533
|
+
}
|
|
534
|
+
const value = typeof domainValue === 'number' ? domainValue : domainValue.valueOf();
|
|
535
|
+
return defaultYAxisTickFormatter(value);
|
|
536
|
+
};
|
|
537
|
+
yAxis.tickFormat(tickFormat);
|
|
516
538
|
let customTickValues;
|
|
517
539
|
if (tickValues) {
|
|
518
540
|
customTickValues = tickValues;
|
|
@@ -529,7 +551,7 @@ export function createNumericYAxis(yAxisParams, isRtl, axisData, isIntegralDatas
|
|
|
529
551
|
const { yMinMaxValues = {
|
|
530
552
|
startValue: 0,
|
|
531
553
|
endValue: 0
|
|
532
|
-
}, yAxisElement = null, yMaxValue = 0, yMinValue = 0, containerHeight, containerWidth, margins, tickPadding = 12, maxOfYVal = 0, yAxisTickFormat, yAxisTickCount = 4, eventAnnotationProps, eventLabelHeight, tickValues, tickStep, tick0 } = yAxisParams;
|
|
554
|
+
}, yAxisElement = null, yMaxValue = 0, yMinValue = 0, containerHeight, containerWidth, margins, tickPadding = 12, maxOfYVal = 0, yAxisTickFormat, yAxisTickCount = 4, eventAnnotationProps, eventLabelHeight, tickValues, tickStep, tick0, tickText } = yAxisParams;
|
|
533
555
|
// maxOfYVal coming from only area chart and Grouped vertical bar chart(Calculation done at base file)
|
|
534
556
|
const tempVal = maxOfYVal || yMinMaxValues.endValue || 0;
|
|
535
557
|
const finalYmax = tempVal > yMaxValue ? tempVal : yMaxValue;
|
|
@@ -584,10 +606,19 @@ export function createNumericYAxis(yAxisParams, isRtl, axisData, isIntegralDatas
|
|
|
584
606
|
}
|
|
585
607
|
}
|
|
586
608
|
const tickFormat = (domainValue, index, defaultFormat)=>{
|
|
609
|
+
if (tickValues && tickText && typeof tickText[index] !== 'undefined') {
|
|
610
|
+
return tickText[index];
|
|
611
|
+
}
|
|
612
|
+
if (typeof yAxisTickFormat === 'function') {
|
|
613
|
+
return yAxisTickFormat(domainValue, index);
|
|
614
|
+
}
|
|
615
|
+
if (typeof yAxisTickFormat === 'string') {
|
|
616
|
+
return d3Format(yAxisTickFormat)(domainValue);
|
|
617
|
+
}
|
|
587
618
|
const value = typeof domainValue === 'number' ? domainValue : domainValue.valueOf();
|
|
588
619
|
return (defaultFormat === null || defaultFormat === void 0 ? void 0 : defaultFormat(value)) === '' ? '' : defaultYAxisTickFormatter(value);
|
|
589
620
|
};
|
|
590
|
-
|
|
621
|
+
yAxis.tickFormat((v, i)=>tickFormat(v, i, yAxisScale.tickFormat(yAxisTickCount)));
|
|
591
622
|
yAxisElement ? d3Select(yAxisElement).call(yAxis).selectAll('text').attr('aria-hidden', 'true').style('direction', 'ltr').style('unicode-bidi', 'isolate').style('text-anchor', !useSecondaryYScale && (_useRtl ? 'start' : 'end')) : '';
|
|
592
623
|
return yAxisScale;
|
|
593
624
|
}
|
|
@@ -597,7 +628,7 @@ export function createNumericYAxis(yAxisParams, isRtl, axisData, isIntegralDatas
|
|
|
597
628
|
* @param dataPoints
|
|
598
629
|
* @param isRtl
|
|
599
630
|
*/ export const createStringYAxisForHorizontalBarChartWithAxis = (yAxisParams, dataPoints, isRtl, barWidth)=>{
|
|
600
|
-
const { containerHeight, tickPadding = 12, margins, yAxisTickFormat, yAxisElement, yAxisPadding } = yAxisParams;
|
|
631
|
+
const { containerHeight, tickPadding = 12, margins, yAxisTickFormat, yAxisElement, yAxisPadding, tickValues, tickText } = yAxisParams;
|
|
601
632
|
let yAxisPaddingValue = yAxisPadding !== null && yAxisPadding !== void 0 ? yAxisPadding : 0.5;
|
|
602
633
|
yAxisPaddingValue = yAxisPaddingValue === 1 ? 0.99 : yAxisPaddingValue;
|
|
603
634
|
const yAxisScale = d3ScaleBand().domain(dataPoints).range([
|
|
@@ -605,10 +636,17 @@ export function createNumericYAxis(yAxisParams, isRtl, axisData, isIntegralDatas
|
|
|
605
636
|
margins.top
|
|
606
637
|
]).padding(yAxisPaddingValue);
|
|
607
638
|
const axis = isRtl ? d3AxisRight(yAxisScale) : d3AxisLeft(yAxisScale);
|
|
608
|
-
const
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
639
|
+
const customTickValues = tickValues !== null && tickValues !== void 0 ? tickValues : dataPoints;
|
|
640
|
+
const tickFormat = (domainValue, _index)=>{
|
|
641
|
+
if (tickValues && tickText && typeof tickText[_index] !== 'undefined') {
|
|
642
|
+
return tickText[_index];
|
|
643
|
+
}
|
|
644
|
+
if (typeof yAxisTickFormat === 'function') {
|
|
645
|
+
return yAxisTickFormat(domainValue, _index);
|
|
646
|
+
}
|
|
647
|
+
return domainValue;
|
|
648
|
+
};
|
|
649
|
+
const yAxis = axis.tickPadding(tickPadding).tickValues(customTickValues).tickFormat(tickFormat);
|
|
612
650
|
yAxisElement ? d3Select(yAxisElement).call(yAxis).selectAll('text') : '';
|
|
613
651
|
return yAxisScale;
|
|
614
652
|
};
|
|
@@ -618,7 +656,7 @@ export function createNumericYAxis(yAxisParams, isRtl, axisData, isIntegralDatas
|
|
|
618
656
|
* @param dataPoints
|
|
619
657
|
* @param isRtl
|
|
620
658
|
*/ export const createStringYAxis = (yAxisParams, dataPoints, isRtl, barWidth, chartType)=>{
|
|
621
|
-
const { containerHeight, tickPadding = 12, margins, yAxisTickFormat, yAxisElement, yAxisPadding = 0, containerWidth } = yAxisParams;
|
|
659
|
+
const { containerHeight, tickPadding = 12, margins, yAxisTickFormat, yAxisElement, yAxisPadding = 0, containerWidth, tickValues, tickText } = yAxisParams;
|
|
622
660
|
const yAxisScale = d3ScaleBand().domain(dataPoints).range([
|
|
623
661
|
containerHeight - margins.bottom,
|
|
624
662
|
margins.top
|
|
@@ -627,13 +665,20 @@ export function createNumericYAxis(yAxisParams, isRtl, axisData, isIntegralDatas
|
|
|
627
665
|
yAxisScale.paddingInner(1).paddingOuter(0);
|
|
628
666
|
}
|
|
629
667
|
const axis = isRtl ? d3AxisRight(yAxisScale) : d3AxisLeft(yAxisScale);
|
|
630
|
-
const
|
|
668
|
+
const customTickValues = tickValues !== null && tickValues !== void 0 ? tickValues : dataPoints;
|
|
669
|
+
const tickFormat = (domainValue, _index)=>{
|
|
670
|
+
if (tickValues && tickText && typeof tickText[_index] !== 'undefined') {
|
|
671
|
+
return tickText[_index];
|
|
672
|
+
}
|
|
673
|
+
if (typeof yAxisTickFormat === 'function') {
|
|
674
|
+
return yAxisTickFormat(domainValue, _index);
|
|
675
|
+
}
|
|
676
|
+
return domainValue;
|
|
677
|
+
};
|
|
678
|
+
const yAxis = axis.tickPadding(tickPadding).tickValues(customTickValues).tickFormat(tickFormat).tickSize(0);
|
|
631
679
|
if (chartType === 3) {
|
|
632
680
|
axis.tickSizeInner(-(containerWidth - margins.left - margins.right));
|
|
633
681
|
}
|
|
634
|
-
if (yAxisTickFormat) {
|
|
635
|
-
yAxis.tickFormat(yAxisTickFormat);
|
|
636
|
-
}
|
|
637
682
|
yAxisElement ? d3Select(yAxisElement).call(yAxis).selectAll('text') : '';
|
|
638
683
|
return yAxisScale;
|
|
639
684
|
};
|
|
@@ -684,14 +729,7 @@ export function calloutData(values) {
|
|
|
684
729
|
];
|
|
685
730
|
}
|
|
686
731
|
});
|
|
687
|
-
|
|
688
|
-
const originalXValue = isNaN(Number(xValue)) ? xValue : Number(xValue);
|
|
689
|
-
return {
|
|
690
|
-
x: originalXValue,
|
|
691
|
-
values: xValToDataPoints[xValue]
|
|
692
|
-
};
|
|
693
|
-
});
|
|
694
|
-
return result;
|
|
732
|
+
return xValToDataPoints;
|
|
695
733
|
}
|
|
696
734
|
export function getUnique(arr, comp) {
|
|
697
735
|
const unique = arr// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -1761,3 +1799,16 @@ const generateDateTicks = (tickStep, tick0, scaleDomain, useUTC)=>{
|
|
|
1761
1799
|
const exp = Math.pow(base, precision);
|
|
1762
1800
|
return Math.round(value * exp) / exp;
|
|
1763
1801
|
}
|
|
1802
|
+
export const findCalloutPoints = (calloutPointsByX, x)=>{
|
|
1803
|
+
if (x === null) {
|
|
1804
|
+
return undefined;
|
|
1805
|
+
}
|
|
1806
|
+
const key = x instanceof Date ? x.getTime() : x;
|
|
1807
|
+
if (!calloutPointsByX[key]) {
|
|
1808
|
+
return undefined;
|
|
1809
|
+
}
|
|
1810
|
+
return {
|
|
1811
|
+
x,
|
|
1812
|
+
values: calloutPointsByX[key]
|
|
1813
|
+
};
|
|
1814
|
+
};
|