Skip to content

Commit efbab33

Browse files
DOC-5991 better tree diagram JS
1 parent ef9cf2f commit efbab33

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

static/js/decision-tree.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@
155155
const charWidth = 8;
156156
const leftMargin = 20;
157157
const topMargin = 10;
158-
const indentWidth = 24;
158+
const indentWidth = 40; // Increased from 24 for wider indent
159159
const boxPadding = 8;
160160
const maxBoxWidth = 280; // Max width for text in box
161161
const maxCharsPerLine = Math.floor(maxBoxWidth / charWidth);
@@ -294,19 +294,20 @@
294294
line.setAttribute('stroke-width', '1');
295295
svg.appendChild(line);
296296

297-
// Horizontal line to child
297+
// Horizontal line to child (extended to match wider indent)
298298
const boxX = x + 10;
299+
const hlineExtension = 15; // Extra space for label
299300
const hline = document.createElementNS('http://www.w3.org/2000/svg', 'line');
300301
hline.setAttribute('x1', connectorX);
301302
hline.setAttribute('y1', y);
302-
hline.setAttribute('x2', boxX);
303+
hline.setAttribute('x2', boxX + hlineExtension);
303304
hline.setAttribute('y2', y);
304305
hline.setAttribute('stroke', '#999');
305306
hline.setAttribute('stroke-width', '1');
306307
svg.appendChild(hline);
307308

308309
// Add answer label on the horizontal line, positioned below it to avoid boxes
309-
const labelX = connectorX + (boxX - connectorX) / 2;
310+
const labelX = connectorX + (boxX + hlineExtension - connectorX) / 2;
310311
const labelY = y + 10;
311312

312313
const label = document.createElementNS('http://www.w3.org/2000/svg', 'text');

0 commit comments

Comments
 (0)