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

Chart has no DataPoints ?

Thread ID:





107542 Mar 6,2013 01:53 PM UTC Mar 14,2013 04:03 AM UTC WinForms 9
Tags: XlsIO
Ralf Stiegele
Asked On March 6, 2013 01:53 PM UTC


I just wanted to add a differen color to a part of a chart with XLSIO.
The chart is created an filled with data without any problem. But if I try to set the color the chart remains on the standard-color.

So I found out that the chartserie has no datapoints in its collection.

This is the code I use:

 Dim chart As IChartShape = xlsheet.Charts.Add()

                    chart.TopRow = xlsheet.Range("IssueStats").Row
                    chart.BottomRow = xlsheet.Range("IssueStats").Row + 18
                    chart.LeftColumn = xlsheet.Range("IssueStats").Column
                    chart.RightColumn = xlsheet.Range("IssueStats").Column + 13

                    chart.DataRange = Workbook.Worksheets("Infos").Range(Workbook.Worksheets("Infos").Range("IssueTypes").Row, 1, lastDataRow, 2)
                    chart.IsSeriesInRows = False
                    chart.Series(0).DataPoints.DefaultDataPoint.DataLabels.Position = ExcelDataLabelPosition.Outside
                    chart.Series(0).DataPoints.DefaultDataPoint.DataLabels.IsValue = True
                    chart.HasLegend = False

                    'Farben setzen:
                    chart.Series(0).DataPoints(1).DataFormat.Fill.BackColor = Drawing.Color.Black
                    chart.Series(0).DataPoints(2).DataFormat.Fill.ForeColor = Drawing.Color.Black

Does anyone has an idea why the color can't be set ?

Thanks & Regards

Johnson Monohar M [Syncfusion]
Replied On March 7, 2013 05:26 AM UTC

Hi Ralf Steigele,

Thank you for using Syncfusion products.

It is possible to set colors for data labels with the following code snippet. Kindly follow the code snippets and let us know if it meets your requirement.

Dim chart As IChart = workbook.Charts(0)

chart.Series(0).DataPoints(0).DataLabels.Color = ExcelKnownColors.Red

chart.Series(0).DataPoints(1).DataLabels.Color = ExcelKnownColors.Green

chart.Series(0).DataPoints(2).DataLabels.Color = ExcelKnownColors.Blue

chart.Series(0).DataPoints(3).DataLabels.Color = ExcelKnownColors.Yellow

We have also provided a sample to illustrate this, which can be downloaded from the following link.

Sample Link : ChartDataPoints.zip



Ralf Stiegele
Replied On March 7, 2013 08:49 AM UTC

Hi Johnson Monohar,

thank you for your advise. But I don't want to colour the datalabels I want to color the bars of the chart itself.

If I set it with:
chart.Series(0).DataPoints.DefaultDataPoint.DataFormat.Fill.BackColor = Drawing.Color.Red
all bars a coloured in red.

But I want them to have in different color like:
                    chart.Series(0).DataPoints(0).DataFormat.Fill.BackColor = Drawing.Color.Red
                    chart.Series(0).DataPoints(1).DataFormat.Fill.BackColor = Drawing.Color.Yellow
                    chart.Series(0).DataPoints(2).DataFormat.Fill.BackColor = Drawing.Color.Green
(But this doesn't change any colour - and I don't get it why)

Ralf Stiegele
Replied On March 7, 2013 08:53 AM UTC

I uploaded a picture fo the result I expect:


Johnson Monohar M [Syncfusion]
Replied On March 11, 2013 05:06 AM UTC

Hi Ralf Steigele,

We are sorry for the inconvenience.

The "BackColor" property doesn't apply in datapoints. To apply custom color to the data points, kindly follow the below code snippets.

            chart.Series(0).DataPoints(0).DataFormat.Fill.ForeColorIndex = ExcelKnownColors.Red
      chart.Series(0).DataPoints(1).DataFormat.Fill.ForeColorIndex = ExcelKnownColors.Orange
      chart.Series(0).DataPoints(2).DataFormat.Fill.ForeColorIndex = ExcelKnownColors.Tan
      chart.Series(0).DataPoints(3).DataFormat.Fill.ForeColorIndex = ExcelKnownColors.Green

The output of the above code is shown in the below image.

Kindly apply the mentioned code snippets in your code and let us know if the provided solution helps.

Please let us know if you need any clarification.


Ralf Stiegele
Replied On March 11, 2013 09:28 AM UTC


after adding the code to my solution the colour still doesn't change (remains default)

I also tried the ForeColor-Property - See the code I used:
                    chart.Series(0).DataPoints(0).DataFormat.Fill.ForeColor = System.Drawing.Color.Red
                    chart.Series(0).DataPoints(1).DataFormat.Fill.ForeColorIndex = ExcelKnownColors.Black
                    chart.Series(0).DataPoints(2).DataFormat.Fill.ForeColor = System.Drawing.Color.Red
                    chart.Series(0).DataPoints(3).DataFormat.Fill.ForeColorIndex = ExcelKnownColors.Black

But I still have the default colours set...


Ralf Stiegele
Replied On March 11, 2013 10:38 AM UTC


I think the problem is:  chart.IsSeriesInRows = False -> Because Excel doesn't seem to support different colours then.

(But you can set different colours in the Excel manually)


Johnson Monohar M [Syncfusion]
Replied On March 12, 2013 04:26 AM UTC

Hi Ralf Steigele,

We are sorry for the inconvenience.

We are able to set colors to the series if IsSeriesInRows property is FALSE or TRUE. To investigate further on this, we request you to create a new incident regarding this and update us a modified sample along with any excel file if used in the sample to reproduce the issue. This will help us to provide you a better solution.

Please let us know if you need any clarification.


Ralf Stiegele
Replied On March 12, 2013 10:18 AM UTC


I created a new Issue:


Johnson Monohar M [Syncfusion]
Replied On March 14, 2013 04:03 AM UTC

Hi Ralf Steigele,

Thank you for creating new incident regarding this.



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