rtalbot89 / flow-svg

Create simple interactive and static flow charts using JavaScript and SVG.
MIT License
62 stars 26 forks source link

How to change 'decision' shape from polygon to rectangle? #8

Open laurfler opened 4 years ago

laurfler commented 4 years ago

I'm a noob and really struggling with changing the 'decision' shape to a rectangle, similar to the 'finish' shape. Also, how would I add a stroke to this shape?

To change the shape I believe I need to alter the function decision(options) but am not sure what the code needs to be changed to.

Apologies for the simple question but any help would be appreciated.

rtalbot89 commented 4 years ago

The definition of the 'finish' shape is in the variables at the start of the 'finish' function. i.e. rect = group .rect(config.finishWidth, config.finishHeight) .attr({ fill: config.finishFill, "class": "fc-finish" }).radius(20), Use this to change the definition of the 'shape' variable near the top of the 'decision' function. i.e. shape = group .rect(config.finishWidth, config.finishHeight) .attr({ fill: config.finishFill, "class": "fc-finish" }).radius(20); Note that you will need to finish the variable with a semi-colon as it's the final one in the list.

To add a stroke to the shape, add something like this property / value pair inside 'attr' for the shape stroke: config.tipStrokeColour, The value here is from the config, but can be any valid colour.

If you want to change the stroke width you can add something like this to 'attr' as well. Note that 'stroke-width' is a string inside quotes: 'stroke-width' : 2,