Skip to content

Commit

Permalink
feat: allow use of functions for y, y0, split and stack accessors (op…
Browse files Browse the repository at this point in the history
  • Loading branch information
nickofthyme authored Dec 9, 2020
1 parent 3d1281b commit e881723
Show file tree
Hide file tree
Showing 14 changed files with 4,857 additions and 545 deletions.
16 changes: 10 additions & 6 deletions packages/osd-charts/api/charts.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -1474,11 +1474,11 @@ export type ScaleType = $Values<typeof ScaleType>;
// @public (undocumented)
export interface SeriesAccessors {
markSizeAccessor?: Accessor | AccessorFn;
splitSeriesAccessors?: Accessor[];
stackAccessors?: Accessor[];
splitSeriesAccessors?: (Accessor | AccessorFn)[];
stackAccessors?: (Accessor | AccessorFn)[];
xAccessor: Accessor | AccessorFn;
y0Accessors?: Accessor[];
yAccessors: Accessor[];
y0Accessors?: (Accessor | AccessorFn)[];
yAccessors: (Accessor | AccessorFn)[];
}

// @public (undocumented)
Expand Down Expand Up @@ -1870,7 +1870,11 @@ export interface TooltipValue {
export type TooltipValueFormatter = (data: TooltipValue) => JSX.Element | string;

// @public
export type UnaryAccessorFn<Return = any> = (datum: Datum) => Return;
export interface UnaryAccessorFn<Return = any> {
// (undocumented)
(datum: Datum): Return;
fieldName?: string;
}

// @public (undocumented)
export type UnboundedDomainWithInterval = DomainBase;
Expand Down Expand Up @@ -1933,7 +1937,7 @@ export interface XYChartSeriesIdentifier extends SeriesIdentifier {
// (undocumented)
splitAccessors: Map<string | number, string | number>;
// (undocumented)
yAccessor: string | number;
yAccessor: Accessor;
}

// @public
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 27 additions & 0 deletions packages/osd-charts/integration/tests/bar_stories.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,4 +200,31 @@ describe('Bar series stories', () => {
});
});
});

describe('functional accessors', () => {
it('functional accessors with fieldName', async () => {
await common.expectChartAtUrlToMatchScreenshot(
'http://localhost:9001/?path=/story/bar-chart--functional-accessors&knob-y fn name=testY&knob-split fn name=testSplit',
);
});

it('functional accessors with fieldName - with tooltip', async () => {
await common.expectChartWithMouseAtUrlToMatchScreenshot(
'http://localhost:9001/?path=/story/bar-chart--functional-accessors&knob-y fn name=testY&knob-split fn name=testSplit',
{
top: 60,
right: 180,
},
{
screenshotSelector: 'body',
},
);
});

it('y1Accessors and y0Accessors', async () => {
await common.expectChartAtUrlToMatchScreenshot(
'http://localhost:9001/?path=/story/bar-chart--band-bar-chart&knob-fit Y domain=true&knob-use fn accessors=true',
);
});
});
});
Loading

0 comments on commit e881723

Please sign in to comment.