Select to view content in your preferred language

No 'showDataLabels' in arcpy.charts for Bar charts?

174
3
Jump to solution
07-02-2024 07:46 AM
Labels (1)
JasonBennett
New Contributor III

I'm using python to create bar charts and export them to SVG. This is no problem. The only issue I have is that I would like the top of each bar to display the value. If you create the bar chart manually in ArcGIS Pro, there is a little checkbox under Data Labels called Label bars.

JasonBennett_1-1719931163443.png

 

However, this does not seem to be exposed to Python. I tried this:

 

chart = arcpy.charts.Bar(x=count_field, y=count_field, aggregation='count', showDataLabels=True, dataSource=input_feature)

 

 

showDataLabels does not appear to be a valid parameter. I get this error:

TypeError: Bar.__init__() got an unexpected keyword argument 'showDataLabels'  

 

showDataLabels works for Pie charts. So I want to verify that there is no way to enable these labels.

Tags (3)
0 Kudos
1 Solution

Accepted Solutions
ChristopherAllen
Esri Contributor

Hi @JasonBennett ,

Thanks for the question. You are correct that the functionality to show data labels is not currently exposed for the `Bar` class, but this enhancement is on our near-term radar. 

Thanks,

Chris

View solution in original post

0 Kudos
3 Replies
ChristopherAllen
Esri Contributor

Hi @JasonBennett ,

Thanks for the question. You are correct that the functionality to show data labels is not currently exposed for the `Bar` class, but this enhancement is on our near-term radar. 

Thanks,

Chris

0 Kudos
JasonBennett
New Contributor III

Thanks for the answer, Chris. Any chance there are plans to allow exports to other formats like PNG?

0 Kudos
ChristopherAllen
Esri Contributor

Hi @JasonBennett ,

Adding functionality to export an ArcPy chart to PNG (and JPG) is on our near-term radar also. I've made a note of your request so that we can prioritize accordingly. In the meantime, we suggest using a third-party Python module such as cairosvg to convert SVG to PNG.

Take care,

Chris

 

0 Kudos