! 제품 버전을 정확하게 입력해 주세요.
제품 버전이 정확하게 기재되어 있지 않은 경우,
최신 버전을 기준으로 안내 드리므로
더욱 빠르고 명확한 안내를 위해
제품 버전을 정확하게 입력해 주세요!

[FlexChart Winforms] 바 그래프에서 각 시리즈마다 채우기 패턴을 변경하는 방법 > 지식 쉐어링

본문 바로가기

ComponentOne

지식 쉐어링

샘플공유 [FlexChart Winforms] 바 그래프에서 각 시리즈마다 채우기 패턴을 변경하는 방법

페이지 정보

작성자 MESCIUS싸이먼 작성일 2023-11-21 18:28 조회 30회 댓글 0건

본문

첨부파일

안녕하세요.

메시어스 입니다.


FlexChart를 사용할 때 각 시리즈의 명확한 구분을 위해 다른 채우기 패턴과 색상을 부여하시고 싶으신 경우 사용하실 수 있는 방법을 안내드립니다.

막대 그래프에 채우기 패턴을 적용하려면 Series 클래스의 Style.Fill 속성에 HatchBrush를 설정합니다.

예를 들어, 왼쪽 위에서 오른쪽 아래로의 대각선 패턴을 설정하려면 HatchBrush의 인수로 HatchStyle.ForwardDiagonal을 지정합니다.

아래의 코드에서 Color.Red는 채우기 색상으로 설정되어 있습니다.

series1.Style.Fill = new HatchBrush(HatchStyle.ForwardDiagonal, Color.Red, Color.White);
 
아래에는 네 가지의 다른 시리즈에 각기 다른 채우기 패턴을 설정하는 예제가 있습니다. 
// 데이터 작성
DataTable dt = new DataTable();
dt.Columns.AddRange(new DataColumn[]
{
    new DataColumn("X", typeof(String)),
    new DataColumn("Y1", typeof(Int32)),
    new DataColumn("Y2", typeof(Int32)),
    new DataColumn("Y3", typeof(Int32)),
    new DataColumn("Y4", typeof(Int32))
});
for (int i = 0; i <= 5; i++)
{
    dt.Rows.Add(((char)(65 + i)).ToString(), i + 1, i + 2, i + 3, i + 4);
    dt.AcceptChanges();
}

// 시리즈 작성
Series series1 = new Series()
{
    Name = "S1",
    Binding = "Y1",
    BindingX = "X"
};
series1.Style.Fill = new HatchBrush(HatchStyle.ForwardDiagonal, Color.Red, Color.White);
series1.Style.StrokeColor = Color.Black;
series1.Style.StrokeWidth = 1;

Series series2 = new Series()
{
    Name = "S2",
    Binding = "Y2",
    BindingX = "X"
};
series2.Style.Fill = new HatchBrush(HatchStyle.BackwardDiagonal, Color.Blue, Color.White);
series2.Style.StrokeColor = Color.Black;
series2.Style.StrokeWidth = 1;

Series series3 = new Series()
{
    Name = "S3",
    Binding = "Y3",
    BindingX = "X"
};
series3.Style.Fill = new HatchBrush(HatchStyle.Cross, Color.LightSlateGray, Color.White);
series3.Style.StrokeColor = Color.Black;
series3.Style.StrokeWidth = 1;

Series series4 = new Series()
{
    Name = "S4",
    Binding = "Y4",
    BindingX = "X"
};
series4.Style.Fill = new HatchBrush(HatchStyle.DarkHorizontal, Color.LightGreen, Color.White);
series4.Style.StrokeColor = Color.Black;
series4.Style.StrokeWidth = 1;

// 막대 그래프 생성
flexChart1.ChartType = ChartType.Column;
flexChart1.DataSource = dt;
flexChart1.Series.Clear();
flexChart1.Series.Add(series1);
flexChart1.Series.Add(series2);
flexChart1.Series.Add(series3);
flexChart1.Series.Add(series4);
 
  • 페이스북으로 공유
  • 트위터로  공유
  • 링크 복사
  • 카카오톡으로 보내기

댓글목록

등록된 댓글이 없습니다.

메시어스 홈페이지를 통해 제품에 대해서 더 자세히 알아 보세요!
홈페이지 바로가기
메시어스 홈페이지를 통해 제품에 대해서 더 자세히 알아 보세요!
홈페이지 바로가기
이메일 : sales-kor@mescius.com | 전화 : 1670-0583 | 경기도 과천시 과천대로 7길 33, 디테크타워 B동 1107호 메시어스(주) 대표자 : 허경명 | 사업자등록번호 : 123-84-00981 | 통신판매업신고번호 : 2013-경기안양-00331 ⓒ 2024 MESCIUS inc. All rights reserved.