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

Colors for bar chart

Thread ID:





55325 Jan 29,2007 03:12 AM UTC Jan 30,2007 11:13 AM UTC ASP.NET Web Forms (Classic) 1
Tags: Chart
Carl Ganz Jr.
Asked On January 29, 2007 03:12 AM UTC

I'm creating the bar chart using the code below. I simply need to know how to set the colors for the different areas of each bar.
Any ideas?



'Adding a New(Embedded chart) to the WorkoWS
Dim shape As IChartShape = oWS.Charts.Add()shape.ChartType = ExcelChartType.Column_Stacked'Specify the data range.shape.DataRange = oWS.Range("B" + sTopRow.ToString + ":D" + (sRow - 1).ToString)

'Setting the Serie Names in a Legend
Dim serieOne As IChartSerie = shape.Series(0)
serieOne.Name = "Completed"
serieOne.CategoryLabels = oWS.Range("A" + sTopRow.ToString + ":A" + (sRow - 1).ToString)
serieOne.DataPoints.DefaultDataPoint.DataLabels.IsValue = True
serieOne.DataPoints.DefaultDataPoint.DataLabels.IsSeriesName = False

Dim serietwo As IChartSerie = shape.Series(1)
serietwo.Name = "Planned/Current"
serietwo.CategoryLabels = oWS.Range("B" + sTopRow.ToString + ":B" + (sRow - 1).ToString)
serietwo.DataPoints.DefaultDataPoint.DataLabels.IsValue = True
serietwo.DataPoints.DefaultDataPoint.DataLabels.IsSeriesName = False

Dim seriethree As IChartSerie = shape.Series(2)
seriethree.Name = "Overdue"
seriethree.CategoryLabels = oWS.Range("C" + sTopRow.ToString + ":C" + (sRow - 1).ToString)
seriethree.DataPoints.DefaultDataPoint.DataLabels.IsValue = True
seriethree.DataPoints.DefaultDataPoint.DataLabels.IsSeriesName = False

'Set title to the chart
shape.ChartTitle = oDT.Rows(0)("DomainName").ToString
shape.ChartTitleArea.Bold = True
shape.ChartArea.IsBorderCornersRound = True
shape.Legend.Position = ExcelLegendPosition.Bottom

Melba Winshia [Syncfusion]
Replied On January 30, 2007 11:13 AM UTC

Hi Carl,

Could you please use the following code snippet to set the colors for the different areas of each bar.

Here is the code snippet:


//First Serie
IChartSerie serieOne = shape.Series[0];

//Color of first serie

//Second Serie
IChartSerie serietwo = shape.Series[1];

//Color of Second serie

// Third Serie
IChartSerie seriethree = shape.Series[2];

//Color of third serie


'First Serie
Dim serieOne As IChartSerie = shape.Series(0)

'Color of first serie

'Second Serie
Dim serietwo As IChartSerie = shape.Series(1)

'Color of Second serie

' Third Serie
Dim seriethree As IChartSerie = shape.Series(2)

'Color of third serie

Here is the sample for your reference:


Please have a look at this sample and let me know if this helps you.

Thanks for your interest in Syncfusion products.

Best Regards,


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

or the page will be automatically redirected to 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