From b300a4decbed65323698afc19f8ef2157ad695d2 Mon Sep 17 00:00:00 2001 From: Brian Mearns Date: Wed, 2 Oct 2019 22:23:30 -0400 Subject: [PATCH] #530 Fit hexagon to width and height The hexagon shape in flow chart now fits the width and height independently, so it can better fit large content without taking up too much space. --- src/diagrams/flowchart/flowRenderer.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/diagrams/flowchart/flowRenderer.js b/src/diagrams/flowchart/flowRenderer.js index 189407909..353400efa 100644 --- a/src/diagrams/flowchart/flowRenderer.js +++ b/src/diagrams/flowchart/flowRenderer.js @@ -362,16 +362,16 @@ export const draw = function(text, id) { }; render.shapes().hexagon = function(parent, bbox, node) { - const w = bbox.width; + const q = 7; + const w = (q / (q - 2)) * bbox.width; const h = bbox.height; - const s = (w + h) * 0.9; const points = [ - { x: s / 4, y: 0 }, - { x: (3 * s) / 4, y: 0 }, - { x: s, y: -s / 2 }, - { x: (3 * s) / 4, y: -s }, - { x: s / 4, y: -s }, - { x: 0, y: -s / 2 } + { x: w / q, y: 0 }, + { x: (w * (q - 1)) / q, y: 0 }, + { x: w, y: -h / 2 }, + { x: (w * (q - 1)) / q, y: -h }, + { x: w / q, y: -h }, + { x: 0, y: -h / 2 } ]; const shapeSvg = parent .insert('polygon', ':first-child') @@ -385,7 +385,7 @@ export const draw = function(text, id) { ) .attr('rx', 5) .attr('ry', 5) - .attr('transform', 'translate(' + -s / 2 + ',' + (s * 2) / 4 + ')'); + .attr('transform', 'translate(' + -w / 2 + ',' + (h * 2) / 4 + ')'); node.intersect = function(point) { return dagreD3.intersect.polygon(node, points, point); };