Skip to content

Commit

Permalink
Add tests and fix issues
Browse files Browse the repository at this point in the history
  • Loading branch information
yoonieaj committed Jun 28, 2024
1 parent 7a0775b commit 0250101
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ and adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
- Fixed a bug where box fill colours would cover box text, and changed the implementation of `hide` style option.
- Removed double quotes when rendering objects of type `None`.
- Removed double quotes when rendering objects that are not of type `str`.
- Fixed issue where diagrams would not render when width inputs to `draw()` were too small.

### 📚 Documentation and demo website changes

Expand Down
16 changes: 9 additions & 7 deletions memory-viz/src/automate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,18 @@ function drawAutomated(objects: DrawnEntity[], width, configuration) {
let item_width;
for (const item of other_items) {
item_width = getSize(item).width;
min_width = item_width > min_width ? item_width : min_width;
if (item_width > min_width) {
min_width = item_width;
}
}

min_width +=
requiredWidth + configuration.padding + configuration.left_margin;
min_width += requiredWidth + 2 * configuration.padding + 1;

if (width < min_width) {
console.warn(
`Warning: provided width (${width}) is smaller than the minimum width of the canvas (${min_width}).`
console.log(
`WARNING: provided width (${width}) is smaller than the minimum width` +
` of the canvas (${min_width}). The provided width has been overwritten` +
` in the generated diagram.`
);
width = min_width;
}
Expand Down Expand Up @@ -116,7 +119,7 @@ function drawAutomatedStackFrames(stack_frames: DrawnEntity[], configuration) {
min_required_height = height + min_required_height;
}

required_width += configuration.padding;
required_width += configuration.left_margin;

return {
StackFrames: draw_stack_frames,
Expand Down Expand Up @@ -206,7 +209,6 @@ function drawAutomatedOtherItems(
let curr_row_objects = [];
for (const item of objs) {
let hor_reach = x_coord + item.width + PADDING;

if (hor_reach < max_width) {
item.x = x_coord;
item.y = y_coord;
Expand Down
Loading

0 comments on commit 0250101

Please sign in to comment.