Click here to Skip to main content
15,894,540 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a chart with a lot of y values. How do I copy just the y values from a series to an array?

I can get the y and x values with this, but it's not what I need, can't seem to figure out how to get to the y values.
VB
 For i = 0 To Chart_Manual_Instantaneous.Series(0).Points.Count - 1
     Debug.Print(Chart_Manual_Instantaneous.Series(0).Points(i).ToString)
Next
Posted
Updated 19-May-11 17:52pm
v2

Something along the lines of

VB
Dim yArray(Chart_Manual_Instantaneous.Series(0).Points.Count) As Double

For i = 0 To Chart_Manual_Instantaneous.Series(0).Points.Count - 1
   yArray(i)=Chart_Manual_Instantaneous.Series(0).Points(i).Y

Next


might do the trick.
I haven't compiled this so there might be some syntax errors in it.

/Fredrik
 
Share this answer
 
Thank you, I've tried something very simular and keep getting stuck

VB
Dim yArray(Chart_Manual_Instantaneous.Series(0).Points.Count) As Double

      For i = 0 To Chart_Manual_Instantaneous.Series(0).Points.Count - 1
          yArray(i) = Chart_Manual_Instantaneous.Series(0).Points(i).YValues

      Next



I keep getting "Value of 1-dimensional array of double cannot be converted to double", the "
VB
Chart_Manual_Instantaneous.Series(0).Points(i).YValues
is what's throwing the error.
 
Share this answer
 
I got it in a round about way, the xvalue works fine with the code above, there is not a yvalue, it's yvalueS, I suspect there is a bug in there code. But anyways this works



VB
Dim yArray(Chart_Manual_Instantaneous.Series(0).Points.Count) As Double
Dim temp() As Double
For i = 0 To Chart_Manual_Instantaneous.Series(0).Points.Count - 1
    temp = Chart_Manual_Instantaneous.Series(0).Points(i).YValues
    yArray(i) = temp(0)
Next
 
Share this answer
 
Comments
chan200uk 3-Dec-12 8:41am    
How to get Xvalues of the series. I am using following code and it displays 0 all the time
Dim str As String = chtStudentResult.Series(0).Points(0).XValue

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900