Skip to content

Commit

Permalink
Added size support from pointseries.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kuznietsov committed May 18, 2022
1 parent 8df17dd commit 34ff430
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ const createDataLayer = (args: XYArgs, table: Datatable): DataLayerConfigResult
yConfig: args.yConfig,
layerType: LayerTypes.DATA,
table: normalizedTable,
markSizeAccessor: args.markSizeAccessor,
...accessors,
};
};
Expand Down Expand Up @@ -113,7 +112,7 @@ export const xyVisFn: XyVisFn['fn'] = async (data, args, handlers) => {
const hasNotHistogramBars = !hasHistogramBarLayer(dataLayers);

validateValueLabels(args.valueLabels, hasBar, hasNotHistogramBars);
validateMarkSizeRatioWithAccessor(args.markSizeRatio, args.markSizeAccessor);
validateMarkSizeRatioWithAccessor(args.markSizeRatio, dataLayers[0].markSizeAccessor);
validateMarkSizeRatioLimits(args.markSizeRatio);

return {
Expand All @@ -123,7 +122,8 @@ export const xyVisFn: XyVisFn['fn'] = async (data, args, handlers) => {
args: {
...restArgs,
layers,
markSizeRatio: args.markSizeAccessor && !args.markSizeRatio ? 10 : args.markSizeRatio,
markSizeRatio:
dataLayers[0].markSizeAccessor && !args.markSizeRatio ? 10 : args.markSizeRatio,
ariaLabel:
args.ariaLabel ??
(handlers.variables?.embeddableTitle as string) ??
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,24 @@ export function getDataLayers(layers: XYExtendedLayerConfigResult[]) {
);
}

export function getAccessors<T, U extends { splitAccessor?: T; xAccessor?: T; accessors: T[] }>(
args: U,
table: Datatable
) {
export function getAccessors<
T,
U extends { splitAccessor?: T; xAccessor?: T; accessors: T[]; markSizeAccessor?: T }
>(args: U, table: Datatable) {
let splitAccessor: T | string | undefined = args.splitAccessor;
let xAccessor: T | string | undefined = args.xAccessor;
let accessors: Array<T | string> = args.accessors ?? [];
if (!splitAccessor && !xAccessor && !(accessors && accessors.length)) {
let markSizeAccessor: T | string | undefined = args.markSizeAccessor;

if (!splitAccessor && !xAccessor && !(accessors && accessors.length) && !markSizeAccessor) {
const y = table.columns.find((column) => column.id === PointSeriesColumnNames.Y)?.id;
xAccessor = table.columns.find((column) => column.id === PointSeriesColumnNames.X)?.id;
splitAccessor = table.columns.find((column) => column.id === PointSeriesColumnNames.COLOR)?.id;
accessors = y ? [y] : [];
markSizeAccessor = table.columns.find(
(column) => column.id === PointSeriesColumnNames.SIZE
)?.id;
}

return { splitAccessor, xAccessor, accessors };
return { splitAccessor, xAccessor, accessors, markSizeAccessor };
}

0 comments on commit 34ff430

Please sign in to comment.