@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,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { ChartTypes, getAccessibleDataObject, getColorContrast, getTypeOfAxis, resolveCSSVariables, XAxisTypes, YAxisType, createNumericYAxis, domainRangeOfXStringAxis, createStringYAxis, useRtl } from '../../utilities/index';
|
|
2
|
+
import { ChartTypes, getAccessibleDataObject, getColorContrast, getTypeOfAxis, resolveCSSVariables, XAxisTypes, YAxisType, createNumericYAxis, domainRangeOfXStringAxis, createStringYAxis, useRtl, sortAxisCategories } from '../../utilities/index';
|
|
3
3
|
import { formatToLocaleString } from '@fluentui/chart-utilities';
|
|
4
4
|
import { CartesianChart } from '../CommonComponents/index';
|
|
5
5
|
import { useId } from '@fluentui/react-utilities';
|
|
@@ -10,7 +10,13 @@ import { scaleLinear as d3ScaleLinear } from 'd3-scale';
|
|
|
10
10
|
import { format as d3Format } from 'd3-format';
|
|
11
11
|
import { timeFormat as d3TimeFormat } from 'd3-time-format';
|
|
12
12
|
import { toImage } from '../../utilities/image-export-utils';
|
|
13
|
-
export const HeatMapChart = /*#__PURE__*/ React.forwardRef((props
|
|
13
|
+
export const HeatMapChart = /*#__PURE__*/ React.forwardRef((props = {
|
|
14
|
+
xAxisCategoryOrder: 'default',
|
|
15
|
+
yAxisCategoryOrder: 'default',
|
|
16
|
+
data: [],
|
|
17
|
+
domainValuesForColorScale: [],
|
|
18
|
+
rangeValuesForColorScale: []
|
|
19
|
+
}, forwardedRef)=>{
|
|
14
20
|
const classes = useHeatMapChartStyles(props);
|
|
15
21
|
const _stringXAxisDataPoints = React.useRef([]);
|
|
16
22
|
const _stringYAxisDataPoints = React.useRef([]);
|
|
@@ -135,16 +141,16 @@ export const HeatMapChart = /*#__PURE__*/ React.forwardRef((props, forwardedRef)
|
|
|
135
141
|
return color === tokens.colorNeutralForeground1 ? tokens.colorNeutralBackground1 : tokens.colorNeutralForeground1;
|
|
136
142
|
};
|
|
137
143
|
/**
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
144
|
+
* This is the function which is responsible for
|
|
145
|
+
* drawing the rectangle in the graph and also
|
|
146
|
+
* attaching dom events to that rectangles
|
|
147
|
+
*/ const _createRectangles = ()=>{
|
|
142
148
|
const rectangles = [];
|
|
143
149
|
const yAxisDataPoints = _stringYAxisDataPoints.current.slice().reverse();
|
|
144
150
|
/**
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
151
|
+
* yAxisDataPoint is noting but the DataPoint
|
|
152
|
+
* which will be rendered on the y-axis
|
|
153
|
+
*/ yAxisDataPoints.forEach((yAxisDataPoint)=>{
|
|
148
154
|
let index = 0;
|
|
149
155
|
_stringXAxisDataPoints.current.forEach((xAxisDataPoint)=>{
|
|
150
156
|
var _dataSet_current_yAxisDataPoint_index, _dataSet_current_yAxisDataPoint_index1;
|
|
@@ -153,9 +159,9 @@ export const HeatMapChart = /*#__PURE__*/ React.forwardRef((props, forwardedRef)
|
|
|
153
159
|
if (((_dataSet_current_yAxisDataPoint_index = _dataSet.current[yAxisDataPoint][index]) === null || _dataSet_current_yAxisDataPoint_index === void 0 ? void 0 : _dataSet_current_yAxisDataPoint_index.x) === xAxisDataPoint && typeof ((_dataSet_current_yAxisDataPoint_index1 = _dataSet.current[yAxisDataPoint][index]) === null || _dataSet_current_yAxisDataPoint_index1 === void 0 ? void 0 : _dataSet_current_yAxisDataPoint_index1.value) === 'number') {
|
|
154
160
|
var _cartesianChartRef_current;
|
|
155
161
|
/**
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
162
|
+
* dataPointObject is an object where it contains information on single
|
|
163
|
+
* data point such as x, y , value, rectText property of the rectangle
|
|
164
|
+
*/ const dataPointObject = _dataSet.current[yAxisDataPoint][index];
|
|
159
165
|
let styleRules = '';
|
|
160
166
|
let foregroundColor = tokens.colorNeutralForeground1;
|
|
161
167
|
if ((_cartesianChartRef_current = cartesianChartRef.current) === null || _cartesianChartRef_current === void 0 ? void 0 : _cartesianChartRef_current.chartContainer) {
|
|
@@ -219,30 +225,30 @@ export const HeatMapChart = /*#__PURE__*/ React.forwardRef((props, forwardedRef)
|
|
|
219
225
|
return rectangles;
|
|
220
226
|
};
|
|
221
227
|
/**
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
228
|
+
* when the legend is hovered we need to highlight
|
|
229
|
+
* all the rectangles which fall under that category
|
|
230
|
+
* and un-highlight the rest of them
|
|
231
|
+
* @param legendTitle
|
|
232
|
+
*/ const _onLegendHover = (legendTitle)=>{
|
|
227
233
|
setActiveLegend(legendTitle);
|
|
228
234
|
};
|
|
229
235
|
/**
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
236
|
+
* when the mouse is out from the legend , we need
|
|
237
|
+
* to show the graph in initial mode.
|
|
238
|
+
*/ const _onLegendLeave = ()=>{
|
|
233
239
|
setActiveLegend('');
|
|
234
240
|
};
|
|
235
241
|
/**
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
242
|
+
* @param legendTitle
|
|
243
|
+
* when the legend is clicked we need to highlight
|
|
244
|
+
* all the rectangles which fall under that category
|
|
245
|
+
* and un highlight the rest of them
|
|
246
|
+
*/ const _onLegendClick = (legendTitle)=>{
|
|
241
247
|
/**
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
248
|
+
* check if the legend is already selceted,
|
|
249
|
+
* if yes, un-select the legend, else
|
|
250
|
+
* set the selected legend state to legendTitle
|
|
251
|
+
*/ if (selectedLegend === legendTitle) {
|
|
246
252
|
setSelectedLegend('');
|
|
247
253
|
} else {
|
|
248
254
|
setSelectedLegend(legendTitle);
|
|
@@ -313,19 +319,13 @@ export const HeatMapChart = /*#__PURE__*/ React.forwardRef((props, forwardedRef)
|
|
|
313
319
|
yAxisStringFormatter
|
|
314
320
|
]);
|
|
315
321
|
/**
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
322
|
+
* This function will return the final sorted and formatted x-axis points
|
|
323
|
+
* which will be rendered on the x-axis
|
|
324
|
+
* @param points
|
|
325
|
+
* @returns x-axis points
|
|
326
|
+
*/ const _getXAxisDataPoints = React.useCallback((points)=>{
|
|
321
327
|
let xAxisPoints = [];
|
|
322
|
-
const unFormattedXAxisDataPoints =
|
|
323
|
-
if (_xAxisType.current === XAxisTypes.DateAxis || _xAxisType.current === XAxisTypes.NumericAxis) {
|
|
324
|
-
return +a - +b;
|
|
325
|
-
} else {
|
|
326
|
-
return props.sortOrder === 'none' ? 0 : a.toLowerCase() > b.toLowerCase() ? 1 : -1;
|
|
327
|
-
}
|
|
328
|
-
});
|
|
328
|
+
const unFormattedXAxisDataPoints = _getOrderedXAxisLabels(points);
|
|
329
329
|
xAxisPoints = unFormattedXAxisDataPoints.map((xPoint)=>{
|
|
330
330
|
if (_xAxisType.current === XAxisTypes.DateAxis) {
|
|
331
331
|
return _getStringFormattedDate(xPoint, props.xAxisDateFormatString);
|
|
@@ -343,19 +343,13 @@ export const HeatMapChart = /*#__PURE__*/ React.forwardRef((props, forwardedRef)
|
|
|
343
343
|
props.xAxisNumberFormatString
|
|
344
344
|
]);
|
|
345
345
|
/**
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
346
|
+
* This function will return the final sorted and formatted y-axis points
|
|
347
|
+
* which will be rendered on the y-axis
|
|
348
|
+
* @param points
|
|
349
|
+
* @returns yaxis points
|
|
350
|
+
*/ const _getYAxisDataPoints = React.useCallback((points)=>{
|
|
351
351
|
let yAxisPoints = [];
|
|
352
|
-
const unFormattedYAxisDataPoints =
|
|
353
|
-
if (_yAxisType.current === YAxisType.DateAxis || _yAxisType.current === YAxisType.NumericAxis) {
|
|
354
|
-
return +a - +b;
|
|
355
|
-
} else {
|
|
356
|
-
return props.sortOrder === 'none' ? 0 : a.toLowerCase() > b.toLowerCase() ? 1 : -1;
|
|
357
|
-
}
|
|
358
|
-
});
|
|
352
|
+
const unFormattedYAxisDataPoints = _getOrderedYAxisLabels(points);
|
|
359
353
|
yAxisPoints = unFormattedYAxisDataPoints.map((yPoint)=>{
|
|
360
354
|
if (_yAxisType.current === YAxisType.DateAxis) {
|
|
361
355
|
return _getStringFormattedDate(yPoint, props.yAxisDateFormatString);
|
|
@@ -373,24 +367,24 @@ export const HeatMapChart = /*#__PURE__*/ React.forwardRef((props, forwardedRef)
|
|
|
373
367
|
props.yAxisNumberFormatString
|
|
374
368
|
]);
|
|
375
369
|
/**
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
370
|
+
* This will create a new data set based on the prop
|
|
371
|
+
* @data
|
|
372
|
+
* We will be using This data set to contsruct our rectangles
|
|
373
|
+
* in the chart, we use this data set becuase, when we loop in this
|
|
374
|
+
* data and build the heat map, it will support accessibility as
|
|
375
|
+
* specified in the figma
|
|
376
|
+
*/ const _createNewDataSet = React.useCallback((data, xAxisDateFormatString, xAxisNumberFormatString, yAxisDateFormatString, yAxisNumberFormatString)=>{
|
|
383
377
|
/**
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
378
|
+
* please do not destructure any of the props here,
|
|
379
|
+
* instead send them as parameter to this functions so that
|
|
380
|
+
* this functions get called whenever the prop changes
|
|
381
|
+
*/ const flattenData = [];
|
|
388
382
|
/**
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
383
|
+
* below for each loop will store all the datapoints in the one array.
|
|
384
|
+
* basically it will flatten the nestesd array (data prop) into single array
|
|
385
|
+
* of object. where each object contains x, y, rectText , value and legend propety of single
|
|
386
|
+
* data point.
|
|
387
|
+
*/ data.forEach((item)=>{
|
|
394
388
|
item.data.forEach((point)=>{
|
|
395
389
|
flattenData.push({
|
|
396
390
|
...point,
|
|
@@ -407,13 +401,13 @@ export const HeatMapChart = /*#__PURE__*/ React.forwardRef((props, forwardedRef)
|
|
|
407
401
|
uniqueXPoints[posX] = '1';
|
|
408
402
|
uniqueYPoints[posY] = '1';
|
|
409
403
|
/** we will check if the property(posY) is already there in object, if Yes,
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
404
|
+
* then we will append the item in the Array related to the pos, if not
|
|
405
|
+
* then we will simply append the item in the new Array and
|
|
406
|
+
* assign that array to the property (posY) in the Object
|
|
407
|
+
* and finally we will get the array of Objects associated to each
|
|
408
|
+
* property (which is nothing but y data point) and object in the
|
|
409
|
+
* array are noting but x data points associated to the property y
|
|
410
|
+
*/ if (yPoints[posY]) {
|
|
417
411
|
yPoints[posY] = [
|
|
418
412
|
...yPoints[posY],
|
|
419
413
|
item
|
|
@@ -425,21 +419,12 @@ export const HeatMapChart = /*#__PURE__*/ React.forwardRef((props, forwardedRef)
|
|
|
425
419
|
}
|
|
426
420
|
});
|
|
427
421
|
/**
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
yPoints[item]
|
|
433
|
-
|
|
434
|
-
return props.sortOrder === 'none' ? 0 : a.x.toLowerCase() > b.x.toLowerCase() ? 1 : -1;
|
|
435
|
-
} else if (_xAxisType.current === XAxisTypes.DateAxis) {
|
|
436
|
-
return a.x.getTime() - b.x.getTime();
|
|
437
|
-
} else if (_xAxisType.current === XAxisTypes.NumericAxis) {
|
|
438
|
-
return +a.x > +b.x ? 1 : -1;
|
|
439
|
-
} else {
|
|
440
|
-
return a.x > b.x ? 1 : -1;
|
|
441
|
-
}
|
|
442
|
-
}).forEach((datapoint)=>{
|
|
422
|
+
* we will now sort(ascending) the array's of y data point based on the x value
|
|
423
|
+
* sorting is important to achive the accessibility order of the
|
|
424
|
+
* rectangles and then format the x and y datapoints respectively
|
|
425
|
+
*/ Object.keys(yPoints).forEach((item)=>{
|
|
426
|
+
yPoints[item] = _getOrderedXPoints(yPoints[item]);
|
|
427
|
+
yPoints[item].forEach((datapoint)=>{
|
|
443
428
|
if (_xAxisType.current === XAxisTypes.DateAxis) {
|
|
444
429
|
datapoint.x = _getStringFormattedDate(datapoint.x, xAxisDateFormatString);
|
|
445
430
|
}
|
|
@@ -461,14 +446,14 @@ export const HeatMapChart = /*#__PURE__*/ React.forwardRef((props, forwardedRef)
|
|
|
461
446
|
});
|
|
462
447
|
});
|
|
463
448
|
/**
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
449
|
+
* if y-axis data points are of type date or number or if we have string formatter,
|
|
450
|
+
* then we need to change data points to their respective string
|
|
451
|
+
* format, becuase in the private variable _stringYAxisDatapoints, points will be stored in
|
|
452
|
+
* string format. and in here `yPoint` are not so we need to change, so that
|
|
453
|
+
* function `_createRectangles` should work perfetcly while looping, and if we don't change
|
|
454
|
+
* then `_createRectangles` will fail while looping, causing the error
|
|
455
|
+
* Cannot read property 'forEach' of undefined
|
|
456
|
+
*/ Object.keys(yPoints).forEach((yPoint)=>{
|
|
472
457
|
if (_yAxisType.current === YAxisType.DateAxis) {
|
|
473
458
|
yPoints[_getStringFormattedDate(yPoint, yAxisDateFormatString)] = yPoints[yPoint];
|
|
474
459
|
} else if (_yAxisType.current === YAxisType.NumericAxis) {
|
|
@@ -478,16 +463,16 @@ export const HeatMapChart = /*#__PURE__*/ React.forwardRef((props, forwardedRef)
|
|
|
478
463
|
}
|
|
479
464
|
});
|
|
480
465
|
/**
|
|
481
|
-
|
|
482
|
-
|
|
466
|
+
* assigning new data set
|
|
467
|
+
*/ const dataSet = yPoints;
|
|
483
468
|
/**
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
469
|
+
* These are the Y axis data points which will get rendered in the
|
|
470
|
+
* Y axis in graph
|
|
471
|
+
*/ const yAxisPoints = _getYAxisDataPoints(uniqueYPoints);
|
|
487
472
|
/**
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
473
|
+
* These are the x axis data points which will get rendered in the
|
|
474
|
+
* x axis in the graph
|
|
475
|
+
*/ const xAxisPoints = _getXAxisDataPoints(uniqueXPoints);
|
|
491
476
|
return {
|
|
492
477
|
dataSet,
|
|
493
478
|
yAxisPoints,
|
|
@@ -509,16 +494,16 @@ export const HeatMapChart = /*#__PURE__*/ React.forwardRef((props, forwardedRef)
|
|
|
509
494
|
return d3Format(formatString || '.2~s')(+point);
|
|
510
495
|
};
|
|
511
496
|
/**
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
497
|
+
* This function checks if the given legend is highlighted or not.
|
|
498
|
+
* A legend can be highlighted in 2 ways:
|
|
499
|
+
* 1. selection: if the user clicks on it
|
|
500
|
+
* 2. hovering: if there is no selected legend and the user hovers over it
|
|
501
|
+
*/ const _legendHighlighted = (legendTitle)=>{
|
|
517
502
|
return selectedLegend === legendTitle || selectedLegend === '' && activeLegend === legendTitle;
|
|
518
503
|
};
|
|
519
504
|
/**
|
|
520
|
-
|
|
521
|
-
|
|
505
|
+
* This function checks if none of the legends is selected or hovered.
|
|
506
|
+
*/ const _noLegendHighlighted = ()=>{
|
|
522
507
|
return selectedLegend === '' && activeLegend === '';
|
|
523
508
|
};
|
|
524
509
|
const _getAriaLabel = (point)=>{
|
|
@@ -538,6 +523,82 @@ export const HeatMapChart = /*#__PURE__*/ React.forwardRef((props, forwardedRef)
|
|
|
538
523
|
const numDataPoints = props.data.reduce((acc, curr)=>acc + curr.data.length, 0);
|
|
539
524
|
return (chartTitle ? `${chartTitle}. ` : '') + `Heat map chart with ${numDataPoints} data points. `;
|
|
540
525
|
};
|
|
526
|
+
const _getOrderedXAxisLabels = (points)=>{
|
|
527
|
+
if (!_shouldOrderXAxisLabelsByCategoryOrder()) {
|
|
528
|
+
// Keep the original ordering logic as the default behavior to ensure backward compatibility
|
|
529
|
+
return Object.keys(points).sort((a, b)=>{
|
|
530
|
+
if (_xAxisType.current === XAxisTypes.DateAxis || _xAxisType.current === XAxisTypes.NumericAxis) {
|
|
531
|
+
return +a - +b;
|
|
532
|
+
} else {
|
|
533
|
+
return props.sortOrder === 'none' ? 0 : a.toLowerCase() > b.toLowerCase() ? 1 : -1;
|
|
534
|
+
}
|
|
535
|
+
});
|
|
536
|
+
}
|
|
537
|
+
return sortAxisCategories(_mapCategoryToValues(), props.xAxisCategoryOrder);
|
|
538
|
+
};
|
|
539
|
+
const _getOrderedYAxisLabels = (points)=>{
|
|
540
|
+
if (!_shouldOrderYAxisLabelsByCategoryOrder()) {
|
|
541
|
+
// Keep the original ordering logic as the default behavior to ensure backward compatibility
|
|
542
|
+
return Object.keys(points).sort((a, b)=>{
|
|
543
|
+
if (_yAxisType.current === YAxisType.DateAxis || _yAxisType.current === YAxisType.NumericAxis) {
|
|
544
|
+
return +a - +b;
|
|
545
|
+
} else {
|
|
546
|
+
return props.sortOrder === 'none' ? 0 : a.toLowerCase() > b.toLowerCase() ? 1 : -1;
|
|
547
|
+
}
|
|
548
|
+
});
|
|
549
|
+
}
|
|
550
|
+
return sortAxisCategories(_mapCategoryToValues(true), props.yAxisCategoryOrder);
|
|
551
|
+
};
|
|
552
|
+
const _getOrderedXPoints = (xPoints)=>{
|
|
553
|
+
if (!_shouldOrderXAxisLabelsByCategoryOrder()) {
|
|
554
|
+
return xPoints.sort((a, b)=>{
|
|
555
|
+
if (_xAxisType.current === XAxisTypes.StringAxis) {
|
|
556
|
+
return props.sortOrder === 'none' ? 0 : a.x.toLowerCase() > b.x.toLowerCase() ? 1 : -1;
|
|
557
|
+
} else if (_xAxisType.current === XAxisTypes.DateAxis) {
|
|
558
|
+
return a.x.getTime() - b.x.getTime();
|
|
559
|
+
} else if (_xAxisType.current === XAxisTypes.NumericAxis) {
|
|
560
|
+
return +a.x > +b.x ? 1 : -1;
|
|
561
|
+
} else {
|
|
562
|
+
return a.x > b.x ? 1 : -1;
|
|
563
|
+
}
|
|
564
|
+
});
|
|
565
|
+
}
|
|
566
|
+
const result = [];
|
|
567
|
+
const xValueToPoints = {};
|
|
568
|
+
xPoints.forEach((point)=>{
|
|
569
|
+
const xValue = point.x;
|
|
570
|
+
if (!xValueToPoints[xValue]) {
|
|
571
|
+
xValueToPoints[xValue] = [];
|
|
572
|
+
}
|
|
573
|
+
xValueToPoints[xValue].push(point);
|
|
574
|
+
});
|
|
575
|
+
const xAxisLabels = _getOrderedXAxisLabels({});
|
|
576
|
+
xAxisLabels.forEach((xValue)=>{
|
|
577
|
+
if (xValueToPoints[xValue]) {
|
|
578
|
+
result.push(...xValueToPoints[xValue]);
|
|
579
|
+
}
|
|
580
|
+
});
|
|
581
|
+
return result;
|
|
582
|
+
};
|
|
583
|
+
const _shouldOrderXAxisLabelsByCategoryOrder = ()=>{
|
|
584
|
+
return _xAxisType.current === XAxisTypes.StringAxis && props.xAxisCategoryOrder !== 'default';
|
|
585
|
+
};
|
|
586
|
+
const _shouldOrderYAxisLabelsByCategoryOrder = ()=>{
|
|
587
|
+
return _yAxisType.current === YAxisType.StringAxis && props.yAxisCategoryOrder !== 'default';
|
|
588
|
+
};
|
|
589
|
+
const _mapCategoryToValues = (isYAxis = false)=>{
|
|
590
|
+
const categoryToValues = {};
|
|
591
|
+
props.data.forEach((item)=>{
|
|
592
|
+
item.data.forEach((point)=>{
|
|
593
|
+
const category = isYAxis ? point.y : point.x;
|
|
594
|
+
if (!categoryToValues[category]) {
|
|
595
|
+
categoryToValues[category] = [];
|
|
596
|
+
}
|
|
597
|
+
categoryToValues[category].push(point.value);
|
|
598
|
+
});
|
|
599
|
+
});
|
|
600
|
+
return categoryToValues;
|
|
601
|
+
};
|
|
541
602
|
const updatePosition = (newX, newY)=>{
|
|
542
603
|
const threshold = 1; // Set a threshold for movement
|
|
543
604
|
const { x, y } = clickPosition;
|