Skip to content

Commit

Permalink
Merge pull request cBioPortal#127 from cBioPortal/custom-max-height
Browse files Browse the repository at this point in the history
Allow setting max height in initialization
  • Loading branch information
adamabeshouse authored and onursumer committed May 27, 2022
1 parent da7dab9 commit 0b6c05d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/oncoprintjs/src/js/oncoprint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export type InitParams = {
init_vert_zoom?: number;
init_track_group_padding?: number;
init_cell_padding_on?: boolean;
max_height?:number;
};

export type HorzZoomCallback = (zoom:number)=>void;
Expand Down
9 changes: 7 additions & 2 deletions packages/oncoprintjs/src/js/oncoprintmodel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ export default class OncoprintModel {
this.sort_config = {};
this.rendering_suppressed_depth = 0;

this.max_height = 500;
this.max_height = ifndef(params.max_height, 500);
this.cell_width = ifndef(params.init_cell_width, 6);
this.horz_zoom = ifndef(params.init_horz_zoom, 1);
this.vert_zoom = ifndef(params.init_vert_zoom, 1);
Expand Down Expand Up @@ -715,7 +715,12 @@ export default class OncoprintModel {
public getMinVertZoom() {
// Can't zoom to be smaller than max height
// That zoom would be z*this.getOncoprintHeight(true) = max_height
return this.max_height / this.getOncoprintHeight(true);
if (this.max_height < Number.POSITIVE_INFINITY) {
return this.max_height / this.getOncoprintHeight(true);
} else {
// if no max height, then cant vert zoom
return 1;
}
}

public setHorzScroll(s:number) {
Expand Down

0 comments on commit 0b6c05d

Please sign in to comment.