We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

change color of bar in bar chart

Thread ID:





132882 Sep 26,2017 10:44 PM UTC Sep 27,2017 12:22 PM UTC ASP.NET MVC 1
Tags: Presentation
Miranda Johnson
Asked On September 26, 2017 10:44 PM UTC

I am trying to change the color of all of the bars in this chart.  I thought that I had found the answer but it is not changing from the default blue color.

here is my code 
// Add a chart
stream = new FileStream(file, FileMode.Open);
stream.Position = 0;

//Gets the worksheet
IWorksheet worksheet19 = destworkbook.Worksheets[0];
worksheet19.UsedRangeIncludesFormatting = false;

//Get The range of values
var saData = worksheet19.UsedRange;
//create new slide showing chart
ISlide saSlide = presentation.Slides.Add(SlideLayoutType.Blank);
IPresentationChart saChart = saSlide.Charts.AddChart(stream, 1, saData.Address, new Rectangle(30, 15, 850, 500));
saChart.ChartType = Syncfusion.OfficeChart.OfficeChartType.Column_Clustered_3D;
saChart.HasLegend = false;
saChart.ChartTitle = "Rate For Strongly Agree";
saChart.PrimaryValueAxis.Title = "Percentage Strongly Agree";
saChart.PrimaryValueAxis.MinimumValue = 0;
saChart.PrimaryValueAxis.MaximumValue = 100;
IOfficeChartFrameFormat saPlotArea = saChart.PlotArea;
saPlotArea.Fill.BackColor = Color.Green;



Ramaraj Marimuthu [Syncfusion]
Replied On September 27, 2017 12:22 PM UTC

Hi Miranda,

Thanks for contacting Syncfusion support.

To set the individual different colors for every bar in a bar chart we have to set the color for individual series. Please use a below code snippet for the same.

saChart.Series[0].DataPoints.DefaultDataPoint.DataFormat.Fill.ForeColor = Color.Green; 
saChart.Series[1].DataPoints.DefaultDataPoint.DataFormat.Fill.ForeColor = Color.GreenYellow; 
saChart.Series[2].DataPoints.DefaultDataPoint.DataFormat.Fill.ForeColor = Color.Aqua; 

Output Presentation - Generated PPTX

We could see that you have used the below code snippet to set the background color. But this is applicable only for setting the background color for plot area with pattern fill.

IOfficeChartFrameFormat saPlotArea = saChart.PlotArea;            saPlotArea.Fill.BackColor = Color.Green; 

If you want to set a background color for the chart plot area other than these patter fill types, you can use the below code snippet this.

IOfficeChartFrameFormat saPlotArea = saChart.PlotArea;            saPlotArea.Fill.ForeColor = Color.Green; 

Please let us know if you need any further assistances in this.


Ramaraj Marimuthu


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon