@fluentui/react-charts 9.2.2 → 9.2.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 +74 -2
- package/dist/index.d.ts +187 -15
- package/lib/components/AreaChart/AreaChart.js +7 -4
- package/lib/components/AreaChart/AreaChart.js.map +1 -1
- package/lib/components/AreaChart/useAreaChartStyles.styles.js +4 -3
- package/lib/components/AreaChart/useAreaChartStyles.styles.js.map +1 -1
- package/lib/components/AreaChart/useAreaChartStyles.styles.raw.js +5 -16
- package/lib/components/AreaChart/useAreaChartStyles.styles.raw.js.map +1 -1
- package/lib/components/ChartTable/ChartTable.js +90 -6
- package/lib/components/ChartTable/ChartTable.js.map +1 -1
- package/lib/components/CommonComponents/CartesianChart.js +83 -38
- package/lib/components/CommonComponents/CartesianChart.js.map +1 -1
- package/lib/components/CommonComponents/CartesianChart.types.js.map +1 -1
- package/lib/components/CommonComponents/useCartesianChartStyles.styles.js +19 -3
- package/lib/components/CommonComponents/useCartesianChartStyles.styles.js.map +1 -1
- package/lib/components/CommonComponents/useCartesianChartStyles.styles.raw.js +8 -23
- package/lib/components/CommonComponents/useCartesianChartStyles.styles.raw.js.map +1 -1
- package/lib/components/DeclarativeChart/DeclarativeChart.js +214 -107
- package/lib/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib/components/DeclarativeChart/PlotlyColorAdapter.js +25 -1
- package/lib/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -1
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +1618 -259
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib/components/DonutChart/Arc/useArcStyles.styles.js +8 -3
- package/lib/components/DonutChart/Arc/useArcStyles.styles.js.map +1 -1
- package/lib/components/DonutChart/Arc/useArcStyles.styles.raw.js +6 -2
- package/lib/components/DonutChart/Arc/useArcStyles.styles.raw.js.map +1 -1
- package/lib/components/DonutChart/DonutChart.js +8 -3
- package/lib/components/DonutChart/DonutChart.js.map +1 -1
- package/lib/components/DonutChart/DonutChart.types.js.map +1 -1
- package/lib/components/DonutChart/useDonutChartStyles.styles.js +21 -4
- package/lib/components/DonutChart/useDonutChartStyles.styles.js.map +1 -1
- package/lib/components/DonutChart/useDonutChartStyles.styles.raw.js +8 -4
- package/lib/components/DonutChart/useDonutChartStyles.styles.raw.js.map +1 -1
- package/lib/components/FunnelChart/FunnelChart.js +4 -2
- package/lib/components/FunnelChart/FunnelChart.js.map +1 -1
- package/lib/components/FunnelChart/funnelGeometry.js.map +1 -1
- package/lib/components/GanttChart/useGanttChartStyles.styles.js +2 -1
- package/lib/components/GanttChart/useGanttChartStyles.styles.js.map +1 -1
- package/lib/components/GanttChart/useGanttChartStyles.styles.raw.js +2 -1
- package/lib/components/GanttChart/useGanttChartStyles.styles.raw.js.map +1 -1
- package/lib/components/GaugeChart/GaugeChart.js +1 -2
- package/lib/components/GaugeChart/GaugeChart.js.map +1 -1
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +31 -10
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
- package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js +6 -18
- package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js.map +1 -1
- package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js +6 -22
- package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js.map +1 -1
- package/lib/components/HeatMapChart/HeatMapChart.js +175 -114
- package/lib/components/HeatMapChart/HeatMapChart.js.map +1 -1
- package/lib/components/HeatMapChart/useHeatMapChartStyles.styles.js +2 -1
- package/lib/components/HeatMapChart/useHeatMapChartStyles.styles.js.map +1 -1
- package/lib/components/HeatMapChart/useHeatMapChartStyles.styles.raw.js +2 -1
- package/lib/components/HeatMapChart/useHeatMapChartStyles.styles.raw.js.map +1 -1
- package/lib/components/HorizontalBarChart/HorizontalBarChart.js +1 -1
- package/lib/components/HorizontalBarChart/HorizontalBarChart.js.map +1 -1
- package/lib/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.js +7 -3
- package/lib/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.js.map +1 -1
- package/lib/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.raw.js +5 -2
- package/lib/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.raw.js.map +1 -1
- package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js +26 -6
- package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js.map +1 -1
- package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js +2 -1
- package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js.map +1 -1
- package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.raw.js +2 -1
- package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.raw.js.map +1 -1
- package/lib/components/LineChart/LineChart.js +349 -176
- package/lib/components/LineChart/LineChart.js.map +1 -1
- package/lib/components/LineChart/LineChart.types.js.map +1 -1
- package/lib/components/LineChart/useLineChartStyles.styles.js +28 -8
- package/lib/components/LineChart/useLineChartStyles.styles.js.map +1 -1
- package/lib/components/LineChart/useLineChartStyles.styles.raw.js +9 -14
- package/lib/components/LineChart/useLineChartStyles.styles.raw.js.map +1 -1
- package/lib/components/ResponsiveContainer/withResponsiveContainer.js.map +1 -1
- package/lib/components/SankeyChart/SankeyChart.js.map +1 -1
- package/lib/components/SankeyChart/useSankeyChartStyles.styles.js +12 -25
- package/lib/components/SankeyChart/useSankeyChartStyles.styles.js.map +1 -1
- package/lib/components/SankeyChart/useSankeyChartStyles.styles.raw.js +2 -12
- package/lib/components/SankeyChart/useSankeyChartStyles.styles.raw.js.map +1 -1
- package/lib/components/ScatterChart/ScatterChart.js +139 -81
- package/lib/components/ScatterChart/ScatterChart.js.map +1 -1
- package/lib/components/ScatterChart/ScatterChart.types.js.map +1 -1
- package/lib/components/ScatterChart/useScatterChartStyles.styles.js +29 -8
- package/lib/components/ScatterChart/useScatterChartStyles.styles.js.map +1 -1
- package/lib/components/ScatterChart/useScatterChartStyles.styles.raw.js +10 -15
- package/lib/components/ScatterChart/useScatterChartStyles.styles.raw.js.map +1 -1
- package/lib/components/VerticalBarChart/VerticalBarChart.js +28 -5
- package/lib/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
- package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.js +10 -7
- package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.js.map +1 -1
- package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js +7 -20
- package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js.map +1 -1
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js +159 -47
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -1
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.types.js.map +1 -1
- package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js +9 -7
- package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js.map +1 -1
- package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js +6 -20
- package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js.map +1 -1
- package/lib/types/DataPoint.js +3 -1
- package/lib/types/DataPoint.js.map +1 -1
- package/lib/utilities/Common.styles.js +47 -0
- package/lib/utilities/Common.styles.js.map +1 -0
- package/lib/utilities/Common.styles.raw.js +47 -0
- package/lib/utilities/Common.styles.raw.js.map +1 -0
- package/lib/utilities/SVGTooltipText.js.map +1 -1
- package/lib/utilities/image-export-utils.js.map +1 -1
- package/lib/utilities/index.js +1 -0
- package/lib/utilities/index.js.map +1 -1
- package/lib/utilities/scatterpolar-utils.js +52 -0
- package/lib/utilities/scatterpolar-utils.js.map +1 -0
- package/lib/utilities/utilities.js +324 -147
- package/lib/utilities/utilities.js.map +1 -1
- package/lib/utilities/vbc-utils.js.map +1 -1
- package/lib-commonjs/components/AreaChart/AreaChart.js +6 -3
- package/lib-commonjs/components/AreaChart/AreaChart.js.map +1 -1
- package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.js +2 -1
- package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.raw.js +4 -15
- package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/ChartTable/ChartTable.js +90 -6
- package/lib-commonjs/components/ChartTable/ChartTable.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/CartesianChart.js +83 -37
- package/lib-commonjs/components/CommonComponents/CartesianChart.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/CartesianChart.types.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.js +17 -2
- package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.raw.js +6 -22
- package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js +212 -107
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.js +31 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +1652 -260
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib-commonjs/components/DonutChart/Arc/useArcStyles.styles.js +12 -3
- package/lib-commonjs/components/DonutChart/Arc/useArcStyles.styles.js.map +1 -1
- package/lib-commonjs/components/DonutChart/Arc/useArcStyles.styles.raw.js +6 -2
- package/lib-commonjs/components/DonutChart/Arc/useArcStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/DonutChart/DonutChart.js +7 -2
- 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/useDonutChartStyles.styles.js +32 -4
- package/lib-commonjs/components/DonutChart/useDonutChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/DonutChart/useDonutChartStyles.styles.raw.js +8 -4
- package/lib-commonjs/components/DonutChart/useDonutChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/FunnelChart/FunnelChart.js +4 -2
- package/lib-commonjs/components/FunnelChart/FunnelChart.js.map +1 -1
- package/lib-commonjs/components/FunnelChart/funnelGeometry.js.map +1 -1
- package/lib-commonjs/components/GanttChart/useGanttChartStyles.styles.js +2 -1
- package/lib-commonjs/components/GanttChart/useGanttChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/GanttChart/useGanttChartStyles.styles.raw.js +2 -1
- package/lib-commonjs/components/GanttChart/useGanttChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/GaugeChart/GaugeChart.js +1 -2
- package/lib-commonjs/components/GaugeChart/GaugeChart.js.map +1 -1
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +30 -9
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
- package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js +4 -20
- package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js +5 -21
- package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/HeatMapChart/HeatMapChart.js +174 -113
- package/lib-commonjs/components/HeatMapChart/HeatMapChart.js.map +1 -1
- package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.js +2 -1
- package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.raw.js +2 -1
- package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChart/HorizontalBarChart.js +1 -1
- package/lib-commonjs/components/HorizontalBarChart/HorizontalBarChart.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.js +10 -3
- package/lib-commonjs/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.raw.js +5 -2
- package/lib-commonjs/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js +25 -5
- package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js +2 -1
- package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.raw.js +2 -1
- package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/LineChart/LineChart.js +347 -175
- package/lib-commonjs/components/LineChart/LineChart.js.map +1 -1
- package/lib-commonjs/components/LineChart/LineChart.types.js.map +1 -1
- package/lib-commonjs/components/LineChart/useLineChartStyles.styles.js +35 -5
- package/lib-commonjs/components/LineChart/useLineChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/LineChart/useLineChartStyles.styles.raw.js +7 -13
- package/lib-commonjs/components/LineChart/useLineChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/ResponsiveContainer/withResponsiveContainer.js.map +1 -1
- package/lib-commonjs/components/SankeyChart/SankeyChart.js.map +1 -1
- package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.js +23 -33
- package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.raw.js +1 -12
- package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/ScatterChart/ScatterChart.js +137 -79
- package/lib-commonjs/components/ScatterChart/ScatterChart.js.map +1 -1
- package/lib-commonjs/components/ScatterChart/ScatterChart.types.js.map +1 -1
- package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.js +39 -6
- package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.raw.js +9 -14
- package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js +27 -4
- package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
- package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.js +7 -4
- package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js +5 -18
- package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js +158 -46
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -1
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.types.js.map +1 -1
- package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js +7 -4
- package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js +5 -19
- package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/types/DataPoint.js +3 -1
- package/lib-commonjs/types/DataPoint.js.map +1 -1
- package/lib-commonjs/utilities/Common.styles.js +71 -0
- package/lib-commonjs/utilities/Common.styles.js.map +1 -0
- package/lib-commonjs/utilities/Common.styles.raw.js +71 -0
- package/lib-commonjs/utilities/Common.styles.raw.js.map +1 -0
- package/lib-commonjs/utilities/SVGTooltipText.js.map +1 -1
- package/lib-commonjs/utilities/image-export-utils.js.map +1 -1
- package/lib-commonjs/utilities/index.js +1 -0
- package/lib-commonjs/utilities/index.js.map +1 -1
- package/lib-commonjs/utilities/scatterpolar-utils.js +67 -0
- package/lib-commonjs/utilities/scatterpolar-utils.js.map +1 -0
- package/lib-commonjs/utilities/utilities.js +337 -137
- package/lib-commonjs/utilities/utilities.js.map +1 -1
- package/lib-commonjs/utilities/vbc-utils.js.map +1 -1
- package/package.json +10 -10
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { axisRight as d3AxisRight, axisBottom as d3AxisBottom, axisLeft as d3AxisLeft } from 'd3-axis';
|
|
2
2
|
import { max as d3Max, min as d3Min, ticks as d3Ticks, nice as d3nice, sum as d3Sum, mean as d3Mean, median as d3Median } from 'd3-array';
|
|
3
|
-
import { scaleLinear as d3ScaleLinear, scaleBand as d3ScaleBand, scaleUtc as d3ScaleUtc, scaleTime as d3ScaleTime } from 'd3-scale';
|
|
3
|
+
import { scaleLinear as d3ScaleLinear, scaleBand as d3ScaleBand, scaleUtc as d3ScaleUtc, scaleTime as d3ScaleTime, scaleLog as d3ScaleLog } from 'd3-scale';
|
|
4
4
|
import { select as d3Select, selectAll as d3SelectAll } from 'd3-selection';
|
|
5
5
|
import { format as d3Format } from 'd3-format';
|
|
6
6
|
import { timeFormat as d3TimeFormat, timeFormatLocale as d3TimeFormatLocale, utcFormat as d3UtcFormat } from 'd3-time-format';
|
|
@@ -8,8 +8,10 @@ import { timeSecond as d3TimeSecond, timeMinute as d3TimeMinute, timeHour as d3T
|
|
|
8
8
|
import { curveLinear as d3CurveLinear, curveNatural as d3CurveNatural, curveStep as d3CurveStep, curveStepAfter as d3CurveStepAfter, curveStepBefore as d3CurveStepBefore } from 'd3-shape';
|
|
9
9
|
import { formatPrefix as d3FormatPrefix } from 'd3-format';
|
|
10
10
|
import { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';
|
|
11
|
-
import { formatDateToLocaleString, formatToLocaleString, getMultiLevelDateTimeFormatOptions } from '@fluentui/chart-utilities';
|
|
11
|
+
import { formatDateToLocaleString, formatToLocaleString, getMultiLevelDateTimeFormatOptions, isInvalidValue, isNumber } from '@fluentui/chart-utilities';
|
|
12
12
|
export const MIN_DOMAIN_MARGIN = 8;
|
|
13
|
+
export const MIN_DONUT_RADIUS = 1;
|
|
14
|
+
export const DEFAULT_DATE_STRING = '2000-01-01';
|
|
13
15
|
export var ChartTypes = /*#__PURE__*/ function(ChartTypes) {
|
|
14
16
|
ChartTypes[ChartTypes["AreaChart"] = 0] = "AreaChart";
|
|
15
17
|
ChartTypes[ChartTypes["LineChart"] = 1] = "LineChart";
|
|
@@ -62,9 +64,9 @@ function yAxisTickFormatterInternal(value, limitWidth = false) {
|
|
|
62
64
|
* Create Numeric X axis
|
|
63
65
|
* @export
|
|
64
66
|
* @param {IXAxisParams} xAxisParams
|
|
65
|
-
*/ export function createNumericXAxis(xAxisParams, tickParams, chartType, culture) {
|
|
66
|
-
const { domainNRangeValues, showRoundOffXTickValues = false, xAxistickSize = 6, tickPadding = 10, xAxisCount, xAxisElement, hideTickOverlap, calcMaxLabelWidth } = xAxisParams;
|
|
67
|
-
const xAxisScale =
|
|
67
|
+
*/ export function createNumericXAxis(xAxisParams, tickParams, chartType, culture, scaleType) {
|
|
68
|
+
const { domainNRangeValues, showRoundOffXTickValues = false, xAxistickSize = 6, tickPadding = 10, xAxisCount, xAxisElement, hideTickOverlap, calcMaxLabelWidth, tickStep, tick0 } = xAxisParams;
|
|
69
|
+
const xAxisScale = createNumericScale(scaleType).domain([
|
|
68
70
|
domainNRangeValues.dStartValue,
|
|
69
71
|
domainNRangeValues.dEndValue
|
|
70
72
|
]).range([
|
|
@@ -73,33 +75,38 @@ function yAxisTickFormatterInternal(value, limitWidth = false) {
|
|
|
73
75
|
]);
|
|
74
76
|
showRoundOffXTickValues && xAxisScale.nice();
|
|
75
77
|
let tickCount = xAxisCount !== null && xAxisCount !== void 0 ? xAxisCount : 6;
|
|
76
|
-
const tickFormat = (domainValue, _index)=>{
|
|
78
|
+
const tickFormat = (domainValue, _index, defaultFormat)=>{
|
|
77
79
|
if (tickParams.tickFormat) {
|
|
78
80
|
return d3Format(tickParams.tickFormat)(domainValue);
|
|
79
81
|
}
|
|
80
82
|
const xAxisValue = typeof domainValue === 'number' ? domainValue : domainValue.valueOf();
|
|
81
|
-
return formatToLocaleString(xAxisValue, culture);
|
|
83
|
+
return (defaultFormat === null || defaultFormat === void 0 ? void 0 : defaultFormat(xAxisValue)) === '' ? '' : formatToLocaleString(xAxisValue, culture);
|
|
82
84
|
};
|
|
83
85
|
if (hideTickOverlap && typeof xAxisCount === 'undefined') {
|
|
84
|
-
const longestLabelWidth = calcMaxLabelWidth(xAxisScale.ticks().map(tickFormat)) + 20;
|
|
86
|
+
const longestLabelWidth = calcMaxLabelWidth(xAxisScale.ticks().map((v, i)=>tickFormat(v, i))) + 20;
|
|
85
87
|
const [start, end] = xAxisScale.range();
|
|
86
88
|
tickCount = Math.min(Math.max(1, Math.floor(Math.abs(end - start) / longestLabelWidth)), 10);
|
|
87
89
|
}
|
|
88
|
-
const xAxis = d3AxisBottom(xAxisScale).tickSize(xAxistickSize).tickPadding(tickPadding).ticks(tickCount).tickFormat(tickFormat);
|
|
90
|
+
const xAxis = d3AxisBottom(xAxisScale).tickSize(xAxistickSize).tickPadding(tickPadding).ticks(tickCount).tickFormat((v, i)=>tickFormat(v, i, xAxisScale.tickFormat(tickCount)));
|
|
89
91
|
if ([
|
|
90
92
|
6,
|
|
91
93
|
8
|
|
92
94
|
].includes(chartType)) {
|
|
93
95
|
xAxis.tickSizeInner(-(xAxisParams.containerHeight - xAxisParams.margins.top));
|
|
94
96
|
}
|
|
97
|
+
let customTickValues;
|
|
95
98
|
if (tickParams.tickValues) {
|
|
96
|
-
|
|
99
|
+
customTickValues = tickParams.tickValues;
|
|
100
|
+
} else if (tickStep) {
|
|
101
|
+
customTickValues = generateNumericTicks(scaleType, tickStep, tick0, xAxisScale.domain());
|
|
102
|
+
}
|
|
103
|
+
if (customTickValues) {
|
|
104
|
+
xAxis.tickValues(customTickValues);
|
|
97
105
|
}
|
|
98
106
|
if (xAxisElement) {
|
|
99
107
|
d3Select(xAxisElement).call(xAxis).selectAll('text').attr('aria-hidden', 'true');
|
|
100
108
|
}
|
|
101
|
-
|
|
102
|
-
const tickValues = ((_tickParams_tickValues = tickParams.tickValues) !== null && _tickParams_tickValues !== void 0 ? _tickParams_tickValues : xAxisScale.ticks(tickCount)).map(xAxis.tickFormat());
|
|
109
|
+
const tickValues = (customTickValues !== null && customTickValues !== void 0 ? customTickValues : xAxisScale.ticks(tickCount)).map(xAxis.tickFormat());
|
|
103
110
|
return {
|
|
104
111
|
xScale: xAxisScale,
|
|
105
112
|
tickValues
|
|
@@ -295,7 +302,7 @@ export function getDateFormatLevel(date, useUTC) {
|
|
|
295
302
|
* @param {IXAxisParams} xAxisParams
|
|
296
303
|
* @param {ITickParams} tickParams
|
|
297
304
|
*/ export function createDateXAxis(xAxisParams, tickParams, culture, options, timeFormatLocale, customDateTimeFormatter, useUTC, chartType) {
|
|
298
|
-
const { domainNRangeValues, xAxisElement, tickPadding = 6, xAxistickSize = 6, xAxisCount, calcMaxLabelWidth } = xAxisParams;
|
|
305
|
+
const { domainNRangeValues, xAxisElement, tickPadding = 6, xAxistickSize = 6, xAxisCount, calcMaxLabelWidth, tickStep, tick0 } = xAxisParams;
|
|
299
306
|
const isUtcSet = useUTC === true || useUTC === 'utc';
|
|
300
307
|
const xAxisScale = isUtcSet ? d3ScaleUtc() : d3ScaleTime();
|
|
301
308
|
xAxisScale.domain([
|
|
@@ -346,12 +353,19 @@ export function getDateFormatLevel(date, useUTC) {
|
|
|
346
353
|
].includes(chartType)) {
|
|
347
354
|
xAxis.tickSizeInner(-(xAxisParams.containerHeight - xAxisParams.margins.top));
|
|
348
355
|
}
|
|
349
|
-
|
|
356
|
+
let customTickValues;
|
|
357
|
+
if (tickParams.tickValues) {
|
|
358
|
+
customTickValues = tickParams.tickValues;
|
|
359
|
+
} else if (tickStep) {
|
|
360
|
+
customTickValues = generateDateTicks(tickStep, tick0, xAxisScale.domain(), useUTC);
|
|
361
|
+
}
|
|
362
|
+
if (customTickValues) {
|
|
363
|
+
xAxis.tickValues(customTickValues);
|
|
364
|
+
}
|
|
350
365
|
if (xAxisElement) {
|
|
351
366
|
d3Select(xAxisElement).call(xAxis).selectAll('text').attr('aria-hidden', 'true');
|
|
352
367
|
}
|
|
353
|
-
|
|
354
|
-
const tickValues = ((_tickParams_tickValues = tickParams.tickValues) !== null && _tickParams_tickValues !== void 0 ? _tickParams_tickValues : xAxisScale.ticks(tickCount)).map(xAxis.tickFormat());
|
|
368
|
+
const tickValues = (customTickValues !== null && customTickValues !== void 0 ? customTickValues : xAxisScale.ticks(tickCount)).map(xAxis.tickFormat());
|
|
355
369
|
return {
|
|
356
370
|
xScale: xAxisScale,
|
|
357
371
|
tickValues
|
|
@@ -483,7 +497,7 @@ export function createYAxisForHorizontalBarChartWithAxis(yAxisParams, isRtl) {
|
|
|
483
497
|
const { yMinMaxValues = {
|
|
484
498
|
startValue: 0,
|
|
485
499
|
endValue: 0
|
|
486
|
-
}, yAxisElement = null, yMaxValue = 0, yMinValue = 0, containerHeight, margins, tickPadding = 12, maxOfYVal = 0, yAxisTickFormat, yAxisTickCount = 4 } = yAxisParams;
|
|
500
|
+
}, yAxisElement = null, yMaxValue = 0, yMinValue = 0, containerHeight, margins, tickPadding = 12, maxOfYVal = 0, yAxisTickFormat, yAxisTickCount = 4, tickValues, tickStep, tick0 } = yAxisParams;
|
|
487
501
|
// maxOfYVal coming from horizontal bar chart with axis (Calculation done at base file)
|
|
488
502
|
const tempVal = maxOfYVal || yMinMaxValues.endValue;
|
|
489
503
|
const finalYmax = tempVal > yMaxValue ? tempVal : yMaxValue;
|
|
@@ -498,14 +512,23 @@ export function createYAxisForHorizontalBarChartWithAxis(yAxisParams, isRtl) {
|
|
|
498
512
|
const axis = isRtl ? d3AxisRight(yAxisScale) : d3AxisLeft(yAxisScale);
|
|
499
513
|
const yAxis = axis.tickPadding(tickPadding).ticks(yAxisTickCount);
|
|
500
514
|
yAxisTickFormat ? yAxis.tickFormat(yAxisTickFormat) : yAxis.tickFormat(defaultYAxisTickFormatter);
|
|
515
|
+
let customTickValues;
|
|
516
|
+
if (tickValues) {
|
|
517
|
+
customTickValues = tickValues;
|
|
518
|
+
} else if (tickStep) {
|
|
519
|
+
customTickValues = generateNumericTicks(undefined, tickStep, tick0, yAxisScale.domain());
|
|
520
|
+
}
|
|
521
|
+
if (customTickValues) {
|
|
522
|
+
yAxis.tickValues(customTickValues);
|
|
523
|
+
}
|
|
501
524
|
yAxisElement ? d3Select(yAxisElement).call(yAxis).selectAll('text').attr('aria-hidden', 'true') : '';
|
|
502
525
|
return yAxisScale;
|
|
503
526
|
}
|
|
504
|
-
export function createNumericYAxis(yAxisParams, isRtl, axisData, isIntegralDataset, chartType, useSecondaryYScale = false, roundedTicks = false) {
|
|
527
|
+
export function createNumericYAxis(yAxisParams, isRtl, axisData, isIntegralDataset, chartType, useSecondaryYScale = false, roundedTicks = false, scaleType) {
|
|
505
528
|
const { yMinMaxValues = {
|
|
506
529
|
startValue: 0,
|
|
507
530
|
endValue: 0
|
|
508
|
-
}, yAxisElement = null, yMaxValue = 0, yMinValue = 0, containerHeight, containerWidth, margins, tickPadding = 12, maxOfYVal = 0, yAxisTickFormat, yAxisTickCount = 4, eventAnnotationProps, eventLabelHeight } = yAxisParams;
|
|
531
|
+
}, yAxisElement = null, yMaxValue = 0, yMinValue = 0, containerHeight, containerWidth, margins, tickPadding = 12, maxOfYVal = 0, yAxisTickFormat, yAxisTickCount = 4, eventAnnotationProps, eventLabelHeight, tickValues, tickStep, tick0 } = yAxisParams;
|
|
509
532
|
// maxOfYVal coming from only area chart and Grouped vertical bar chart(Calculation done at base file)
|
|
510
533
|
const tempVal = maxOfYVal || yMinMaxValues.endValue || 0;
|
|
511
534
|
const finalYmax = tempVal > yMaxValue ? tempVal : yMaxValue;
|
|
@@ -518,18 +541,53 @@ export function createNumericYAxis(yAxisParams, isRtl, axisData, isIntegralDatas
|
|
|
518
541
|
yMin = yMin - yPadding;
|
|
519
542
|
yMax = yMax + yPadding;
|
|
520
543
|
}
|
|
521
|
-
|
|
544
|
+
let scaleDomain = [
|
|
522
545
|
domainValues[0],
|
|
523
|
-
|
|
524
|
-
]
|
|
546
|
+
domainValues[domainValues.length - 1]
|
|
547
|
+
];
|
|
548
|
+
if (scaleType === 'log') {
|
|
549
|
+
let domainStart = yMinMaxValues.startValue;
|
|
550
|
+
let domainEnd = yMinMaxValues.endValue;
|
|
551
|
+
if (yMinValue > 0) {
|
|
552
|
+
domainStart = Math.min(domainStart, yMinValue);
|
|
553
|
+
}
|
|
554
|
+
if (yMaxValue > 0) {
|
|
555
|
+
domainEnd = Math.max(domainEnd, yMaxValue);
|
|
556
|
+
}
|
|
557
|
+
scaleDomain = [
|
|
558
|
+
domainStart,
|
|
559
|
+
domainEnd
|
|
560
|
+
];
|
|
561
|
+
}
|
|
562
|
+
const yAxisScale = createNumericScale(scaleType).domain(scaleDomain).range([
|
|
525
563
|
containerHeight - margins.bottom,
|
|
526
564
|
margins.top + (eventAnnotationProps ? eventLabelHeight : 0)
|
|
527
565
|
]);
|
|
528
566
|
const axis = !isRtl && useSecondaryYScale || isRtl && !useSecondaryYScale ? d3AxisRight(yAxisScale) : d3AxisLeft(yAxisScale);
|
|
529
|
-
const yAxis = axis.tickPadding(tickPadding).
|
|
530
|
-
|
|
567
|
+
const yAxis = axis.tickPadding(tickPadding).tickSizeInner(-(containerWidth - margins.left - margins.right));
|
|
568
|
+
let customTickValues;
|
|
569
|
+
if (tickValues) {
|
|
570
|
+
customTickValues = tickValues;
|
|
571
|
+
} else if (tickStep) {
|
|
572
|
+
customTickValues = generateNumericTicks(scaleType, tickStep, tick0, yAxisScale.domain());
|
|
573
|
+
}
|
|
574
|
+
if (customTickValues) {
|
|
575
|
+
yAxis.tickValues(customTickValues);
|
|
576
|
+
axisData.yAxisDomainValues = customTickValues;
|
|
577
|
+
} else {
|
|
578
|
+
if (scaleType === 'log') {
|
|
579
|
+
axisData.yAxisDomainValues = yAxisScale.ticks();
|
|
580
|
+
} else {
|
|
581
|
+
yAxis.tickValues(domainValues);
|
|
582
|
+
axisData.yAxisDomainValues = domainValues;
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
const tickFormat = (domainValue, index, defaultFormat)=>{
|
|
586
|
+
const value = typeof domainValue === 'number' ? domainValue : domainValue.valueOf();
|
|
587
|
+
return (defaultFormat === null || defaultFormat === void 0 ? void 0 : defaultFormat(value)) === '' ? '' : defaultYAxisTickFormatter(value);
|
|
588
|
+
};
|
|
589
|
+
yAxisTickFormat ? yAxis.tickFormat(yAxisTickFormat) : yAxis.tickFormat((v, i)=>tickFormat(v, i, yAxisScale.tickFormat(yAxisTickCount)));
|
|
531
590
|
yAxisElement ? d3Select(yAxisElement).call(yAxis).selectAll('text').attr('aria-hidden', 'true') : '';
|
|
532
|
-
axisData.yAxisDomainValues = domainValues;
|
|
533
591
|
return yAxisScale;
|
|
534
592
|
}
|
|
535
593
|
/**
|
|
@@ -558,14 +616,20 @@ export function createNumericYAxis(yAxisParams, isRtl, axisData, isIntegralDatas
|
|
|
558
616
|
* @param yAxisParams
|
|
559
617
|
* @param dataPoints
|
|
560
618
|
* @param isRtl
|
|
561
|
-
*/ export const createStringYAxis = (yAxisParams, dataPoints, isRtl)=>{
|
|
562
|
-
const { containerHeight, tickPadding = 12, margins, yAxisTickFormat, yAxisElement, yAxisPadding = 0 } = yAxisParams;
|
|
619
|
+
*/ export const createStringYAxis = (yAxisParams, dataPoints, isRtl, barWidth, chartType)=>{
|
|
620
|
+
const { containerHeight, tickPadding = 12, margins, yAxisTickFormat, yAxisElement, yAxisPadding = 0, containerWidth } = yAxisParams;
|
|
563
621
|
const yAxisScale = d3ScaleBand().domain(dataPoints).range([
|
|
564
622
|
containerHeight - margins.bottom,
|
|
565
623
|
margins.top
|
|
566
624
|
]).padding(yAxisPadding);
|
|
625
|
+
if (chartType === 3) {
|
|
626
|
+
yAxisScale.paddingInner(1).paddingOuter(0);
|
|
627
|
+
}
|
|
567
628
|
const axis = isRtl ? d3AxisRight(yAxisScale) : d3AxisLeft(yAxisScale);
|
|
568
629
|
const yAxis = axis.tickPadding(tickPadding).tickValues(dataPoints).tickSize(0);
|
|
630
|
+
if (chartType === 3) {
|
|
631
|
+
axis.tickSizeInner(-(containerWidth - margins.left - margins.right));
|
|
632
|
+
}
|
|
569
633
|
if (yAxisTickFormat) {
|
|
570
634
|
yAxis.tickFormat(yAxisTickFormat);
|
|
571
635
|
}
|
|
@@ -576,7 +640,9 @@ export function createNumericYAxis(yAxisParams, isRtl, axisData, isIntegralDatas
|
|
|
576
640
|
* For area chart and line chart, while displaying stackCallout, Need to form a callout data object.
|
|
577
641
|
* This methos creates an object for those 2 charts.
|
|
578
642
|
* @param values
|
|
579
|
-
*/
|
|
643
|
+
*/ // changing the type to any as it is used by multiple charts with different data types
|
|
644
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
645
|
+
export function calloutData(values) {
|
|
580
646
|
let combinedResult = [];
|
|
581
647
|
values.forEach((line)=>{
|
|
582
648
|
const elements = line.data.filter((point)=>!point.hideCallout).map((point)=>{
|
|
@@ -590,6 +656,7 @@ export function createNumericYAxis(yAxisParams, isRtl, axisData, isIntegralDatas
|
|
|
590
656
|
combinedResult = combinedResult.concat(elements);
|
|
591
657
|
});
|
|
592
658
|
const xValToDataPoints = {};
|
|
659
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
593
660
|
combinedResult.forEach((ele)=>{
|
|
594
661
|
const xValue = ele.x instanceof Date ? ele.x.getTime() : ele.x;
|
|
595
662
|
if (xValue in xValToDataPoints) {
|
|
@@ -740,9 +807,9 @@ yAxis, noOfCharsToTruncate, truncateLabel, isRtl) {
|
|
|
740
807
|
const uid = tickIndex++;
|
|
741
808
|
text.text(null).append('tspan').attr('x', x).attr('y', y).attr('id', `BaseSpan-${uid}`).attr('dy', dy + 'em').attr('data-', totalWord);
|
|
742
809
|
if (truncateLabel && totalWordLength > noOfCharsToTruncate) {
|
|
743
|
-
text.append('tspan').attr('id', `showDots-${uid}`).attr('x',
|
|
810
|
+
text.append('tspan').attr('id', `showDots-${uid}`).attr('x', x).attr('y', y).attr('dy', dy + 'em').attr('dx', padding + dx + 'em').text(truncatedWord);
|
|
744
811
|
} else {
|
|
745
|
-
text.
|
|
812
|
+
text.append('tspan').attr('id', `LessLength-${uid}`).attr('x', x).attr('y', y).attr('dx', padding + dx + 'em').text(totalWord);
|
|
746
813
|
}
|
|
747
814
|
});
|
|
748
815
|
}
|
|
@@ -796,7 +863,7 @@ export function tooltipOfAxislabels(axistooltipProps) {
|
|
|
796
863
|
return null;
|
|
797
864
|
}
|
|
798
865
|
const div = d3Select('body').append('div').attr('id', id).attr('class', tooltipCls).style('opacity', 0);
|
|
799
|
-
const aa = axis.selectAll('
|
|
866
|
+
const aa = axis.selectAll('[id^="BaseSpan-"]')._groups[0];
|
|
800
867
|
const baseSpanLength = aa && Object.keys(aa).length;
|
|
801
868
|
const originalDataArray = [];
|
|
802
869
|
for(let i = 0; i < baseSpanLength; i++){
|
|
@@ -840,59 +907,24 @@ export function tooltipOfAxislabels(axistooltipProps) {
|
|
|
840
907
|
* @param {number} width
|
|
841
908
|
* @param {boolean} isRTL
|
|
842
909
|
* @returns {IDomainNRange}
|
|
843
|
-
*/ export function
|
|
844
|
-
const
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
});
|
|
852
|
-
const rStartValue = margins.left;
|
|
853
|
-
const rEndValue = width - margins.right;
|
|
854
|
-
return isRTL ? {
|
|
855
|
-
dStartValue: xMax,
|
|
856
|
-
dEndValue: xMin,
|
|
857
|
-
rStartValue,
|
|
858
|
-
rEndValue
|
|
859
|
-
} : {
|
|
860
|
-
dStartValue: xMin,
|
|
861
|
-
dEndValue: xMax,
|
|
862
|
-
rStartValue,
|
|
863
|
-
rEndValue
|
|
864
|
-
};
|
|
865
|
-
}
|
|
866
|
-
/**
|
|
867
|
-
* Calculates Domain and range values for Numeric X axis for scatter chart.
|
|
868
|
-
* @export
|
|
869
|
-
* @param {LineChartPoints[]} points
|
|
870
|
-
* @param {IMargins} margins
|
|
871
|
-
* @param {number} width
|
|
872
|
-
* @param {boolean} isRTL
|
|
873
|
-
* @returns {IDomainNRange}
|
|
874
|
-
*/ export function domainRangeOfNumericForScatterChart(points, margins, width, isRTL) {
|
|
875
|
-
let xMin = d3Min(points, (point)=>{
|
|
876
|
-
return d3Min(point.data, (item)=>item.x);
|
|
877
|
-
});
|
|
878
|
-
let xMax = d3Max(points, (point)=>{
|
|
879
|
-
return d3Max(point.data, (item)=>{
|
|
880
|
-
return item.x;
|
|
881
|
-
});
|
|
882
|
-
});
|
|
883
|
-
const xPadding = (xMax - xMin) * 0.1;
|
|
884
|
-
xMin = xMin - xPadding;
|
|
885
|
-
xMax = xMax + xPadding;
|
|
910
|
+
*/ export function domainRangeOfNumericForAreaLineScatterCharts(points, margins, width, isRTL, scaleType, hasMarkersMode) {
|
|
911
|
+
const isScatterPolar = isScatterPolarSeries(points);
|
|
912
|
+
let [xMin, xMax] = getScatterXDomainExtent(points, scaleType);
|
|
913
|
+
if (hasMarkersMode) {
|
|
914
|
+
const xPadding = getDomainPaddingForMarkers(xMin, xMax, scaleType);
|
|
915
|
+
xMin = xMin - xPadding.start;
|
|
916
|
+
xMax = xMax + xPadding.end;
|
|
917
|
+
}
|
|
886
918
|
const rStartValue = margins.left;
|
|
887
919
|
const rEndValue = width - margins.right;
|
|
888
920
|
return isRTL ? {
|
|
889
|
-
dStartValue: xMax,
|
|
890
|
-
dEndValue: xMin,
|
|
921
|
+
dStartValue: isScatterPolar ? 1 : xMax,
|
|
922
|
+
dEndValue: isScatterPolar ? -1 : xMin,
|
|
891
923
|
rStartValue,
|
|
892
924
|
rEndValue
|
|
893
925
|
} : {
|
|
894
|
-
dStartValue: xMin,
|
|
895
|
-
dEndValue: xMax,
|
|
926
|
+
dStartValue: isScatterPolar ? -1 : xMin,
|
|
927
|
+
dEndValue: isScatterPolar ? 1 : xMax,
|
|
896
928
|
rStartValue,
|
|
897
929
|
rEndValue
|
|
898
930
|
};
|
|
@@ -1020,22 +1052,15 @@ export function tooltipOfAxislabels(axistooltipProps) {
|
|
|
1020
1052
|
* @param {boolean} isRTL
|
|
1021
1053
|
* @param {Date[] | number[]} tickValues
|
|
1022
1054
|
* @returns {IDomainNRange}
|
|
1023
|
-
*/ export function
|
|
1055
|
+
*/ export function domainRangeOfDateForAreaLineScatterVerticalBarCharts(points, margins, width, isRTL, tickValues = [], chartType, barWidth, hasMarkersMode) {
|
|
1024
1056
|
let sDate;
|
|
1025
1057
|
let lDate;
|
|
1026
|
-
if (
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
});
|
|
1033
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1034
|
-
lDate = d3Max(points, (point)=>{
|
|
1035
|
-
return d3Max(point.data, (item)=>{
|
|
1036
|
-
return item.x;
|
|
1037
|
-
});
|
|
1038
|
-
});
|
|
1058
|
+
if ([
|
|
1059
|
+
0,
|
|
1060
|
+
1,
|
|
1061
|
+
7
|
|
1062
|
+
].includes(chartType)) {
|
|
1063
|
+
[sDate, lDate] = getScatterXDomainExtent(points);
|
|
1039
1064
|
// Need to draw graph with given small and large date
|
|
1040
1065
|
// (Which Involves customization of date axis tick values)
|
|
1041
1066
|
// That may be Either from given graph data or from prop 'tickValues' date values.
|
|
@@ -1053,6 +1078,11 @@ export function tooltipOfAxislabels(axistooltipProps) {
|
|
|
1053
1078
|
sDate = d3Min(points, (point)=>point.x);
|
|
1054
1079
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1055
1080
|
lDate = d3Max(points, (point)=>point.x);
|
|
1081
|
+
if (hasMarkersMode || chartType === 7) {
|
|
1082
|
+
const xPadding = getDomainPaddingForMarkers(sDate.getTime(), lDate.getTime());
|
|
1083
|
+
sDate = new Date(sDate.getTime() - xPadding.start);
|
|
1084
|
+
lDate = new Date(lDate.getTime() + xPadding.end);
|
|
1085
|
+
}
|
|
1056
1086
|
}
|
|
1057
1087
|
const rStartValue = margins.left;
|
|
1058
1088
|
const rEndValue = width - margins.right;
|
|
@@ -1068,59 +1098,6 @@ export function tooltipOfAxislabels(axistooltipProps) {
|
|
|
1068
1098
|
rEndValue
|
|
1069
1099
|
};
|
|
1070
1100
|
}
|
|
1071
|
-
/**
|
|
1072
|
-
* Calculates Domain and range values for Date X axis for scatter chart.
|
|
1073
|
-
* @export
|
|
1074
|
-
* @param {LineChartPoints[]} points
|
|
1075
|
-
* @param {IMargins} margins
|
|
1076
|
-
* @param {number} width
|
|
1077
|
-
* @param {boolean} isRTL
|
|
1078
|
-
* @param {Date[] | number[]} tickValues
|
|
1079
|
-
* @returns {IDomainNRange}
|
|
1080
|
-
*/ export function domainRangeOfDateForScatterChart(points, margins, width, isRTL, tickValues = []) {
|
|
1081
|
-
let sDate;
|
|
1082
|
-
let lDate;
|
|
1083
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1084
|
-
sDate = d3Min(points, (point)=>{
|
|
1085
|
-
return d3Min(point.data, (item)=>{
|
|
1086
|
-
return item.x;
|
|
1087
|
-
});
|
|
1088
|
-
});
|
|
1089
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1090
|
-
lDate = d3Max(points, (point)=>{
|
|
1091
|
-
return d3Max(point.data, (item)=>{
|
|
1092
|
-
return item.x;
|
|
1093
|
-
});
|
|
1094
|
-
});
|
|
1095
|
-
const xPadding = (lDate.getTime() - sDate.getTime()) * 0.1;
|
|
1096
|
-
sDate = new Date(sDate.getTime() - xPadding);
|
|
1097
|
-
lDate = new Date(lDate.getTime() + xPadding);
|
|
1098
|
-
// Need to draw graph with given small and large date
|
|
1099
|
-
// (Which Involves customization of date axis tick values)
|
|
1100
|
-
// That may be Either from given graph data or from prop 'tickValues' date values.
|
|
1101
|
-
// So, Finding smallest and largest dates
|
|
1102
|
-
sDate = d3Min([
|
|
1103
|
-
...tickValues,
|
|
1104
|
-
sDate
|
|
1105
|
-
]);
|
|
1106
|
-
lDate = d3Max([
|
|
1107
|
-
...tickValues,
|
|
1108
|
-
lDate
|
|
1109
|
-
]);
|
|
1110
|
-
const rStartValue = margins.left;
|
|
1111
|
-
const rEndValue = width - margins.right;
|
|
1112
|
-
return isRTL ? {
|
|
1113
|
-
dStartValue: lDate,
|
|
1114
|
-
dEndValue: sDate,
|
|
1115
|
-
rStartValue,
|
|
1116
|
-
rEndValue
|
|
1117
|
-
} : {
|
|
1118
|
-
dStartValue: sDate,
|
|
1119
|
-
dEndValue: lDate,
|
|
1120
|
-
rStartValue,
|
|
1121
|
-
rEndValue
|
|
1122
|
-
};
|
|
1123
|
-
}
|
|
1124
1101
|
/**
|
|
1125
1102
|
* Calculate domain and range values to the Vertical bar chart - For Numeric axis
|
|
1126
1103
|
* @export
|
|
@@ -1152,12 +1129,14 @@ export function tooltipOfAxislabels(axistooltipProps) {
|
|
|
1152
1129
|
* @export
|
|
1153
1130
|
* @param {LineChartPoints[]} points
|
|
1154
1131
|
* @returns {{ startValue: number; endValue: number }}
|
|
1155
|
-
*/ export function findNumericMinMaxOfY(points, yAxisType, useSecondaryYScale) {
|
|
1132
|
+
*/ export function findNumericMinMaxOfY(points, yAxisType, useSecondaryYScale, scaleType) {
|
|
1156
1133
|
const values = [];
|
|
1157
1134
|
points.forEach((point)=>{
|
|
1158
1135
|
if (!useSecondaryYScale === !point.useSecondaryYScale) {
|
|
1159
1136
|
point.data.forEach((data)=>{
|
|
1160
|
-
|
|
1137
|
+
if (isValidDomainValue(data.y, scaleType)) {
|
|
1138
|
+
values.push(data.y);
|
|
1139
|
+
}
|
|
1161
1140
|
});
|
|
1162
1141
|
}
|
|
1163
1142
|
});
|
|
@@ -1583,3 +1562,201 @@ export const createMeasurementSpan = (text, className, parentElement)=>{
|
|
|
1583
1562
|
measurementSpan.textContent = `${text}`;
|
|
1584
1563
|
return measurementSpan;
|
|
1585
1564
|
};
|
|
1565
|
+
/**
|
|
1566
|
+
* Utility function to check if an array of points is scatterpolar
|
|
1567
|
+
* @param points - Array of chart points
|
|
1568
|
+
* @returns true if any point has lineOptions.mode as 'scatterpolar'
|
|
1569
|
+
*/ export function isScatterPolarSeries(points) {
|
|
1570
|
+
return points.some(// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1571
|
+
(item)=>{
|
|
1572
|
+
var _item_lineOptions;
|
|
1573
|
+
return typeof ((_item_lineOptions = item.lineOptions) === null || _item_lineOptions === void 0 ? void 0 : _item_lineOptions.mode) === 'string' && item.lineOptions.mode === 'scatterpolar';
|
|
1574
|
+
});
|
|
1575
|
+
}
|
|
1576
|
+
/**
|
|
1577
|
+
* Utility function to check if an array of points contains mode as 'text' only
|
|
1578
|
+
* @param points - Array of chart points
|
|
1579
|
+
* @returns true if any point has lineOptions.mode as 'text'
|
|
1580
|
+
*/ export function isTextMode(points) {
|
|
1581
|
+
return points.some(// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1582
|
+
(item)=>{
|
|
1583
|
+
var _item_lineOptions;
|
|
1584
|
+
return typeof ((_item_lineOptions = item.lineOptions) === null || _item_lineOptions === void 0 ? void 0 : _item_lineOptions.mode) === 'string' && item.lineOptions.mode === 'text';
|
|
1585
|
+
});
|
|
1586
|
+
}
|
|
1587
|
+
// TODO: Refactor to encapsulate the complete numeric scale creation logic here, including setting domain and range.
|
|
1588
|
+
const createNumericScale = (scaleType)=>{
|
|
1589
|
+
if (scaleType === 'log') {
|
|
1590
|
+
return d3ScaleLog();
|
|
1591
|
+
} else {
|
|
1592
|
+
return d3ScaleLinear();
|
|
1593
|
+
}
|
|
1594
|
+
};
|
|
1595
|
+
export const getDomainPaddingForMarkers = (minVal, maxVal, scaleType)=>{
|
|
1596
|
+
if (scaleType === 'log') {
|
|
1597
|
+
return {
|
|
1598
|
+
start: minVal * 0.5,
|
|
1599
|
+
end: maxVal
|
|
1600
|
+
};
|
|
1601
|
+
}
|
|
1602
|
+
const defaultPadding = (maxVal - minVal) * 0.1;
|
|
1603
|
+
return {
|
|
1604
|
+
start: defaultPadding,
|
|
1605
|
+
end: defaultPadding
|
|
1606
|
+
};
|
|
1607
|
+
};
|
|
1608
|
+
/**
|
|
1609
|
+
* Determines whether a value is valid for inclusion in the scale domain.
|
|
1610
|
+
* For log scales, ensures the value is strictly positive to prevent undefined scale behavior.
|
|
1611
|
+
*/ // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1612
|
+
export const isValidDomainValue = (value, scaleType)=>{
|
|
1613
|
+
return typeof value !== 'number' || scaleType !== 'log' || value > 0;
|
|
1614
|
+
};
|
|
1615
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1616
|
+
export const isPlottable = (x, y)=>{
|
|
1617
|
+
return !isInvalidValue(x) && !isInvalidValue(y);
|
|
1618
|
+
};
|
|
1619
|
+
export const getScatterXDomainExtent = (points, scaleType)=>{
|
|
1620
|
+
const isValidDataPointForScale = (item)=>isValidDomainValue(item.x, scaleType);
|
|
1621
|
+
const xMin = d3Min(points, (point)=>{
|
|
1622
|
+
return d3Min(point.data.filter(isValidDataPointForScale), (item)=>item.x);
|
|
1623
|
+
});
|
|
1624
|
+
const xMax = d3Max(points, (point)=>{
|
|
1625
|
+
return d3Max(point.data.filter(isValidDataPointForScale), (item)=>{
|
|
1626
|
+
return item.x;
|
|
1627
|
+
});
|
|
1628
|
+
});
|
|
1629
|
+
return [
|
|
1630
|
+
xMin,
|
|
1631
|
+
xMax
|
|
1632
|
+
];
|
|
1633
|
+
};
|
|
1634
|
+
export const getRangeForScatterMarkerSize = ({ data, xScale, yScalePrimary, yScaleSecondary, useSecondaryYScale, xScaleType, yScaleType: primaryYScaleType, secondaryYScaleType })=>{
|
|
1635
|
+
// Note: This function is executed after the scale is created, so the actual padding can be
|
|
1636
|
+
// obtained by calculating the difference between the respective minimums or maximums of the
|
|
1637
|
+
// scale domain and the data. However, doing so often causes the marker size to scale up
|
|
1638
|
+
// unnecessarily when the scale uses a wider domain than required (due to the use of D3's nice
|
|
1639
|
+
// function or our own tick value calculations).
|
|
1640
|
+
// A better approach could be to treat the marker size as a fixed pixel value and adjust the
|
|
1641
|
+
// scale domain with sufficient padding to accommodate the maximum marker size—instead of doing
|
|
1642
|
+
// it the other way around (i.e., adjusting the scale domain first with padding and then scaling
|
|
1643
|
+
// the markers to fit inside the plot area).
|
|
1644
|
+
const [xMin, xMax] = getScatterXDomainExtent(data, xScaleType);
|
|
1645
|
+
const xPadding = getDomainPaddingForMarkers(+xMin, +xMax, xScaleType);
|
|
1646
|
+
const scaleXMin = xMin instanceof Date ? new Date(+xMin - xPadding.start) : xMin - xPadding.start;
|
|
1647
|
+
const scaleXMax = xMax instanceof Date ? new Date(+xMax + xPadding.end) : xMax + xPadding.end;
|
|
1648
|
+
const extraXPixels = Math.min(Math.abs(xScale(xMin) - xScale(scaleXMin)), Math.abs(xScale(scaleXMax) - xScale(xMax)));
|
|
1649
|
+
const yScaleType = useSecondaryYScale ? secondaryYScaleType : primaryYScaleType;
|
|
1650
|
+
const { startValue: yMin, endValue: yMax } = findNumericMinMaxOfY(data, undefined, useSecondaryYScale, yScaleType);
|
|
1651
|
+
const yPadding = getDomainPaddingForMarkers(yMin, yMax, yScaleType);
|
|
1652
|
+
const scaleYMin = yMin - yPadding.start;
|
|
1653
|
+
const scaleYMax = yMax + yPadding.end;
|
|
1654
|
+
const yScale = useSecondaryYScale ? yScaleSecondary : yScalePrimary;
|
|
1655
|
+
const extraYPixels = Math.min(Math.abs(yScale(scaleYMin) - yScale(yMin)), Math.abs(yScale(yMax) - yScale(scaleYMax)));
|
|
1656
|
+
return Math.min(extraXPixels, extraYPixels);
|
|
1657
|
+
};
|
|
1658
|
+
export const generateLinearTicks = (tick0, tickStep, scaleDomain)=>{
|
|
1659
|
+
const domainMin = d3Min(scaleDomain);
|
|
1660
|
+
const domainMax = d3Max(scaleDomain);
|
|
1661
|
+
const precision = Math.max(calculatePrecision(tick0), calculatePrecision(tickStep));
|
|
1662
|
+
const start = Math.ceil(precisionRound((domainMin - tick0) / tickStep, precision));
|
|
1663
|
+
const end = Math.floor(precisionRound((domainMax - tick0) / tickStep, precision));
|
|
1664
|
+
const ticks = [];
|
|
1665
|
+
for(let i = start; i <= end; i++){
|
|
1666
|
+
ticks.push(precisionRound(tick0 + i * tickStep, precision));
|
|
1667
|
+
}
|
|
1668
|
+
return ticks;
|
|
1669
|
+
};
|
|
1670
|
+
export const generateMonthlyTicks = (tick0, tickStepInMonths, scaleDomain, useUTC)=>{
|
|
1671
|
+
const domainMin = +d3Min(scaleDomain);
|
|
1672
|
+
const domainMax = +d3Max(scaleDomain);
|
|
1673
|
+
const getMonth = (d)=>useUTC ? d.getUTCMonth() : d.getMonth();
|
|
1674
|
+
const setMonth = (d, month)=>useUTC ? new Date(d.setUTCMonth(month)) : new Date(d.setMonth(month));
|
|
1675
|
+
// Find the earliest tick <= domainMin
|
|
1676
|
+
let start = 0;
|
|
1677
|
+
for(let firstTick = new Date(+tick0); +firstTick > domainMin;){
|
|
1678
|
+
firstTick = setMonth(firstTick, getMonth(firstTick) - tickStepInMonths);
|
|
1679
|
+
start -= tickStepInMonths;
|
|
1680
|
+
}
|
|
1681
|
+
const baseMonth = getMonth(tick0);
|
|
1682
|
+
const ticks = [];
|
|
1683
|
+
// Generate ticks forward until domainMax
|
|
1684
|
+
for(let i = start;; i += tickStepInMonths){
|
|
1685
|
+
let tickDate = setMonth(new Date(+tick0), baseMonth + i);
|
|
1686
|
+
// Handle month rollover (e.g., Jan 31 + 1 month → Mar 3 instead of Feb)
|
|
1687
|
+
if (getMonth(tickDate) !== ((baseMonth + i) % 12 + 12) % 12) {
|
|
1688
|
+
tickDate = useUTC ? new Date(tickDate.setUTCDate(0)) : new Date(tickDate.setDate(0));
|
|
1689
|
+
}
|
|
1690
|
+
if (+tickDate > domainMax) {
|
|
1691
|
+
break;
|
|
1692
|
+
}
|
|
1693
|
+
if (+tickDate >= domainMin) {
|
|
1694
|
+
ticks.push(tickDate);
|
|
1695
|
+
}
|
|
1696
|
+
}
|
|
1697
|
+
return ticks;
|
|
1698
|
+
};
|
|
1699
|
+
const generateNumericTicks = (scaleType, tickStep, tick0, scaleDomain)=>{
|
|
1700
|
+
const refTick = typeof tick0 === 'number' ? tick0 : 0;
|
|
1701
|
+
if (scaleType === 'log') {
|
|
1702
|
+
if (typeof tickStep === 'number' && tickStep > 0) {
|
|
1703
|
+
return generateLinearTicks(refTick, tickStep, scaleDomain.map((d)=>Math.log10(d))).map((t)=>Math.pow(10, t));
|
|
1704
|
+
}
|
|
1705
|
+
if (typeof tickStep === 'string') {
|
|
1706
|
+
const prefix = tickStep[0];
|
|
1707
|
+
const num = isNumber(tickStep.slice(1)) ? Number(tickStep.slice(1)) : 0;
|
|
1708
|
+
if (prefix === 'L' && num > 0) {
|
|
1709
|
+
return generateLinearTicks(refTick, num, scaleDomain);
|
|
1710
|
+
}
|
|
1711
|
+
}
|
|
1712
|
+
return;
|
|
1713
|
+
}
|
|
1714
|
+
if (typeof tickStep === 'number' && tickStep > 0) {
|
|
1715
|
+
return generateLinearTicks(refTick, tickStep, scaleDomain);
|
|
1716
|
+
}
|
|
1717
|
+
};
|
|
1718
|
+
const generateDateTicks = (tickStep, tick0, scaleDomain, useUTC)=>{
|
|
1719
|
+
const refTick = tick0 instanceof Date ? tick0 : new Date(DEFAULT_DATE_STRING);
|
|
1720
|
+
if (typeof tickStep === 'number' && tickStep > 0) {
|
|
1721
|
+
return generateLinearTicks(+refTick, tickStep, scaleDomain.map((d)=>+d)).map((t)=>new Date(t));
|
|
1722
|
+
}
|
|
1723
|
+
if (typeof tickStep === 'string') {
|
|
1724
|
+
const prefix = tickStep[0];
|
|
1725
|
+
const num = isNumber(tickStep.slice(1)) ? Number(tickStep.slice(1)) : 0;
|
|
1726
|
+
if (prefix === 'M' && num > 0 && num === Math.round(num)) {
|
|
1727
|
+
return generateMonthlyTicks(refTick, num, scaleDomain, useUTC);
|
|
1728
|
+
}
|
|
1729
|
+
}
|
|
1730
|
+
};
|
|
1731
|
+
/**
|
|
1732
|
+
* Calculates a number's precision based on the number of trailing
|
|
1733
|
+
* zeros if the number does not have a decimal indicated by a negative
|
|
1734
|
+
* precision. Otherwise, it calculates the number of digits after
|
|
1735
|
+
* the decimal point indicated by a positive precision.
|
|
1736
|
+
* @param value - the value to determine the precision of
|
|
1737
|
+
*/ export function calculatePrecision(value) {
|
|
1738
|
+
/**
|
|
1739
|
+
* Group 1:
|
|
1740
|
+
* [1-9]([0]+$) matches trailing zeros
|
|
1741
|
+
* Group 2:
|
|
1742
|
+
* \.([0-9]*) matches all digits after a decimal point.
|
|
1743
|
+
*/ const groups = /[1-9]([0]+$)|\.([0-9]*)/.exec(String(value));
|
|
1744
|
+
if (!groups) {
|
|
1745
|
+
return 0;
|
|
1746
|
+
}
|
|
1747
|
+
if (groups[1]) {
|
|
1748
|
+
return -groups[1].length;
|
|
1749
|
+
}
|
|
1750
|
+
if (groups[2]) {
|
|
1751
|
+
return groups[2].length;
|
|
1752
|
+
}
|
|
1753
|
+
return 0;
|
|
1754
|
+
}
|
|
1755
|
+
/**
|
|
1756
|
+
* Rounds a number to a certain level of precision. Accepts negative precision.
|
|
1757
|
+
* @param value - The value that is being rounded.
|
|
1758
|
+
* @param precision - The number of decimal places to round the number to
|
|
1759
|
+
*/ export function precisionRound(value, precision, base = 10) {
|
|
1760
|
+
const exp = Math.pow(base, precision);
|
|
1761
|
+
return Math.round(value * exp) / exp;
|
|
1762
|
+
}
|