scanny / python-pptx

Create Open XML PowerPoint documents in Python
MIT License
2.45k stars 528 forks source link

MSO_LINE.ROUND_DOT Dot Density #332

Open tedwards999 opened 7 years ago

tedwards999 commented 7 years ago

I use the following statement to set the dash style of a specific series on a line chart to ROUND_DOT:

chart.series[2].format.line.dash_style = MSO_LINE.ROUND_DOT

This produces the expected output however the density of the dots on the line differs from the density of dots when using Powerpoint to set the same dash_style. The Python-Pptx version has fewer dots and therefore does not render very clearly.

scanny commented 7 years ago

How are you determining the PowerPoint line you're comparing against has the "same" dash style?

tedwards999 commented 7 years ago

It is also called round dot

On 8 Nov 2017 21:22, "Steve Canny" notifications@github.com wrote:

How do you know you got the matching PowerPoint dash style?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/scanny/python-pptx/issues/332#issuecomment-342930267, or mute the thread https://github.com/notifications/unsubscribe-auth/Ae8nHfAdOIwjrxwU8H3eiNl_eoOWMmKxks5s0f-AgaJpZM4QWUgE .

scanny commented 7 years ago

What are you looking at in the PowerPoint application that says "round dot"? You say you're "using PowerPoint to set the same dash_style" and I'm asking you how you know you're setting it to the same style? The UI on my version doesn't use words, it shows you samples of each line style and the ones I get usually don't match the UI "gallery sample" very well (at all sometimes).

In any case, I think you're going to find this is just a discrepancy between the "official" name of the dash style and the visual appearance of the actual line that gets drawn. I know the dots that I get for round dot are not at all round, for example, they're, actually quite square.

There is a small number of options in the MSO_LINE enumeration (nine to be exact). https://github.com/scanny/python-pptx/blob/master/pptx/enum/dml.py#L112 You could write a short script that creates a shape on a new slide for each of these options so you can see what they look like when rendered.

If you're comparing against an existing PowerPoint shape, I expect you'll find the one you want is there, just named differently. If you're comparing against the gallery samples, I expect you'll scratch your head, like me, wondering where they got those from :)

By the way, the option names come from the Microsoft API here, just pythonized: https://msdn.microsoft.com/en-us/vba/office-shared-vba/articles/msolinedashstyle-enumeration-office

If you do this and find that none of the nine python-pptx-set line styles match one in a manually created shape (not the gallery samples), we can take a closer look at the XML generated by your version of PowerPoint and see what we find there.

SnovnaU commented 2 years ago

Hi Scanny,

unfortunately I was not able to reproduce the "round dot" from Powerpoint either. All other names/values are matching the Powerpoint dash types when producing charts with them and then checking the dash type dropdown in Powerpoint. Only the "round dot" seems to be a maybe outdated version and will not tick anything in the list.

In here are a few more DashStyles, not sure if any of them will match the round dot from Powerpoint: https://docs.microsoft.com/en-us/dotnet/api/microsoft.office.core.msolinedashstyle

My best guess would be the msoLineSysDot. Would you mind looking into that again?