c#chart 的x轴怎么设置时间形式,是从0开始的计时,试了很多,没试出来。请求指点
4条回答 默认 最新
threenewbee 2018-07-20 02:16关注using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Windows.Forms.DataVisualization.Charting; namespace Q695236 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { Random rnd = new Random(); var data = Enumerable.Range(0, 10).Select((x, i) => rnd.NextDouble() + x * 0.6).ToList(); var t = Enumerable.Range(0, 10).Select(x => x * 30).Select(x => new { h = x / 3600, m = (x % 3600) / 60, s = (x % 3600) % 60 }) .Select(x => new DateTime(1900, 1, 1, x.h, x.m, x.s, DateTimeKind.Local)).ToList(); chart1.Series[0].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line; chart1.Series[0].XValueType = ChartValueType.Time; chart1.Series[0].YValueType = ChartValueType.Double; chart1.Series[0].Points.DataBindXY(t, data); } } }解决 无用评论 打赏 举报