gpt4 book ai didi

c# - ZedGraph - 如何从点到时间更改 X 轴?

转载 作者:太空宇宙 更新时间:2023-11-03 13:35:19 29 4
gpt4 key购买 nike

我有一个工作 DLL,其中我有一个函数可以将数组添加到列表中,另一个函数可以在 ZED-Graph-diagram 中显示所有列表数组。所有数组都具有相同的大小。当前,x 轴显示为从 0 到 1024 的点。问题是:我必须更改什么才能及时显示 x 轴?

我有值“Intervall”(两点之间的时间),我可以将其传递给函数。

感谢您的帮助。

这是我目前所拥有的:

public void AddGraph(double[] Values, string LegendName)
{
int i = 0;
PointPairList list = new PointPairList();
for (i = 0; i < Values.Length; i++)
{
list.Add(i, Values[i]);
}

if (i > MaxXAxis)
MaxXAxis = i;

SList.Add(list);
SListColor.Add(Color.Black);
SListName.Add(LegendName);
}

public void ShowDiagram(string Title, string XAxisName, string YAxisName, int Timeout_ms)
{
ZedGraph.ZedGraphControl zgc = new ZedGraphControl();
GraphPane myPane = zgc.GraphPane;
LineItem myCurve = null;


// Set the titles and axis labels
myPane.Title.Text = Title;
myPane.XAxis.Title.Text = XAxisName;
myPane.YAxis.Title.Text = YAxisName;

for (int i = 0; i < SList.Count(); i++)
{
myCurve = myPane.AddCurve(SListName[i], SList[i], SListColor[i], SymbolType.None);
myCurve.Line.Width = 2;
}

// Add gridlines to the plot, and make them gray
myPane.XAxis.MinorGrid.IsVisible = true;
myPane.YAxis.MinorGrid.IsVisible = true;
myPane.XAxis.MinorGrid.Color = Color.LightGray;
myPane.YAxis.MinorGrid.Color = Color.LightGray;
myPane.XAxis.MinorGrid.DashOff = 0;
myPane.YAxis.MinorGrid.DashOff = 0;

myPane.XAxis.MajorGrid.IsVisible = true;
myPane.YAxis.MajorGrid.IsVisible = true;
myPane.XAxis.MajorGrid.Color = Color.Gray;
myPane.YAxis.MajorGrid.Color = Color.Gray;
myPane.XAxis.MajorGrid.DashOff = 0;
myPane.YAxis.MajorGrid.DashOff = 0;

// Move Legend to buttom
myPane.Legend.Position = LegendPos.Bottom;

zgc.AxisChange();

myPane.XAxis.Scale.Max = MaxXAxis;

zgc.Location = new Point(0, 0);
zgc.Size = new Size(panel_diagramm.ClientRectangle.Width, panel_diagramm.ClientRectangle.Height);

panel_diagramm.Controls.Add(zgc);
}

最佳答案

这是我第一次发帖,所以我很抱歉没有把它放在更好的格式中。以下内容允许您设置 x 轴以显示时间:

myPane.XAxis.Type = AxisType.Date;
myPane.XAxis.Title.Text = "Time (HH:MM:SS)";
myPane.XAxis.Scale.Format = "HH:mm:ss";
myPane.XAxis.Scale.MajorUnit = DateUnit.Minute;
myPane.XAxis.Scale.MinorUnit = DateUnit.Minute;
myPane.XAxis.Scale.Min = DateTime.Now.Subtract(new TimeSpan(0, 0, 10, 0, 0).ToOADate();
myPane.XAxis.Scale.Max = DateTime.Now.ToOADate();

关于c# - ZedGraph - 如何从点到时间更改 X 轴?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18910989/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com