@fluentui/react-charts 9.1.8 → 9.1.10
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 +34 -2
- package/dist/index.d.ts +309 -8
- package/lib/AreaChart.js.map +1 -1
- package/lib/CartesianChart.js.map +1 -1
- package/lib/DeclarativeChart.js.map +1 -1
- package/lib/DonutChart.js.map +1 -1
- package/lib/FunnelChart.js +1 -0
- package/lib/FunnelChart.js.map +1 -0
- package/lib/GanttChart.js +1 -0
- package/lib/GanttChart.js.map +1 -0
- package/lib/GaugeChart.js.map +1 -1
- package/lib/GroupedVerticalBarChart.js.map +1 -1
- package/lib/HeatMapChart.js.map +1 -1
- package/lib/HorizontalBarChart.js.map +1 -1
- package/lib/HorizontalBarChartWithAxis.js.map +1 -1
- package/lib/Legends.js.map +1 -1
- package/lib/LineChart.js.map +1 -1
- package/lib/Popover.js.map +1 -1
- package/lib/ResponsiveContainer.js.map +1 -1
- package/lib/SankeyChart.js.map +1 -1
- package/lib/ScatterChart.js.map +1 -1
- package/lib/Sparkline.js.map +1 -1
- package/lib/VerticalBarChart.js.map +1 -1
- package/lib/VerticalStackedBarChart.js.map +1 -1
- package/lib/components/AreaChart/AreaChart.js +13 -5
- package/lib/components/AreaChart/AreaChart.js.map +1 -1
- package/lib/components/AreaChart/AreaChart.types.js.map +1 -1
- package/lib/components/AreaChart/index.js.map +1 -1
- package/lib/components/CommonComponents/CartesianChart.js +10 -7
- package/lib/components/CommonComponents/CartesianChart.js.map +1 -1
- package/lib/components/CommonComponents/CartesianChart.types.js.map +1 -1
- package/lib/components/CommonComponents/ChartPopover.js.map +1 -1
- package/lib/components/CommonComponents/ChartPopover.types.js.map +1 -1
- package/lib/components/CommonComponents/index.js.map +1 -1
- package/lib/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib/components/DeclarativeChart/imageExporter.js.map +1 -1
- package/lib/components/DeclarativeChart/index.js.map +1 -1
- package/lib/components/DonutChart/Arc/Arc.js +5 -5
- package/lib/components/DonutChart/Arc/Arc.js.map +1 -1
- package/lib/components/DonutChart/Arc/Arc.types.js.map +1 -1
- package/lib/components/DonutChart/Arc/index.js.map +1 -1
- package/lib/components/DonutChart/DonutChart.js +7 -1
- 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/DonutChart/Pie/Pie.types.js.map +1 -1
- package/lib/components/DonutChart/Pie/index.js.map +1 -1
- package/lib/components/DonutChart/index.js.map +1 -1
- package/lib/components/FunnelChart/FunnelChart.js +391 -0
- package/lib/components/FunnelChart/FunnelChart.js.map +1 -0
- package/lib/components/FunnelChart/FunnelChart.types.js +1 -0
- package/lib/components/FunnelChart/FunnelChart.types.js.map +1 -0
- package/lib/components/FunnelChart/funnelGeometry.js +220 -0
- package/lib/components/FunnelChart/funnelGeometry.js.map +1 -0
- package/lib/components/FunnelChart/index.js +2 -0
- package/lib/components/FunnelChart/index.js.map +1 -0
- package/lib/components/FunnelChart/useFunnelChartStyles.styles.js +59 -0
- package/lib/components/FunnelChart/useFunnelChartStyles.styles.js.map +1 -0
- package/lib/components/GanttChart/GanttChart.js +530 -0
- package/lib/components/GanttChart/GanttChart.js.map +1 -0
- package/lib/components/GanttChart/GanttChart.types.js +4 -0
- package/lib/components/GanttChart/GanttChart.types.js.map +1 -0
- package/lib/components/GanttChart/index.js +2 -0
- package/lib/components/GanttChart/index.js.map +1 -0
- package/lib/components/GanttChart/useGanttChartStyles.styles.js +25 -0
- package/lib/components/GanttChart/useGanttChartStyles.styles.js.map +1 -0
- package/lib/components/GaugeChart/GaugeChart.js.map +1 -1
- package/lib/components/GaugeChart/GaugeChart.types.js.map +1 -1
- package/lib/components/GaugeChart/index.js.map +1 -1
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +10 -5
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.types.js.map +1 -1
- package/lib/components/GroupedVerticalBarChart/index.js.map +1 -1
- package/lib/components/HeatMapChart/HeatMapChart.js.map +1 -1
- package/lib/components/HeatMapChart/HeatMapChart.types.js.map +1 -1
- package/lib/components/HeatMapChart/index.js.map +1 -1
- package/lib/components/HorizontalBarChart/HorizontalBarChart.js.map +1 -1
- package/lib/components/HorizontalBarChart/HorizontalBarChart.types.js +5 -3
- package/lib/components/HorizontalBarChart/HorizontalBarChart.types.js.map +1 -1
- package/lib/components/HorizontalBarChart/index.js.map +1 -1
- package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js +9 -3
- package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js.map +1 -1
- package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.types.js.map +1 -1
- package/lib/components/HorizontalBarChartWithAxis/index.js.map +1 -1
- package/lib/components/Legends/Legends.js.map +1 -1
- package/lib/components/Legends/Legends.types.js.map +1 -1
- package/lib/components/Legends/OverflowMenu.js.map +1 -1
- package/lib/components/Legends/index.js.map +1 -1
- package/lib/components/Legends/shape.js +3 -3
- package/lib/components/Legends/shape.js.map +1 -1
- package/lib/components/LineChart/LineChart.js +14 -7
- package/lib/components/LineChart/LineChart.js.map +1 -1
- package/lib/components/LineChart/LineChart.types.js.map +1 -1
- package/lib/components/LineChart/eventAnnotation/EventAnnotation.js.map +1 -1
- package/lib/components/LineChart/eventAnnotation/LabelLink.js.map +1 -1
- package/lib/components/LineChart/eventAnnotation/Textbox.js +2 -1
- package/lib/components/LineChart/eventAnnotation/Textbox.js.map +1 -1
- package/lib/components/LineChart/index.js.map +1 -1
- package/lib/components/ResponsiveContainer/ResponsiveContainer.js.map +1 -1
- package/lib/components/ResponsiveContainer/ResponsiveContainer.types.js.map +1 -1
- package/lib/components/ResponsiveContainer/index.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/SankeyChart.types.js.map +1 -1
- package/lib/components/SankeyChart/index.js.map +1 -1
- package/lib/components/ScatterChart/ScatterChart.js +8 -2
- package/lib/components/ScatterChart/ScatterChart.js.map +1 -1
- package/lib/components/ScatterChart/ScatterChart.types.js.map +1 -1
- package/lib/components/ScatterChart/index.js.map +1 -1
- package/lib/components/Sparkline/Sparkline.js.map +1 -1
- package/lib/components/Sparkline/Sparkline.types.js.map +1 -1
- package/lib/components/Sparkline/index.js.map +1 -1
- package/lib/components/VerticalBarChart/VerticalBarChart.js +10 -4
- package/lib/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
- package/lib/components/VerticalBarChart/VerticalBarChart.types.js.map +1 -1
- package/lib/components/VerticalBarChart/index.js.map +1 -1
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js +4 -4
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -1
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.types.js.map +1 -1
- package/lib/components/VerticalStackedBarChart/index.js.map +1 -1
- package/lib/index.js +2 -0
- package/lib/index.js.map +1 -1
- package/lib/types/DataPoint.js +3 -1
- package/lib/types/DataPoint.js.map +1 -1
- package/lib/types/EventAnnotation.js.map +1 -1
- package/lib/types/LegendDataItem.js.map +1 -1
- package/lib/types/index.js.map +1 -1
- package/lib/utilities/FocusableTooltipText.js.map +1 -1
- package/lib/utilities/KeyCodes.js.map +1 -1
- package/lib/utilities/SVGTooltipText.js.map +1 -1
- package/lib/utilities/async-utils.js.map +1 -1
- package/lib/utilities/colors.js +12 -0
- package/lib/utilities/colors.js.map +1 -1
- package/lib/utilities/getWindow.js.map +1 -1
- package/lib/utilities/index.js.map +1 -1
- package/lib/utilities/overflow-utils.js.map +1 -1
- package/lib/utilities/string.js.map +1 -1
- package/lib/utilities/test-data.js +236 -0
- package/lib/utilities/test-data.js.map +1 -1
- package/lib/utilities/utilities.js +90 -22
- package/lib/utilities/utilities.js.map +1 -1
- package/lib/utilities/vbc-utils.js +2 -2
- package/lib/utilities/vbc-utils.js.map +1 -1
- package/lib-commonjs/AreaChart.js.map +1 -1
- package/lib-commonjs/CartesianChart.js.map +1 -1
- package/lib-commonjs/DeclarativeChart.js.map +1 -1
- package/lib-commonjs/DonutChart.js.map +1 -1
- package/lib-commonjs/FunnelChart.js +6 -0
- package/lib-commonjs/FunnelChart.js.map +1 -0
- package/lib-commonjs/GanttChart.js +6 -0
- package/lib-commonjs/GanttChart.js.map +1 -0
- package/lib-commonjs/GaugeChart.js.map +1 -1
- package/lib-commonjs/GroupedVerticalBarChart.js.map +1 -1
- package/lib-commonjs/HeatMapChart.js.map +1 -1
- package/lib-commonjs/HorizontalBarChart.js.map +1 -1
- package/lib-commonjs/HorizontalBarChartWithAxis.js.map +1 -1
- package/lib-commonjs/Legends.js.map +1 -1
- package/lib-commonjs/LineChart.js.map +1 -1
- package/lib-commonjs/Popover.js.map +1 -1
- package/lib-commonjs/ResponsiveContainer.js.map +1 -1
- package/lib-commonjs/SankeyChart.js.map +1 -1
- package/lib-commonjs/ScatterChart.js.map +1 -1
- package/lib-commonjs/Sparkline.js.map +1 -1
- package/lib-commonjs/VerticalBarChart.js.map +1 -1
- package/lib-commonjs/VerticalStackedBarChart.js.map +1 -1
- package/lib-commonjs/components/AreaChart/AreaChart.js +13 -5
- package/lib-commonjs/components/AreaChart/AreaChart.js.map +1 -1
- package/lib-commonjs/components/AreaChart/AreaChart.types.js.map +1 -1
- package/lib-commonjs/components/AreaChart/index.js.map +1 -1
- package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/CartesianChart.js +9 -6
- 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.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/ChartPopover.types.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/index.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/useChartPopoverStyles.styles.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/imageExporter.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/index.js.map +1 -1
- package/lib-commonjs/components/DonutChart/Arc/Arc.js +5 -5
- package/lib-commonjs/components/DonutChart/Arc/Arc.js.map +1 -1
- package/lib-commonjs/components/DonutChart/Arc/Arc.types.js.map +1 -1
- package/lib-commonjs/components/DonutChart/Arc/index.js.map +1 -1
- package/lib-commonjs/components/DonutChart/Arc/useArcStyles.styles.js.map +1 -1
- package/lib-commonjs/components/DonutChart/DonutChart.js +7 -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/DonutChart/Pie/Pie.types.js.map +1 -1
- package/lib-commonjs/components/DonutChart/Pie/index.js.map +1 -1
- package/lib-commonjs/components/DonutChart/Pie/usePieStyles.styles.js.map +1 -1
- package/lib-commonjs/components/DonutChart/index.js.map +1 -1
- package/lib-commonjs/components/DonutChart/useDonutChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/FunnelChart/FunnelChart.js +402 -0
- package/lib-commonjs/components/FunnelChart/FunnelChart.js.map +1 -0
- package/lib-commonjs/components/FunnelChart/FunnelChart.types.js +6 -0
- package/lib-commonjs/components/FunnelChart/FunnelChart.types.js.map +1 -0
- package/lib-commonjs/components/FunnelChart/funnelGeometry.js +248 -0
- package/lib-commonjs/components/FunnelChart/funnelGeometry.js.map +1 -0
- package/lib-commonjs/components/FunnelChart/index.js +7 -0
- package/lib-commonjs/components/FunnelChart/index.js.map +1 -0
- package/lib-commonjs/components/FunnelChart/useFunnelChartStyles.styles.js +79 -0
- package/lib-commonjs/components/FunnelChart/useFunnelChartStyles.styles.js.map +1 -0
- package/lib-commonjs/components/GanttChart/GanttChart.js +541 -0
- package/lib-commonjs/components/GanttChart/GanttChart.js.map +1 -0
- package/lib-commonjs/components/GanttChart/GanttChart.types.js +7 -0
- package/lib-commonjs/components/GanttChart/GanttChart.types.js.map +1 -0
- package/lib-commonjs/components/GanttChart/index.js +7 -0
- package/lib-commonjs/components/GanttChart/index.js.map +1 -0
- package/lib-commonjs/components/GanttChart/useGanttChartStyles.styles.js +39 -0
- package/lib-commonjs/components/GanttChart/useGanttChartStyles.styles.js.map +1 -0
- package/lib-commonjs/components/GaugeChart/GaugeChart.js.map +1 -1
- package/lib-commonjs/components/GaugeChart/GaugeChart.types.js.map +1 -1
- package/lib-commonjs/components/GaugeChart/index.js.map +1 -1
- package/lib-commonjs/components/GaugeChart/useGaugeChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +10 -5
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.types.js.map +1 -1
- package/lib-commonjs/components/GroupedVerticalBarChart/index.js.map +1 -1
- package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/HeatMapChart/HeatMapChart.js.map +1 -1
- package/lib-commonjs/components/HeatMapChart/HeatMapChart.types.js.map +1 -1
- package/lib-commonjs/components/HeatMapChart/index.js.map +1 -1
- package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChart/HorizontalBarChart.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChart/HorizontalBarChart.types.js +3 -3
- package/lib-commonjs/components/HorizontalBarChart/HorizontalBarChart.types.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChart/index.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js +9 -3
- package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.types.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChartWithAxis/index.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js.map +1 -1
- package/lib-commonjs/components/Legends/Legends.js.map +1 -1
- package/lib-commonjs/components/Legends/Legends.types.js.map +1 -1
- package/lib-commonjs/components/Legends/OverflowMenu.js.map +1 -1
- package/lib-commonjs/components/Legends/index.js.map +1 -1
- package/lib-commonjs/components/Legends/shape.js +2 -2
- package/lib-commonjs/components/Legends/shape.js.map +1 -1
- package/lib-commonjs/components/Legends/useLegendsStyles.styles.js.map +1 -1
- package/lib-commonjs/components/LineChart/LineChart.js +14 -7
- 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/eventAnnotation/EventAnnotation.js.map +1 -1
- package/lib-commonjs/components/LineChart/eventAnnotation/LabelLink.js.map +1 -1
- package/lib-commonjs/components/LineChart/eventAnnotation/Textbox.js +2 -1
- package/lib-commonjs/components/LineChart/eventAnnotation/Textbox.js.map +1 -1
- package/lib-commonjs/components/LineChart/index.js.map +1 -1
- package/lib-commonjs/components/LineChart/useLineChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/ResponsiveContainer/ResponsiveContainer.js.map +1 -1
- package/lib-commonjs/components/ResponsiveContainer/ResponsiveContainer.types.js.map +1 -1
- package/lib-commonjs/components/ResponsiveContainer/index.js.map +1 -1
- package/lib-commonjs/components/ResponsiveContainer/useResponsiveChildStyles.styles.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/SankeyChart.types.js.map +1 -1
- package/lib-commonjs/components/SankeyChart/index.js.map +1 -1
- package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/ScatterChart/ScatterChart.js +8 -2
- 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/index.js.map +1 -1
- package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/Sparkline/Sparkline.js.map +1 -1
- package/lib-commonjs/components/Sparkline/Sparkline.types.js.map +1 -1
- package/lib-commonjs/components/Sparkline/index.js.map +1 -1
- package/lib-commonjs/components/Sparkline/useSparklineStyles.styles.js.map +1 -1
- package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js +10 -4
- package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
- package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.types.js.map +1 -1
- package/lib-commonjs/components/VerticalBarChart/index.js.map +1 -1
- package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js +4 -4
- 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/index.js.map +1 -1
- package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js.map +1 -1
- package/lib-commonjs/index.js +2 -0
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/types/DataPoint.js +3 -1
- package/lib-commonjs/types/DataPoint.js.map +1 -1
- package/lib-commonjs/types/EventAnnotation.js.map +1 -1
- package/lib-commonjs/types/LegendDataItem.js.map +1 -1
- package/lib-commonjs/types/index.js.map +1 -1
- package/lib-commonjs/utilities/FocusableTooltipText.js.map +1 -1
- package/lib-commonjs/utilities/KeyCodes.js.map +1 -1
- package/lib-commonjs/utilities/SVGTooltipText.js.map +1 -1
- package/lib-commonjs/utilities/async-utils.js.map +1 -1
- package/lib-commonjs/utilities/colors.js +18 -0
- package/lib-commonjs/utilities/colors.js.map +1 -1
- package/lib-commonjs/utilities/getWindow.js.map +1 -1
- package/lib-commonjs/utilities/index.js.map +1 -1
- package/lib-commonjs/utilities/overflow-utils.js.map +1 -1
- package/lib-commonjs/utilities/string.js.map +1 -1
- package/lib-commonjs/utilities/test-data.js +245 -0
- package/lib-commonjs/utilities/test-data.js.map +1 -1
- package/lib-commonjs/utilities/utilities.js +86 -17
- package/lib-commonjs/utilities/utilities.js.map +1 -1
- package/lib-commonjs/utilities/vbc-utils.js +2 -2
- package/lib-commonjs/utilities/vbc-utils.js.map +1 -1
- package/package.json +9 -9
|
@@ -0,0 +1,530 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { max as d3Max, min as d3Min } from 'd3-array';
|
|
3
|
+
import { useId } from '@fluentui/react-utilities';
|
|
4
|
+
import { Legends } from '../Legends/index';
|
|
5
|
+
import { CartesianChart } from '../CommonComponents/index';
|
|
6
|
+
import { ChartPopover } from '../CommonComponents/ChartPopover';
|
|
7
|
+
import { ChartTypes, YAxisType, XAxisTypes, getTypeOfAxis, getNextColor, findHBCWANumericMinMaxOfY, createYAxisForHorizontalBarChartWithAxis, createStringYAxisForHorizontalBarChartWithAxis, areArraysEqual, MIN_DOMAIN_MARGIN, sortAxisCategories, calculateAppropriateBarWidth, getColorFromToken, getScalePadding, getDateFormatLevel } from '../../utilities/index';
|
|
8
|
+
import { formatDateToLocaleString, getMultiLevelDateTimeFormatOptions } from '@fluentui/chart-utilities';
|
|
9
|
+
const DEFAULT_BAR_HEIGHT = 24;
|
|
10
|
+
const MIN_BAR_HEIGHT = 1;
|
|
11
|
+
export const GanttChart = /*#__PURE__*/ React.forwardRef(({ useUTC = true, yAxisCategoryOrder = 'default', maxBarHeight = 24, ...props }, forwardedRef)=>{
|
|
12
|
+
var _props_legendProps;
|
|
13
|
+
const _barHeight = React.useRef(DEFAULT_BAR_HEIGHT);
|
|
14
|
+
const _margins = React.useRef({});
|
|
15
|
+
const _calloutAnchorPoint = React.useRef(null);
|
|
16
|
+
const _emptyChartId = useId('Gantt_empty');
|
|
17
|
+
const _legendId = useId('gantt_legend');
|
|
18
|
+
const _legendMap = React.useRef({});
|
|
19
|
+
const _prevProps = React.useRef({});
|
|
20
|
+
const [calloutColor, setCalloutColor] = React.useState('');
|
|
21
|
+
const [hoveredLegend, setHoveredLegend] = React.useState('');
|
|
22
|
+
const [calloutLegend, setCalloutLegend] = React.useState('');
|
|
23
|
+
const [xCalloutValue, setXCalloutValue] = React.useState('');
|
|
24
|
+
const [yCalloutValue, setYCalloutValue] = React.useState('');
|
|
25
|
+
const [selectedLegends, setSelectedLegends] = React.useState(((_props_legendProps = props.legendProps) === null || _props_legendProps === void 0 ? void 0 : _props_legendProps.selectedLegends) || []);
|
|
26
|
+
const [calloutDataPoint, setCalloutDataPoint] = React.useState();
|
|
27
|
+
const [clickPosition, setClickPosition] = React.useState({
|
|
28
|
+
x: 0,
|
|
29
|
+
y: 0
|
|
30
|
+
});
|
|
31
|
+
const [isPopoverOpen, setPopoverOpen] = React.useState(false);
|
|
32
|
+
React.useEffect(()=>{
|
|
33
|
+
var _prevProps_current_legendProps, _props_legendProps;
|
|
34
|
+
if (!areArraysEqual((_prevProps_current_legendProps = _prevProps.current.legendProps) === null || _prevProps_current_legendProps === void 0 ? void 0 : _prevProps_current_legendProps.selectedLegends, (_props_legendProps = props.legendProps) === null || _props_legendProps === void 0 ? void 0 : _props_legendProps.selectedLegends)) {
|
|
35
|
+
var _props_legendProps1;
|
|
36
|
+
setSelectedLegends(((_props_legendProps1 = props.legendProps) === null || _props_legendProps1 === void 0 ? void 0 : _props_legendProps1.selectedLegends) || []);
|
|
37
|
+
}
|
|
38
|
+
_prevProps.current = props;
|
|
39
|
+
}, [
|
|
40
|
+
props
|
|
41
|
+
]);
|
|
42
|
+
const _points = React.useMemo(()=>{
|
|
43
|
+
var _props_data;
|
|
44
|
+
_legendMap.current = {};
|
|
45
|
+
let colorIndex = 0;
|
|
46
|
+
var _props_data_map;
|
|
47
|
+
return (_props_data_map = (_props_data = props.data) === null || _props_data === void 0 ? void 0 : _props_data.map((point)=>{
|
|
48
|
+
const legend = `${point.legend}`;
|
|
49
|
+
if (!_legendMap.current[legend]) {
|
|
50
|
+
let startColor = point.color ? getColorFromToken(point.color) : getNextColor(colorIndex, 0);
|
|
51
|
+
let endColor = startColor;
|
|
52
|
+
if (props.enableGradient) {
|
|
53
|
+
var _point_gradient, _point_gradient1;
|
|
54
|
+
startColor = (_point_gradient = point.gradient) === null || _point_gradient === void 0 ? void 0 : _point_gradient[0];
|
|
55
|
+
endColor = (_point_gradient1 = point.gradient) === null || _point_gradient1 === void 0 ? void 0 : _point_gradient1[1];
|
|
56
|
+
}
|
|
57
|
+
_legendMap.current[legend] = {
|
|
58
|
+
id: `${_legendId}_${colorIndex}`,
|
|
59
|
+
startColor,
|
|
60
|
+
endColor
|
|
61
|
+
};
|
|
62
|
+
colorIndex += 1;
|
|
63
|
+
}
|
|
64
|
+
const { startColor, endColor } = _legendMap.current[legend];
|
|
65
|
+
return {
|
|
66
|
+
...point,
|
|
67
|
+
color: startColor,
|
|
68
|
+
...props.enableGradient ? {
|
|
69
|
+
gradient: [
|
|
70
|
+
startColor,
|
|
71
|
+
endColor
|
|
72
|
+
]
|
|
73
|
+
} : {}
|
|
74
|
+
};
|
|
75
|
+
})) !== null && _props_data_map !== void 0 ? _props_data_map : [];
|
|
76
|
+
}, [
|
|
77
|
+
props.data,
|
|
78
|
+
props.enableGradient
|
|
79
|
+
]);
|
|
80
|
+
const _xAxisType = React.useMemo(()=>{
|
|
81
|
+
if (_points.length > 0) {
|
|
82
|
+
return getTypeOfAxis(_points[0].x.start, true);
|
|
83
|
+
}
|
|
84
|
+
return XAxisTypes.DateAxis;
|
|
85
|
+
}, [
|
|
86
|
+
_points
|
|
87
|
+
]);
|
|
88
|
+
const _yAxisType = React.useMemo(()=>{
|
|
89
|
+
if (_points.length > 0) {
|
|
90
|
+
return getTypeOfAxis(_points[0].y, false);
|
|
91
|
+
}
|
|
92
|
+
return YAxisType.StringAxis;
|
|
93
|
+
}, [
|
|
94
|
+
_points
|
|
95
|
+
]);
|
|
96
|
+
const _yAxisPadding = React.useMemo(()=>{
|
|
97
|
+
return getScalePadding(props.yAxisPadding, undefined, 1 / 2);
|
|
98
|
+
}, [
|
|
99
|
+
props.yAxisPadding
|
|
100
|
+
]);
|
|
101
|
+
const _dateFormatOptions = React.useMemo(()=>{
|
|
102
|
+
if (_xAxisType !== XAxisTypes.DateAxis) {
|
|
103
|
+
return undefined;
|
|
104
|
+
}
|
|
105
|
+
let lowestFormatLevel = 100;
|
|
106
|
+
let highestFormatLevel = -1;
|
|
107
|
+
_points.forEach((p)=>{
|
|
108
|
+
const startFormatLevel = getDateFormatLevel(p.x.start, useUTC);
|
|
109
|
+
const endFormatLevel = getDateFormatLevel(p.x.end, useUTC);
|
|
110
|
+
lowestFormatLevel = Math.min(lowestFormatLevel, startFormatLevel, endFormatLevel);
|
|
111
|
+
highestFormatLevel = Math.max(highestFormatLevel, startFormatLevel, endFormatLevel);
|
|
112
|
+
});
|
|
113
|
+
return getMultiLevelDateTimeFormatOptions(lowestFormatLevel, highestFormatLevel);
|
|
114
|
+
}, [
|
|
115
|
+
useUTC,
|
|
116
|
+
_points,
|
|
117
|
+
_xAxisType
|
|
118
|
+
]);
|
|
119
|
+
const _mapYValueToXValues = React.useCallback(()=>{
|
|
120
|
+
const yValueToXValues = {};
|
|
121
|
+
_points.forEach((point)=>{
|
|
122
|
+
if (!yValueToXValues[point.y]) {
|
|
123
|
+
yValueToXValues[point.y] = [];
|
|
124
|
+
}
|
|
125
|
+
yValueToXValues[point.y].push(+point.x.end - +point.x.start);
|
|
126
|
+
});
|
|
127
|
+
return yValueToXValues;
|
|
128
|
+
}, [
|
|
129
|
+
_points
|
|
130
|
+
]);
|
|
131
|
+
const _getOrderedYAxisLabels = React.useCallback(()=>{
|
|
132
|
+
const yValueToXValues = _mapYValueToXValues();
|
|
133
|
+
if (_yAxisType !== YAxisType.StringAxis) {
|
|
134
|
+
return Object.keys(yValueToXValues).sort((a, b)=>+a - +b);
|
|
135
|
+
}
|
|
136
|
+
if (yAxisCategoryOrder === 'default') {
|
|
137
|
+
return Object.keys(yValueToXValues).reverse();
|
|
138
|
+
}
|
|
139
|
+
return sortAxisCategories(yValueToXValues, yAxisCategoryOrder);
|
|
140
|
+
}, [
|
|
141
|
+
_mapYValueToXValues,
|
|
142
|
+
_yAxisType,
|
|
143
|
+
yAxisCategoryOrder
|
|
144
|
+
]);
|
|
145
|
+
const _yAxisLabels = React.useMemo(()=>_getOrderedYAxisLabels(), [
|
|
146
|
+
_getOrderedYAxisLabels
|
|
147
|
+
]);
|
|
148
|
+
const _getDomainNRangeValues = React.useCallback((points, margins, containerWidth, chartType, isRTL, xAxisType, barWidth, tickValues, shiftX)=>{
|
|
149
|
+
const xValues = [];
|
|
150
|
+
points.forEach((point)=>{
|
|
151
|
+
xValues.push(point.x.start, point.x.end);
|
|
152
|
+
});
|
|
153
|
+
const xMin = d3Min(xValues) || 0;
|
|
154
|
+
const xMax = d3Max(xValues) || 0;
|
|
155
|
+
return {
|
|
156
|
+
dStartValue: isRTL ? xMax : xMin,
|
|
157
|
+
dEndValue: isRTL ? xMin : xMax,
|
|
158
|
+
rStartValue: margins.left + (isRTL ? 0 : shiftX),
|
|
159
|
+
rEndValue: containerWidth - margins.right - (isRTL ? shiftX : 0)
|
|
160
|
+
};
|
|
161
|
+
}, []);
|
|
162
|
+
const _getMargins = React.useCallback((margins)=>{
|
|
163
|
+
_margins.current = margins;
|
|
164
|
+
}, []);
|
|
165
|
+
const _getFormattedXValue = React.useCallback((point)=>{
|
|
166
|
+
let formattedStartX;
|
|
167
|
+
let formattedEndX;
|
|
168
|
+
if (_xAxisType === XAxisTypes.DateAxis) {
|
|
169
|
+
formattedStartX = formatDateToLocaleString(point.x.start, props.culture, useUTC, false, _dateFormatOptions);
|
|
170
|
+
formattedEndX = formatDateToLocaleString(point.x.end, props.culture, useUTC, false, _dateFormatOptions);
|
|
171
|
+
} else {
|
|
172
|
+
formattedStartX = point.x.start.toString();
|
|
173
|
+
formattedEndX = point.x.end.toString();
|
|
174
|
+
}
|
|
175
|
+
return `${formattedStartX} - ${formattedEndX}`;
|
|
176
|
+
}, [
|
|
177
|
+
props.culture,
|
|
178
|
+
useUTC,
|
|
179
|
+
_dateFormatOptions,
|
|
180
|
+
_xAxisType
|
|
181
|
+
]);
|
|
182
|
+
const _getCustomizedCallout = React.useCallback(()=>{
|
|
183
|
+
const defaultRender = (point)=>{
|
|
184
|
+
return point ? /*#__PURE__*/ React.createElement(ChartPopover, {
|
|
185
|
+
isPopoverOpen: isPopoverOpen,
|
|
186
|
+
clickPosition: clickPosition,
|
|
187
|
+
XValue: point.yAxisCalloutData || point.y.toString(),
|
|
188
|
+
legend: point.legend,
|
|
189
|
+
YValue: point.xAxisCalloutData || _getFormattedXValue(point),
|
|
190
|
+
color: point.color,
|
|
191
|
+
culture: props.culture
|
|
192
|
+
}) : null;
|
|
193
|
+
};
|
|
194
|
+
return props.onRenderCalloutPerDataPoint ? props.onRenderCalloutPerDataPoint(calloutDataPoint, defaultRender) : null;
|
|
195
|
+
//eslint-disable-next-line react-hooks/exhaustive-deps
|
|
196
|
+
}, [
|
|
197
|
+
_getFormattedXValue,
|
|
198
|
+
calloutDataPoint,
|
|
199
|
+
props.culture,
|
|
200
|
+
props.onRenderCalloutPerDataPoint
|
|
201
|
+
]);
|
|
202
|
+
const _getAriaLabel = React.useCallback((point)=>{
|
|
203
|
+
var _point_callOutAccessibilityData;
|
|
204
|
+
const xValue = point.xAxisCalloutData || _getFormattedXValue(point);
|
|
205
|
+
const yValue = point.yAxisCalloutData || point.y;
|
|
206
|
+
return ((_point_callOutAccessibilityData = point.callOutAccessibilityData) === null || _point_callOutAccessibilityData === void 0 ? void 0 : _point_callOutAccessibilityData.ariaLabel) || `${yValue}. ` + (point.legend ? `${point.legend}, ` : '') + `${xValue}.`;
|
|
207
|
+
}, [
|
|
208
|
+
_getFormattedXValue
|
|
209
|
+
]);
|
|
210
|
+
const _getHighlightedLegend = React.useCallback(()=>{
|
|
211
|
+
return selectedLegends.length > 0 ? selectedLegends : hoveredLegend ? [
|
|
212
|
+
hoveredLegend
|
|
213
|
+
] : [];
|
|
214
|
+
}, [
|
|
215
|
+
hoveredLegend,
|
|
216
|
+
selectedLegends
|
|
217
|
+
]);
|
|
218
|
+
/**
|
|
219
|
+
* This function checks if the given legend is highlighted or not.
|
|
220
|
+
* A legend can be highlighted in 2 ways:
|
|
221
|
+
* 1. selection: if the user clicks on it
|
|
222
|
+
* 2. hovering: if there is no selected legend and the user hovers over it
|
|
223
|
+
*/ const _legendHighlighted = React.useCallback((legend)=>{
|
|
224
|
+
return _getHighlightedLegend().includes(`${legend}`);
|
|
225
|
+
}, [
|
|
226
|
+
_getHighlightedLegend
|
|
227
|
+
]);
|
|
228
|
+
/**
|
|
229
|
+
* This function checks if none of the legends is selected or hovered.
|
|
230
|
+
*/ const _noLegendHighlighted = React.useCallback(()=>{
|
|
231
|
+
return _getHighlightedLegend().length === 0;
|
|
232
|
+
}, [
|
|
233
|
+
_getHighlightedLegend
|
|
234
|
+
]);
|
|
235
|
+
const _showCallout = React.useCallback((target, point)=>{
|
|
236
|
+
if (!(_noLegendHighlighted() || _legendHighlighted(point.legend)) || _calloutAnchorPoint.current === point) {
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
if ('clientX' in target && 'clientY' in target) {
|
|
240
|
+
updatePosition(target.clientX, target.clientY);
|
|
241
|
+
} else {
|
|
242
|
+
const rect = target.target.getBoundingClientRect();
|
|
243
|
+
updatePosition(rect.left, rect.top);
|
|
244
|
+
}
|
|
245
|
+
_calloutAnchorPoint.current = point;
|
|
246
|
+
setPopoverOpen(true);
|
|
247
|
+
setCalloutLegend(point.legend);
|
|
248
|
+
setCalloutColor(point.color);
|
|
249
|
+
setXCalloutValue(point.yAxisCalloutData || point.y.toString());
|
|
250
|
+
setYCalloutValue(point.xAxisCalloutData || _getFormattedXValue(point));
|
|
251
|
+
setCalloutDataPoint(point);
|
|
252
|
+
}, [
|
|
253
|
+
_getFormattedXValue,
|
|
254
|
+
_legendHighlighted,
|
|
255
|
+
_noLegendHighlighted
|
|
256
|
+
]);
|
|
257
|
+
const _onBarFocus = React.useCallback((point, focusEvent)=>{
|
|
258
|
+
_showCallout(focusEvent, point);
|
|
259
|
+
}, [
|
|
260
|
+
_showCallout
|
|
261
|
+
]);
|
|
262
|
+
const _onBarHover = React.useCallback((point, mouseEvent)=>{
|
|
263
|
+
_showCallout(mouseEvent, point);
|
|
264
|
+
}, [
|
|
265
|
+
_showCallout
|
|
266
|
+
]);
|
|
267
|
+
const _onBarLeave = React.useCallback(()=>{
|
|
268
|
+
// do nothing
|
|
269
|
+
}, []);
|
|
270
|
+
const _handleChartMouseLeave = React.useCallback(()=>{
|
|
271
|
+
_calloutAnchorPoint.current = null;
|
|
272
|
+
setPopoverOpen(false);
|
|
273
|
+
setCalloutLegend('');
|
|
274
|
+
setCalloutColor('');
|
|
275
|
+
setXCalloutValue('');
|
|
276
|
+
setYCalloutValue('');
|
|
277
|
+
setCalloutDataPoint(undefined);
|
|
278
|
+
}, []);
|
|
279
|
+
const _getBarHeight = React.useCallback((adjustedValue)=>{
|
|
280
|
+
let barHeight;
|
|
281
|
+
if (typeof props.barHeight === 'number') {
|
|
282
|
+
barHeight = props.barHeight;
|
|
283
|
+
} else {
|
|
284
|
+
barHeight = adjustedValue;
|
|
285
|
+
}
|
|
286
|
+
if (typeof maxBarHeight === 'number') {
|
|
287
|
+
barHeight = Math.min(barHeight, maxBarHeight);
|
|
288
|
+
}
|
|
289
|
+
barHeight = Math.max(barHeight, MIN_BAR_HEIGHT);
|
|
290
|
+
return barHeight;
|
|
291
|
+
}, [
|
|
292
|
+
maxBarHeight,
|
|
293
|
+
props.barHeight
|
|
294
|
+
]);
|
|
295
|
+
const _getOrderedDataPoints = React.useCallback(()=>{
|
|
296
|
+
const result = [];
|
|
297
|
+
const yValueToPoints = {};
|
|
298
|
+
_points.forEach((point)=>{
|
|
299
|
+
if (!yValueToPoints[point.y]) {
|
|
300
|
+
yValueToPoints[point.y] = [];
|
|
301
|
+
}
|
|
302
|
+
yValueToPoints[point.y].push(point);
|
|
303
|
+
});
|
|
304
|
+
for(let i = _yAxisLabels.length - 1; i >= 0; i--){
|
|
305
|
+
const yValue = _yAxisLabels[i];
|
|
306
|
+
if (yValueToPoints[yValue]) {
|
|
307
|
+
result.push(...yValueToPoints[yValue].sort((a, b)=>+a.x.start - +b.x.start));
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
return result;
|
|
311
|
+
}, [
|
|
312
|
+
_points,
|
|
313
|
+
_yAxisLabels
|
|
314
|
+
]);
|
|
315
|
+
const _createBars = React.useCallback(({ xScale, yScalePrimary: yScale })=>{
|
|
316
|
+
const getGradientId = (legend)=>{
|
|
317
|
+
const legendId = _legendMap.current[`${legend}`].id;
|
|
318
|
+
return `${legendId}_gradient`;
|
|
319
|
+
};
|
|
320
|
+
const gradientDefs = [];
|
|
321
|
+
if (props.enableGradient) {
|
|
322
|
+
Object.keys(_legendMap.current).forEach((legend, index)=>{
|
|
323
|
+
const { startColor, endColor } = _legendMap.current[legend];
|
|
324
|
+
gradientDefs.push(/*#__PURE__*/ React.createElement("linearGradient", {
|
|
325
|
+
key: index,
|
|
326
|
+
id: getGradientId(legend)
|
|
327
|
+
}, /*#__PURE__*/ React.createElement("stop", {
|
|
328
|
+
offset: "0",
|
|
329
|
+
stopColor: startColor
|
|
330
|
+
}), /*#__PURE__*/ React.createElement("stop", {
|
|
331
|
+
offset: "100%",
|
|
332
|
+
stopColor: endColor
|
|
333
|
+
})));
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
let scaleBandwidth = 0;
|
|
337
|
+
if (_yAxisType === YAxisType.StringAxis) {
|
|
338
|
+
scaleBandwidth = yScale.bandwidth();
|
|
339
|
+
_barHeight.current = _getBarHeight(scaleBandwidth);
|
|
340
|
+
}
|
|
341
|
+
const points = _getOrderedDataPoints();
|
|
342
|
+
const bars = points.map((point, index)=>{
|
|
343
|
+
const rectStartX = xScale(point.x.start);
|
|
344
|
+
const rectEndX = xScale(point.x.end);
|
|
345
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
346
|
+
const rectY = yScale(point.y) + (scaleBandwidth - _barHeight.current) / 2;
|
|
347
|
+
const shouldHighlight = _noLegendHighlighted() || _legendHighlighted(point.legend);
|
|
348
|
+
return /*#__PURE__*/ React.createElement("rect", {
|
|
349
|
+
key: index,
|
|
350
|
+
x: Math.min(rectStartX, rectEndX),
|
|
351
|
+
y: rectY,
|
|
352
|
+
width: Math.abs(rectEndX - rectStartX),
|
|
353
|
+
height: _barHeight.current,
|
|
354
|
+
rx: props.roundCorners ? 3 : 0,
|
|
355
|
+
fill: props.enableGradient ? `url(#${getGradientId(point.legend)})` : point.color,
|
|
356
|
+
opacity: shouldHighlight ? 1 : 0.1,
|
|
357
|
+
onClick: point.onClick,
|
|
358
|
+
onMouseOver: (event)=>_onBarHover(point, event),
|
|
359
|
+
onMouseLeave: _onBarLeave,
|
|
360
|
+
onFocus: (event)=>_onBarFocus(point, event),
|
|
361
|
+
onBlur: _onBarLeave,
|
|
362
|
+
tabIndex: shouldHighlight ? 0 : -1,
|
|
363
|
+
role: "img",
|
|
364
|
+
"aria-label": _getAriaLabel(point)
|
|
365
|
+
});
|
|
366
|
+
});
|
|
367
|
+
return /*#__PURE__*/ React.createElement("g", null, gradientDefs.length > 0 ? /*#__PURE__*/ React.createElement("defs", null, gradientDefs) : null, bars);
|
|
368
|
+
}, [
|
|
369
|
+
_getAriaLabel,
|
|
370
|
+
_getBarHeight,
|
|
371
|
+
_getOrderedDataPoints,
|
|
372
|
+
_legendHighlighted,
|
|
373
|
+
_noLegendHighlighted,
|
|
374
|
+
_onBarFocus,
|
|
375
|
+
_onBarHover,
|
|
376
|
+
_onBarLeave,
|
|
377
|
+
_yAxisType,
|
|
378
|
+
props.enableGradient,
|
|
379
|
+
props.roundCorners
|
|
380
|
+
]);
|
|
381
|
+
const _onLegendHover = React.useCallback((legend)=>{
|
|
382
|
+
setHoveredLegend(legend);
|
|
383
|
+
}, []);
|
|
384
|
+
const _onLegendLeave = React.useCallback(()=>{
|
|
385
|
+
setHoveredLegend('');
|
|
386
|
+
}, []);
|
|
387
|
+
const _onLegendSelectionChange = React.useCallback((_selectedLegends, event, currentLegend)=>{
|
|
388
|
+
var _props_legendProps, _props_legendProps1;
|
|
389
|
+
if ((_props_legendProps = props.legendProps) === null || _props_legendProps === void 0 ? void 0 : _props_legendProps.canSelectMultipleLegends) {
|
|
390
|
+
setSelectedLegends(_selectedLegends);
|
|
391
|
+
} else {
|
|
392
|
+
setSelectedLegends(_selectedLegends.slice(-1));
|
|
393
|
+
}
|
|
394
|
+
if ((_props_legendProps1 = props.legendProps) === null || _props_legendProps1 === void 0 ? void 0 : _props_legendProps1.onChange) {
|
|
395
|
+
props.legendProps.onChange(_selectedLegends, event, currentLegend);
|
|
396
|
+
}
|
|
397
|
+
}, [
|
|
398
|
+
props.legendProps
|
|
399
|
+
]);
|
|
400
|
+
const _getLegendData = React.useCallback(()=>{
|
|
401
|
+
const actions = [];
|
|
402
|
+
Object.keys(_legendMap.current).forEach((legendTitle)=>{
|
|
403
|
+
const legend = {
|
|
404
|
+
title: legendTitle,
|
|
405
|
+
color: _legendMap.current[legendTitle].startColor,
|
|
406
|
+
hoverAction: ()=>{
|
|
407
|
+
_handleChartMouseLeave();
|
|
408
|
+
_onLegendHover(legendTitle);
|
|
409
|
+
},
|
|
410
|
+
onMouseOutAction: ()=>{
|
|
411
|
+
_onLegendLeave();
|
|
412
|
+
}
|
|
413
|
+
};
|
|
414
|
+
actions.push(legend);
|
|
415
|
+
});
|
|
416
|
+
const legends = /*#__PURE__*/ React.createElement(Legends, {
|
|
417
|
+
legends: actions,
|
|
418
|
+
enabledWrapLines: props.enabledLegendsWrapLines,
|
|
419
|
+
overflowText: props.legendsOverflowText,
|
|
420
|
+
onChange: _onLegendSelectionChange,
|
|
421
|
+
...props.legendProps
|
|
422
|
+
});
|
|
423
|
+
return legends;
|
|
424
|
+
}, [
|
|
425
|
+
_handleChartMouseLeave,
|
|
426
|
+
_onLegendHover,
|
|
427
|
+
_onLegendLeave,
|
|
428
|
+
_onLegendSelectionChange,
|
|
429
|
+
props.enabledLegendsWrapLines,
|
|
430
|
+
props.legendProps,
|
|
431
|
+
props.legendsOverflowText
|
|
432
|
+
]);
|
|
433
|
+
const _getChartTitle = React.useCallback(()=>{
|
|
434
|
+
return (props.chartTitle ? `${props.chartTitle}. ` : '') + `Gantt chart with ${_points.length} data points. `;
|
|
435
|
+
}, [
|
|
436
|
+
_points.length,
|
|
437
|
+
props.chartTitle
|
|
438
|
+
]);
|
|
439
|
+
const _isChartEmpty = React.useCallback(()=>{
|
|
440
|
+
return _points.length === 0;
|
|
441
|
+
}, [
|
|
442
|
+
_points.length
|
|
443
|
+
]);
|
|
444
|
+
const _getYDomainMargins = React.useCallback((containerHeight)=>{
|
|
445
|
+
let domainMargin = MIN_DOMAIN_MARGIN;
|
|
446
|
+
const ySet = new Set();
|
|
447
|
+
_points.forEach((point)=>{
|
|
448
|
+
ySet.add(point.y);
|
|
449
|
+
});
|
|
450
|
+
const uniqueY = Array.from(ySet);
|
|
451
|
+
/** Total height available to render the bars */ const totalHeight = containerHeight - (_margins.current.top + MIN_DOMAIN_MARGIN) - (_margins.current.bottom + MIN_DOMAIN_MARGIN);
|
|
452
|
+
if (_yAxisType !== YAxisType.StringAxis) {
|
|
453
|
+
_barHeight.current = _getBarHeight(calculateAppropriateBarWidth(uniqueY, totalHeight, _yAxisPadding));
|
|
454
|
+
domainMargin += _barHeight.current / 2;
|
|
455
|
+
}
|
|
456
|
+
return {
|
|
457
|
+
..._margins.current,
|
|
458
|
+
top: _margins.current.top + domainMargin,
|
|
459
|
+
bottom: _margins.current.bottom + domainMargin
|
|
460
|
+
};
|
|
461
|
+
}, [
|
|
462
|
+
_getBarHeight,
|
|
463
|
+
_points,
|
|
464
|
+
_yAxisPadding,
|
|
465
|
+
_yAxisType
|
|
466
|
+
]);
|
|
467
|
+
function updatePosition(newX, newY) {
|
|
468
|
+
const threshold = 1; // Set a threshold for movement
|
|
469
|
+
const { x, y } = clickPosition;
|
|
470
|
+
// Calculate the distance moved
|
|
471
|
+
const distance = Math.sqrt(Math.pow(newX - x, 2) + Math.pow(newY - y, 2));
|
|
472
|
+
// Update the position only if the distance moved is greater than the threshold
|
|
473
|
+
if (distance > threshold) {
|
|
474
|
+
setClickPosition({
|
|
475
|
+
x: newX,
|
|
476
|
+
y: newY
|
|
477
|
+
});
|
|
478
|
+
setPopoverOpen(true);
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
if (!_isChartEmpty()) {
|
|
482
|
+
_barHeight.current = _getBarHeight(DEFAULT_BAR_HEIGHT);
|
|
483
|
+
const calloutProps = {
|
|
484
|
+
isPopoverOpen,
|
|
485
|
+
clickPosition,
|
|
486
|
+
color: calloutColor,
|
|
487
|
+
legend: calloutLegend,
|
|
488
|
+
XValue: xCalloutValue,
|
|
489
|
+
YValue: yCalloutValue,
|
|
490
|
+
...props.calloutProps
|
|
491
|
+
};
|
|
492
|
+
const tickParams = {
|
|
493
|
+
tickValues: props.tickValues,
|
|
494
|
+
tickFormat: props.tickFormat
|
|
495
|
+
};
|
|
496
|
+
return /*#__PURE__*/ React.createElement(CartesianChart, {
|
|
497
|
+
...props,
|
|
498
|
+
yAxisPadding: _yAxisPadding,
|
|
499
|
+
chartTitle: _getChartTitle(),
|
|
500
|
+
points: _points,
|
|
501
|
+
chartType: ChartTypes.GanttChart,
|
|
502
|
+
xAxisType: _xAxisType,
|
|
503
|
+
yAxisType: _yAxisType,
|
|
504
|
+
stringDatasetForYAxisDomain: _yAxisLabels,
|
|
505
|
+
calloutProps: calloutProps,
|
|
506
|
+
tickParams: tickParams,
|
|
507
|
+
legendBars: _getLegendData(),
|
|
508
|
+
createYAxis: createYAxisForHorizontalBarChartWithAxis,
|
|
509
|
+
getDomainNRangeValues: _getDomainNRangeValues,
|
|
510
|
+
createStringYAxis: createStringYAxisForHorizontalBarChartWithAxis,
|
|
511
|
+
getMinMaxOfYAxis: findHBCWANumericMinMaxOfY,
|
|
512
|
+
customizedCallout: _getCustomizedCallout(),
|
|
513
|
+
getmargins: _getMargins,
|
|
514
|
+
getYDomainMargins: _getYDomainMargins,
|
|
515
|
+
onChartMouseLeave: _handleChartMouseLeave,
|
|
516
|
+
useUTC: useUTC,
|
|
517
|
+
children: _createBars
|
|
518
|
+
});
|
|
519
|
+
} else {
|
|
520
|
+
return /*#__PURE__*/ React.createElement("div", {
|
|
521
|
+
id: _emptyChartId,
|
|
522
|
+
role: 'alert',
|
|
523
|
+
style: {
|
|
524
|
+
opacity: '0'
|
|
525
|
+
},
|
|
526
|
+
"aria-label": 'Graph has no data to display'
|
|
527
|
+
});
|
|
528
|
+
}
|
|
529
|
+
});
|
|
530
|
+
GanttChart.displayName = 'GanttChart';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["GanttChart.tsx"],"sourcesContent":["import * as React from 'react';\nimport { max as d3Max, min as d3Min } from 'd3-array';\nimport { ScaleLinear, ScaleBand, ScaleTime } from 'd3-scale';\nimport { useId } from '@fluentui/react-utilities';\nimport { Legend, Legends } from '../Legends/index';\nimport { Margins, GanttChartDataPoint } from '../../types/DataPoint';\nimport { CartesianChart, ModifiedCartesianChartProps } from '../CommonComponents/index';\nimport { GanttChartProps } from './GanttChart.types';\nimport { ChartPopover } from '../CommonComponents/ChartPopover';\nimport { ChartPopoverProps } from '../../index';\nimport {\n ChartTypes,\n YAxisType,\n XAxisTypes,\n getTypeOfAxis,\n getNextColor,\n findHBCWANumericMinMaxOfY,\n createYAxisForHorizontalBarChartWithAxis,\n IDomainNRange,\n createStringYAxisForHorizontalBarChartWithAxis,\n areArraysEqual,\n MIN_DOMAIN_MARGIN,\n sortAxisCategories,\n calculateAppropriateBarWidth,\n getColorFromToken,\n getScalePadding,\n getDateFormatLevel,\n} from '../../utilities/index';\nimport { formatDateToLocaleString, getMultiLevelDateTimeFormatOptions } from '@fluentui/chart-utilities';\n\ntype NumberScale = ScaleLinear<number, number>;\ntype StringScale = ScaleBand<string>;\ntype DateScale = ScaleTime<Date, number>;\n\nconst DEFAULT_BAR_HEIGHT = 24;\nconst MIN_BAR_HEIGHT = 1;\n\nexport const GanttChart: React.FunctionComponent<GanttChartProps> = React.forwardRef<HTMLDivElement, GanttChartProps>(\n ({ useUTC = true, yAxisCategoryOrder = 'default', maxBarHeight = 24, ...props }, forwardedRef) => {\n const _barHeight = React.useRef<number>(DEFAULT_BAR_HEIGHT);\n const _margins = React.useRef<Margins>({});\n const _calloutAnchorPoint = React.useRef<GanttChartDataPoint | null>(null);\n const _emptyChartId = useId('Gantt_empty');\n const _legendId = useId('gantt_legend');\n const _legendMap = React.useRef<Record<string, { id: string; startColor: string; endColor: string }>>({});\n const _prevProps = React.useRef<Partial<GanttChartProps>>({});\n\n const [calloutColor, setCalloutColor] = React.useState<string>('');\n const [hoveredLegend, setHoveredLegend] = React.useState<string>('');\n const [calloutLegend, setCalloutLegend] = React.useState<string>('');\n const [xCalloutValue, setXCalloutValue] = React.useState<string>('');\n const [yCalloutValue, setYCalloutValue] = React.useState<string>('');\n const [selectedLegends, setSelectedLegends] = React.useState<string[]>(props.legendProps?.selectedLegends || []);\n const [calloutDataPoint, setCalloutDataPoint] = React.useState<GanttChartDataPoint>();\n const [clickPosition, setClickPosition] = React.useState({ x: 0, y: 0 });\n const [isPopoverOpen, setPopoverOpen] = React.useState(false);\n\n React.useEffect(() => {\n if (!areArraysEqual(_prevProps.current.legendProps?.selectedLegends, props.legendProps?.selectedLegends)) {\n setSelectedLegends(props.legendProps?.selectedLegends || []);\n }\n _prevProps.current = props;\n }, [props]);\n\n const _points = React.useMemo(() => {\n _legendMap.current = {};\n let colorIndex = 0;\n\n return (\n props.data?.map(point => {\n const legend = `${point.legend}`;\n if (!_legendMap.current[legend]) {\n let startColor = point.color ? getColorFromToken(point.color) : getNextColor(colorIndex, 0);\n let endColor = startColor;\n\n if (props.enableGradient) {\n startColor = point.gradient?.[0]!;\n endColor = point.gradient?.[1]!;\n }\n\n _legendMap.current[legend] = { id: `${_legendId}_${colorIndex}`, startColor, endColor };\n colorIndex += 1;\n }\n\n const { startColor, endColor } = _legendMap.current[legend];\n return {\n ...point,\n color: startColor,\n ...(props.enableGradient ? { gradient: [startColor, endColor] as [string, string] } : {}),\n };\n }) ?? []\n );\n }, [props.data, props.enableGradient]);\n\n const _xAxisType = React.useMemo(() => {\n if (_points.length > 0) {\n return getTypeOfAxis(_points[0].x.start, true) as XAxisTypes;\n }\n return XAxisTypes.DateAxis;\n }, [_points]);\n\n const _yAxisType = React.useMemo(() => {\n if (_points.length > 0) {\n return getTypeOfAxis(_points[0].y, false) as YAxisType;\n }\n return YAxisType.StringAxis;\n }, [_points]);\n\n const _yAxisPadding = React.useMemo(() => {\n return getScalePadding(props.yAxisPadding, undefined, 1 / 2);\n }, [props.yAxisPadding]);\n\n const _dateFormatOptions = React.useMemo(() => {\n if (_xAxisType !== XAxisTypes.DateAxis) {\n return undefined;\n }\n\n let lowestFormatLevel = 100;\n let highestFormatLevel = -1;\n _points.forEach(p => {\n const startFormatLevel = getDateFormatLevel(p.x.start as Date, useUTC as boolean);\n const endFormatLevel = getDateFormatLevel(p.x.end as Date, useUTC as boolean);\n lowestFormatLevel = Math.min(lowestFormatLevel, startFormatLevel, endFormatLevel);\n highestFormatLevel = Math.max(highestFormatLevel, startFormatLevel, endFormatLevel);\n });\n\n return getMultiLevelDateTimeFormatOptions(lowestFormatLevel, highestFormatLevel);\n }, [useUTC, _points, _xAxisType]);\n\n const _mapYValueToXValues = React.useCallback(() => {\n const yValueToXValues: Record<string, number[]> = {};\n _points.forEach(point => {\n if (!yValueToXValues[point.y]) {\n yValueToXValues[point.y] = [];\n }\n yValueToXValues[point.y].push(+point.x.end - +point.x.start);\n });\n return yValueToXValues;\n }, [_points]);\n\n const _getOrderedYAxisLabels = React.useCallback(() => {\n const yValueToXValues = _mapYValueToXValues();\n\n if (_yAxisType !== YAxisType.StringAxis) {\n return Object.keys(yValueToXValues).sort((a, b) => +a - +b);\n }\n\n if (yAxisCategoryOrder === 'default') {\n return Object.keys(yValueToXValues).reverse();\n }\n return sortAxisCategories(yValueToXValues, yAxisCategoryOrder);\n }, [_mapYValueToXValues, _yAxisType, yAxisCategoryOrder]);\n\n const _yAxisLabels = React.useMemo(() => _getOrderedYAxisLabels(), [_getOrderedYAxisLabels]);\n\n const _getDomainNRangeValues = React.useCallback(\n (\n points: GanttChartDataPoint[],\n margins: Margins,\n containerWidth: number,\n chartType: ChartTypes,\n isRTL: boolean,\n xAxisType: XAxisTypes,\n barWidth: number,\n tickValues: Date[] | number[] | undefined,\n shiftX: number,\n ): IDomainNRange => {\n const xValues: (Date | number)[] = [];\n points.forEach(point => {\n xValues.push(point.x.start, point.x.end);\n });\n\n const xMin = d3Min(xValues) || 0;\n const xMax = d3Max(xValues) || 0;\n\n return {\n dStartValue: isRTL ? xMax : xMin,\n dEndValue: isRTL ? xMin : xMax,\n rStartValue: margins.left! + (isRTL ? 0 : shiftX),\n rEndValue: containerWidth - margins.right! - (isRTL ? shiftX : 0),\n };\n },\n [],\n );\n\n const _getMargins = React.useCallback((margins: Margins) => {\n _margins.current = margins;\n }, []);\n\n const _getFormattedXValue = React.useCallback(\n (point: GanttChartDataPoint): string => {\n let formattedStartX: string;\n let formattedEndX: string;\n\n if (_xAxisType === XAxisTypes.DateAxis) {\n formattedStartX = formatDateToLocaleString(\n point.x.start as Date,\n props.culture,\n useUTC as boolean,\n false,\n _dateFormatOptions,\n );\n formattedEndX = formatDateToLocaleString(\n point.x.end as Date,\n props.culture,\n useUTC as boolean,\n false,\n _dateFormatOptions,\n );\n } else {\n formattedStartX = point.x.start.toString();\n formattedEndX = point.x.end.toString();\n }\n\n return `${formattedStartX} - ${formattedEndX}`;\n },\n [props.culture, useUTC, _dateFormatOptions, _xAxisType],\n );\n\n const _getCustomizedCallout = React.useCallback(() => {\n const defaultRender = (point?: GanttChartDataPoint): React.JSX.Element | null => {\n return point ? (\n <ChartPopover\n isPopoverOpen={isPopoverOpen}\n clickPosition={clickPosition}\n XValue={point.yAxisCalloutData || point.y.toString()}\n legend={point.legend}\n YValue={point.xAxisCalloutData || _getFormattedXValue(point)}\n color={point.color}\n culture={props.culture}\n />\n ) : null;\n };\n\n return props.onRenderCalloutPerDataPoint\n ? props.onRenderCalloutPerDataPoint(calloutDataPoint, defaultRender)\n : null;\n //eslint-disable-next-line react-hooks/exhaustive-deps\n }, [_getFormattedXValue, calloutDataPoint, props.culture, props.onRenderCalloutPerDataPoint]);\n\n const _getAriaLabel = React.useCallback(\n (point: GanttChartDataPoint): string => {\n const xValue = point.xAxisCalloutData || _getFormattedXValue(point);\n const yValue = point.yAxisCalloutData || point.y;\n return (\n point.callOutAccessibilityData?.ariaLabel ||\n `${yValue}. ` + (point.legend ? `${point.legend}, ` : '') + `${xValue}.`\n );\n },\n [_getFormattedXValue],\n );\n\n const _getHighlightedLegend = React.useCallback(() => {\n return selectedLegends.length > 0 ? selectedLegends : hoveredLegend ? [hoveredLegend] : [];\n }, [hoveredLegend, selectedLegends]);\n\n /**\n * This function checks if the given legend is highlighted or not.\n * A legend can be highlighted in 2 ways:\n * 1. selection: if the user clicks on it\n * 2. hovering: if there is no selected legend and the user hovers over it\n */\n const _legendHighlighted = React.useCallback(\n (legend: string | undefined) => {\n return _getHighlightedLegend().includes(`${legend}`);\n },\n [_getHighlightedLegend],\n );\n\n /**\n * This function checks if none of the legends is selected or hovered.\n */\n const _noLegendHighlighted = React.useCallback(() => {\n return _getHighlightedLegend().length === 0;\n }, [_getHighlightedLegend]);\n\n const _showCallout = React.useCallback(\n (target: React.MouseEvent<SVGElement> | React.FocusEvent<SVGElement>, point: GanttChartDataPoint) => {\n if (!(_noLegendHighlighted() || _legendHighlighted(point.legend)) || _calloutAnchorPoint.current === point) {\n return;\n }\n if ('clientX' in target && 'clientY' in target) {\n updatePosition(target.clientX, target.clientY);\n } else {\n const rect = (target.target as SVGElement).getBoundingClientRect();\n updatePosition(rect.left, rect.top);\n }\n _calloutAnchorPoint.current = point;\n setPopoverOpen(true);\n setCalloutLegend(point.legend!);\n setCalloutColor(point.color!);\n setXCalloutValue(point.yAxisCalloutData || point.y.toString());\n setYCalloutValue(point.xAxisCalloutData! || _getFormattedXValue(point));\n setCalloutDataPoint(point);\n },\n [_getFormattedXValue, _legendHighlighted, _noLegendHighlighted],\n );\n\n const _onBarFocus = React.useCallback(\n (point: GanttChartDataPoint, focusEvent: React.FocusEvent<SVGElement>): void => {\n _showCallout(focusEvent, point);\n },\n [_showCallout],\n );\n\n const _onBarHover = React.useCallback(\n (point: GanttChartDataPoint, mouseEvent: React.MouseEvent<SVGElement>): void => {\n _showCallout(mouseEvent, point);\n },\n [_showCallout],\n );\n\n const _onBarLeave = React.useCallback((): void => {\n // do nothing\n }, []);\n\n const _handleChartMouseLeave = React.useCallback((): void => {\n _calloutAnchorPoint.current = null;\n setPopoverOpen(false);\n setCalloutLegend('');\n setCalloutColor('');\n setXCalloutValue('');\n setYCalloutValue('');\n setCalloutDataPoint(undefined);\n }, []);\n\n const _getBarHeight = React.useCallback(\n (adjustedValue: number): number => {\n let barHeight: number;\n if (typeof props.barHeight === 'number') {\n barHeight = props.barHeight;\n } else {\n barHeight = adjustedValue;\n }\n if (typeof maxBarHeight === 'number') {\n barHeight = Math.min(barHeight, maxBarHeight);\n }\n barHeight = Math.max(barHeight, MIN_BAR_HEIGHT);\n return barHeight;\n },\n [maxBarHeight, props.barHeight],\n );\n\n const _getOrderedDataPoints = React.useCallback(() => {\n const result: GanttChartDataPoint[] = [];\n\n const yValueToPoints: Record<string, GanttChartDataPoint[]> = {};\n _points.forEach(point => {\n if (!yValueToPoints[point.y]) {\n yValueToPoints[point.y] = [];\n }\n yValueToPoints[point.y].push(point);\n });\n\n for (let i = _yAxisLabels.length - 1; i >= 0; i--) {\n const yValue = _yAxisLabels[i];\n if (yValueToPoints[yValue]) {\n result.push(...yValueToPoints[yValue].sort((a, b) => +a.x.start - +b.x.start));\n }\n }\n\n return result;\n }, [_points, _yAxisLabels]);\n\n const _createBars = React.useCallback(\n ({\n xScale,\n yScalePrimary: yScale,\n }: {\n xScale: DateScale | NumberScale;\n yScalePrimary: NumberScale | StringScale;\n }): React.JSX.Element => {\n const getGradientId = (legend: string | undefined) => {\n const legendId = _legendMap.current[`${legend}`].id;\n return `${legendId}_gradient`;\n };\n\n const gradientDefs: React.JSX.Element[] = [];\n if (props.enableGradient) {\n Object.keys(_legendMap.current).forEach((legend: string, index: number) => {\n const { startColor, endColor } = _legendMap.current[legend];\n gradientDefs.push(\n <linearGradient key={index} id={getGradientId(legend)}>\n <stop offset=\"0\" stopColor={startColor} />\n <stop offset=\"100%\" stopColor={endColor} />\n </linearGradient>,\n );\n });\n }\n\n let scaleBandwidth = 0;\n if (_yAxisType === YAxisType.StringAxis) {\n scaleBandwidth = (yScale as StringScale).bandwidth();\n _barHeight.current = _getBarHeight(scaleBandwidth);\n }\n\n const points = _getOrderedDataPoints();\n const bars = points.map((point: GanttChartDataPoint, index: number) => {\n const rectStartX = xScale(point.x.start);\n const rectEndX = xScale(point.x.end);\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const rectY = yScale(point.y as any)! + (scaleBandwidth - _barHeight.current) / 2;\n\n const shouldHighlight = _noLegendHighlighted() || _legendHighlighted(point.legend);\n\n return (\n <rect\n key={index}\n x={Math.min(rectStartX, rectEndX)}\n y={rectY}\n width={Math.abs(rectEndX - rectStartX)}\n height={_barHeight.current}\n rx={props.roundCorners ? 3 : 0}\n fill={props.enableGradient ? `url(#${getGradientId(point.legend)})` : point.color}\n opacity={shouldHighlight ? 1 : 0.1}\n onClick={point.onClick}\n onMouseOver={(event: React.MouseEvent<SVGElement>) => _onBarHover(point, event)}\n onMouseLeave={_onBarLeave}\n onFocus={(event: React.FocusEvent<SVGElement>) => _onBarFocus(point, event)}\n onBlur={_onBarLeave}\n tabIndex={shouldHighlight ? 0 : -1}\n role=\"img\"\n aria-label={_getAriaLabel(point)}\n />\n );\n });\n return (\n <g>\n {gradientDefs.length > 0 ? <defs>{gradientDefs}</defs> : null}\n {bars}\n </g>\n );\n },\n [\n _getAriaLabel,\n _getBarHeight,\n _getOrderedDataPoints,\n _legendHighlighted,\n _noLegendHighlighted,\n _onBarFocus,\n _onBarHover,\n _onBarLeave,\n _yAxisType,\n props.enableGradient,\n props.roundCorners,\n ],\n );\n\n const _onLegendHover = React.useCallback((legend: string): void => {\n setHoveredLegend(legend);\n }, []);\n\n const _onLegendLeave = React.useCallback((): void => {\n setHoveredLegend('');\n }, []);\n\n const _onLegendSelectionChange = React.useCallback(\n (_selectedLegends: string[], event: React.MouseEvent<HTMLButtonElement>, currentLegend?: Legend): void => {\n if (props.legendProps?.canSelectMultipleLegends) {\n setSelectedLegends(_selectedLegends);\n } else {\n setSelectedLegends(_selectedLegends.slice(-1));\n }\n if (props.legendProps?.onChange) {\n props.legendProps.onChange(_selectedLegends, event, currentLegend);\n }\n },\n [props.legendProps],\n );\n\n const _getLegendData = React.useCallback((): React.JSX.Element => {\n const actions: Legend[] = [];\n\n Object.keys(_legendMap.current).forEach((legendTitle: string) => {\n const legend: Legend = {\n title: legendTitle,\n color: _legendMap.current[legendTitle].startColor,\n hoverAction: () => {\n _handleChartMouseLeave();\n _onLegendHover(legendTitle);\n },\n onMouseOutAction: () => {\n _onLegendLeave();\n },\n };\n\n actions.push(legend);\n });\n\n const legends = (\n <Legends\n legends={actions}\n enabledWrapLines={props.enabledLegendsWrapLines}\n overflowText={props.legendsOverflowText}\n onChange={_onLegendSelectionChange}\n {...props.legendProps}\n />\n );\n return legends;\n }, [\n _handleChartMouseLeave,\n _onLegendHover,\n _onLegendLeave,\n _onLegendSelectionChange,\n props.enabledLegendsWrapLines,\n props.legendProps,\n props.legendsOverflowText,\n ]);\n\n const _getChartTitle = React.useCallback((): string => {\n return (props.chartTitle ? `${props.chartTitle}. ` : '') + `Gantt chart with ${_points.length} data points. `;\n }, [_points.length, props.chartTitle]);\n\n const _isChartEmpty = React.useCallback((): boolean => {\n return _points.length === 0;\n }, [_points.length]);\n\n const _getYDomainMargins = React.useCallback(\n (containerHeight: number): Margins => {\n let domainMargin = MIN_DOMAIN_MARGIN;\n\n const ySet = new Set<string | number>();\n _points.forEach((point: GanttChartDataPoint) => {\n ySet.add(point.y);\n });\n const uniqueY = Array.from(ySet);\n\n /** Total height available to render the bars */\n const totalHeight =\n containerHeight -\n (_margins.current.top! + MIN_DOMAIN_MARGIN) -\n (_margins.current.bottom! + MIN_DOMAIN_MARGIN);\n\n if (_yAxisType !== YAxisType.StringAxis) {\n _barHeight.current = _getBarHeight(\n calculateAppropriateBarWidth(uniqueY as number[] | Date[], totalHeight, _yAxisPadding),\n );\n domainMargin += _barHeight.current / 2;\n }\n\n return {\n ..._margins.current,\n top: _margins.current.top! + domainMargin,\n bottom: _margins.current.bottom! + domainMargin,\n };\n },\n [_getBarHeight, _points, _yAxisPadding, _yAxisType],\n );\n\n function updatePosition(newX: number, newY: number) {\n const threshold = 1; // Set a threshold for movement\n const { x, y } = clickPosition;\n // Calculate the distance moved\n const distance = Math.sqrt(Math.pow(newX - x, 2) + Math.pow(newY - y, 2));\n // Update the position only if the distance moved is greater than the threshold\n if (distance > threshold) {\n setClickPosition({ x: newX, y: newY });\n setPopoverOpen(true);\n }\n }\n\n if (!_isChartEmpty()) {\n _barHeight.current = _getBarHeight(DEFAULT_BAR_HEIGHT);\n\n const calloutProps: ChartPopoverProps = {\n isPopoverOpen,\n clickPosition,\n color: calloutColor,\n legend: calloutLegend,\n XValue: xCalloutValue,\n YValue: yCalloutValue,\n ...props.calloutProps,\n };\n const tickParams: ModifiedCartesianChartProps['tickParams'] = {\n tickValues: props.tickValues,\n tickFormat: props.tickFormat,\n };\n\n return (\n <CartesianChart\n {...props}\n yAxisPadding={_yAxisPadding}\n chartTitle={_getChartTitle()}\n points={_points}\n chartType={ChartTypes.GanttChart}\n xAxisType={_xAxisType}\n yAxisType={_yAxisType}\n stringDatasetForYAxisDomain={_yAxisLabels}\n calloutProps={calloutProps}\n tickParams={tickParams}\n legendBars={_getLegendData()}\n createYAxis={createYAxisForHorizontalBarChartWithAxis}\n getDomainNRangeValues={_getDomainNRangeValues}\n createStringYAxis={createStringYAxisForHorizontalBarChartWithAxis}\n getMinMaxOfYAxis={findHBCWANumericMinMaxOfY}\n customizedCallout={_getCustomizedCallout()}\n getmargins={_getMargins}\n getYDomainMargins={_getYDomainMargins}\n onChartMouseLeave={_handleChartMouseLeave}\n useUTC={useUTC}\n children={_createBars}\n />\n );\n } else {\n return (\n <div id={_emptyChartId} role={'alert'} style={{ opacity: '0' }} aria-label={'Graph has no data to display'} />\n );\n }\n },\n);\n\nGanttChart.displayName = 'GanttChart';\n"],"names":["React","max","d3Max","min","d3Min","useId","Legends","CartesianChart","ChartPopover","ChartTypes","YAxisType","XAxisTypes","getTypeOfAxis","getNextColor","findHBCWANumericMinMaxOfY","createYAxisForHorizontalBarChartWithAxis","createStringYAxisForHorizontalBarChartWithAxis","areArraysEqual","MIN_DOMAIN_MARGIN","sortAxisCategories","calculateAppropriateBarWidth","getColorFromToken","getScalePadding","getDateFormatLevel","formatDateToLocaleString","getMultiLevelDateTimeFormatOptions","DEFAULT_BAR_HEIGHT","MIN_BAR_HEIGHT","GanttChart","forwardRef","useUTC","yAxisCategoryOrder","maxBarHeight","props","forwardedRef","_barHeight","useRef","_margins","_calloutAnchorPoint","_emptyChartId","_legendId","_legendMap","_prevProps","calloutColor","setCalloutColor","useState","hoveredLegend","setHoveredLegend","calloutLegend","setCalloutLegend","xCalloutValue","setXCalloutValue","yCalloutValue","setYCalloutValue","selectedLegends","setSelectedLegends","legendProps","calloutDataPoint","setCalloutDataPoint","clickPosition","setClickPosition","x","y","isPopoverOpen","setPopoverOpen","useEffect","current","_points","useMemo","colorIndex","data","map","point","legend","startColor","color","endColor","enableGradient","gradient","id","_xAxisType","length","start","DateAxis","_yAxisType","StringAxis","_yAxisPadding","yAxisPadding","undefined","_dateFormatOptions","lowestFormatLevel","highestFormatLevel","forEach","p","startFormatLevel","endFormatLevel","end","Math","_mapYValueToXValues","useCallback","yValueToXValues","push","_getOrderedYAxisLabels","Object","keys","sort","a","b","reverse","_yAxisLabels","_getDomainNRangeValues","points","margins","containerWidth","chartType","isRTL","xAxisType","barWidth","tickValues","shiftX","xValues","xMin","xMax","dStartValue","dEndValue","rStartValue","left","rEndValue","right","_getMargins","_getFormattedXValue","formattedStartX","formattedEndX","culture","toString","_getCustomizedCallout","defaultRender","XValue","yAxisCalloutData","YValue","xAxisCalloutData","onRenderCalloutPerDataPoint","_getAriaLabel","xValue","yValue","callOutAccessibilityData","ariaLabel","_getHighlightedLegend","_legendHighlighted","includes","_noLegendHighlighted","_showCallout","target","updatePosition","clientX","clientY","rect","getBoundingClientRect","top","_onBarFocus","focusEvent","_onBarHover","mouseEvent","_onBarLeave","_handleChartMouseLeave","_getBarHeight","adjustedValue","barHeight","_getOrderedDataPoints","result","yValueToPoints","i","_createBars","xScale","yScalePrimary","yScale","getGradientId","legendId","gradientDefs","index","linearGradient","key","stop","offset","stopColor","scaleBandwidth","bandwidth","bars","rectStartX","rectEndX","rectY","shouldHighlight","width","abs","height","rx","roundCorners","fill","opacity","onClick","onMouseOver","event","onMouseLeave","onFocus","onBlur","tabIndex","role","aria-label","g","defs","_onLegendHover","_onLegendLeave","_onLegendSelectionChange","_selectedLegends","currentLegend","canSelectMultipleLegends","slice","onChange","_getLegendData","actions","legendTitle","title","hoverAction","onMouseOutAction","legends","enabledWrapLines","enabledLegendsWrapLines","overflowText","legendsOverflowText","_getChartTitle","chartTitle","_isChartEmpty","_getYDomainMargins","containerHeight","domainMargin","ySet","Set","add","uniqueY","Array","from","totalHeight","bottom","newX","newY","threshold","distance","sqrt","pow","calloutProps","tickParams","tickFormat","yAxisType","stringDatasetForYAxisDomain","legendBars","createYAxis","getDomainNRangeValues","createStringYAxis","getMinMaxOfYAxis","customizedCallout","getmargins","getYDomainMargins","onChartMouseLeave","children","div","style","displayName"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,OAAOC,KAAK,EAAEC,OAAOC,KAAK,QAAQ,WAAW;AAEtD,SAASC,KAAK,QAAQ,4BAA4B;AAClD,SAAiBC,OAAO,QAAQ,mBAAmB;AAEnD,SAASC,cAAc,QAAqC,4BAA4B;AAExF,SAASC,YAAY,QAAQ,mCAAmC;AAEhE,SACEC,UAAU,EACVC,SAAS,EACTC,UAAU,EACVC,aAAa,EACbC,YAAY,EACZC,yBAAyB,EACzBC,wCAAwC,EAExCC,8CAA8C,EAC9CC,cAAc,EACdC,iBAAiB,EACjBC,kBAAkB,EAClBC,4BAA4B,EAC5BC,iBAAiB,EACjBC,eAAe,EACfC,kBAAkB,QACb,wBAAwB;AAC/B,SAASC,wBAAwB,EAAEC,kCAAkC,QAAQ,4BAA4B;AAMzG,MAAMC,qBAAqB;AAC3B,MAAMC,iBAAiB;AAEvB,OAAO,MAAMC,2BAAuD5B,MAAM6B,UAAU,CAClF,CAAC,EAAEC,SAAS,IAAI,EAAEC,qB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BAAmB5H;YACnB6H,YAAYnI;YACZoI,mBAAmB7B;YACnB8B,mBAAmBlG;YACnBtI,QAAQA;YACRyO,UAAU3F;;IAGhB,OAAO;QACL,qBACE,oBAAC4F;YAAIzL,IAAIxC;YAAeuK,MAAM;YAAS2D,OAAO;gBAAEnE,SAAS;YAAI;YAAGS,cAAY;;IAEhF;AACF,GACA;AAEFnL,WAAW8O,WAAW,GAAG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["GanttChart.types.ts"],"sourcesContent":["import { RenderFunction } from '../../utilities/index';\nimport { CartesianChartProps, CartesianChartStyleProps, CartesianChartStyles, GanttChartDataPoint } from '../../index';\n\n/**\n * Gantt Chart properties\n * {@docCategory GanttChart}\n */\nexport interface GanttChartProps extends CartesianChartProps {\n /**\n * An array of data points to be rendered in the chart.\n */\n data?: GanttChartDataPoint[];\n\n /**\n * Callback function to render a custom callout for each data point.\n */\n onRenderCalloutPerDataPoint?: RenderFunction<GanttChartDataPoint>;\n\n /**\n * Height of each bar, in pixels.\n */\n barHeight?: number;\n\n /**\n * Title of the chart.\n */\n chartTitle?: string;\n\n /**\n * Locale identifier string used to format numbers and dates according to the specified culture.\n * Example: 'en-US', 'fr-FR'.\n */\n culture?: string;\n\n /**\n * Padding between bars as a fraction of the [step](https://d3js.org/d3-scale/band#band_step).\n * Takes a number in the range [0, 1].\n * @default 1/2\n */\n yAxisPadding?: number;\n\n /**\n * If true, truncates y-axis tick labels longer than `noOfCharsToTruncate` with ellipses\n * and displays them in a tooltip on hover.\n * @default false\n */\n showYAxisLablesTooltip?: boolean;\n\n /**\n * If true, renders full y-axis tick labels without truncation.\n * @default false\n */\n showYAxisLables?: boolean;\n\n /**\n * If true, enables gradient fills for the bars.\n * @default false\n */\n enableGradient?: boolean;\n\n /**\n * If true, applies rounded corners to the bars.\n * @default false\n */\n roundCorners?: boolean;\n\n /**\n * Maximum height of each bar, in pixels.\n * @default 24\n */\n maxBarHeight?: number;\n}\n\n/**\n * Gantt Chart style properties\n * {@docCategory GanttChart}\n */\nexport interface GanttChartStyleProps extends CartesianChartStyleProps {}\n\n/**\n * Gantt Chart styles\n * {@docCategory GanttChart}\n */\nexport interface GanttChartStyles extends CartesianChartStyles {}\n"],"names":[],"mappings":"AA+EA;;;CAGC,GACD,WAAiE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["index.ts"],"sourcesContent":["export * from './GanttChart';\nexport * from './GanttChart.types';\n"],"names":[],"mappings":"AAAA,cAAc,eAAe;AAC7B,cAAc,qBAAqB"}
|