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.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Colors for bar chart

Thread ID:

Created:

Updated:

Platform:

Replies:

55325 Jan 29,2007 03:12 AM UTC Jan 30,2007 11:13 AM UTC ASP.NET Web Forms (Classic) 1
loading
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?

Thanks

Carl

'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:

[C#]

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

//Color of first serie
serieOne.DataPoints.DefaultDataPoint.DataFormat.AreaProperties.ForegroundColorIndex=ExcelKnownColors.Lavender;

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

//Color of Second serie
serietwo.DataPoints.DefaultDataPoint.DataFormat.AreaProperties.ForegroundColor=System.Drawing.Color.Orange;

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

//Color of third serie
seriethree.DataPoints.DefaultDataPoint.DataFormat.AreaProperties.ForegroundColor=System.Drawing.Color.Purple;

[VB.NET]

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

'Color of first serie
serieOne.DataPoints.DefaultDataPoint.DataFormat.AreaProperties.ForegroundColorIndex=ExcelKnownColors.Lavender

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

'Color of Second serie
serietwo.DataPoints.DefaultDataPoint.DataFormat.AreaProperties.ForegroundColor=System.Drawing.Color.Orange

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

'Color of third serie
seriethree.DataPoints.DefaultDataPoint.DataFormat.AreaProperties.ForegroundColor=System.Drawing.Color.Purple

Here is the sample for your reference:

Chart.zip

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

Thanks for your interest in Syncfusion products.

Best Regards,
Melba


CONFIRMATION

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.

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

;