Skip to content

Commit

Permalink
chore: cleanup bar logic, remove zip file, export accessor types
Browse files Browse the repository at this point in the history
  • Loading branch information
nickofthyme committed Sep 30, 2020
1 parent 2afb928 commit c28e687
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 17 deletions.
Binary file removed elastic-charts-22.0.0.tgz
Binary file not shown.
30 changes: 16 additions & 14 deletions src/chart_types/xy_chart/state/selectors/get_debug_state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,23 +113,25 @@ const getBarsState = (seriesNameMap: Map<string, string>, barGeometries: BarGeom
displayValue,
}: BarGeometry) => {
const label = displayValue?.text;
if (!buckets.has(key)) {
const name = seriesNameMap.get(key) ?? '';
buckets.set(key, {
key,
name,
color,
bars: [],
labels: [],
visible: hasVisibleStyle(rect) || hasVisibleStyle(rectBorder),
});
}

buckets.get(key)!.bars.push({ x, y, mark });
const name = seriesNameMap.get(key) ?? '';
const bucket: DebugStateBar = buckets.get(key) ?? {
key,
name,
color,
bars: [],
labels: [],
visible: hasVisibleStyle(rect) || hasVisibleStyle(rectBorder),
};

bucket.bars.push({ x, y, mark });

if (label) {
buckets.get(key)!.labels.push(label);
bucket.labels.push(label);
}

buckets.set(key, bucket);

return buckets;
},
);

Expand Down
9 changes: 8 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,14 @@ export {
} from './chart_types/partition_chart/layout/types/config_types';
export { Layer as PartitionLayer } from './chart_types/partition_chart/specs/index';
export * from './chart_types/goal_chart/specs/index';
export { Accessor, AccessorFn, IndexedAccessorFn, UnaryAccessorFn } from './utils/accessor';
export {
Accessor,
AccessorFn,
IndexedAccessorFn,
UnaryAccessorFn,
AccessorObjectKey,
AccessorArrayIndex,
} from './utils/accessor';
export { CustomTooltip, TooltipInfo } from './components/tooltip/types';

// scales
Expand Down
14 changes: 12 additions & 2 deletions src/utils/accessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,18 @@ export type AccessorFn = UnaryAccessorFn;
* @public
*/
export type IndexedAccessorFn = UnaryAccessorFn | BinaryAccessorFn;
type AccessorObjectKey = string;
type AccessorArrayIndex = number;

/**
* A key accessor string
* @public
*/
export type AccessorObjectKey = string;

/**
* An index accessor number
* @public
*/
export type AccessorArrayIndex = number;

/**
* A datum accessor in form of object key accessor string/number
Expand Down

0 comments on commit c28e687

Please sign in to comment.