I have a chart I've created using openpyxl. Everything turns out as expected, however I would like to hide the data points from the legend while keeping their formats in the chart. In short, I would like to hide/remove all of the data points from the right hand side of the chart while preserving the colors of the bars.
Here's a snippet of code used to build the chart:
chart1 = BarChart()
series = chart1.series[0]
ndcs = Set()
scfs = Set()
for i, row in enumerate(results):
if 'DNDC' in row[0]: ndcs.add(i-1)
if 'DSCF' in row[0]: scfs.add(i-1)
for index in ndcs:
fill = PatternFillProperties(prst="pct5")
fill.background = ColorChoice(prstClr="red")
pt = DataPoint(idx=index)
pt.graphicalProperties.pattFill = fill
series.dPt.append(pt)
for index in scfs:
fill = PatternFillProperties(prst="pct5")
fill.background = ColorChoice(prstClr="blue")
pt = DataPoint(idx=index)
pt.graphicalProperties.pattFill = fill
series.dPt.append(pt)
FWIW, I tried to follow the example from the docs here, however I couldn't find anything specific about hiding the information on the legend.
My question is, what members/attributes will I need to toggle off to hide the data points from showing on my legend while preserving the colors of the bars?
I have to dive into the source code, the documentation is seriously lacking.
Try:
chart1.legend = None
I think you need to set chart.legend.delete = True
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With