Changing axis type in ZedGraph

删除回忆录丶 提交于 2020-01-11 07:12:05

问题


I have a data of time of consecutive heart beats (in milliseconds) and I'm trying to make a dynamic chart of them. So on XAxis I have XDate variable increased by .AddMilliseconds(heart_beat_time) and on YAxis heart_beat_time.

When I use AxisType.Date it's pretty good. I can change Min, Max and other related values, but when I change to AxisType.DateAsOrdinal I can not see points nor labels. During some debugging it has showed up that Zedgraph does paint the points and labels, but there are very large gaps between consecutive ones.

How can I control DateAsOrdinal Min, Max, MajorStep and so on? There is an answer Format DateAsOrdinal xAxis labels in ZedGraph but it doesn't work for me.

There are two reasons I want to make it work:

  1. Ordinal seems to be faster (as I got nearly 100k points)

  2. With AxisType.Date when I scroll chart automatically it's not showing labels under ticks

My code:

myPane.XAxis.Type = AxisType.DateAsOrdinal;
myPane.XAxis.Scale.MajorStepAuto = false;
myPane.XAxis.Scale.MinorStepAuto = false;
myPane.XAxis.Scale.MajorUnit = DateUnit.Minute;
myPane.XAxis.Scale.MinorUnit = DateUnit.Minute;
myPane.XAxis.Scale.Format = "HH:mm:ss";
myPane.XAxis.Scale.Min = Min;
myPane.XAxis.Scale.Max = Max;
myPane.XAxis.Scale.MinorStep = minor;
myPane.XAxis.Scale.MajorStep = major;
myPane.XAxis.Scale.BaseTic = new XDate(1999, 1, 1, 0, 0, 0, 0);
myPane.YAxis.Scale.Min = min_rr;
myPane.YAxis.Scale.Max = max_rr;

where

int min_rr = 100;
int max_rr = 2500;
XDate Min = new XDate(1999, 1, 1, 0, 0, 0, 0);
XDate Max = new XDate(1999, 1, 1, 1, 0, 0, 0);
int minor = 5;
int major = 10;

回答1:


I have the same problem (no graph or labels on XAxis) when using AxisType.DateAsOrdinal.

I solved by omitting the code lines myPane.XAxis.Scale.Min=??? and Max=???. This gives me a nice graph without gaps.

However now I have problems with the MousePositionValues function in my MouseMoveEvent.



来源:https://stackoverflow.com/questions/9951465/changing-axis-type-in-zedgraph

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!