X轴是Date类型的Y轴是Text类型的现在 Y轴是设备的名称,X轴想要表示 该设备运行的时间信息,比如
X轴显示的是 12月5日 ~ 12月9日 则要表现出来 该设备在(12月5日 9:00~ 15:00、16:00~21:00)
(12月6日 7:00~ 11:05、12:10~21:50) 运行的信息表现出来,显示成带状图,现在要处理的
DataTable我已经得到了,但是怎么写能让ZedGraph正确显示 不知道怎么写,知道的麻烦给说下。现在我的部分代码:
for (int j =0;j<DataTable.Rows.count;j++)
{
barItem[j] = myPane.AddBar(labels[j], XAxis, YAxis, Color(2));
barItem[j].Bar.Fill = new Fill(Color(2));
...........
}
myPane.XAxis.Scale.IsVisible = true;
myPane.XAxis.Scale.MajorStepAuto = true;
myPane.XAxis.Scale.MinorStepAuto = true;
myPane.XAxis.Type = AxisType.DateAsOrdinal;
myPane.XAxis.MajorGrid.IsVisible = true;
myPane.XAxis.MajorGrid.Color = Color.Green; myPane.YAxis.Scale.IsVisible = true;
myPane.YAxis.MajorGrid.IsVisible = true;
myPane.YAxis.MajorGrid.IsVisible = true;
myPane.YAxis.Type = AxisType.Text;
myPane.YAxis.MajorGrid.Color = Color.Green;
myPane.YAxis.Scale.TextLabels = labels; myPane.BarSettings.Base = BarBase.Y;
myPane.BarSettings.Type = BarType.PercentStack;
this.zgOthello.AxisChange();
this.zgOthello.Invalidate();
X轴显示的是 12月5日 ~ 12月9日 则要表现出来 该设备在(12月5日 9:00~ 15:00、16:00~21:00)
(12月6日 7:00~ 11:05、12:10~21:50) 运行的信息表现出来,显示成带状图,现在要处理的
DataTable我已经得到了,但是怎么写能让ZedGraph正确显示 不知道怎么写,知道的麻烦给说下。现在我的部分代码:
for (int j =0;j<DataTable.Rows.count;j++)
{
barItem[j] = myPane.AddBar(labels[j], XAxis, YAxis, Color(2));
barItem[j].Bar.Fill = new Fill(Color(2));
...........
}
myPane.XAxis.Scale.IsVisible = true;
myPane.XAxis.Scale.MajorStepAuto = true;
myPane.XAxis.Scale.MinorStepAuto = true;
myPane.XAxis.Type = AxisType.DateAsOrdinal;
myPane.XAxis.MajorGrid.IsVisible = true;
myPane.XAxis.MajorGrid.Color = Color.Green; myPane.YAxis.Scale.IsVisible = true;
myPane.YAxis.MajorGrid.IsVisible = true;
myPane.YAxis.MajorGrid.IsVisible = true;
myPane.YAxis.Type = AxisType.Text;
myPane.YAxis.MajorGrid.Color = Color.Green;
myPane.YAxis.Scale.TextLabels = labels; myPane.BarSettings.Base = BarBase.Y;
myPane.BarSettings.Type = BarType.PercentStack;
this.zgOthello.AxisChange();
this.zgOthello.Invalidate();
1.仔细看看zedGraph的说明以及帮助文档,看能不能对X轴坐标进行一些修改,直接显示时间2.因为zedGraph是开源的,你可以去修改它的源代码,以达到你的目的。这样是理论肯定可以实现的。3.你把你的运行时间段标记成对应的整数,就是把时间段转换成普通的坐标。
比如现在代码:
for (int i = 0; i < arrDevice.Length; i++)
{
XAxis[i] = (double)new XDate(Convert.ToDateTime(arrDevice[i][1]));
YAxis[i] = (double)new XDate(Convert.ToDateTime(arrDevice[i][2]));
}
还有我把想要显示的结果描述一下:
(Y轴 设备名称)
| ______ _____
|____ _____ ___
|
|___ ____ _______
|______________________ (X轴 DateTime)
1月2号 1月3号 1月4号 做完后 显示的结果就是这样的。
{
XDate xd = new XDate();
DateTime dt = Convert.ToDateTime(Dr["Time"]);
xd.SetDate(dt);
}
myPane.XAxis.Type = AxisType.Date;//X描述轴显示类型
我觉得应该类似以下这样的
XAxis[m] = (double)new XDate(Convert.ToDateTime(arrDevice[i][1]));
XAxis[n] = (double)new XDate(Convert.ToDateTime(arrDevice[i][2]));myPane.XAxis.Type = AxisType.Date;
主要是X轴的显示