graphical_properties of PieChart doesn't work

Issue #776 resolved
liuyuqian
created an issue

I tried to add solidFill、pattFill、noFill to the background of piechart,refer to this mail: https://groups.google.com/forum/#!searchin/openpyxl-users/graphicalProperties|sort:relevance/openpyxl-users/ZOQByC-rKJI/BnS3UydCAwAJ

I made several tries,but none of them works,it seems that graphical_properties of PieChart doesn't work,unlike graphical_properties of series.

--------- 1 -------------

props = GraphicalProperties(solidFill="CC0000") 
pie.graphical_properties = props 
pie.plot_area.graphical_properites = props 
pie.graphicalProperties = props
pie.plot_area.graphicalProperties = props

--------- 2 -------------

pie.graphicalProperties = GraphicalProperties(solidFill= drawing.colors.ColorChoice(prstClr='blue'))
pie.plot_area.graphicalProperties = GraphicalProperties(solidFill= drawing.colors.ColorChoice(prstClr='red'))
pie.graphical_properties = GraphicalProperties(solidFill= drawing.colors.ColorChoice(prstClr='blue'))
pie.plot_area.graphical_properties = GraphicalProperties(solidFill= drawing.colors.ColorChoice(prstClr='red'))

--------- 3 -------------

fill =  PatternFillProperties(prst="pct5")
fill.foreground = ColorChoice(prstClr="red")
fill.background = ColorChoice(prstClr="blue")
pie.graphicalProperties.pattFill=fill
pie.plot_area.graphicalProperties.pattFill=fill
pie.graphical_properties.pattFill=fill
pie.plot_area.graphical_properties.pattFill=fill

Thanks~

Comments (8)

  1. CharlieC

    Thanks for the report. It looks like that this should work in principle but, in practice, the plot area is overwritten in the _write() method of the chart. If this line is commented out then it's possible to format the plot area using "1" and "2" but not "3" (the fill is not acceptable). However, the result might not be quite what you expect. I'm happy to extend the functionality but only as long as we can provide a clear API on its use and someone else should write the documentation.

  2. liuyuqian reporter

    Thanks!Mr Clark,I'm sorry about making a test until now. The new _write() method can change the style of plot area correctly But GraphicalProperties still can't change the background of chart,such as:

    props = GraphicalProperties(solidFill="CC0000") 
    pie.graphicalProperties = props
    
  3. liuyuqian reporter

    I've found how to solve this issue,but I still don't know how to use mercurial to submit code... change line 127 in _chart.py: before:

    cs = ChartSpace(chart=container)
    

    after:

    cs = ChartSpace(chart=container,spPr=self.graphical_properties)
    
  4. sriiyer

    Hi, Having a problem with setting the plot area color of a scatter chart. The chart area color works fine, however. Tried different combinations as shown below, also tried changing the order in which I set, nothing seems to help with changing the plot area color. What am I doing wrong here? Tried the following:

    props = GraphicalProperties(solidFill = drawing.colors.ColorChoice(prstClr="grey")) --> this does not work
        #props = GraphicalProperties(solidFill="CC0000") --> neither does this
        chart.plot_area.graphicalProperties = props
    
        props = GraphicalProperties(solidFill = drawing.colors.ColorChoice(prstClr="grey"))
        chart.graphical_properties = props
    

    Also, the chart.scatterStyle = "smooth" also does not take effect. Tried out all the possible combinations from: scatterStyle = ['marker', 'smoothMarker', 'line', 'smooth', 'lineMarker'] but it does not work.

    Tried openpyxl 2.3.1, 2.3.5 and 2.4.5. Changes the chart.py in line 127 to cs = ChartSpace(chart=container,spPr=self.graphical_properties)

    Also what is chart.style?

    Thanks

  5. Log in to comment