Skip to content

Commit

Permalink
Add comments
Browse files Browse the repository at this point in the history
Signed-off-by: Tyler Ohlsen <ohltyler@amazon.com>
  • Loading branch information
ohltyler committed May 24, 2023
1 parent 12b34fd commit 991ceae
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/plugins/vis_type_vega/public/expressions/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ export const cleanString = (rawString: string): string => {
return rawString.replaceAll('"', '');
};

// When using autosize features of vega-lite, the chart is expected to reposition
// correctly such that there is space for the chart and legend within the canvas.
// This works for horizontal positions (left/right), but breaks for vertical positions
// (top/bottom). To make up for this, we set the offset to 0 for these positions such that
// the chart will not get truncated or potentially cut off within the canvas.
export const calculateLegendOffset = (legendPosition: string): number =>
// 18 is the default offset as of vega lite 5
legendPosition === 'top' || legendPosition === 'bottom' ? 0 : 18;
Expand Down
3 changes: 3 additions & 0 deletions src/plugins/vis_type_vega/public/vega_view/vega_base_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,9 @@ export class VegaBaseView {
// space and leave enough space to show the bottom view (the events vis).
// Ref: https://vega.github.io/vega-lite/docs/size.html#limitations
addPointInTimeEventPadding(view) {
// This value represents the pixel height of the event canvas. It is determined
// based on the event mark size, such that there is sufficient but minimal space
// needed to render the event marks.
const eventVisHeight = 100;
const height = Math.max(0, this._$container.height()) - eventVisHeight;
if (view._signals.concat_0_height !== undefined) {
Expand Down

0 comments on commit 991ceae

Please sign in to comment.