Jump to content

Extracting chart colors from line chart with python

Doug Blackwell

Recommended Posts

I need to extract the line colors in hex format from a line chart, but when I use the below code to put the categories and colors into a dictionary, it gets cut off (I have around 5000 different categories). Is there some kind of limit on the length of lists in IronPython

Note that I don't need all of these categories, only those shown on the legend (of which there are 4) and the chart is filtered using the show/hide filter, not a filtering scheme.

Is there some way I can access the colors and textin the legend via python/javascript

visCont = vis.As[VisualContent]()

color_dict = {}

for x in visCont.ColorAxis.Coloring.AddCategoricalColorRule().GetExplicitCategories():

color = visCont.ColorAxis.Coloring.GetColorForCategory(x)

color_dict[str(x)] = str('%02x%02x%02x' % (color.R, color.G, color.B))

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...