Question

Bar Color

Posted 5 months ago by Avatar Jerin Sebastian

How do you change the Bar color of a Bar chart through C# code?


Comments (4)

Posted 5 months ago by Actipro Software Support - Cleveland, OH, USA

Hello Jerin,

Please take a look at the XY / BarStyles QuickStart in the samples.  If you have your XYChart.SeriesStyleSelector property set to a SeriesPaletteStyleSelector instance, you can set properties like BarBrushCustom to indicate a specific brush for all bars.

Or alternatively the BarSeries class has BarStyle and BarTemplate properties.  The BarStyle property can be set to a Style targeting Border that has Background and BorderBrush properties set.  That can be set up in code.

If you want to have total control over what each individual bar looks like, you can inherit SeriesPaletteStyleSelector and override its SelectBarStyle method to return an appropriate Style.


Actipro Software Support
Posted 5 months ago by Jerin Sebastian

It worked.

Thanks for the support.

Posted 5 months ago by Jerin Sebastian

Even though the bar color changed but the Legend color didn't change.

How do we fix that?

See the below link to see the screenshot.

https://drive.google.com/open?id=1OdVxY7sEUCq8sVtzZO3aBFCO0xDduvwO

Posted 5 months ago by Actipro Software Support - Cleveland, OH, USA

Hi Jerin,

The legend swatch is generated from the SeriesStyleSelector.SelectLegendMarkerStyle method.  If you are using SeriesPaletteStyleSelector, it will base the legend swatch on the palette color that is selected for that particular series.  Using a custom Palette with a SeriesPaletteStyleSelector is another way that also will affect the bars and the legend together.  You can define a set of base colors (one per series) in the Palette and have the SeriesPaletteStyleSelector use it.


Actipro Software Support
Information The latest build of this product (2018.1 build 0671) was released 1 month ago, which was after the last post in this thread.

Add a Comment

Please log in to a validated account to post comments.