Skip to content

Commit

Permalink
fix: comment and constant
Browse files Browse the repository at this point in the history
  • Loading branch information
monfera committed Jan 19, 2021
1 parent 35400a1 commit fa82675
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down
28 changes: 14 additions & 14 deletions src/chart_types/partition_chart/partition.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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,
Expand All @@ -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' },
],
Expand All @@ -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' },
],
Expand All @@ -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,
Expand All @@ -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' },
],
Expand All @@ -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' },
],
Expand All @@ -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,
Expand All @@ -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' },
],
Expand All @@ -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' },
],
Expand All @@ -211,7 +211,7 @@ describe('Retain hierarchy even with arbitrary names', () => {
path: [
{
index: 0,
value: hierarchyRootKey,
value: HIERARCHY_ROOT_KEY,
},
{
index: 0,
Expand All @@ -228,7 +228,7 @@ describe('Retain hierarchy even with arbitrary names', () => {
path: [
{
index: 0,
value: hierarchyRootKey,
value: HIERARCHY_ROOT_KEY,
},
{
index: 0,
Expand Down Expand Up @@ -256,7 +256,7 @@ describe('Retain hierarchy even with arbitrary names', () => {
path: [
{
index: 0,
value: hierarchyRootKey,
value: HIERARCHY_ROOT_KEY,
},
{
index: 0,
Expand All @@ -273,7 +273,7 @@ describe('Retain hierarchy even with arbitrary names', () => {
path: [
{
index: 0,
value: hierarchyRootKey,
value: HIERARCHY_ROOT_KEY,
},
{
index: 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ export type LegendStrategy = $Values<typeof LegendStrategy>;
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[] => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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));
}
Expand Down
4 changes: 2 additions & 2 deletions src/chart_types/partition_chart/state/selectors/tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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,
);
},
Expand Down

0 comments on commit fa82675

Please sign in to comment.