AnsweredAssumed Answered

Python code to update Chart fonts and text in ArcGIS Pro

Question asked by swapphead039 on Jun 12, 2018

I am looking for some python code to update the text and fonts for about 28 bar charts.  I have the code to autogenerate the bar charts in python but did not see any reference to updating text in the ArcGIS Pro Chart Arcpy reference guide or code snippets. Here is what I have to generate the charts.  I tried to add tags inside the field definitions but that did not work.

import arcpy
aprx = arcpy.mp.ArcGISProject("current")
map = aprx.listMaps()[0]
indicatorLayer1 = map.listLayers()[0]
indicatorLayer2 = map.listLayers()[1]
print (indicatorLayer1, indicatorLayer2)
for x in range (1, 7):
    c = arcpy.Chart('MyChart'+ str(x))
    c.type = 'bar'
    c.legend.visible = "True"
    c.title = "Zone" + str(x) + " - Rivers, Streams, and Canals (2015 to 2017)"
    c.description = "CHL=Chlorophyll a, DO = Dissolved Oxygen, FC=Fecal Coliform, pH=hydrogen ion concentration, TN=Total Nitrogen, TP=Total Phosphorus, UIA=Un-ionized Ammonia"
    c.xAxis.field = 'Indicator'
    c.xAxis.sort = 'ASC'
    c.xAxis.title = 'Indicator'
    c.yAxis.field = 'Zone' + x
    c.yAxis.title = 'Percent Meeting Threshold'
    c.addToLayer(indicatorLayer1)
    ##additional chart mods
    ##updates to the chart
    c.bar.splitCategory = 'ResourceFullName'
    c.bar.aggregation = 'SUM'
    c.updateChart()

 

Any help would be appreciated. I am using the Chart tab format ribbon to update the styles and fonts manually but thought there must be some Python code exposed to change this in a script.

Outcomes