diff --git a/integration/tests/__image_snapshots__/all-test-ts-baseline-visual-tests-for-all-stories-waffle-alpha-test-visually-looks-correct-1-snap.png b/integration/tests/__image_snapshots__/all-test-ts-baseline-visual-tests-for-all-stories-waffle-alpha-test-visually-looks-correct-1-snap.png new file mode 100644 index 0000000000..f4b4694ce5 Binary files /dev/null and b/integration/tests/__image_snapshots__/all-test-ts-baseline-visual-tests-for-all-stories-waffle-alpha-test-visually-looks-correct-1-snap.png differ diff --git a/packages/charts/src/components/legend/utils.ts b/packages/charts/src/components/legend/utils.ts index 30d1518274..287b454207 100644 --- a/packages/charts/src/components/legend/utils.ts +++ b/packages/charts/src/components/legend/utils.ts @@ -18,6 +18,6 @@ export function getExtra(extraValues: Map, item: const [{ key }] = seriesIdentifiers; const extraValueKey = path.map(({ index }) => index).join('__'); const itemExtraValues = extraValues.has(extraValueKey) ? extraValues.get(extraValueKey) : extraValues.get(key); - const actionExtra = childId && itemExtraValues?.get(childId); + const actionExtra = childId !== undefined && itemExtraValues?.get(childId); return actionExtra ?? (extraValues.size === totalItems ? defaultExtra?.formatted : null) ?? ''; } diff --git a/packages/charts/src/mocks/hierarchical/dimension_codes.ts b/packages/charts/src/mocks/hierarchical/dimension_codes.ts index 88c5eb071d..61a3cd6053 100644 --- a/packages/charts/src/mocks/hierarchical/dimension_codes.ts +++ b/packages/charts/src/mocks/hierarchical/dimension_codes.ts @@ -6,6 +6,18 @@ * Side Public License, v 1. */ +/**@internal */ +export const productPriceNames = [ + { products_price: 0.0, name: '0' }, + { products_price: 50.0, name: '50' }, + { products_price: 100.0, name: '100' }, + { products_price: 150.0, name: '150' }, + { products_price: 200.0, name: '200' }, + { products_price: 350.0, name: '350' }, + { products_price: 400.0, name: '400' }, + { products_price: 1050.0, name: '1050' }, +]; + /** @internal */ export const productDimension = [ { diff --git a/storybook/stories/utils/utils.ts b/storybook/stories/utils/utils.ts index 322e745ee8..7a602c1040 100644 --- a/storybook/stories/utils/utils.ts +++ b/storybook/stories/utils/utils.ts @@ -11,12 +11,14 @@ import { countryDimension, productDimension, regionDimension, + productPriceNames, } from '@elastic/charts/src/mocks/hierarchical/dimension_codes'; import { palettes } from '@elastic/charts/src/mocks/hierarchical/palettes'; export const productLookup = arrayToLookup((d: any) => d.sitc1, productDimension); export const regionLookup = arrayToLookup((d: any) => d.region, regionDimension); export const countryLookup = arrayToLookup((d: any) => d.country, countryDimension); +export const productPriceLookup = arrayToLookup((d: any) => d.products_price, productPriceNames); type ColorMaker = (x: number) => string; diff --git a/storybook/stories/waffle/2_test.story.tsx b/storybook/stories/waffle/2_test.story.tsx new file mode 100644 index 0000000000..2d9a858a9c --- /dev/null +++ b/storybook/stories/waffle/2_test.story.tsx @@ -0,0 +1,55 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import React from 'react'; + +import { Chart, Datum, Partition, PartitionLayout, Settings, ShapeTreeNode } from '@elastic/charts'; + +import { useBaseTheme } from '../../use_base_theme'; +import { colorBrewerCategoricalStark9, discreteColor, productPriceLookup } from '../utils/utils'; + +export const Example = () => { + return ( + + + d.median_day_of_week_i as number} + layers={[ + { + groupByRollup: (d: Datum) => d.products_price, + nodeLabel: (d: Datum) => productPriceLookup[d].name, + shape: { + fillColor: (d: ShapeTreeNode) => discreteColor(colorBrewerCategoricalStark9.slice(1))(d.sortIndex), + }, + }, + ]} + /> + + ); +}; diff --git a/storybook/stories/waffle/waffle.stories.tsx b/storybook/stories/waffle/waffle.stories.tsx index 62274f29bb..ea3f88759b 100644 --- a/storybook/stories/waffle/waffle.stories.tsx +++ b/storybook/stories/waffle/waffle.stories.tsx @@ -11,3 +11,4 @@ export default { }; export { Example as simple } from './1_simple.story'; +export { Example as test } from './2_test.story';