다음을 통해 공유


차트 컨트롤에서 빈 데이터 요소 사용

빈 데이터 요소는 Y 값이 없는 요소입니다.이러한 데이터 요소는 차트 데이터의 모양과 구조를 제어하고 데이터가 null 값인 요소를 처리하는 데 유용합니다.

빈 요소 사용 용도:

  • NULL 값을 갖는 요소 표시

  • 그림 영역에서 누락된 데이터 요소의 모양 변경

  • 두 개 이상의 계열 맞춤.데이터 맞춤에 대한 자세한 내용은 데이터 맞춤을 참조하십시오.

빈 요소 추가

다음 중 한 가지 방법으로 데이터 계열에 빈 요소를 추가합니다.

  • 데이터 요소의 Empty 속성을 True로 설정합니다.

  • 데이터 요소를 DBNull 형식의 값으로 데이터 바인딩합니다.

  • DataManipulator 클래스의 InsertEmptyPoints 메서드를 사용하여 빈 요소를 수동으로 삽입합니다.

InsertEmptyPoints 메서드는 X축의 간격을 사용하여 각 간격에 대한 데이터 요소가 있는지를 확인합니다.요소가 없는 경우 메서드는 빈 요소를 삽입합니다.빈 요소를 올바르게 표시하려면 차트 영역의 주 축 또는 보조 축(ChartArea.AxisX 또는 ChartArea.AxisX2 개체)의 Interval, IntervalOffset, IntervalTypeIntervalOffsetType 속성과 일치하도록 간격을 지정합니다.

또한 누락된 데이터 요소를 확인할 X 값의 범위를 정의할 수 있습니다.

참고

입력 매개 변수의 쉼표로 구분된 목록에서 계열 이름의 이름을 지정하여 여러 계열에서 InsertEmptyPoints 메서드를 사용할 수 있습니다.

다음 코드에서는 빈 요소를 두 계열에 삽입하는 방법을 보여 줍니다.첫 번째 메서드 호출에서는 1일을 간격으로 사용하여 Series1을 확인하고 결과를 동일한 계열에 저장합니다.두 번째 메서드 호출에서는 오프셋을 적용하여 매주 월요일을 간격으로 사용하고, 결과 데이터를 ResultSeries라는 새 계열에 저장합니다.

Imports Dundas.Charting.WebControl
  ...
  
With Chart1.DataManipulator
' Insert empty point for each day if there is no data point present.
.InsertEmptyPoints(1, IntervalType.Days, "Series1")

' Insert empty point for each Monday, but if there is no data point present, then
' Monday is offset by 1 day from the beginning of the week (Sunday).
.InsertEmptyPoints(1, IntervalType.Weeks, 1, IntervalType.Days, "Series2", "ResultSeries")
End With
// Insert empty point for each day if there is no data point present.
Chart1.DataManipulator.InsertEmptyPoints(1, IntervalType.Days, "Series1");

// Insert empty point for each Monday, but if there is no data point present, then
// Monday is offset by 1 day from the beginning of the week (Sunday).
Chart1.DataManipulator.InsertEmptyPoints(1, IntervalType.Weeks, 1, IntervalType.Days, "Series2", "ResultSeries");

빈 요소 모양 변경

Series.EmptyPointStyle 속성을 사용하여 적용 가능한 차트 종류에서 표시된 빈 요소의 시각적 표시를 변경합니다.EmptyPointValue 사용자 지정 속성을 사용하여 빈 요소를 0으로 처리하거나, 빈 요소의 왼쪽과 오른쪽에 대한 요소 평균으로 처리할 수 있습니다.사용자 지정 속성에 대한 자세한 내용은 사용자 지정 속성을 참조하십시오.

다음 코드에서는 Series.EmptyPointStyle 속성을 사용하는 방법을 보여 줍니다.

' Show marker (red cross) instead of a line for first series.
Chart1.Series("Series1").EmptyPointStyle.BorderWidth = 1
Chart1.Series("Series1").EmptyPointStyle.BorderColor = Color.Black
Chart1.Series("Series1").EmptyPointStyle.MarkerColor = Color.Red
Chart1.Series("Series1").EmptyPointStyle.MarkerSize = 15
Chart1.Series("Series1").EmptyPointStyle.MarkerStyle = MarkerStyle.Cross
 
' Show empty point of second series as thin dotted line (treated as an average).
Chart1.Series("Series2").EmptyPointStyle.BorderStyle = ChartDashStyle.DashDotDot
Chart1.Series("Series2").EmptyPointStyle.MarkerColor = Color.FromArgb(64, 64, 64)
 
' Treat empty point of third series as a zero using the EmptyPointValue custom property.
Chart1.Series("Series3").EmptyPointStyle.BorderWidth = 1
Chart1.Series("Series3").EmptyPointStyle.MarkerColor = Color.FromArgb(0, 192, 0)
Chart1.Series("Series3").EmptyPointStyle.CustomProperties = "EmptyPointValue = Zero"
// Show marker (red cross) instead of a line for first series.
Chart1.Series["Series1"].EmptyPointStyle.BorderWidth = 1;
Chart1.Series["Series1"].EmptyPointStyle.BorderColor = Color.Black;
Chart1.Series["Series1"].EmptyPointStyle.MarkerColor = Color.Red;
Chart1.Series["Series1"].EmptyPointStyle.MarkerSize = 15;
Chart1.Series["Series1"].EmptyPointStyle.MarkerStyle = MarkerStyle.Cross;

// Show empty point of second series as thin dotted line (treated as an average).
Chart1.Series["Series2"].EmptyPointStyle.BorderStyle = ChartDashStyle.DashDotDot;
Chart1.Series["Series2"].EmptyPointStyle.MarkerColor = Color.FromArgb(64, 64, 64);

// Treat empty point of third series as a zero using the EmptyPointValue custom property.
Chart1.Series["Series3"].EmptyPointStyle.BorderWidth = 1;
Chart1.Series["Series3"].EmptyPointStyle.MarkerColor = Color.FromArgb(0, 192, 0);
Chart1.Series["Series3"].EmptyPointStyle.CustomProperties = "EmptyPointValue = Zero";

참고 항목

참조

System.Windows.Forms.DataVisualization.Charting

System.Web.UI.DataVisualization.Charting

개념

데이터 정렬

데이터 맞춤

데이터 필터링

기타 리소스

데이터 바인딩 및 조작