PieChart边框不显示

问题描述

我正在从事与{python-pptx: change border width for pie chart

相关的类似主题

但是似乎不起作用

def pieChartCreator(slide,categories,series,x,y,cx,cy,fontText = 'Calibri',sizeText = 20,dona="no"):
chart_data = ChartData()
chart_data.categories = categories
chart_data.add_series('Series 1',series)
if dona == "no":
  chart = slide.shapes.add_chart(
    XL_CHART_TYPE.PIE,Inches(x),Inches(y),Inches(cx),Inches(cy),chart_data
  ).chart
else:
  chart = slide.shapes.add_chart(
    XL_CHART_TYPE.DOUGHNUT,chart_data
  ).chart
chart.has_legend = True
chart.legend.position = XL_LEGEND_POSITION.LEFT
chart.legend.include_in_layout = False
chart.plots[0].has_data_labels = True

plotArea = chart._chartSpace.plotArea
# ---get-or-add spPr---
spPrs = plotArea.xpath("c:spPr")
if len(spPrs) > 0:
  spPr = spPrs[0]
else:
  # ---add spPr---
  spPr_xml = (
      "<c:spPr %s %s>\n"
      "  <a:noFill/>\n"
      "  <a:ln>\n"
      "    <a:solidFill>\n"
      "      <a:srgbClr val=\"FFFF00\"/>\n"
      "    </a:solidFill>\n"
      "  </a:ln>\n"
      "  <a:effectLst/>\n"
      "</c:spPr>\n" % (nsdecls("c"),nsdecls("a"))
  )
  spPr = parse_xml(spPr_xml)
  plotArea.insert_element_before(spPr,"c:extLst")
line = LineFormat(spPr)

line.color.rgb = RGBColor.from_string("FFFF00")
line.width = Pt(20)
line.dash_style = MSO_LINE.DASH

我从json文件获取了所有参数,并且可以正常工作,问题出在边框上。我不确定这种实现方法是否正确

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)