ocaccy
asked on
C# and ZedGraph with time and date in X axis.
How to put the current date and time on the x-axis of the ZedGraph?
How to make the graph plot lines for 10 minutes and stop?
How to make the graph plot lines for 10 minutes and stop?
// GraphPane SETTINGS
GraphPane myPane02m = zed2mm.GraphPane;
timer1.Enabled = false;
//double xRange = myPane02m.XAxis.Scale.Max - myPane02m.XAxis.Scale.Min;
//myPane02m.XAxis.Scale.Max = new XDate(DateTime.Now);
//myPane02m.XAxis.Scale.Min = myPane02m.XAxis.Scale.Max - xRange;
// Y AXIS SETTINGS
myPane02m.YAxis.Title.Text = "Particles"; // Setta como Legenda (Particles) no Eixo Y
myPane02m.YAxis.MajorGrid.IsVisible = true; // Setta Linhas no Eixo Y ou seja na Horizontal.
myPane02m.YAxis.MajorGrid.DashOff = 5; // Seta a Intensidade da Linha no Eixo Y.
// X AXIS SETTINGS
myPane02m.XAxis.MajorGrid.DashOff = 5; // Seta a Intensidade da Linha no Eixo X.
myPane02m.XAxis.MajorGrid.IsVisible = true; // Setta Linhas no Eixo X ou seja na Vertical.
myPane02m.XAxis.MajorTic.IsOpposite = false;
myPane02m.XAxis.MinorTic.IsAllTics = false; // mudei aqui para ver se para de pular o grafico.
myPane02m.XAxis.Scale.FontSpec.Angle = 90; // Setta o Angulo do Scale do Eixo X.
myPane02m.XAxis.Scale.FontSpec.Family = "Arial, Narrow"; // Setta a Fonte da Scale no Eixo X.
myPane02m.XAxis.Scale.FontSpec.FontColor = Color.Fuchsia; // Setta a Cor da Legenda do Dado que Entrara no Eixo X.
myPane02m.XAxis.Scale.FontSpec.IsBold = true; // Setta Negrito na Scale no Eixo X.
myPane02m.XAxis.Scale.FontSpec.Size = 10; // Setta o Tamanho da Fonte da Scale no Eixo X.
myPane02m.XAxis.Scale.Format = "HH:mm:ss\nyy/MM/dd"; // Setta o formato de data e hora e o \n faz uma mudança de linha.
myPane02m.XAxis.Scale.IsSkipCrossLabel = true;
myPane02m.XAxis.Scale.IsPreventLabelOverlap = true;
// Set the initial viewed range
myPane02m.XAxis.Scale.Min = new XDate(DateTime.Now); // We want to use time from now
myPane02m.XAxis.Scale.Max = new XDate(DateTime.Now.AddMinutes(1)); // to 5 min per default
myPane02m.XAxis.Scale.MinorUnit = DateUnit.Second; // set the minimum x unit to time/seconds
myPane02m.XAxis.Scale.MajorUnit = DateUnit.Minute; // set the maximum x unit to time/minutes
myPane02m.XAxis.Scale.MinorStep = 1; // Setta os tracinhos da reta.
myPane02m.XAxis.Scale.MajorStep = 10; // Setta o intervalo do tempo na Scale X.
//myPane02m.XAxis.Scale.MinGrace = 1;
//myPane02m.XAxis.Scale.MaxGrace = 10;
myPane02m.XAxis.Title.FontSpec.FontColor = Color.DarkViolet; // Setta a Cor do Titulo no Eixo X.
myPane02m.XAxis.Title.Text = "Date & Time"; // Setta a Legenda Date & Time no Eixo X.
myPane02m.XAxis.Type = AxisType.Date; // Setta o Tipo do Eixo X como Data.
myPane02m.Legend.Position = ZedGraph.LegendPos.TopCenter;
//myPane02m.Legend.Location.AlignH = AlignH.Right;
//myPane02m.Legend.Location.AlignV = AlignV.Top;
ASKER
Thank you for your replies.
What should change in the lines below to obtain a graph with 10 minutes?
I really need to fix this, I tried a lot on the net, but unfortunately did not find this information.
However, the ZedGraph is a powerful tool and just not know the way.
What should change in the lines below to obtain a graph with 10 minutes?
I really need to fix this, I tried a lot on the net, but unfortunately did not find this information.
However, the ZedGraph is a powerful tool and just not know the way.
myPane02m.XAxis.Scale.Min = new XDate(DateTime.Now);
myPane02m.XAxis.Scale.Max = new XDate(DateTime.Now.AddMinutes(1));
myPane02m.XAxis.Scale.MinorUnit = DateUnit.Second;
myPane02m.XAxis.Scale.MajorUnit = DateUnit.Minute;
myPane02m.XAxis.Scale.MinorStep = 1;
myPane02m.XAxis.Scale.MajorStep = 10;
//myPane02m.XAxis.Scale.MinGrace = 1;
//myPane02m.XAxis.Scale.MaxGrace = 10;
myPane02m.XAxis.Scale.Max = new XDate(DateTime.Now.AddMinu tes(10));
That will create a 10 minute page size on the x axis. If you only want to show a 1 minute page size you will need to scroll the graph.
That will create a 10 minute page size on the x axis. If you only want to show a 1 minute page size you will need to scroll the graph.
ASKER
How do to scroll the graph?
How to setup the legend on Top Right?
Axshun, do you have a model running.
My line chart has problem in the scroll.
Best Regards,
ocaccy
How to setup the legend on Top Right?
Axshun, do you have a model running.
My line chart has problem in the scroll.
Best Regards,
ocaccy
To show the horizontal scrollbar, set the IsShowHScrollBar property of your ZedGraphControl object (I don't see it's name in your code):
yourZedGraphControlName.Is ShowHScrol lBar = true.
To set the legend position, I think you want to use:
myPane02m.Legend.Position = LegendPos.InsideTopRight;
yourZedGraphControlName.Is
To set the legend position, I think you want to use:
myPane02m.Legend.Position = LegendPos.InsideTopRight;
ASKER
I can not use inside.
I need the top right.
Not have otherwise?
best Regards,
ocaccy
I need the top right.
Not have otherwise?
best Regards,
ocaccy
Try using
myPane02m.Legend.Position = LegendPos.Float;
then set the myPane02m.Legend.Location property.
Legend.Location only works when Legend.Position = LegendPos.Float.
myPane02m.Legend.Position = LegendPos.Float;
then set the myPane02m.Legend.Location property.
Legend.Location only works when Legend.Position = LegendPos.Float.
ASKER
How do like this video?
However the X axis by placing the 10 minutes.
http://www.youtube.com/watch?v=XXjbu2v1AMU
However the X axis by placing the 10 minutes.
http://www.youtube.com/watch?v=XXjbu2v1AMU
To get the graph to "auto-scroll" like the one in the video you need to change myPane02m.XAxis.Scale.Min and .Max when each new point of data is added to the curve, but only when a data point is beyond the original .Max.
ASKER
Axshun, thank you.
I text and come back .
Best regards,
ocaccy
I text and come back .
Best regards,
ocaccy
ASKER
It's not working, you have a working model or example?
It may be that I am changing properties.
How to show only the time in the X axis and not be shown any more in the X axis.
Best Regards,
ocaccy
It may be that I am changing properties.
How to show only the time in the X axis and not be shown any more in the X axis.
Best Regards,
ocaccy
The project in which I have used ZedGraph is too complex to post any meaningful code here. Maybe you could post your code along with more specific questions/problems?
ASKER
Ok, Axshun.
myPane02m.YAxis.Title.Text = "Particles";
myPane02m.XAxis.Title.Text = "Date & Time";
How to bring up only the values ¿¿in X and Y axes.
Does not appear XAxis.Title and YAxis.Title and not apperasl X axis and Y axis?
Thank you,
ocaccy
myPane02m.YAxis.Title.Text
myPane02m.XAxis.Title.Text
How to bring up only the values ¿¿in X and Y axes.
Does not appear XAxis.Title and YAxis.Title and not apperasl X axis and Y axis?
Thank you,
ocaccy
Ok, I built a quick form application using your code and I see you need
zed2mm.Invalidate();
after your other code in order to update the graph changes.
zed2mm.Invalidate();
after your other code in order to update the graph changes.
After trying your code I also see you have the MajorStep and MinorStep values set too high. They should be something like:
myPane02m.XAxis.Scale.Mino rStep = .1; myPane02m.XAxis.Scale.Majo rStep = 1.0;
myPane02m.XAxis.Scale.Mino
To get the legend put in the upper right I used the code below.
This will only show a legend if you have added at least one curve to your graph pane.
This will only show a legend if you have added at least one curve to your graph pane.
myPane02m.AddCurve("test curve", new ZedGraph.PointPairList(), Color.Red);
myPane02m.Legend.IsVisible = true;
myPane02m.Legend.Position = LegendPos.Float;
myPane02m.Legend.Location = new Location(0.8, 0.0, CoordType.PaneFraction);
ASKER
OK Axshun,
His information about positioning.
Positioning solved!
See the picture.
The contents of this rectangle appears on two lines.
How to enlarge the rectangle so that it is the content in just one (line) row?
I tried that, but the subscript appears in red.
Zedgraph-capturado.JPG
His information about positioning.
Positioning solved!
See the picture.
The contents of this rectangle appears on two lines.
How to enlarge the rectangle so that it is the content in just one (line) row?
I tried that, but the subscript appears in red.
Zedgraph-capturado.JPG
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I did that too.
As was very small, I am looking for a solution.
It seems to me that this related to the myPane .... Float.
But I learned a lot from you, and my graphics are better.
Thank you.
I'll finish it for scoring.
I'll ask another question to this problem.
Best Regards,
ocaccy
As was very small, I am looking for a solution.
It seems to me that this related to the myPane .... Float.
But I learned a lot from you, and my graphics are better.
Thank you.
I'll finish it for scoring.
I'll ask another question to this problem.
Best Regards,
ocaccy
ASKER
I learned a lot, and my graphics are better.
ocaccy
ocaccy
The only other way I could get a single line legend was to use LegendPos.TopCenter.
ASKER
I did that too.
However, the customer wants right-aligned in a row and with font size 14.
If don`t have a solution within the library ZefGraph; do a backgroud.
However, the customer wants right-aligned in a row and with font size 14.
If don`t have a solution within the library ZefGraph; do a backgroud.
You would need to modify ZedGraph's LegendPos enum to add TopFlushRight, and then modify the graph pane Paint() method to work with that.
ASKER
Wow, this was very good.
But you said ZedGraph and not myPane, which way?
But you said ZedGraph and not myPane, which way?
You would have to modifiy ZedGraph source files and rebuild their dll file.
ASKER
I'll try it then.
I will take a while.
It is best to ask another question or we can continue this same?
I will take a while.
It is best to ask another question or we can continue this same?
Probably best to ask a new question when you have one.
ASKER
Thank you Axshun.
Best Regards,
ocaccy
Best Regards,
ocaccy
As far as stopping the graph at 10 minutes, I think your application needs to handle that in the method that adds the points to the curve.