Jump to content

How to set the color by of a barchart using hexadecimal codes via ironpython?


Prateek Rawat 3

Recommended Posts

I am using below script to set the colors in a bar graph. The problem is that it does not allow me to give hexadecimal values:

How can the color hexadecimal code be used in below script instead of color name?

from System.Collections.Generic import List

from Spotfire.Dxp.Framework.Library import *

#add a script parameter lchart referring to a visualization

chart_a=achart.As[barChart]()

chart_b=bchart.As[barChart]()

chart_c=cchart.As[barChart]()

chart_a.ColorAxis.Expression = "<[Axis.Default.Names]>"

chart_b.ColorAxis.Expression = "<[Axis.Default.Names]>"

chart_c.ColorAxis.Expression = "<[Axis.Default.Names]>"

#Get Categories based on expression

keys1=List[CategoryKey]()

keys1=chart_a.ColorAxis.Coloring.AddCategoricalColorRule().GetExplicitCategories()

keys2=List[CategoryKey]()

keys2=chart_b.ColorAxis.Coloring.AddCategoricalColorRule().GetExplicitCategories()

keys3=List[CategoryKey]()

keys3=chart_c.ColorAxis.Coloring.AddCategoricalColorRule().GetExplicitCategories()

#Add colors to each category

chart_a.ColorAxis.Coloring.SetColorForCategory(keys1[0], Color.FromName("green"))

chart_a.ColorAxis.Coloring.SetColorForCategory(keys1[1], Color.FromName("darkblue"))

chart_a.ColorAxis.Coloring.SetColorForCategory(keys1[2], Color.FromName("pink"))

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...