@fluentui/react-charts 9.2.1 → 9.2.3
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 +57 -2
- package/dist/index.d.ts +168 -15
- package/lib/ChartTable.js +1 -0
- package/lib/ChartTable.js.map +1 -0
- package/lib/components/AreaChart/AreaChart.js +4 -1
- package/lib/components/AreaChart/AreaChart.js.map +1 -1
- package/lib/components/AreaChart/useAreaChartStyles.styles.js +2 -1
- package/lib/components/AreaChart/useAreaChartStyles.styles.js.map +1 -1
- package/lib/components/AreaChart/useAreaChartStyles.styles.raw.js +2 -1
- package/lib/components/AreaChart/useAreaChartStyles.styles.raw.js.map +1 -1
- package/lib/components/ChartTable/ChartTable.js +58 -0
- package/lib/components/ChartTable/ChartTable.js.map +1 -0
- package/lib/components/ChartTable/ChartTable.types.js +1 -0
- package/lib/components/ChartTable/ChartTable.types.js.map +1 -0
- package/lib/components/ChartTable/index.js +3 -0
- package/lib/components/ChartTable/index.js.map +1 -0
- package/lib/components/ChartTable/useChartTableStyles.styles.js +93 -0
- package/lib/components/ChartTable/useChartTableStyles.styles.js.map +1 -0
- package/lib/components/ChartTable/useChartTableStyles.styles.raw.js +55 -0
- package/lib/components/ChartTable/useChartTableStyles.styles.raw.js.map +1 -0
- package/lib/components/CommonComponents/CartesianChart.js +170 -100
- package/lib/components/CommonComponents/CartesianChart.js.map +1 -1
- package/lib/components/CommonComponents/CartesianChart.types.js.map +1 -1
- package/lib/components/CommonComponents/ChartPopover.types.js.map +1 -1
- package/lib/components/CommonComponents/useCartesianChartStyles.styles.js +13 -0
- package/lib/components/CommonComponents/useCartesianChartStyles.styles.js.map +1 -1
- package/lib/components/CommonComponents/useCartesianChartStyles.styles.raw.js +12 -0
- package/lib/components/CommonComponents/useCartesianChartStyles.styles.raw.js.map +1 -1
- package/lib/components/DeclarativeChart/DeclarativeChart.js +180 -102
- package/lib/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib/components/DeclarativeChart/PlotlyColorAdapter.js +100 -0
- package/lib/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -0
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +890 -211
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib/components/DonutChart/DonutChart.js +2 -2
- 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.map +1 -1
- package/lib/components/FunnelChart/FunnelChart.js.map +1 -1
- package/lib/components/GanttChart/GanttChart.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/GroupedVerticalBarChart/GroupedVerticalBarChart.js +185 -144
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
- package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js +2 -1
- package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js.map +1 -1
- package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js +2 -1
- 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.map +1 -1
- package/lib/components/HorizontalBarChart/HorizontalBarChart.types.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/Legends/Legends.js.map +1 -1
- package/lib/components/Legends/OverflowMenu.js.map +1 -1
- package/lib/components/LineChart/LineChart.js +251 -78
- 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 +10 -3
- package/lib/components/LineChart/useLineChartStyles.styles.js.map +1 -1
- package/lib/components/LineChart/useLineChartStyles.styles.raw.js +14 -2
- package/lib/components/LineChart/useLineChartStyles.styles.raw.js.map +1 -1
- package/lib/components/ScatterChart/ScatterChart.js +56 -37
- 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 +21 -4
- package/lib/components/ScatterChart/useScatterChartStyles.styles.js.map +1 -1
- package/lib/components/ScatterChart/useScatterChartStyles.styles.raw.js +16 -3
- package/lib/components/ScatterChart/useScatterChartStyles.styles.raw.js.map +1 -1
- package/lib/components/VerticalBarChart/VerticalBarChart.js +38 -14
- package/lib/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
- package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.js +2 -1
- package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.js.map +1 -1
- package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js +2 -1
- package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js.map +1 -1
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js +214 -96
- 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 +2 -1
- package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js.map +1 -1
- package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js +2 -1
- package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js.map +1 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/types/DataPoint.js.map +1 -1
- package/lib/utilities/FocusableTooltipText.js.map +1 -1
- package/lib/utilities/utilities.js +41 -42
- package/lib/utilities/utilities.js.map +1 -1
- package/lib/utilities/vbc-utils.js +24 -0
- package/lib/utilities/vbc-utils.js.map +1 -1
- package/lib-commonjs/ChartTable.js +6 -0
- package/lib-commonjs/ChartTable.js.map +1 -0
- package/lib-commonjs/components/AreaChart/AreaChart.js +4 -1
- 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 +2 -1
- package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/ChartTable/ChartTable.js +69 -0
- package/lib-commonjs/components/ChartTable/ChartTable.js.map +1 -0
- package/lib-commonjs/components/ChartTable/ChartTable.types.js +6 -0
- package/lib-commonjs/components/ChartTable/ChartTable.types.js.map +1 -0
- package/lib-commonjs/components/ChartTable/index.js +8 -0
- package/lib-commonjs/components/ChartTable/index.js.map +1 -0
- package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.js +196 -0
- package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.js.map +1 -0
- package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.raw.js +69 -0
- package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.raw.js.map +1 -0
- package/lib-commonjs/components/CommonComponents/CartesianChart.js +169 -98
- 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/ChartPopover.types.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.js +13 -0
- package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.raw.js +12 -0
- package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js +176 -100
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.js +128 -0
- package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -0
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +909 -209
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib-commonjs/components/DonutChart/DonutChart.js +1 -1
- 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.map +1 -1
- package/lib-commonjs/components/FunnelChart/FunnelChart.js.map +1 -1
- package/lib-commonjs/components/GanttChart/GanttChart.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/GroupedVerticalBarChart/GroupedVerticalBarChart.js +183 -142
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
- package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js +2 -1
- package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js +2 -1
- 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.map +1 -1
- package/lib-commonjs/components/HorizontalBarChart/HorizontalBarChart.types.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/Legends/Legends.js.map +1 -1
- package/lib-commonjs/components/Legends/OverflowMenu.js.map +1 -1
- package/lib-commonjs/components/LineChart/LineChart.js +250 -78
- 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 +12 -3
- package/lib-commonjs/components/LineChart/useLineChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/LineChart/useLineChartStyles.styles.raw.js +14 -2
- package/lib-commonjs/components/LineChart/useLineChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/ScatterChart/ScatterChart.js +56 -37
- 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 +30 -3
- package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.raw.js +15 -2
- package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js +37 -13
- package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
- package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.js +2 -1
- package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js +2 -1
- package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js +213 -95
- 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 +2 -1
- package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js +2 -1
- package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/index.js +1 -0
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/types/DataPoint.js.map +1 -1
- package/lib-commonjs/utilities/FocusableTooltipText.js.map +1 -1
- package/lib-commonjs/utilities/utilities.js +44 -41
- package/lib-commonjs/utilities/utilities.js.map +1 -1
- package/lib-commonjs/utilities/vbc-utils.js +27 -0
- package/lib-commonjs/utilities/vbc-utils.js.map +1 -1
- package/package.json +10 -10
|
@@ -21,7 +21,13 @@ const _d3scale = require("d3-scale");
|
|
|
21
21
|
const _d3format = require("d3-format");
|
|
22
22
|
const _d3timeformat = require("d3-time-format");
|
|
23
23
|
const _imageexportutils = require("../../utilities/image-export-utils");
|
|
24
|
-
const HeatMapChart = /*#__PURE__*/ _react.forwardRef((props
|
|
24
|
+
const HeatMapChart = /*#__PURE__*/ _react.forwardRef((props = {
|
|
25
|
+
xAxisCategoryOrder: 'default',
|
|
26
|
+
yAxisCategoryOrder: 'default',
|
|
27
|
+
data: [],
|
|
28
|
+
domainValuesForColorScale: [],
|
|
29
|
+
rangeValuesForColorScale: []
|
|
30
|
+
}, forwardedRef)=>{
|
|
25
31
|
const classes = (0, _useHeatMapChartStylesstyles.useHeatMapChartStyles)(props);
|
|
26
32
|
const _stringXAxisDataPoints = _react.useRef([]);
|
|
27
33
|
const _stringYAxisDataPoints = _react.useRef([]);
|
|
@@ -146,16 +152,16 @@ const HeatMapChart = /*#__PURE__*/ _react.forwardRef((props, forwardedRef)=>{
|
|
|
146
152
|
return color === _reacttheme.tokens.colorNeutralForeground1 ? _reacttheme.tokens.colorNeutralBackground1 : _reacttheme.tokens.colorNeutralForeground1;
|
|
147
153
|
};
|
|
148
154
|
/**
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
155
|
+
* This is the function which is responsible for
|
|
156
|
+
* drawing the rectangle in the graph and also
|
|
157
|
+
* attaching dom events to that rectangles
|
|
158
|
+
*/ const _createRectangles = ()=>{
|
|
153
159
|
const rectangles = [];
|
|
154
160
|
const yAxisDataPoints = _stringYAxisDataPoints.current.slice().reverse();
|
|
155
161
|
/**
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
162
|
+
* yAxisDataPoint is noting but the DataPoint
|
|
163
|
+
* which will be rendered on the y-axis
|
|
164
|
+
*/ yAxisDataPoints.forEach((yAxisDataPoint)=>{
|
|
159
165
|
let index = 0;
|
|
160
166
|
_stringXAxisDataPoints.current.forEach((xAxisDataPoint)=>{
|
|
161
167
|
var _dataSet_current_yAxisDataPoint_index, _dataSet_current_yAxisDataPoint_index1;
|
|
@@ -164,9 +170,9 @@ const HeatMapChart = /*#__PURE__*/ _react.forwardRef((props, forwardedRef)=>{
|
|
|
164
170
|
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') {
|
|
165
171
|
var _cartesianChartRef_current;
|
|
166
172
|
/**
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
173
|
+
* dataPointObject is an object where it contains information on single
|
|
174
|
+
* data point such as x, y , value, rectText property of the rectangle
|
|
175
|
+
*/ const dataPointObject = _dataSet.current[yAxisDataPoint][index];
|
|
170
176
|
let styleRules = '';
|
|
171
177
|
let foregroundColor = _reacttheme.tokens.colorNeutralForeground1;
|
|
172
178
|
if ((_cartesianChartRef_current = cartesianChartRef.current) === null || _cartesianChartRef_current === void 0 ? void 0 : _cartesianChartRef_current.chartContainer) {
|
|
@@ -230,30 +236,30 @@ const HeatMapChart = /*#__PURE__*/ _react.forwardRef((props, forwardedRef)=>{
|
|
|
230
236
|
return rectangles;
|
|
231
237
|
};
|
|
232
238
|
/**
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
239
|
+
* when the legend is hovered we need to highlight
|
|
240
|
+
* all the rectangles which fall under that category
|
|
241
|
+
* and un-highlight the rest of them
|
|
242
|
+
* @param legendTitle
|
|
243
|
+
*/ const _onLegendHover = (legendTitle)=>{
|
|
238
244
|
setActiveLegend(legendTitle);
|
|
239
245
|
};
|
|
240
246
|
/**
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
247
|
+
* when the mouse is out from the legend , we need
|
|
248
|
+
* to show the graph in initial mode.
|
|
249
|
+
*/ const _onLegendLeave = ()=>{
|
|
244
250
|
setActiveLegend('');
|
|
245
251
|
};
|
|
246
252
|
/**
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
253
|
+
* @param legendTitle
|
|
254
|
+
* when the legend is clicked we need to highlight
|
|
255
|
+
* all the rectangles which fall under that category
|
|
256
|
+
* and un highlight the rest of them
|
|
257
|
+
*/ const _onLegendClick = (legendTitle)=>{
|
|
252
258
|
/**
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
259
|
+
* check if the legend is already selceted,
|
|
260
|
+
* if yes, un-select the legend, else
|
|
261
|
+
* set the selected legend state to legendTitle
|
|
262
|
+
*/ if (selectedLegend === legendTitle) {
|
|
257
263
|
setSelectedLegend('');
|
|
258
264
|
} else {
|
|
259
265
|
setSelectedLegend(legendTitle);
|
|
@@ -324,19 +330,13 @@ const HeatMapChart = /*#__PURE__*/ _react.forwardRef((props, forwardedRef)=>{
|
|
|
324
330
|
yAxisStringFormatter
|
|
325
331
|
]);
|
|
326
332
|
/**
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
333
|
+
* This function will return the final sorted and formatted x-axis points
|
|
334
|
+
* which will be rendered on the x-axis
|
|
335
|
+
* @param points
|
|
336
|
+
* @returns x-axis points
|
|
337
|
+
*/ const _getXAxisDataPoints = _react.useCallback((points)=>{
|
|
332
338
|
let xAxisPoints = [];
|
|
333
|
-
const unFormattedXAxisDataPoints =
|
|
334
|
-
if (_xAxisType.current === _index.XAxisTypes.DateAxis || _xAxisType.current === _index.XAxisTypes.NumericAxis) {
|
|
335
|
-
return +a - +b;
|
|
336
|
-
} else {
|
|
337
|
-
return props.sortOrder === 'none' ? 0 : a.toLowerCase() > b.toLowerCase() ? 1 : -1;
|
|
338
|
-
}
|
|
339
|
-
});
|
|
339
|
+
const unFormattedXAxisDataPoints = _getOrderedXAxisLabels(points);
|
|
340
340
|
xAxisPoints = unFormattedXAxisDataPoints.map((xPoint)=>{
|
|
341
341
|
if (_xAxisType.current === _index.XAxisTypes.DateAxis) {
|
|
342
342
|
return _getStringFormattedDate(xPoint, props.xAxisDateFormatString);
|
|
@@ -354,19 +354,13 @@ const HeatMapChart = /*#__PURE__*/ _react.forwardRef((props, forwardedRef)=>{
|
|
|
354
354
|
props.xAxisNumberFormatString
|
|
355
355
|
]);
|
|
356
356
|
/**
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
357
|
+
* This function will return the final sorted and formatted y-axis points
|
|
358
|
+
* which will be rendered on the y-axis
|
|
359
|
+
* @param points
|
|
360
|
+
* @returns yaxis points
|
|
361
|
+
*/ const _getYAxisDataPoints = _react.useCallback((points)=>{
|
|
362
362
|
let yAxisPoints = [];
|
|
363
|
-
const unFormattedYAxisDataPoints =
|
|
364
|
-
if (_yAxisType.current === _index.YAxisType.DateAxis || _yAxisType.current === _index.YAxisType.NumericAxis) {
|
|
365
|
-
return +a - +b;
|
|
366
|
-
} else {
|
|
367
|
-
return props.sortOrder === 'none' ? 0 : a.toLowerCase() > b.toLowerCase() ? 1 : -1;
|
|
368
|
-
}
|
|
369
|
-
});
|
|
363
|
+
const unFormattedYAxisDataPoints = _getOrderedYAxisLabels(points);
|
|
370
364
|
yAxisPoints = unFormattedYAxisDataPoints.map((yPoint)=>{
|
|
371
365
|
if (_yAxisType.current === _index.YAxisType.DateAxis) {
|
|
372
366
|
return _getStringFormattedDate(yPoint, props.yAxisDateFormatString);
|
|
@@ -384,24 +378,24 @@ const HeatMapChart = /*#__PURE__*/ _react.forwardRef((props, forwardedRef)=>{
|
|
|
384
378
|
props.yAxisNumberFormatString
|
|
385
379
|
]);
|
|
386
380
|
/**
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
381
|
+
* This will create a new data set based on the prop
|
|
382
|
+
* @data
|
|
383
|
+
* We will be using This data set to contsruct our rectangles
|
|
384
|
+
* in the chart, we use this data set becuase, when we loop in this
|
|
385
|
+
* data and build the heat map, it will support accessibility as
|
|
386
|
+
* specified in the figma
|
|
387
|
+
*/ const _createNewDataSet = _react.useCallback((data, xAxisDateFormatString, xAxisNumberFormatString, yAxisDateFormatString, yAxisNumberFormatString)=>{
|
|
394
388
|
/**
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
389
|
+
* please do not destructure any of the props here,
|
|
390
|
+
* instead send them as parameter to this functions so that
|
|
391
|
+
* this functions get called whenever the prop changes
|
|
392
|
+
*/ const flattenData = [];
|
|
399
393
|
/**
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
394
|
+
* below for each loop will store all the datapoints in the one array.
|
|
395
|
+
* basically it will flatten the nestesd array (data prop) into single array
|
|
396
|
+
* of object. where each object contains x, y, rectText , value and legend propety of single
|
|
397
|
+
* data point.
|
|
398
|
+
*/ data.forEach((item)=>{
|
|
405
399
|
item.data.forEach((point)=>{
|
|
406
400
|
flattenData.push({
|
|
407
401
|
...point,
|
|
@@ -418,13 +412,13 @@ const HeatMapChart = /*#__PURE__*/ _react.forwardRef((props, forwardedRef)=>{
|
|
|
418
412
|
uniqueXPoints[posX] = '1';
|
|
419
413
|
uniqueYPoints[posY] = '1';
|
|
420
414
|
/** we will check if the property(posY) is already there in object, if Yes,
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
415
|
+
* then we will append the item in the Array related to the pos, if not
|
|
416
|
+
* then we will simply append the item in the new Array and
|
|
417
|
+
* assign that array to the property (posY) in the Object
|
|
418
|
+
* and finally we will get the array of Objects associated to each
|
|
419
|
+
* property (which is nothing but y data point) and object in the
|
|
420
|
+
* array are noting but x data points associated to the property y
|
|
421
|
+
*/ if (yPoints[posY]) {
|
|
428
422
|
yPoints[posY] = [
|
|
429
423
|
...yPoints[posY],
|
|
430
424
|
item
|
|
@@ -436,21 +430,12 @@ const HeatMapChart = /*#__PURE__*/ _react.forwardRef((props, forwardedRef)=>{
|
|
|
436
430
|
}
|
|
437
431
|
});
|
|
438
432
|
/**
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
yPoints[item]
|
|
444
|
-
|
|
445
|
-
return props.sortOrder === 'none' ? 0 : a.x.toLowerCase() > b.x.toLowerCase() ? 1 : -1;
|
|
446
|
-
} else if (_xAxisType.current === _index.XAxisTypes.DateAxis) {
|
|
447
|
-
return a.x.getTime() - b.x.getTime();
|
|
448
|
-
} else if (_xAxisType.current === _index.XAxisTypes.NumericAxis) {
|
|
449
|
-
return +a.x > +b.x ? 1 : -1;
|
|
450
|
-
} else {
|
|
451
|
-
return a.x > b.x ? 1 : -1;
|
|
452
|
-
}
|
|
453
|
-
}).forEach((datapoint)=>{
|
|
433
|
+
* we will now sort(ascending) the array's of y data point based on the x value
|
|
434
|
+
* sorting is important to achive the accessibility order of the
|
|
435
|
+
* rectangles and then format the x and y datapoints respectively
|
|
436
|
+
*/ Object.keys(yPoints).forEach((item)=>{
|
|
437
|
+
yPoints[item] = _getOrderedXPoints(yPoints[item]);
|
|
438
|
+
yPoints[item].forEach((datapoint)=>{
|
|
454
439
|
if (_xAxisType.current === _index.XAxisTypes.DateAxis) {
|
|
455
440
|
datapoint.x = _getStringFormattedDate(datapoint.x, xAxisDateFormatString);
|
|
456
441
|
}
|
|
@@ -472,14 +457,14 @@ const HeatMapChart = /*#__PURE__*/ _react.forwardRef((props, forwardedRef)=>{
|
|
|
472
457
|
});
|
|
473
458
|
});
|
|
474
459
|
/**
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
460
|
+
* if y-axis data points are of type date or number or if we have string formatter,
|
|
461
|
+
* then we need to change data points to their respective string
|
|
462
|
+
* format, becuase in the private variable _stringYAxisDatapoints, points will be stored in
|
|
463
|
+
* string format. and in here `yPoint` are not so we need to change, so that
|
|
464
|
+
* function `_createRectangles` should work perfetcly while looping, and if we don't change
|
|
465
|
+
* then `_createRectangles` will fail while looping, causing the error
|
|
466
|
+
* Cannot read property 'forEach' of undefined
|
|
467
|
+
*/ Object.keys(yPoints).forEach((yPoint)=>{
|
|
483
468
|
if (_yAxisType.current === _index.YAxisType.DateAxis) {
|
|
484
469
|
yPoints[_getStringFormattedDate(yPoint, yAxisDateFormatString)] = yPoints[yPoint];
|
|
485
470
|
} else if (_yAxisType.current === _index.YAxisType.NumericAxis) {
|
|
@@ -489,16 +474,16 @@ const HeatMapChart = /*#__PURE__*/ _react.forwardRef((props, forwardedRef)=>{
|
|
|
489
474
|
}
|
|
490
475
|
});
|
|
491
476
|
/**
|
|
492
|
-
|
|
493
|
-
|
|
477
|
+
* assigning new data set
|
|
478
|
+
*/ const dataSet = yPoints;
|
|
494
479
|
/**
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
480
|
+
* These are the Y axis data points which will get rendered in the
|
|
481
|
+
* Y axis in graph
|
|
482
|
+
*/ const yAxisPoints = _getYAxisDataPoints(uniqueYPoints);
|
|
498
483
|
/**
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
484
|
+
* These are the x axis data points which will get rendered in the
|
|
485
|
+
* x axis in the graph
|
|
486
|
+
*/ const xAxisPoints = _getXAxisDataPoints(uniqueXPoints);
|
|
502
487
|
return {
|
|
503
488
|
dataSet,
|
|
504
489
|
yAxisPoints,
|
|
@@ -520,16 +505,16 @@ const HeatMapChart = /*#__PURE__*/ _react.forwardRef((props, forwardedRef)=>{
|
|
|
520
505
|
return (0, _d3format.format)(formatString || '.2~s')(+point);
|
|
521
506
|
};
|
|
522
507
|
/**
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
508
|
+
* This function checks if the given legend is highlighted or not.
|
|
509
|
+
* A legend can be highlighted in 2 ways:
|
|
510
|
+
* 1. selection: if the user clicks on it
|
|
511
|
+
* 2. hovering: if there is no selected legend and the user hovers over it
|
|
512
|
+
*/ const _legendHighlighted = (legendTitle)=>{
|
|
528
513
|
return selectedLegend === legendTitle || selectedLegend === '' && activeLegend === legendTitle;
|
|
529
514
|
};
|
|
530
515
|
/**
|
|
531
|
-
|
|
532
|
-
|
|
516
|
+
* This function checks if none of the legends is selected or hovered.
|
|
517
|
+
*/ const _noLegendHighlighted = ()=>{
|
|
533
518
|
return selectedLegend === '' && activeLegend === '';
|
|
534
519
|
};
|
|
535
520
|
const _getAriaLabel = (point)=>{
|
|
@@ -549,6 +534,82 @@ const HeatMapChart = /*#__PURE__*/ _react.forwardRef((props, forwardedRef)=>{
|
|
|
549
534
|
const numDataPoints = props.data.reduce((acc, curr)=>acc + curr.data.length, 0);
|
|
550
535
|
return (chartTitle ? `${chartTitle}. ` : '') + `Heat map chart with ${numDataPoints} data points. `;
|
|
551
536
|
};
|
|
537
|
+
const _getOrderedXAxisLabels = (points)=>{
|
|
538
|
+
if (!_shouldOrderXAxisLabelsByCategoryOrder()) {
|
|
539
|
+
// Keep the original ordering logic as the default behavior to ensure backward compatibility
|
|
540
|
+
return Object.keys(points).sort((a, b)=>{
|
|
541
|
+
if (_xAxisType.current === _index.XAxisTypes.DateAxis || _xAxisType.current === _index.XAxisTypes.NumericAxis) {
|
|
542
|
+
return +a - +b;
|
|
543
|
+
} else {
|
|
544
|
+
return props.sortOrder === 'none' ? 0 : a.toLowerCase() > b.toLowerCase() ? 1 : -1;
|
|
545
|
+
}
|
|
546
|
+
});
|
|
547
|
+
}
|
|
548
|
+
return (0, _index.sortAxisCategories)(_mapCategoryToValues(), props.xAxisCategoryOrder);
|
|
549
|
+
};
|
|
550
|
+
const _getOrderedYAxisLabels = (points)=>{
|
|
551
|
+
if (!_shouldOrderYAxisLabelsByCategoryOrder()) {
|
|
552
|
+
// Keep the original ordering logic as the default behavior to ensure backward compatibility
|
|
553
|
+
return Object.keys(points).sort((a, b)=>{
|
|
554
|
+
if (_yAxisType.current === _index.YAxisType.DateAxis || _yAxisType.current === _index.YAxisType.NumericAxis) {
|
|
555
|
+
return +a - +b;
|
|
556
|
+
} else {
|
|
557
|
+
return props.sortOrder === 'none' ? 0 : a.toLowerCase() > b.toLowerCase() ? 1 : -1;
|
|
558
|
+
}
|
|
559
|
+
});
|
|
560
|
+
}
|
|
561
|
+
return (0, _index.sortAxisCategories)(_mapCategoryToValues(true), props.yAxisCategoryOrder);
|
|
562
|
+
};
|
|
563
|
+
const _getOrderedXPoints = (xPoints)=>{
|
|
564
|
+
if (!_shouldOrderXAxisLabelsByCategoryOrder()) {
|
|
565
|
+
return xPoints.sort((a, b)=>{
|
|
566
|
+
if (_xAxisType.current === _index.XAxisTypes.StringAxis) {
|
|
567
|
+
return props.sortOrder === 'none' ? 0 : a.x.toLowerCase() > b.x.toLowerCase() ? 1 : -1;
|
|
568
|
+
} else if (_xAxisType.current === _index.XAxisTypes.DateAxis) {
|
|
569
|
+
return a.x.getTime() - b.x.getTime();
|
|
570
|
+
} else if (_xAxisType.current === _index.XAxisTypes.NumericAxis) {
|
|
571
|
+
return +a.x > +b.x ? 1 : -1;
|
|
572
|
+
} else {
|
|
573
|
+
return a.x > b.x ? 1 : -1;
|
|
574
|
+
}
|
|
575
|
+
});
|
|
576
|
+
}
|
|
577
|
+
const result = [];
|
|
578
|
+
const xValueToPoints = {};
|
|
579
|
+
xPoints.forEach((point)=>{
|
|
580
|
+
const xValue = point.x;
|
|
581
|
+
if (!xValueToPoints[xValue]) {
|
|
582
|
+
xValueToPoints[xValue] = [];
|
|
583
|
+
}
|
|
584
|
+
xValueToPoints[xValue].push(point);
|
|
585
|
+
});
|
|
586
|
+
const xAxisLabels = _getOrderedXAxisLabels({});
|
|
587
|
+
xAxisLabels.forEach((xValue)=>{
|
|
588
|
+
if (xValueToPoints[xValue]) {
|
|
589
|
+
result.push(...xValueToPoints[xValue]);
|
|
590
|
+
}
|
|
591
|
+
});
|
|
592
|
+
return result;
|
|
593
|
+
};
|
|
594
|
+
const _shouldOrderXAxisLabelsByCategoryOrder = ()=>{
|
|
595
|
+
return _xAxisType.current === _index.XAxisTypes.StringAxis && props.xAxisCategoryOrder !== 'default';
|
|
596
|
+
};
|
|
597
|
+
const _shouldOrderYAxisLabelsByCategoryOrder = ()=>{
|
|
598
|
+
return _yAxisType.current === _index.YAxisType.StringAxis && props.yAxisCategoryOrder !== 'default';
|
|
599
|
+
};
|
|
600
|
+
const _mapCategoryToValues = (isYAxis = false)=>{
|
|
601
|
+
const categoryToValues = {};
|
|
602
|
+
props.data.forEach((item)=>{
|
|
603
|
+
item.data.forEach((point)=>{
|
|
604
|
+
const category = isYAxis ? point.y : point.x;
|
|
605
|
+
if (!categoryToValues[category]) {
|
|
606
|
+
categoryToValues[category] = [];
|
|
607
|
+
}
|
|
608
|
+
categoryToValues[category].push(point.value);
|
|
609
|
+
});
|
|
610
|
+
});
|
|
611
|
+
return categoryToValues;
|
|
612
|
+
};
|
|
552
613
|
const updatePosition = (newX, newY)=>{
|
|
553
614
|
const threshold = 1; // Set a threshold for movement
|
|
554
615
|
const { x, y } = clickPosition;
|