Skip to content

Commit

Permalink
Merge pull request #20 from DylanHojnoski/per_graph_settings
Browse files Browse the repository at this point in the history
Per graph settings
  • Loading branch information
DylanHojnoski authored Jun 29, 2024
2 parents f2cc89d + 49fad6f commit 2e2d7f4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ export interface GraphInfo {
defaultAxes: any,
drag: boolean,
elements: ElementInfo[],
// plugin specific settings
height: number | undefined,
width: number | undefined,
}

export interface ElementInfo {
Expand Down
11 changes: 10 additions & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ export function parseCodeBlock(source: string) :GraphInfo {
drag: true,
showNavigation: true,
axis: true, defaultAxes: JXG.Options.board.defaultAxes,
elements: []};
elements: [],
height: undefined,
width: undefined};

// there is nothing inside of the codeblock
if (source == null || source == "") {
Expand Down Expand Up @@ -76,6 +78,13 @@ export function createBoard(graphDiv: HTMLElement, graphInfo: GraphInfo) :Board
theme: 'obsidian',
keepAspectRatio: graphInfo.keepAspectRatio});

if (graphInfo.height) {
graphDiv.style.height = graphInfo.height + "px";
}
if (graphInfo.width) {
graphDiv.style.maxWidth = graphInfo.width + "px";
}

return graph;
}

Expand Down

0 comments on commit 2e2d7f4

Please sign in to comment.