기타 TeeChart - 바차트 만들기. (BarChart)
페이지 정보
본문
안녕하세요. 엔지엠소프트웨어입니다. 이전 글에서 티차트에 대해 기본적인 내용을 알아봤는데요. 오늘은 데이터를 이용해서 바차트 만드는 방법에 대해 테스트 해보겠습니다. 우선, Visual Studio를 실행하고 프로젝트에서 아래와 같이 코딩해보세요. 먼저 티차트가 설치되어 있어야 하는데요. 티차트가 없으면 [ 여기 ]를 참고해주세요.
using Steema.TeeChart;
using Steema.TeeChart.Styles;
using System;
using System.Drawing;
using System.Windows.Forms;
namespace WindowsFormsApp1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
tChart1.Header.Text = "NGMsoftware";
Axis leftAxis = tChart1.Axes.Left;
leftAxis.AxisPen.Color = Color.Red;
leftAxis.Title.Font.Color = Color.Red;
leftAxis.Title.Font.Bold = true;
leftAxis.Title.Text = "Alarm count";
Axis bottomAxis = tChart1.Axes.Bottom;
bottomAxis.AxisPen.Color = Color.Red;
bottomAxis.Title.Font.Color = Color.Red;
bottomAxis.Title.Font.Bold = true;
bottomAxis.Title.Text = "Date time";
bottomAxis.Labels.Angle = 45;
Bar bar = new Bar(tChart1.Chart);
bar.Add(DateTime.Parse("2021-01-01"), 70, Color.Orange);
bar.Add(DateTime.Parse("2021-02-01"), 100, Color.Blue);
bar.Add(DateTime.Parse("2021-03-01"), 90, Color.Green);
bar.Add(DateTime.Parse("2021-04-01"), 40, Color.Red);
bar.Add(DateTime.Parse("2021-05-01"), 90);
}
}
}
실행하면 아래와 같이 바차트가 만들어진걸 알 수 있습니다.
X축에 날짜가 45도 기울어져 있습니다. 데이터가 많고 표시할 영역이 작다면 아래와 같이 앵글을 적용시킬 수 있습니다.
bottomAxis.Labels.Angle = 45;
개발자에게 후원하기
추천, 구독, 홍보 꼭~ 부탁드립니다.
여러분의 후원이 빠른 귀농을 가능하게 해줍니다~ 답답한 도시를 벗어나 귀농하고 싶은 개발자~
감사합니다~
추천0 비추천0
- 이전글TeeChart - 라인차트 만들기. (LineChart) 21.04.30
- 다음글티차트에 제목 표시하기. (Set title in teechart.) 21.04.29
댓글목록
등록된 댓글이 없습니다.