diff --git a/integration/tests/__image_snapshots__/all-test-ts-baseline-visual-tests-for-all-stories-sunburst-sunburst-with-two-layers-visually-looks-correct-1-snap.png b/integration/tests/__image_snapshots__/all-test-ts-baseline-visual-tests-for-all-stories-sunburst-sunburst-with-two-layers-visually-looks-correct-1-snap.png index 521fc02048..32230a4d9b 100644 Binary files a/integration/tests/__image_snapshots__/all-test-ts-baseline-visual-tests-for-all-stories-sunburst-sunburst-with-two-layers-visually-looks-correct-1-snap.png and b/integration/tests/__image_snapshots__/all-test-ts-baseline-visual-tests-for-all-stories-sunburst-sunburst-with-two-layers-visually-looks-correct-1-snap.png differ diff --git a/integration/tests/all.test.ts b/integration/tests/all.test.ts index 928833ef35..1a64a9b0f3 100644 --- a/integration/tests/all.test.ts +++ b/integration/tests/all.test.ts @@ -24,7 +24,7 @@ jest.mock('../../.storybook/theme_service.ts', () => ({ switchTheme: () => undefined, })); -const storyGroups = getStorybookInfo(); +const storyGroups = getStorybookInfo().filter(({ group }) => group === 'Sunburst'); describe('Baseline Visual tests for all stories', () => { storyGroups.forEach(({ group, encodedGroup, stories }) => { diff --git a/src/chart_types/partition_chart/state/selectors/get_legend_items_labels.ts b/src/chart_types/partition_chart/state/selectors/get_legend_items_labels.ts index 7c7b88b495..91dc55af4a 100644 --- a/src/chart_types/partition_chart/state/selectors/get_legend_items_labels.ts +++ b/src/chart_types/partition_chart/state/selectors/get_legend_items_labels.ts @@ -29,10 +29,20 @@ import { getSettingsSpecSelector } from '../../../../state/selectors/get_setting export const getLegendItemsLabels = createCachedSelector( [getPieSpecOrNull, getSettingsSpecSelector, getTree], (pieSpec, { legendMaxDepth }, tree): LegendItemLabel[] => { - if (!pieSpec || (typeof legendMaxDepth === 'number' && legendMaxDepth <= 0)) { + if (!pieSpec) { return []; } - return flatSlicesNames(pieSpec.layers, 0, tree); + if (typeof legendMaxDepth === 'number' && (Number.isNaN(legendMaxDepth) || legendMaxDepth <= 0)) { + return []; + } + const labels = flatSlicesNames(pieSpec.layers, 0, tree).filter(({ depth }) => { + if (typeof legendMaxDepth !== 'number') { + return true; + } + return depth <= legendMaxDepth; + }); + + return labels; }, )(getChartIdSelector); @@ -45,6 +55,7 @@ function flatSlicesNames( if (tree.length === 0) { return []; } + for (let i = 0; i < tree.length; i++) { const branch = tree[i]; const arrayNode = branch[1]; diff --git a/stories/sunburst/8_sunburst_two_layers.tsx b/stories/sunburst/8_sunburst_two_layers.tsx index ead5bb5bc1..f69af30730 100644 --- a/stories/sunburst/8_sunburst_two_layers.tsx +++ b/stories/sunburst/8_sunburst_two_layers.tsx @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -import { Chart, Datum, Partition, PartitionLayout } from '../../src'; +import { Chart, Datum, Partition, PartitionLayout, Settings } from '../../src'; import { mocks } from '../../src/mocks/hierarchical/index'; import { config } from '../../src/chart_types/partition_chart/layout/config/config'; import React from 'react'; @@ -24,6 +24,7 @@ import { countryLookup, indexInterpolatedFillColor, interpolatorCET2s, regionLoo export const example = () => ( +