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. Image for the cookie policy date

change color of bar in bar chart

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;



1 Reply

RM Ramaraj Marimuthu Syncfusion Team 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

Live Chat Icon For mobile
Up arrow icon