2014-07-08 6 views
0

나는 6 개의 데이터 배열을 longs으로 가지고있다. Chart Control에 6 개의 모든 배열을 별도의 선으로 그래프로 표시하는 방법을 찾고 싶습니다.배열에서 선 그래프를 만들 수 있습니까?

개체를 만들었습니다. 내 Series Collection Editor에는 6 명의 구성원이 있지만, chart1.series1.setData(myArray) 행을 따라 수행하는 기능을 찾을 수 없습니다.

모든 포인트를 통해 .add()을 호출 할 수 있다는 것을 알고 있지만, Series에 배열을 할당하는 직접적인 방법이 있는지 궁금합니다.

답변

3

데이터 바인딩과는 별도로 전체 범위를 추가하는 방법은 없습니다. 당신은 다차원의 데이터가있는 경우 (

'Add data from Array1 to the first series of the chart 
Chart.Series(0).Points.Clear() 'Clear all points 
For i = 0 to Array1.Count - 1 
    Chart.Series(0).Points.AddXY(i, Array1(i)) 'Adds the data from the array to the first series 
Next 

: 당신이 말한대로 당신은 AddXYPoints 재산의 방법 (또는 유형 DataPointCollection의 관련 방법 중 하나) 시리즈의,과 같이, 호출 할 수 있습니다 1) 당신이 더 이상 정보를 제공하지 않기 때문에 - 예를 들면 Dim Data()() As Long)는

For a = 0 to Data.Count - 1 
    Chart.Series(a).Points.Clear() 'Clear all points from the ath series 
    For i = 0 to Data(a).Count - 1 
     Chart.Series(a).Points.AddXY(i, Data(a)(i)) 'Adds the data from the ath array to the ath series 
    Next  
Next 

참고 X 값이 될 것입니다 배열의 수를 그냥 인덱스 (0 같은 일을 할 수 있습니다.

또는 당신은 이제 당신은 그냥 시리즈의 Points 속성에 대한 AddRange 메소드를 호출 할 수있는 새로운 Module

Public Module Extensions 
    <System.Runtime.CompilerServices.Extension> 
    Public Sub AddRange(d As System.Windows.Forms.DataVisualization.Charting.DataPointCollection, data() As Long) 
     Dim meCount As Integer = d.Count 
     For i = 0 To data.Count - 1 
      d.AddXY(meCount + i, data(i)) 
     Next 
    End Sub 
End Module 

에서 확장 메서드를 작성할 수

Chart.Series(0).Points.AddRange(Array1) 
2

당신은 그것을 할 수 있습니다 Jens가 말한 것처럼 포인트를 한 점씩 추가하면이 기능이 작동합니다. 잘 작동합니다 또 다른 방법은 다음과 같습니다

For a as integer = 0 to AmountOfSeries.count - 1 step 1 
    Chart1.Series(a).Points.DataBindXY(ArrayX1, ArrayY1) 
Next 

이 당신이 찾고 있던 무슨 가까이있을 수 있습니다 - 일련의 두 배열을 설정하는 방법.

Dim xs As Double() = {0, 1, 2, 3, 4} 
Dim ys As Double() = {0, 1, 2, 3, 4} 
Chart1.Series(0).Points.DataBindXY(xs, ys) 
: 여기

은 하나의 시리즈처럼 보일 것이다 무엇
관련 문제