PptxGenJS icon indicating copy to clipboard operation
PptxGenJS copied to clipboard

Shapes: How to add vertical lines

Open simonjcarr opened this issue 8 years ago • 6 comments

If I try to add a vertical line with the following command for example

slide.addShape(pptx.shapes.LINE, { x:14 , y:8.20, w:0, h:3.50, line:'FF0000', line_size:1});

The line is drawn at an angle and I have to add a rotate option, this would not be too bad, but sometimes I have to add a rotation of 5 and other times a rotation of 15.

The only work around I have found is to draw a horizontal line and then rotate it, but that means you have to start doing calculations to work out offsets because the line is rotated from it's center point.

simonjcarr avatar Jan 20 '18 16:01 simonjcarr

Incase it helps anyone else, and until I find another solution to this problem, I have put a simple app online to calculate the coords for vertical lines.

https://pptx-position-calc.appspot.com/#/

simonjcarr avatar Jan 21 '18 00:01 simonjcarr

This seems to be a bug.

MickaToast avatar Apr 11 '18 19:04 MickaToast

Hi All,

The addShape()method is being called incorrectly. Lines should be a given w and zero height.

// Correct
slide.addShape(pptx.shapes.LINE, { x:1 , y:1, w:3.5, h:0, line:'FF0000', line_size:1});

// Incorrect
slide.addShape(pptx.shapes.LINE, { x:1 , y:1, w:0, h:3.5, line:'00FF00', line_size:1});

screen shot 2018-04-16 at 22 54 24

Line API

gitbrent avatar Apr 17 '18 03:04 gitbrent

@gitbrent The problem here is that everyone is trying to create vertical line. They can be created but since rotation is done from the center point of a line, it's really hard to create them. I think this should be explained somewhere or maybe you should change lines rotating from their center points. I think, with a rotation or without, the line should always start from its coordinates {x, y}

MickaToast avatar Apr 19 '18 18:04 MickaToast

Oh dang it, it's a defect. Setting a zero w and a >0 h should draw a vertical line

Thanks for the feedback, I completely mistook what you reported.

Fixed in 2.2.0-beta now.

slide.addShape(pptx.shapes.LINE, { x:1 , y:1, w:0, h:5, line:'FF0000', line_size:1});

screen shot 2018-04-19 at 18 46 04

gitbrent avatar Apr 19 '18 23:04 gitbrent

Seems like it's still not working in 2.2.0

MickaToast avatar Jul 03 '18 15:07 MickaToast