Skip to content

Commit 09c8d69

Browse files
authored
White backgrounds for vega plots (microsoft#13006)
1 parent b1e9031 commit 09c8d69

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/datascience-ui/renderers/render.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export class CellOutput extends React.Component<ICellOutputProps> {
3131
return this.renderImage(mimeBundle, this.props.output.metadata);
3232

3333
default:
34-
return this.renderOutput(data);
34+
return this.renderOutput(data, this.props.mimeType);
3535
}
3636
}
3737
/**
@@ -73,10 +73,13 @@ export class CellOutput extends React.Component<ICellOutputProps> {
7373
</div>
7474
);
7575
}
76-
private renderOutput(data: nbformat.MultilineString | JSONObject) {
76+
private renderOutput(data: nbformat.MultilineString | JSONObject, mimeType?: string) {
7777
const Transform = getTransform(this.props.mimeType!);
78+
const divStyle: React.CSSProperties = {
79+
backgroundColor: mimeType && isAltairPlot(mimeType) ? 'white' : undefined
80+
};
7881
return (
79-
<div>
82+
<div style={divStyle}>
8083
<Transform data={data} />
8184
</div>
8285
);
@@ -87,3 +90,7 @@ export class CellOutput extends React.Component<ICellOutputProps> {
8790
return this.renderOutput(data);
8891
}
8992
}
93+
94+
function isAltairPlot(mimeType: string) {
95+
return mimeType.includes('application/vnd.vega');
96+
}

0 commit comments

Comments
 (0)