Error assigning series chart area in

Posted on 2010-08-22
Last Modified: 2012-05-10
I'm developing a application that includes a graphing module.  I keep getting a error on line
  series.ChartArea = "Default"

The error reads
A chart element with the name of 'Default' could not be found in the chart collection'.5
All I am doing is assigning a name to that series chart area.  I've used this code previously with no problem so I am not sure what is going on.

For Each g As GraphReport In graphs

                If MatchingMetricUnits(g) = Nothing Then

                    MessageBox.Show(g.DataVersionIdOne.ToString & " and " & g.DataVersionIdTwo.ToString & " do not have corresponding units!", "Erro")

                    Exit Sub


                    strUnits = MatchingMetricUnits(g)

                End If

                Dim ds As New DataTable

                ds = ReportDB.GetDeltaSeriesData(g.DataVersionIdOne, g.DataVersionIdTwo, g.MetricName)

                Dim dtgv As New DataTable

                dtgv = ReportDB.GetDeltaReportData(g.DataVersionIdOne, g.DataVersionIdTwo, g.MetricName)

                Dim newtable As New DataTable


                For Each table As DataTable In dset.Tables



                dgvGraphResults.DataSource = newtable

                Dim strSeriesName As String = g.DataVersionIdOne.ToString & " - " & g.DataVersionIdTwo.ToString

                RemoveDuplicateSeries(Chart1.Series, strSeriesName)

                Dim series As Series = Chart1.Series.Add(strSeriesName)

                series.Tag = g.DataVersionIdOne & "-" & g.DataVersionIdTwo

                If g.GraphType = 0 Then

                    series.ChartType = SeriesChartType.Spline

                ElseIf g.GraphType = 1 Then

                    series.ChartType = SeriesChartType.Column

                ElseIf g.GraphType = 2 Then

                    series.ChartType = SeriesChartType.StackedArea

                ElseIf g.GraphType = 3 Then

                    series.ChartType = SeriesChartType.StackedColumn

                End If

                strTitleName = g.GraphTitle.ToString

                'MetricName = g.GraphTitle.ToString

                series.ChartArea = "Default"

                Dim xfield As String = "ForecastYear"

                Dim xval As New ArrayList

                For Each r As DataRow In ds.Rows



                Dim yfield As String = "MetricValue"

                Dim yval As New ArrayList

                For Each r As DataRow In ds.Rows



                ' Bind the double array to the Y axis points of the Default data series

                Chart1.Series(strSeriesName).Points.DataBindXY(xval, yval)

                series.BorderWidth = 2



Open in new window

Question by:chtullu135
1 Comment
LVL 17

Accepted Solution

calacuccia earned 500 total points
ID: 33496916
In my opinion, ChartArea should be assign to the Chart object, not the Series object.

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (…
This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now