C#chart - X轴以小时为单位,数据以秒为单位提供 [英] C# chart - X Axis in hours, Data provided in seconds

查看:723
本文介绍了C#chart - X轴以小时为单位,数据以秒为单位提供的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我希望有人可以帮助我。

I hope somebody can help me.

我正在尝试用c#创建一个图表。

I'm trying to create a chart in c#.

我的数据以秒为单位提供时间戳和其他数据。

My Data is provided in timestamps in seconds and other data.

我的问题是创建x轴,小时0 - 23h。

My Problem is to create the x axis with hour 0 - 23h.

我的代码到目前为止:

 double[] timestamps = { 0, 337, 675, 1012, 1350, 1687, 2025, 2362, 2700, 3037, 3375, 3712, 4050, 4387, 4725, 5062, 5400, 5737, 6075, 6412, 6750, 7087, 7425, 7762, 8100, 8437, 8775, 9112, 9450, 9787, 10125, 10462, 10800, 11137, 11475, 11812, 12150, 12487, 12825, 13162, 13500, 13837, 14175, 14512, 14850, 15187, 15525, 15862, 16200, 16537, 16875, 17212, 17550, 17887, 18225, 18562, 18900, 19237, 19575, 19912, 20250, 20587, 20925, 21262, 21600, 21937, 22275, 22612, 22950, 23287, 23625, 23962, 24300, 24637, 24975, 25312, 25650, 25987, 26325, 26662, 27000, 27337, 27675, 28012, 28350, 28687, 29025, 29362, 29700, 30037, 30375, 30712, 31050, 31387, 31725, 32062, 32400, 32737, 33075, 33412, 33750, 34087, 34425, 34762, 35100, 35437, 35775, 36112, 36450, 36787, 37125, 37462, 37800, 38137, 38475, 38812, 39150, 39487, 39825, 40162, 40500, 40837, 41175, 41512, 41850, 42187, 42525, 42862};
       double[] peaks = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 666, 2443, 3998, 6072, 8293, 10663, 12662, 15254, 17920, 20067, 22807, 25621, 27917, 30805, 33619, 36433, 38728, 41468, 44134, 46281, 48799, 51243, 53094, 55241, 57315, 58796, 60499, 62054, 63461, 64424, 65460, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65312, 64868, 64350, 63831, 63387, 62795, 62202, 61684, 61091, 60425, 59833, 59166, 58426, 57611, 57019, 56130, 55241, 54501, 53538, 52576, 51687, 50576, 49465, 48207, 47244, 45911, 44504, 43319, 41838, 40283, 39024, 37321, 35618, 34211, 32434, 30582, 28731, 27250, 25251, 23326, 21696, 19697, 17624, 15994, 13921, 11848, 9700, 7997, 5850, 3702, 1999 };
              

            Series peak_white = new Series("White");
           

            for (int i = 0; i < timestamps.Length; i++)
            {

                peak_white.Points.AddXY(timestamps[i]/3600, peaks[i]);

            }

            peak_white.Name = "White";
            peak_white.Color = Color.Yellow;
            peak_white.ChartType = SeriesChartType.Spline;
                        
            peak_white.ToolTip = "#SERIESNAME : X=#VALX, Y=#VALY";
            peak_white.MarkerSize = 5;
            peak_white.MarkerStyle = MarkerStyle.Square;
        
         
            chart1.ChartAreas[0].AxisY.Minimum = 0;
            chart1.ChartAreas[0].AxisY.Maximum = 65535;
            chart1.ChartAreas[0].AxisX.IntervalType = DateTimeIntervalType.Hours;
            chart1.ChartAreas[0].AxisX.Minimum = 0;
            chart1.ChartAreas[0].AxisX.Maximum = 23;
            chart1.ChartAreas[0].AxisX.Interval = 1;
            chart1.ChartAreas[0].AxisX.LabelStyle.Format = "HH:mm";



            chart1.Series.Add(peak_white);

        }


    }
}

亲切的问候,

Andreas

推荐答案

您目前如何输出?你能告诉我们一个截图吗?

how is you output currently? Can you show us a screenshot?


这篇关于C#chart - X轴以小时为单位,数据以秒为单位提供的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆