@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/GanttChart/useGanttChartStyles.styles.ts"],"sourcesContent":["import { GanttChartStyles, GanttChartProps } from '../../index';\nimport type { SlotClassNames } from '@fluentui/react-utilities';\n\n/**\n * @internal\n */\nexport const ganttClassNames: SlotClassNames<GanttChartStyles> = {\n root: '',\n xAxis: '',\n yAxis: '',\n legendContainer: '',\n hover: '',\n descriptionMessage: '',\n tooltip: '',\n axisTitle: '',\n chartTitle: '',\n opacityChangeOnHover: '',\n shapeStyles: '',\n chartWrapper: '',\n svgTooltip: '',\n chart: '',\n};\n\n/**\n * Apply styling to the GanttChart component\n */\nexport const useGanttChartStyles = (props: GanttChartProps): GanttChartStyles => {\n return {};\n};\n"],"names":["ganttClassNames","root","xAxis","yAxis","legendContainer","hover","descriptionMessage","tooltip","axisTitle","chartTitle","opacityChangeOnHover","shapeStyles","chartWrapper","svgTooltip","chart","useGanttChartStyles","props"],"mappings":"AAGA;;CAEC,GACD,OAAO,MAAMA,kBAAoD;IAC/DC,MAAM;IACNC,OAAO;IACPC,OAAO;IACPC,iBAAiB;IACjBC,OAAO;IACPC,oBAAoB;IACpBC,SAAS;IACTC,WAAW;IACXC,YAAY;IACZC,sBAAsB;IACtBC,aAAa;IACbC,cAAc;IACdC,YAAY;IACZC,OAAO;
|
|
1
|
+
{"version":3,"sources":["../src/components/GanttChart/useGanttChartStyles.styles.ts"],"sourcesContent":["import { GanttChartStyles, GanttChartProps } from '../../index';\nimport type { SlotClassNames } from '@fluentui/react-utilities';\n\n/**\n * @internal\n */\nexport const ganttClassNames: SlotClassNames<GanttChartStyles> = {\n root: '',\n xAxis: '',\n yAxis: '',\n legendContainer: '',\n hover: '',\n descriptionMessage: '',\n tooltip: '',\n axisTitle: '',\n chartTitle: '',\n opacityChangeOnHover: '',\n shapeStyles: '',\n chartWrapper: '',\n svgTooltip: '',\n chart: '',\n axisAnnotation: '',\n};\n\n/**\n * Apply styling to the GanttChart component\n */\nexport const useGanttChartStyles = (props: GanttChartProps): GanttChartStyles => {\n return {};\n};\n"],"names":["ganttClassNames","root","xAxis","yAxis","legendContainer","hover","descriptionMessage","tooltip","axisTitle","chartTitle","opacityChangeOnHover","shapeStyles","chartWrapper","svgTooltip","chart","axisAnnotation","useGanttChartStyles","props"],"mappings":"AAGA;;CAEC,GACD,OAAO,MAAMA,kBAAoD;IAC/DC,MAAM;IACNC,OAAO;IACPC,OAAO;IACPC,iBAAiB;IACjBC,OAAO;IACPC,oBAAoB;IACpBC,SAAS;IACTC,WAAW;IACXC,YAAY;IACZC,sBAAsB;IACtBC,aAAa;IACbC,cAAc;IACdC,YAAY;IACZC,OAAO;IACPC,gBAAgB;AAClB,EAAE;AAEF;;CAEC,GACD,OAAO,MAAMC,sBAAsB,CAACC;IAClC,OAAO,CAAC;AACV,EAAE"}
|
|
@@ -4,25 +4,22 @@ import { select as d3Select } from 'd3-selection';
|
|
|
4
4
|
import { max as d3Max, min as d3Min } from 'd3-array';
|
|
5
5
|
import { scaleBand as d3ScaleBand } from 'd3-scale';
|
|
6
6
|
import { useId } from '@fluentui/react-utilities';
|
|
7
|
-
import { ChartTypes, getAccessibleDataObject, tooltipOfAxislabels, XAxisTypes, getTypeOfAxis, formatScientificLimitWidth, getScalePadding, getBarWidth, isScalePaddingDefined, createNumericYAxis, domainRangeOfXStringAxis, createStringYAxis, getNextColor, areArraysEqual, calculateLongestLabelWidth, useRtl } from '../../utilities/index';
|
|
8
|
-
import { CartesianChart, Legends
|
|
7
|
+
import { ChartTypes, getAccessibleDataObject, tooltipOfAxislabels, XAxisTypes, getTypeOfAxis, formatScientificLimitWidth, getScalePadding, getBarWidth, isScalePaddingDefined, createNumericYAxis, domainRangeOfXStringAxis, createStringYAxis, getNextColor, areArraysEqual, calculateLongestLabelWidth, useRtl, calcRequiredWidth, calcTotalWidth, calcBandwidth, calcTotalBandUnits, sortAxisCategories } from '../../utilities/index';
|
|
8
|
+
import { CartesianChart, Legends } from '../../index';
|
|
9
9
|
import { toImage } from '../../utilities/image-export-utils';
|
|
10
10
|
const MIN_DOMAIN_MARGIN = 8;
|
|
11
11
|
const X1_INNER_PADDING = 0.1;
|
|
12
|
-
// x1_inner_padding = space_between_bars / (space_between_bars + bar_width)
|
|
13
|
-
// => space_between_bars = (x1_inner_padding / (1 - x1_inner_padding)) * bar_width
|
|
14
|
-
/** Rate at which the space between the bars in a group changes wrt the bar width */ const BAR_GAP_RATE = X1_INNER_PADDING / (1 - X1_INNER_PADDING);
|
|
15
12
|
const VERTICAL_BAR_GAP = 1;
|
|
16
13
|
const MIN_BAR_HEIGHT = 1;
|
|
17
14
|
export const GroupedVerticalBarChart = /*#__PURE__*/ React.forwardRef((props = {
|
|
18
|
-
maxBarWidth: 24
|
|
15
|
+
maxBarWidth: 24,
|
|
16
|
+
xAxisCategoryOrder: 'default'
|
|
19
17
|
}, forwardedRef)=>{
|
|
20
18
|
var _props_legendProps, _props_legendProps1;
|
|
21
19
|
const _tooltipId = useId('GVBCTooltipId_');
|
|
22
20
|
const _emptyChartId = useId('_GVBC_empty');
|
|
23
21
|
const _useRtl = useRtl();
|
|
24
22
|
let _domainMargin = MIN_DOMAIN_MARGIN;
|
|
25
|
-
let _keys = [];
|
|
26
23
|
let _xAxisLabels = [];
|
|
27
24
|
let _datasetForBars = [];
|
|
28
25
|
let _margins = {
|
|
@@ -32,13 +29,14 @@ export const GroupedVerticalBarChart = /*#__PURE__*/ React.forwardRef((props = {
|
|
|
32
29
|
left: 0
|
|
33
30
|
};
|
|
34
31
|
let _groupedVerticalBarGraph = [];
|
|
35
|
-
let _refArray = [];
|
|
36
32
|
let _yMax = 0;
|
|
37
33
|
let _calloutAnchorPoint = null;
|
|
38
34
|
let _barWidth = 0;
|
|
39
35
|
let _groupWidth = 0;
|
|
40
36
|
let _xAxisInnerPadding = 0;
|
|
41
37
|
let _xAxisOuterPadding = 0;
|
|
38
|
+
let _legends = [];
|
|
39
|
+
let _legendColorMap = {};
|
|
42
40
|
const cartesianChartRef = React.useRef(null);
|
|
43
41
|
const Y_ORIGIN = 0;
|
|
44
42
|
const _legendsRef = React.useRef(null);
|
|
@@ -82,44 +80,53 @@ export const GroupedVerticalBarChart = /*#__PURE__*/ React.forwardRef((props = {
|
|
|
82
80
|
_barWidth = getBarWidth(props.barWidth, props.maxBarWidth);
|
|
83
81
|
// x0_inner_padding = space_between_groups / (space_between_groups + group_width)
|
|
84
82
|
// space_between_groups = 2 * bar_width
|
|
85
|
-
// group_width =
|
|
86
|
-
_xAxisInnerPadding = getScalePadding(props.xAxisInnerPadding, undefined, 2 / (2 +
|
|
83
|
+
// group_width = _legends.length * bar_width + (_legends.length - 1) * space_between_bars
|
|
84
|
+
_xAxisInnerPadding = getScalePadding(props.xAxisInnerPadding, undefined, 2 / (2 + calcTotalBandUnits(_legends.length, X1_INNER_PADDING)));
|
|
87
85
|
_xAxisOuterPadding = getScalePadding(props.xAxisOuterPadding);
|
|
88
86
|
};
|
|
89
87
|
const _createDataset = (points)=>{
|
|
90
88
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
91
89
|
const datasetForBars = [];
|
|
92
|
-
const dataset = [];
|
|
93
90
|
points.forEach((point, index)=>{
|
|
94
|
-
const singleDatasetPoint = {};
|
|
95
91
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
96
92
|
const singleDatasetPointForBars = {};
|
|
97
|
-
const
|
|
98
|
-
point.series.forEach((seriesPoint
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
93
|
+
const legendToBarPoint = {};
|
|
94
|
+
point.series.forEach((seriesPoint)=>{
|
|
95
|
+
if (!singleDatasetPointForBars[seriesPoint.legend]) {
|
|
96
|
+
singleDatasetPointForBars[seriesPoint.legend] = [
|
|
97
|
+
{
|
|
98
|
+
...seriesPoint
|
|
99
|
+
}
|
|
100
|
+
];
|
|
101
|
+
legendToBarPoint[seriesPoint.legend] = {
|
|
102
|
+
...seriesPoint
|
|
103
|
+
};
|
|
104
|
+
} else {
|
|
105
|
+
singleDatasetPointForBars[seriesPoint.legend].push({
|
|
106
|
+
...seriesPoint
|
|
107
|
+
});
|
|
108
|
+
legendToBarPoint[seriesPoint.legend].data += seriesPoint.data;
|
|
109
|
+
}
|
|
104
110
|
});
|
|
105
111
|
singleDatasetPointForBars.xAxisPoint = point.name;
|
|
106
112
|
singleDatasetPointForBars.indexNum = index;
|
|
107
|
-
singleDatasetPointForBars.groupSeries =
|
|
113
|
+
singleDatasetPointForBars.groupSeries = Object.values(legendToBarPoint);
|
|
108
114
|
singleDatasetPointForBars.stackCallOutAccessibilityData = point.stackCallOutAccessibilityData;
|
|
109
115
|
datasetForBars.push(singleDatasetPointForBars);
|
|
110
|
-
dataset.push(singleDatasetPoint);
|
|
111
116
|
});
|
|
112
117
|
return datasetForBars;
|
|
113
118
|
};
|
|
114
119
|
const _createDataSetOfGVBC = (points)=>{
|
|
115
|
-
const
|
|
116
|
-
const xAxisLabels = points
|
|
117
|
-
points
|
|
118
|
-
|
|
120
|
+
const legends = new Set();
|
|
121
|
+
const xAxisLabels = _getOrderedXAxisLabels(points);
|
|
122
|
+
points.forEach((point)=>{
|
|
123
|
+
point.series.forEach((seriesPoint)=>{
|
|
124
|
+
legends.add(seriesPoint.legend);
|
|
125
|
+
});
|
|
119
126
|
});
|
|
120
127
|
const datasetForBars = _createDataset(points);
|
|
121
128
|
return {
|
|
122
|
-
|
|
129
|
+
legends: Array.from(legends),
|
|
123
130
|
xAxisLabels,
|
|
124
131
|
datasetForBars
|
|
125
132
|
};
|
|
@@ -135,36 +142,22 @@ export const GroupedVerticalBarChart = /*#__PURE__*/ React.forwardRef((props = {
|
|
|
135
142
|
props.legendProps.onChange(selectedLegends, event, currentLegend);
|
|
136
143
|
}
|
|
137
144
|
};
|
|
145
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
138
146
|
const _getLegendData = (points)=>{
|
|
139
|
-
const data = points;
|
|
140
|
-
const defaultPalette = [
|
|
141
|
-
getColorFromToken(DataVizPalette.color1),
|
|
142
|
-
getColorFromToken(DataVizPalette.color2),
|
|
143
|
-
getColorFromToken(DataVizPalette.color3),
|
|
144
|
-
getColorFromToken(DataVizPalette.color4),
|
|
145
|
-
getColorFromToken(DataVizPalette.color5)
|
|
146
|
-
];
|
|
147
147
|
const actions = [];
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
148
|
+
_legends.forEach((legendTitle)=>{
|
|
149
|
+
const legend = {
|
|
150
|
+
title: legendTitle,
|
|
151
|
+
color: _legendColorMap[legendTitle][0],
|
|
152
|
+
hoverAction: ()=>{
|
|
153
|
+
_handleChartMouseLeave();
|
|
154
|
+
_onLegendHover(legendTitle);
|
|
155
|
+
},
|
|
156
|
+
onMouseOutAction: ()=>{
|
|
157
|
+
_onLegendLeave();
|
|
154
158
|
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
color,
|
|
158
|
-
hoverAction: ()=>{
|
|
159
|
-
_handleChartMouseLeave();
|
|
160
|
-
_onLegendHover(point.legend);
|
|
161
|
-
},
|
|
162
|
-
onMouseOutAction: ()=>{
|
|
163
|
-
_onLegendLeave();
|
|
164
|
-
}
|
|
165
|
-
};
|
|
166
|
-
actions.push(legend);
|
|
167
|
-
});
|
|
159
|
+
};
|
|
160
|
+
actions.push(legend);
|
|
168
161
|
});
|
|
169
162
|
return /*#__PURE__*/ React.createElement(Legends, {
|
|
170
163
|
legends: actions,
|
|
@@ -175,13 +168,60 @@ export const GroupedVerticalBarChart = /*#__PURE__*/ React.forwardRef((props = {
|
|
|
175
168
|
legendRef: _legendsRef
|
|
176
169
|
});
|
|
177
170
|
};
|
|
178
|
-
const
|
|
179
|
-
|
|
180
|
-
|
|
171
|
+
const _addDefaultColors = (data)=>{
|
|
172
|
+
_legendColorMap = {};
|
|
173
|
+
let colorIndex = 0;
|
|
174
|
+
var _data_map;
|
|
175
|
+
return (_data_map = data === null || data === void 0 ? void 0 : data.map((point)=>{
|
|
176
|
+
var _point_series;
|
|
177
|
+
var _point_series_map;
|
|
178
|
+
return {
|
|
179
|
+
...point,
|
|
180
|
+
series: (_point_series_map = (_point_series = point.series) === null || _point_series === void 0 ? void 0 : _point_series.map((seriesPoint)=>{
|
|
181
|
+
// TODO: Add support for gradient colors
|
|
182
|
+
let startColor = seriesPoint.color ? seriesPoint.color : getNextColor(colorIndex, 0);
|
|
183
|
+
let endColor = startColor;
|
|
184
|
+
if (!_legendColorMap[seriesPoint.legend]) {
|
|
185
|
+
_legendColorMap[seriesPoint.legend] = [
|
|
186
|
+
startColor,
|
|
187
|
+
endColor
|
|
188
|
+
];
|
|
189
|
+
}
|
|
190
|
+
colorIndex += 1;
|
|
191
|
+
var _seriesPoint_color;
|
|
192
|
+
return {
|
|
193
|
+
...seriesPoint,
|
|
194
|
+
color: (_seriesPoint_color = seriesPoint.color) !== null && _seriesPoint_color !== void 0 ? _seriesPoint_color : _legendColorMap[seriesPoint.legend][0]
|
|
195
|
+
};
|
|
196
|
+
})) !== null && _point_series_map !== void 0 ? _point_series_map : []
|
|
197
|
+
};
|
|
198
|
+
})) !== null && _data_map !== void 0 ? _data_map : [];
|
|
199
|
+
};
|
|
200
|
+
const _getOrderedXAxisLabels = (points)=>{
|
|
201
|
+
if (_xAxisType !== XAxisTypes.StringAxis) {
|
|
202
|
+
return [];
|
|
203
|
+
}
|
|
204
|
+
return sortAxisCategories(_mapCategoryToValues(points), props.xAxisCategoryOrder);
|
|
205
|
+
};
|
|
206
|
+
const _mapCategoryToValues = (points)=>{
|
|
207
|
+
const categoryToValues = {};
|
|
208
|
+
points.forEach((point)=>{
|
|
209
|
+
if (!categoryToValues[point.name]) {
|
|
210
|
+
categoryToValues[point.name] = [];
|
|
211
|
+
}
|
|
212
|
+
point.series.forEach((seriesPoint)=>{
|
|
213
|
+
categoryToValues[point.name].push(seriesPoint.data);
|
|
214
|
+
});
|
|
215
|
+
});
|
|
216
|
+
return categoryToValues;
|
|
217
|
+
};
|
|
218
|
+
const points = _addDefaultColors(props.data);
|
|
219
|
+
const _xAxisType = getTypeOfAxis(points[0].name, true);
|
|
220
|
+
const { legends, xAxisLabels, datasetForBars } = _createDataSetOfGVBC(points);
|
|
221
|
+
_legends = legends;
|
|
181
222
|
_xAxisLabels = xAxisLabels;
|
|
182
223
|
_datasetForBars = datasetForBars;
|
|
183
|
-
const
|
|
184
|
-
const legends = _getLegendData(points);
|
|
224
|
+
const legendBars = _getLegendData(points);
|
|
185
225
|
_adjustProps();
|
|
186
226
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Add commentMore actions
|
|
187
227
|
function _getMinMaxOfYAxis(datasetForBars, yAxisType, useSecondaryYScale) {
|
|
@@ -241,8 +281,8 @@ export const GroupedVerticalBarChart = /*#__PURE__*/ React.forwardRef((props = {
|
|
|
241
281
|
const xScale0 = _createX0Scale(containerWidth);
|
|
242
282
|
// Setting the bar width here is safe because there are no dependencies earlier in the code
|
|
243
283
|
// that rely on the width of bars in vertical bar charts with string x-axis.
|
|
244
|
-
_barWidth = getBarWidth(props.barWidth, props.maxBarWidth, xScale0.bandwidth()
|
|
245
|
-
_groupWidth = (
|
|
284
|
+
_barWidth = getBarWidth(props.barWidth, props.maxBarWidth, calcBandwidth(xScale0.bandwidth(), _legends.length, X1_INNER_PADDING));
|
|
285
|
+
_groupWidth = calcRequiredWidth(_barWidth, _legends.length, X1_INNER_PADDING);
|
|
246
286
|
const xScale1 = _createX1Scale();
|
|
247
287
|
const allGroupsBars = [];
|
|
248
288
|
_datasetForBars.forEach((singleSet)=>{
|
|
@@ -253,10 +293,6 @@ export const GroupedVerticalBarChart = /*#__PURE__*/ React.forwardRef((props = {
|
|
|
253
293
|
const _getMargins = (margins)=>{
|
|
254
294
|
_margins = margins;
|
|
255
295
|
};
|
|
256
|
-
const _getOpacity = (legendTitle)=>{
|
|
257
|
-
const opacity = _legendHighlighted(legendTitle) || _noLegendHighlighted() ? '' : '0.1';
|
|
258
|
-
return opacity;
|
|
259
|
-
};
|
|
260
296
|
function updatePosition(newX, newY) {
|
|
261
297
|
const threshold = 1; // Set a threshold for movement
|
|
262
298
|
const { x, y } = clickPosition;
|
|
@@ -295,96 +331,102 @@ export const GroupedVerticalBarChart = /*#__PURE__*/ React.forwardRef((props = {
|
|
|
295
331
|
setPopoverOpen(false);
|
|
296
332
|
};
|
|
297
333
|
const onBarFocus = (event, pointData, // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
298
|
-
groupData
|
|
334
|
+
groupData)=>{
|
|
299
335
|
let x = 0;
|
|
300
336
|
let y = 0;
|
|
301
337
|
const targetRect = event.target.getBoundingClientRect();
|
|
302
338
|
x = targetRect.left + targetRect.width / 2;
|
|
303
339
|
y = targetRect.top + targetRect.height / 2;
|
|
304
340
|
updatePosition(x, y);
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
setYValueHover(groupData.groupSeries);
|
|
315
|
-
setHoverXValue(pointData.xAxisCalloutData);
|
|
316
|
-
}
|
|
317
|
-
});
|
|
318
|
-
};
|
|
319
|
-
const _refCallback = (element, legendTitle, refIndexNumber)=>{
|
|
320
|
-
_refArray[refIndexNumber] = {
|
|
321
|
-
index: legendTitle,
|
|
322
|
-
refElement: element
|
|
323
|
-
};
|
|
341
|
+
setPopoverOpen(_noLegendHighlighted() || _legendHighlighted(pointData.legend));
|
|
342
|
+
setCalloutLegend(pointData.legend);
|
|
343
|
+
setDataForHoverCard(pointData.data);
|
|
344
|
+
setColor(pointData.color);
|
|
345
|
+
setXCalloutValue(pointData.xAxisCalloutData);
|
|
346
|
+
setYCalloutValue(pointData.yAxisCalloutData);
|
|
347
|
+
setCallOutAccessibilityData(props.isCalloutForStack ? groupData.stackCallOutAccessibilityData : pointData.callOutAccessibilityData);
|
|
348
|
+
setYValueHover(groupData.groupSeries);
|
|
349
|
+
setHoverXValue(pointData.xAxisCalloutData);
|
|
324
350
|
};
|
|
325
351
|
const _buildGraph = (// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
326
352
|
singleSet, // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
327
353
|
xScale0, // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
328
354
|
xScale1, yScalePrimary, yScaleSecondary, containerHeight, xElement)=>{
|
|
355
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
329
356
|
const singleGroup = [];
|
|
357
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
330
358
|
const barLabelsForGroup = [];
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
359
|
+
// Get the actual legends present at this x-axis point
|
|
360
|
+
const presentLegends = Object.keys(singleSet).filter((key)=>key in _legendColorMap);
|
|
361
|
+
const effectiveGroupWidth = calcRequiredWidth(_barWidth, presentLegends.length, X1_INNER_PADDING);
|
|
362
|
+
// For stacked bars, center the single bar group in the available space
|
|
363
|
+
// Instead of using the global legend position, use the local position within present legends
|
|
364
|
+
const localScale = d3ScaleBand().domain(presentLegends).range(_useRtl ? [
|
|
365
|
+
effectiveGroupWidth,
|
|
366
|
+
0
|
|
367
|
+
] : [
|
|
368
|
+
0,
|
|
369
|
+
effectiveGroupWidth
|
|
370
|
+
]).paddingInner(X1_INNER_PADDING);
|
|
371
|
+
_legends.forEach((legendTitle, legendIndex)=>{
|
|
372
|
+
const barPoints = singleSet[legendTitle];
|
|
373
|
+
if (barPoints) {
|
|
374
|
+
const yBarScale = barPoints[0].useSecondaryYScale && yScaleSecondary ? yScaleSecondary : yScalePrimary;
|
|
375
|
+
var _localScale;
|
|
376
|
+
const xPoint = ((_localScale = localScale(legendTitle)) !== null && _localScale !== void 0 ? _localScale : 0) + (localScale.bandwidth() - _barWidth) / 2;
|
|
377
|
+
const isLegendActive = _legendHighlighted(legendTitle) || _noLegendHighlighted();
|
|
378
|
+
const barOpacity = isLegendActive ? '' : '0.1';
|
|
379
|
+
let barTotalValue = 0;
|
|
341
380
|
const yBaseline = yBarScale(Y_ORIGIN);
|
|
342
381
|
let yPositiveStart = yBaseline;
|
|
343
382
|
let yNegativeStart = yBaseline;
|
|
344
383
|
let yPoint = Y_ORIGIN;
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
384
|
+
barPoints.forEach((pointData, pointIndex)=>{
|
|
385
|
+
if (!pointData.data) {
|
|
386
|
+
// Not rendering data with 0.
|
|
387
|
+
return;
|
|
388
|
+
}
|
|
389
|
+
const barGap = VERTICAL_BAR_GAP / 2 * (pointIndex > 0 ? 2 : 0);
|
|
390
|
+
const height = Math.max(yBarScale(Y_ORIGIN) - yBarScale(Math.abs(pointData.data)), MIN_BAR_HEIGHT);
|
|
391
|
+
const pointColor = pointData.color; // Use the color of the current point
|
|
392
|
+
if (pointData.data >= Y_ORIGIN) {
|
|
393
|
+
yPositiveStart -= height + barGap;
|
|
394
|
+
yPoint = yPositiveStart;
|
|
395
|
+
} else {
|
|
396
|
+
yPoint = yNegativeStart + barGap;
|
|
397
|
+
yNegativeStart = yPoint + height;
|
|
398
|
+
}
|
|
399
|
+
singleGroup.push(/*#__PURE__*/ React.createElement("rect", {
|
|
400
|
+
key: `${singleSet.indexNum}-${legendIndex}-${pointIndex}`,
|
|
401
|
+
className: classes.opacityChangeOnHover,
|
|
402
|
+
height: height,
|
|
403
|
+
width: _barWidth,
|
|
404
|
+
x: xPoint,
|
|
405
|
+
y: yPoint,
|
|
406
|
+
opacity: barOpacity,
|
|
407
|
+
fill: pointColor,
|
|
408
|
+
rx: 0,
|
|
409
|
+
onMouseOver: (event)=>onBarHover(pointData, singleSet, event),
|
|
410
|
+
onMouseMove: (event)=>onBarHover(pointData, singleSet, event),
|
|
411
|
+
onMouseOut: _onBarLeave,
|
|
412
|
+
onFocus: (event)=>onBarFocus(event, pointData, singleSet),
|
|
413
|
+
onBlur: _onBarLeave,
|
|
414
|
+
onClick: pointData.onClick,
|
|
415
|
+
"aria-label": getAriaLabel(pointData, singleSet.xAxisPoint),
|
|
416
|
+
tabIndex: _legendHighlighted(pointData.legend) || _noLegendHighlighted() ? 0 : undefined,
|
|
417
|
+
role: "img"
|
|
418
|
+
}));
|
|
419
|
+
barTotalValue += pointData.data;
|
|
420
|
+
});
|
|
421
|
+
if (barTotalValue !== null && !props.hideLabels && _barWidth >= 16 && isLegendActive) {
|
|
380
422
|
barLabelsForGroup.push(/*#__PURE__*/ React.createElement("text", {
|
|
381
|
-
key: `${singleSet.indexNum}-${
|
|
423
|
+
key: `${singleSet.indexNum}-${legendIndex}`,
|
|
382
424
|
x: xPoint + _barWidth / 2,
|
|
383
|
-
y:
|
|
425
|
+
y: barTotalValue >= Y_ORIGIN ? yPositiveStart - 6 : yNegativeStart + 12,
|
|
384
426
|
textAnchor: "middle",
|
|
385
427
|
className: classes.barLabel,
|
|
386
428
|
"aria-hidden": true
|
|
387
|
-
}, typeof props.yAxisTickFormat === 'function' ? props.yAxisTickFormat(
|
|
429
|
+
}, typeof props.yAxisTickFormat === 'function' ? props.yAxisTickFormat(barTotalValue) : formatScientificLimitWidth(barTotalValue)));
|
|
388
430
|
}
|
|
389
431
|
}
|
|
390
432
|
});
|
|
@@ -404,7 +446,7 @@ export const GroupedVerticalBarChart = /*#__PURE__*/ React.forwardRef((props = {
|
|
|
404
446
|
}
|
|
405
447
|
return /*#__PURE__*/ React.createElement("g", {
|
|
406
448
|
key: singleSet.indexNum,
|
|
407
|
-
transform: `translate(${xScale0(singleSet.xAxisPoint) + (xScale0.bandwidth() -
|
|
449
|
+
transform: `translate(${xScale0(singleSet.xAxisPoint) + (xScale0.bandwidth() - effectiveGroupWidth) / 2}, 0)`
|
|
408
450
|
}, singleGroup, barLabelsForGroup);
|
|
409
451
|
};
|
|
410
452
|
// For grouped vertical bar chart, First need to define total scale (from start to end)
|
|
@@ -421,7 +463,7 @@ export const GroupedVerticalBarChart = /*#__PURE__*/ React.forwardRef((props = {
|
|
|
421
463
|
};
|
|
422
464
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
423
465
|
const _createX1Scale = ()=>{
|
|
424
|
-
return d3ScaleBand().domain(
|
|
466
|
+
return d3ScaleBand().domain(_legends)// When there is only one group, xScale0 adds padding around it,
|
|
425
467
|
// causing the bandwidth to become smaller than the actual group width.
|
|
426
468
|
// So to render bars in the group correctly, use groupWidth instead of the generated scale bandwidth.
|
|
427
469
|
.range(_useRtl ? [
|
|
@@ -472,8 +514,7 @@ export const GroupedVerticalBarChart = /*#__PURE__*/ React.forwardRef((props = {
|
|
|
472
514
|
return ((_point_callOutAccessibilityData = point.callOutAccessibilityData) === null || _point_callOutAccessibilityData === void 0 ? void 0 : _point_callOutAccessibilityData.ariaLabel) || `${xValue}. ${legend}, ${yValue}.`;
|
|
473
515
|
};
|
|
474
516
|
const _getDomainMargins = (containerWidth)=>{
|
|
475
|
-
/** Total width available to render the bars */ const totalWidth = containerWidth
|
|
476
|
-
/** Rate at which the space between the groups changes wrt the group width */ const groupGapRate = _xAxisInnerPadding / (1 - _xAxisInnerPadding);
|
|
517
|
+
/** Total width available to render the bars */ const totalWidth = calcTotalWidth(containerWidth, _margins, MIN_DOMAIN_MARGIN);
|
|
477
518
|
if (_xAxisType === XAxisTypes.StringAxis) {
|
|
478
519
|
if (isScalePaddingDefined(props.xAxisOuterPadding)) {
|
|
479
520
|
// Setting the domain margin for string x-axis to 0 because the xAxisOuterPadding prop is now available
|
|
@@ -483,19 +524,19 @@ export const GroupedVerticalBarChart = /*#__PURE__*/ React.forwardRef((props = {
|
|
|
483
524
|
// Update the bar width so that when CartesianChart rerenders,
|
|
484
525
|
// the following calculations don't use the previous bar width.
|
|
485
526
|
_barWidth = getBarWidth(props.barWidth, props.maxBarWidth);
|
|
486
|
-
const groupWidth = (
|
|
487
|
-
/** Total width required to render the groups. Directly proportional to group width */ const reqWidth = (
|
|
527
|
+
const groupWidth = calcRequiredWidth(_barWidth, _legends.length, X1_INNER_PADDING);
|
|
528
|
+
/** Total width required to render the groups. Directly proportional to group width */ const reqWidth = calcRequiredWidth(groupWidth, _xAxisLabels.length, _xAxisInnerPadding);
|
|
488
529
|
if (totalWidth >= reqWidth) {
|
|
489
530
|
// Center align the chart by setting equal left and right margins for domain
|
|
490
531
|
_domainMargin = MIN_DOMAIN_MARGIN + (totalWidth - reqWidth) / 2;
|
|
491
532
|
}
|
|
492
533
|
} else if (props.mode === 'plotly' && xAxisLabels.length > 1) {
|
|
493
534
|
// Calculate the remaining width after rendering groups at their maximum allowable width
|
|
494
|
-
const groupBandwidth = totalWidth
|
|
495
|
-
const barBandwidth = groupBandwidth
|
|
535
|
+
const groupBandwidth = calcBandwidth(totalWidth, _xAxisLabels.length, _xAxisInnerPadding);
|
|
536
|
+
const barBandwidth = calcBandwidth(groupBandwidth, _legends.length, X1_INNER_PADDING);
|
|
496
537
|
const barWidth = getBarWidth(props.barWidth, props.maxBarWidth, barBandwidth);
|
|
497
|
-
const groupWidth = (
|
|
498
|
-
let reqWidth = (
|
|
538
|
+
const groupWidth = calcRequiredWidth(barWidth, _legends.length, X1_INNER_PADDING);
|
|
539
|
+
let reqWidth = calcRequiredWidth(groupWidth, _xAxisLabels.length, _xAxisInnerPadding);
|
|
499
540
|
const margin1 = (totalWidth - reqWidth) / 2;
|
|
500
541
|
let margin2 = Number.POSITIVE_INFINITY;
|
|
501
542
|
if (!props.hideTickOverlap) {
|
|
@@ -517,7 +558,7 @@ export const GroupedVerticalBarChart = /*#__PURE__*/ React.forwardRef((props = {
|
|
|
517
558
|
return !(props.data && props.data.length > 0 && props.data.filter((item)=>item.series.length).length > 0);
|
|
518
559
|
};
|
|
519
560
|
const _getChartTitle = ()=>{
|
|
520
|
-
return (props.chartTitle ? `${props.chartTitle}. ` : '') + `Vertical bar chart with ${_xAxisLabels.length} groups of ${
|
|
561
|
+
return (props.chartTitle ? `${props.chartTitle}. ` : '') + `Vertical bar chart with ${_xAxisLabels.length} groups of ${_legends.length} bars each. `;
|
|
521
562
|
};
|
|
522
563
|
return !_isChartEmpty() ? /*#__PURE__*/ React.createElement(CartesianChart, {
|
|
523
564
|
...props,
|
|
@@ -528,7 +569,7 @@ export const GroupedVerticalBarChart = /*#__PURE__*/ React.forwardRef((props = {
|
|
|
528
569
|
getMinMaxOfYAxis: _getMinMaxOfYAxis,
|
|
529
570
|
createStringYAxis: createStringYAxis,
|
|
530
571
|
calloutProps: calloutProps,
|
|
531
|
-
legendBars:
|
|
572
|
+
legendBars: legendBars,
|
|
532
573
|
xAxisType: _xAxisType,
|
|
533
574
|
createYAxis: createNumericYAxis,
|
|
534
575
|
datasetForXAxisDomain: _xAxisLabels,
|