scanny / python-pptx

Create Open XML PowerPoint documents in Python
MIT License
2.26k stars 499 forks source link

Set Category Axis tickMarkSkip #886

Open OptrixAU opened 1 year ago

OptrixAU commented 1 year ago

There doesn't seem to be a way to manually or automatically set the tickMarkSkip value on the category axis of a chart.

This is particularly important when you're doing line charts with large numbers of points. For example, my charts have between 1000 and 2000 points, and in most cases the X-axis and the whole chart becomes solid black because of all the major gridlines.

I've created a simple method for automatically generating a suitable value for tickMarkSkip, and I've made a very basic hack with https://github.com/OptrixAU/python-pptx, but this isn't usable for the public.

Happy to complete the fix myself. I'd suggest adding a tickMarkSkip property to the CategoryAxis class, and perhaps a helper function to calculate the ideal skip value for the current set of categories - but while I can see the chart_data in the code that creates the XML for the chart, I'm not sure how I get access to the category axis settings in the _cat_ax_xml function of _LineChartXMLWriter.