1

I am trying to generate line chart using python-pptx, and I am able to generate chart using below code.

chart_data = ChartData()
chart_data.categories = ['Q1 Sales', 'Q2 Sales', 'Q3 Sales']
chart_data.add_series('West',    (32.2, 28.4, 34.7))
chart_data.add_series('East',    (24.3, 30.6, 20.2))
chart_data.add_series('Midwest', (20.4, 18.3, 26.2))

x, y, cx, cy = Inches(2), Inches(2), Inches(6), Inches(4.5)
chart = slide.shapes.add_chart(
    XL_CHART_TYPE.LINE, x, y, cx, cy, chart_data
).chart

chart.has_legend = True
chart.legend.include_in_layout = False

This will generate a graph like this http://python-pptx.readthedocs.org/en/latest/_images/chart-06.png a line series with three points.

My requirement is- for "East" I don't have second point, so the line for "East" should be a breaking line, only two point will show first and third.

I tried below by making it empty but didn't work

chart_data.add_series('East',    (24.3, "", 20.2))

Is there any way to achieve this? Its possible in high charts but not supported in ppt.

I am trying to achieve something like this: enter image description here

Thanks in advance.

A J
  • 3,684
  • 2
  • 19
  • 24
  • I think as of now there is no support in python-pptx. – A J Apr 01 '16 at 10:07
  • 1
    What do you mean by "It's possible in *high* charts .."? What is a high chart? Also, what do you mean ".. but not supported in ppt."? – scanny Apr 01 '16 at 17:51
  • Just to make everyone understand my requirement, I tried in high charts for discontinued line attached a image for same. Secondly, I tried with empty values in PPT but it didn't work. I know both are different library for different language. – A J Apr 02 '16 at 01:22
  • 1
    How about passing in None instead of an empty string? – Varun Dec 06 '18 at 19:58

1 Answers1

0

I ran into the same issue and when I passed None into python-pptx I got the gaps just like in highcharts.

That is, instead of passing in an empty string pass in None.

  • This does not seem to provide an answer to the question. You can search for similar questions, or refer to the related and linked questions on the right-hand side of the page to find an answer. If you have a related but different question, ask a new question, and include a link to this one to help provide context. See [How do I ask a good question?](https://stackoverflow.com/help/how-to-ask) – Alain Merigot Jan 30 '19 at 22:01