custom data labels in xlsxwriter
Asked Answered
S

1

7

I am create a fairly complicated graph using xlsxwriter and I need the data labels to be different than the values of the data looking through the documentation, I see that I can add data labels the following way

chart2.add_series({
    'name':       '=Sheet1!$J$1',
    'categories': '=Sheet1!$A$2:$A$22',
    'values':     '=Sheet1!$J$2:$J$22',
    'data_labels': {values: True}
})

The problem is that the data labels for my graph need to be different than the values, I need to point to a different part of the sheet to get my labels something like:

'data_labels': 'values_from_cells'=Sheet1!$K$2:$K$22

within Excel this is very easy to do, 1. right click on the graph,

  1. right click format data labels

  2. label contains: values from cells

  3. I then select the cells I want and it creates the data labels

is this a functionality of xlsxwriter?

Scyphozoan answered 15/12, 2015 at 23:58 Comment(8)
Unfortunately that feature isn't supported.Resect
will it be at some point @Resect ?Glimpse
Probably. But probably not in the short term.Resect
Thanks for the answer! xlsxWriter is a great library and I understand that not every feature can be unsupported, and Excel is tough to code around I certainly don't know enough to implement it myself so thank you!Scyphozoan
@Resect any updates?Ill
@Ill It will probably be added in the next month or two. There is a GitHub Feature Request for it. If you add a +1 comment or watch the thread you will get an update when the feature is implemented.Resect
@Resect Thanks for information, visited the thread, added comment in it. Have a nice day!Ill
You made a typo in the code you show, you need to write: 'data_labels': {'value': True}. However this does not solve your problem.Gantrisin
U
1

Custom Data Labels

The custom data label property is used to set the properties of individual data labels in a series.

I think that is what you searched for and i found the documentation here: https://xlsxwriter.readthedocs.io/working_with_charts.html

Just search for "Custom Data Labels" and the first big Heading should be it.

Udale answered 4/8, 2022 at 6:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.