diff --git a/src/chart_types/partition_chart/layout/utils/group_by_rollup.ts b/src/chart_types/partition_chart/layout/utils/group_by_rollup.ts index 58efe0630c..05aae6c1ad 100644 --- a/src/chart_types/partition_chart/layout/utils/group_by_rollup.ts +++ b/src/chart_types/partition_chart/layout/utils/group_by_rollup.ts @@ -58,7 +58,7 @@ interface MapNode extends NodeDescriptor { } /** @internal */ -export const hierarchyRootKey: Key = '__root_key__'; +export const HIERARCHY_ROOT_KEY: Key = '__root_key__'; export type PrimitiveValue = string | number | null; // there could be more but sufficient for now type Key = CategoryKey; @@ -129,8 +129,8 @@ export function groupByRollup( }); return p; }, new Map()); - if (reductionMap.get(hierarchyRootKey) !== undefined) { - statistics.globalAggregate = (reductionMap.get(hierarchyRootKey) as MapNode)[AGGREGATE_KEY]; + if (reductionMap.get(HIERARCHY_ROOT_KEY) !== undefined) { + statistics.globalAggregate = (reductionMap.get(HIERARCHY_ROOT_KEY) as MapNode)[AGGREGATE_KEY]; } return reductionMap; } diff --git a/src/chart_types/partition_chart/partition.test.tsx b/src/chart_types/partition_chart/partition.test.tsx index 73b7513e52..05f257e8d5 100644 --- a/src/chart_types/partition_chart/partition.test.tsx +++ b/src/chart_types/partition_chart/partition.test.tsx @@ -23,7 +23,7 @@ import { MockSeriesSpec } from '../../mocks/specs'; import { MockStore } from '../../mocks/store'; import { GlobalChartState } from '../../state/chart_state'; import { LegendItemLabel } from '../../state/selectors/get_legend_items_labels'; -import { hierarchyRootKey } from './layout/utils/group_by_rollup'; +import { HIERARCHY_ROOT_KEY } from './layout/utils/group_by_rollup'; import { computeLegendSelector } from './state/selectors/compute_legend'; import { getLegendItemsLabels } from './state/selectors/get_legend_items_labels'; @@ -98,7 +98,7 @@ describe('Retain hierarchy even with arbitrary names', () => { childId: 'A', color: 'rgba(128, 0, 0, 0.5)', path: [ - { index: 0, value: hierarchyRootKey }, + { index: 0, value: HIERARCHY_ROOT_KEY }, { index: 0, value: 'A' }, ], depth: 0, @@ -109,7 +109,7 @@ describe('Retain hierarchy even with arbitrary names', () => { childId: 'A', color: 'rgba(128, 0, 0, 0.5)', path: [ - { index: 0, value: hierarchyRootKey }, + { index: 0, value: HIERARCHY_ROOT_KEY }, { index: 0, value: 'A' }, { index: 0, value: 'A' }, ], @@ -121,7 +121,7 @@ describe('Retain hierarchy even with arbitrary names', () => { childId: 'B', color: 'rgba(128, 0, 0, 0.5)', path: [ - { index: 0, value: hierarchyRootKey }, + { index: 0, value: HIERARCHY_ROOT_KEY }, { index: 0, value: 'A' }, { index: 1, value: 'B' }, ], @@ -133,7 +133,7 @@ describe('Retain hierarchy even with arbitrary names', () => { childId: 'B', color: 'rgba(128, 0, 0, 0.5)', path: [ - { index: 0, value: hierarchyRootKey }, + { index: 0, value: HIERARCHY_ROOT_KEY }, { index: 1, value: 'B' }, ], depth: 0, @@ -144,7 +144,7 @@ describe('Retain hierarchy even with arbitrary names', () => { childId: 'A', color: 'rgba(128, 0, 0, 0.5)', path: [ - { index: 0, value: hierarchyRootKey }, + { index: 0, value: HIERARCHY_ROOT_KEY }, { index: 1, value: 'B' }, { index: 0, value: 'A' }, ], @@ -156,7 +156,7 @@ describe('Retain hierarchy even with arbitrary names', () => { childId: 'B', color: 'rgba(128, 0, 0, 0.5)', path: [ - { index: 0, value: hierarchyRootKey }, + { index: 0, value: HIERARCHY_ROOT_KEY }, { index: 1, value: 'B' }, { index: 1, value: 'B' }, ], @@ -168,7 +168,7 @@ describe('Retain hierarchy even with arbitrary names', () => { childId: 'C', color: 'rgba(128, 0, 0, 0.5)', path: [ - { index: 0, value: hierarchyRootKey }, + { index: 0, value: HIERARCHY_ROOT_KEY }, { index: 2, value: 'C' }, ], depth: 0, @@ -179,7 +179,7 @@ describe('Retain hierarchy even with arbitrary names', () => { childId: 'A', color: 'rgba(128, 0, 0, 0.5)', path: [ - { index: 0, value: hierarchyRootKey }, + { index: 0, value: HIERARCHY_ROOT_KEY }, { index: 2, value: 'C' }, { index: 0, value: 'A' }, ], @@ -191,7 +191,7 @@ describe('Retain hierarchy even with arbitrary names', () => { childId: 'B', color: 'rgba(128, 0, 0, 0.5)', path: [ - { index: 0, value: hierarchyRootKey }, + { index: 0, value: HIERARCHY_ROOT_KEY }, { index: 2, value: 'C' }, { index: 1, value: 'B' }, ], @@ -211,7 +211,7 @@ describe('Retain hierarchy even with arbitrary names', () => { path: [ { index: 0, - value: hierarchyRootKey, + value: HIERARCHY_ROOT_KEY, }, { index: 0, @@ -228,7 +228,7 @@ describe('Retain hierarchy even with arbitrary names', () => { path: [ { index: 0, - value: hierarchyRootKey, + value: HIERARCHY_ROOT_KEY, }, { index: 0, @@ -256,7 +256,7 @@ describe('Retain hierarchy even with arbitrary names', () => { path: [ { index: 0, - value: hierarchyRootKey, + value: HIERARCHY_ROOT_KEY, }, { index: 0, @@ -273,7 +273,7 @@ describe('Retain hierarchy even with arbitrary names', () => { path: [ { index: 0, - value: hierarchyRootKey, + value: HIERARCHY_ROOT_KEY, }, { index: 0, diff --git a/src/chart_types/partition_chart/state/selectors/get_highlighted_shapes.ts b/src/chart_types/partition_chart/state/selectors/get_highlighted_shapes.ts index 4ff31854b1..dc6e1c516b 100644 --- a/src/chart_types/partition_chart/state/selectors/get_highlighted_shapes.ts +++ b/src/chart_types/partition_chart/state/selectors/get_highlighted_shapes.ts @@ -93,7 +93,6 @@ export type LegendStrategy = $Values; const defaultStrategy: LegendStrategy = LegendStrategy.Key; /** @internal */ -// why is it called highlighted... when it's a legend hover related thing, not a hover over the slices? export const legendHoverHighlightNodes = createCachedSelector( [getSettingsSpecSelector, getHighlightedLegendItemPath, partitionGeometries], (specs, highlightedLegendItemPath, geoms): QuadViewModel[] => { 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 ce4e53fd68..9aedd42cbf 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 @@ -22,7 +22,7 @@ import createCachedSelector from 're-reselect'; import { getChartIdSelector } from '../../../../state/selectors/get_chart_id'; import { LegendItemLabel } from '../../../../state/selectors/get_legend_items_labels'; import { getSettingsSpecSelector } from '../../../../state/selectors/get_settings_specs'; -import { CHILDREN_KEY, HierarchyOfArrays, hierarchyRootKey } from '../../layout/utils/group_by_rollup'; +import { CHILDREN_KEY, HierarchyOfArrays, HIERARCHY_ROOT_KEY } from '../../layout/utils/group_by_rollup'; import { Layer } from '../../specs'; import { getPieSpec } from './pie_spec'; import { getTree } from './tree'; @@ -57,7 +57,7 @@ function flatSlicesNames( formattedValue = formatter ? formatter(key) : `${key}`; } // preventing errors from external formatters - if (formattedValue != null && formattedValue !== '' && formattedValue !== hierarchyRootKey) { + if (formattedValue != null && formattedValue !== '' && formattedValue !== HIERARCHY_ROOT_KEY) { // save only the max depth, so we can compute the the max extension of the legend keys.set(formattedValue, Math.max(depth, keys.get(formattedValue) ?? 0)); } diff --git a/src/chart_types/partition_chart/state/selectors/tree.ts b/src/chart_types/partition_chart/state/selectors/tree.ts index aadd68cb96..2839720442 100644 --- a/src/chart_types/partition_chart/state/selectors/tree.ts +++ b/src/chart_types/partition_chart/state/selectors/tree.ts @@ -24,7 +24,7 @@ import { SpecTypes } from '../../../../specs'; import { GlobalChartState } from '../../../../state/chart_state'; import { getSpecsFromStore } from '../../../../state/utils'; import { configMetadata } from '../../layout/config/config'; -import { childOrders, HierarchyOfArrays, hierarchyRootKey } from '../../layout/utils/group_by_rollup'; +import { childOrders, HierarchyOfArrays, HIERARCHY_ROOT_KEY } from '../../layout/utils/group_by_rollup'; import { getHierarchyOfArrays } from '../../layout/viewmodel/hierarchy_of_arrays'; import { isSunburst, isTreemap } from '../../layout/viewmodel/viewmodel'; import { PartitionSpec } from '../../specs'; @@ -45,7 +45,7 @@ export const getTree = createCachedSelector( return getHierarchyOfArrays( data, valueAccessor, - [() => hierarchyRootKey, ...layers.map(({ groupByRollup }) => groupByRollup)], + [() => HIERARCHY_ROOT_KEY, ...layers.map(({ groupByRollup }) => groupByRollup)], sorter, ); },