Closed funnel20 closed 1 year ago
I think it is fair to say that this is a feature request rather than a bug since that wasn't an intended feature.
I'll add it to the feature request backlog.
The implementation of this feature in XlsxWriter is incomplete w.r.t. Excel, since it misses the ability to specify the inverted colour. Since I can't get the same functionality (i.e. red negative bars) programmatically as by the menu in Excel, it seems to me like a bug. It would love to see this inverted colour added.
Again, it wasn't an intended feature, or documented behaviour, so its absence isn't a bug.
This feature doesn't even exist in Excel 2007 and the original xlsx specification. It was added in a later version of Excel and the specification. If you convert this to a feature request I will look into it, along with other items on the backlog.
@jmcnamara I've changed the subject. If I can assist you with anything, please let me know. For example finding Excel docu about the constant name for this colour setting.
Thanks. I'll look into it.
I've added this feature to main. You can now use an additional "invert_if_negative_color"
parameter:
import xlsxwriter
workbook = xlsxwriter.Workbook("chart.xlsx")
worksheet = workbook.add_worksheet()
chart = workbook.add_chart({"type": "column"})
worksheet.write_column("A1", [1, 2, -3, 4, -1])
chart.add_series(
{
"values": "=Sheet1!$A$1:$A$5",
"fill": {"color": "red"},
"invert_if_negative": True,
"invert_if_negative_color": "yellow",
}
)
worksheet.insert_chart("C1", chart)
workbook.close()
Output:
Current behavior
Enabling option "invert if negative" in Excel (more info), shows an additional Colour picker to define the Inverted Fill Colour:
This makes it useful to specify 2 colours; for example green for positive and red for negative values:
s
XlsxWriter has the option
invert_if_negative
forchart.add_series()
, but does not allow to specify the Inverted Fill Colour.Hence the negative bars are always coloured white (default), which makes property
invert_if_negative
not very useful:Expected behavior
I expect besides property
fill
, a new property to define the inverted colour wheninvert_if_negative
is set toTrue
, e.g.inverted_fill
.Or instead of 2 parameters for the invert option, change data type of
invert_if_negative
frombool
todict
; just specify a colour likefill
:This allows users to specify both the positive and negative bar colours.
Sample code to reproduce
Environment
Any other information
No response
OpenOffice and LibreOffice users