티스토리 뷰

프로그래밍/C#

c# 차트 x좌표 날짜 나오게 하기

뽀로로친구에디 2020. 1. 22. 17:31

 private void button1_Click(object sender, EventArgs e)
        {
            var s = new Series();
            s.ChartType = SeriesChartType.Line;

            var d = new DateTime(2013, 04, 01);

            s.Points.AddXY(d, 3);
            s.Points.AddXY(d.AddMonths(-1), 2);
            s.Points.AddXY(d.AddMonths(-2), 1);
            s.Points.AddXY(d.AddMonths(-3), 4);

            chart1.Series.Clear();
            chart1.Series.Add(s);


            chart1.Series[0].XValueType = ChartValueType.DateTime;
           chart1.ChartAreas[0].AxisX.LabelStyle.Format = "yyyy-MM-dd";
           
            chart1.ChartAreas[0].AxisX.Interval = 1;
            chart1.ChartAreas[0].AxisX.IntervalType = DateTimeIntervalType.Months;
            chart1.ChartAreas[0].AxisX.IntervalOffset = 1;

            chart1.Series[0].XValueType = ChartValueType.DateTime;
     

        /  DateTime minDate = new DateTime(2013, 01, 01).AddSeconds(-1);
            DateTime maxDate = new DateTime(2013, 05, 01); // or DateTime.Now;
            chart1.ChartAreas[0].AxisX.Minimum = minDate.ToOADate();
            chart1.ChartAreas[0].AxisX.Maximum = maxDate.ToOADate();
        }

'프로그래밍 > C#' 카테고리의 다른 글

C# MySQL 연결하기 #1  (0) 2020.12.29
c# 차트 지우기  (0) 2020.01.23
c# 차트 사이즈 고정 하는 방법  (0) 2020.01.22
C# 현재시간 얻어오기  (0) 2020.01.22
C# datagridView 예제  (0) 2019.12.05
댓글
최근에 달린 댓글
글 보관함
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
Total
Today
Yesterday
    뽀로로친구에디
    최근에 올라온 글