Skip to content

Commit

Permalink
fix: do not ignore config.title.angle/limit (#7667)
Browse files Browse the repository at this point in the history
Co-authored-by: GitHub Actions Bot <vega-actions-bot@users.noreply.github.com>
  • Loading branch information
kanitw and GitHub Actions Bot authored Aug 30, 2021
1 parent c10efdf commit 874b7e5
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/compile/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ export abstract class Model {
const {encoding, ...titleNoEncoding} = this.title ?? ({} as TitleParams<SignalRef>);

const title: VgTitle = {
...extractTitleConfig(this.config.title).nonMark,
...extractTitleConfig(this.config.title).nonMarkTitleProperties,
...titleNoEncoding,
...(encoding ? {encode: {update: encoding}} : {})
};
Expand Down
15 changes: 10 additions & 5 deletions src/title.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ export interface TitleParams<ES extends ExprRef | SignalRef> extends TitleBase<E
export function extractTitleConfig(titleConfig: TitleConfig<SignalRef>): {
titleMarkConfig: MarkConfig<SignalRef>;
subtitleMarkConfig: MarkConfig<SignalRef>;
nonMark: BaseTitleNoValueRefs<SignalRef>;
/** These are non-mark title config that need to be hardcoded in the title directive. */
nonMarkTitleProperties: BaseTitleNoValueRefs<SignalRef>;
subtitle: BaseTitleNoValueRefs<SignalRef>;
} {
const {
Expand All @@ -74,6 +75,8 @@ export function extractTitleConfig(titleConfig: TitleConfig<SignalRef>): {
frame,
offset,
orient,
angle,
limit,

// color needs to be redirect to fill
color,
Expand All @@ -97,11 +100,13 @@ export function extractTitleConfig(titleConfig: TitleConfig<SignalRef>): {
};

// These are non-mark title config that need to be hardcoded
const nonMark: BaseTitleNoValueRefs<SignalRef> = {
const nonMarkTitleProperties: BaseTitleNoValueRefs<SignalRef> = {
...(anchor ? {anchor} : {}),
...(frame ? {frame} : {}),
...(offset ? {offset} : {}),
...(orient ? {orient} : {})
...(orient ? {orient} : {}),
...(angle !== undefined ? {angle} : {}),
...(limit !== undefined ? {limit} : {})
};

// subtitle part can stay in config.title since header titles do not use subtitle
Expand All @@ -115,9 +120,9 @@ export function extractTitleConfig(titleConfig: TitleConfig<SignalRef>): {
...(subtitlePadding ? {subtitlePadding} : {})
};

const subtitleMarkConfig = pick(titleMarkConfig, ['align', 'baseline', 'dx', 'dy', 'limit']);
const subtitleMarkConfig = pick(titleConfig, ['align', 'baseline', 'dx', 'dy', 'limit']);

return {titleMarkConfig, subtitleMarkConfig, nonMark, subtitle};
return {titleMarkConfig, subtitleMarkConfig, nonMarkTitleProperties: nonMarkTitleProperties, subtitle};
}

export function isText(v: any): v is Text {
Expand Down
1 change: 1 addition & 0 deletions test/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ describe('config', () => {
baseline: 'middle',
dx: 5,
dy: 5,
angle: 1,
limit: 5
},
boxplot: {
Expand Down
8 changes: 8 additions & 0 deletions test/title.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import {extractTitleConfig} from '../src/title';
describe('title', () => {
describe('extractTitleConfig', () => {
it('extract angle and limit of config.title as title property', () => {
expect(extractTitleConfig({angle: 1, limit: 5}).nonMarkTitleProperties).toEqual({angle: 1, limit: 5});
});
});
});

0 comments on commit 874b7e5

Please sign in to comment.