0

VB.net - How come only one point is plotted?

Dim ReceivedValue As String ="1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20"
Dim myArray = Array.ConvertAll(ReceivedValue.Split(","c), AddressOf Convert.ToDouble)
Chart1.Series(0).Points.Add(myArray)

PS. I got the plot array idea from here

2
  • A point is two values (X and Y). This is an array of single values (just X?). How do you want this graphed? Do you want them paired up? Do you have set value for X or Y? Do you want the X or Y value to be the index in the array? Commented Oct 31, 2018 at 19:31
  • Good question, the x doesn't matter at this point. It is reference waveform and no labels or numbers are even shown. Commented Nov 1, 2018 at 0:54

1 Answer 1

2

I get the same results as you - one point on the chart. Upon inspecting the chart's Points object, it looks like this:

enter image description here

Showing an array with one X=0, and an array of all the Ys.

If you do it in a loop like this, it works

For Each point In myArray
    Chart1.Series(0).Points.Add(point)
Next

Now there is an actual series of points

enter image description here

enter image description here

I'm going to add what I think is more correct, because this results in actual x, y pairs with real x values (you can make them whatever you want)

For i = 0 To myArray.Count - 1
    Chart1.Series(0).Points.Add(New DataPoint(i, myArray(i)))
Next
Sign up to request clarification or add additional context in comments.

3 Comments

Ok thank you. That makes sense. I think that solution is the way to go. Thanks!
So if I understand, all the Y values were plotting top of the same X position.
Yes, even though when inspecting the Points object when added in a loop, all the Y values also have X = 0, the chart is able to chart it for some reason.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.