This is a migrated thread and some comments may be shown as answers.

Adding the chart series dynamically using an array

1 Answer 84 Views
Chart (Obsolete)
This is a migrated thread and some comments may be shown as answers.
ervin
Top achievements
Rank 1
ervin asked on 31 May 2011, 07:47 PM

Hi,
My chart has more than one series (the number always changes).
I want to add these series dynamically into my chart (sometimes 2 sometimes 5 series). I tried to use an array but it did not work. How can I add the (changing number) chart series dynamically? and what is the problem with the array? (Please see the code below)

Thanks,
Ervin

 

Dim rowNumber As Integer = ds.Tables(0).Rows.Count
Dim myChartSeries(rowNumber - 1) As ChartSeries
For index As Integer = 0 To rowNumber - 1
With myChartSeries(index)

.Name = s1

.Appearance.TextAppearance.TextProperties.Color = Color.Blue

.Type = ChartSeriesType.Line

.Appearance.LabelAppearance.Visible = True

.Appearance.PointMark.Dimensions.AutoSize = False

.Appearance.PointMark.Dimensions.Width = 7

.Appearance.PointMark.Dimensions.Height = 7

.Appearance.PointMark.FillStyle.MainColor = Color.Black

.Appearance.PointMark.Visible = True
For index2 As Integer = 0 To 5
Dim
mychartSeriesItem As Integer = Int(ds.Tables(0).Rows(0).Item(index2 + 1))

 

 

myChartSeries(index2).AddItem(mychartSeriesItem)
Next

End With

chart.AddChartSeries(myChartSeries(index))
Next

chart.DataBind()

1 Answer, 1 is accepted

Sort by
0
ervin
Top achievements
Rank 1
answered on 01 Jun 2011, 09:48 PM
Ok, I found it.
I forgot a very basic line... When you add the below line, it works...
myChartSeries(index) = New ChartSeries()

Thanks,
Ervin

Tags
Chart (Obsolete)
Asked by
ervin
Top achievements
Rank 1
Answers by
ervin
Top achievements
Rank 1
Share this question
or