devexpress wpf chartControl设置x轴为时间轴的问题 20
Seriess1=newLineSeries2D();DataTabledt=newDataTable();dt.Columns.Add("time",typeof(Da...
Series s1 = new LineSeries2D();
DataTable dt = new DataTable();
dt.Columns.Add("time", typeof(DateTime));
dt.Columns.Add("number", typeof(int));
s1.ArgumentDataMember = "time";
s1.ValueDataMember = "number";
s1.ArgumentScaleType =ScaleType.DateTime;
//结果显示只有一个点,设为ScaleType.qualitative时正常有250个点
for (int i = 0; i < 250; i++)
{
DataRow drNew = dt.NewRow();
drNew["time"] =(DateTime.Now.Ticks+i*100000000);
drNew["number"] = i;
dt.Rows.Add(drNew);
}
s1.DataSource = dt;
MessageBox.Show(dt.ToString());
diagram1.Series.Clear();
diagram1.Series.Add(s1); 展开
DataTable dt = new DataTable();
dt.Columns.Add("time", typeof(DateTime));
dt.Columns.Add("number", typeof(int));
s1.ArgumentDataMember = "time";
s1.ValueDataMember = "number";
s1.ArgumentScaleType =ScaleType.DateTime;
//结果显示只有一个点,设为ScaleType.qualitative时正常有250个点
for (int i = 0; i < 250; i++)
{
DataRow drNew = dt.NewRow();
drNew["time"] =(DateTime.Now.Ticks+i*100000000);
drNew["number"] = i;
dt.Rows.Add(drNew);
}
s1.DataSource = dt;
MessageBox.Show(dt.ToString());
diagram1.Series.Clear();
diagram1.Series.Add(s1); 展开
1个回答
展开全部
Line ax = ((Line)this.chartControl1.Diagram).AxisX;//这里需要验证下。。就是找到Line的对象
ax.DateTimeMeasureUnit = DateTimeMeasurementUnit.Minute;
ax.DateTimeGridAlignment = DateTimeMeasurementUnit.Hour;
//ax.DateTimeOptions.Format = DateTimeFormat.Custom;
//ax.DateTimeOptions.FormatString = "HH:mm:ss";
你还需要设置DateTimeMeasureUnit 和DateTimeGridAlignment 。。DateTimeMeasureUnit就是一个大刻度里的小刻度;DateTimeGridAlignment 每个大刻度的表示方法!
没用过,WPF的chartControl,以我在winform中用过的经验作答。
谢谢,希望对你有帮助。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询