Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7806427
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T02:31:53+00:00 2026-06-02T02:31:53+00:00

In following my question ZedGraph custom graph I have chart with every second inserting

  • 0

In following my question “ZedGraph custom graph” I have chart with every second inserting of datas, now I have other questions:

  1. How to smoothly move down Y2Axis (DateTime type) with a chart line and show in chart always only last 30 minutes?

  2. How to format Y2Axis labels “HH:mm” to get 10:05, 10:10, 10:15, …, 10:30?

Thanks for help!

UPD1:
Thanks kmp! I try your code – its good, but with issue: when I started I see this:
enter image description here
When after few minutes I see this picture:
enter image description here

I have a “compression” of chart area, but I want statically show always last 30 minute and slowly move down old datas, without of scaling or “packing” chart with axis. I hope you understand me.

UPD2:
Yet another issue – labels of Y2Axis haven’t fixed values. For example now:
enter image description here

And after few seconds:
enter image description here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T02:31:55+00:00Added an answer on June 2, 2026 at 2:31 am

    Starting with the easiest – formatting the labels can be done like so:

    myPane.Y2Axis.Scale.Format = "HH:mm";
    

    One way you could do this (and it feels a bit flaky but I will let you decide) is to simply remove the points from the curve once they go beyond your threshold (in this case more than 30 minutes). That way when the chart redraws the axis will update accordingly.

    I feel like taking the scale min value might be a better approach than this, but failing that you can simply maintain a queue as you add the points like so and then remove them when they go beyond your threshold:

    private Queue<DateTime> axisTimes;
    
    private static readonly Random rnd = new Random();
    
    private void button1_Click(object sender, EventArgs e)
    {
        GraphPane myPane = zg1.GraphPane;
    
        myPane.XAxis.IsVisible = false;
    
        myPane.X2Axis.IsVisible = true;
        myPane.X2Axis.MajorGrid.IsVisible = true;
        myPane.X2Axis.Scale.Min = 0;
        myPane.X2Axis.Scale.Max = 600;
    
        myPane.YAxis.IsVisible = false;
    
        myPane.Y2Axis.IsVisible = true;
        myPane.Y2Axis.Scale.MajorUnit = DateUnit.Minute;
        myPane.Y2Axis.Scale.MinorUnit = DateUnit.Second;
        myPane.Y2Axis.Scale.Format = "HH:mm";
        myPane.Y2Axis.Type = AxisType.DateAsOrdinal;
    
        LineItem myCurve = myPane.AddCurve("Alpha",
                                      new PointPairList(),
                                      Color.Red,
                                      SymbolType.None);
    
        myCurve.Symbol.Fill = new Fill(Color.White);
        myCurve.IsX2Axis = true;
        myCurve.IsY2Axis = true;
    
        myPane.Chart.Fill = new Fill(Color.White, Color.LightGray, 45.0f);
        zg1.IsShowPointValues = true;
    
        axisTimes = new Queue<DateTime>();
    
        var t = new System.Windows.Forms.Timer();
        t.Interval = 1000;
        t.Tick += ShowData;
    
        Thread.Sleep(100);
    
        t.Start();
    }
    
    private void ShowData(object sender, EventArgs e)
    {
        var t = (System.Windows.Forms.Timer) sender;
        t.Enabled = false;
    
        int x = rnd.Next(500, 600);
        var y = new XDate(DateTime.Now);
    
        var myCurve = zg1.GraphPane.CurveList[0];
    
        if (axisTimes.Any())
        {             
            // Remove any points that go beyond our time threshold
            while ((((DateTime)y) - axisTimes.Peek()).TotalMinutes > 30)
            {
                myCurve.RemovePoint(0);
                axisTimes.Dequeue();
    
                if (!axisTimes.Any())
                {
                    break;
                }
            }
        }
    
        // Add the new point and store the datetime that it was added in
        // our own queue
        axisTimes.Enqueue(y);
        myCurve.AddPoint(x, y);
    
        zg1.AxisChange();
        zg1.Invalidate();
    
        t.Enabled = true;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a following question. Now, suppose we have two repositories, a stable one
I have gone through following question. Convert NSString to NSDictionary It is something different
Based on the following question: Check if one string is a rotation of other
I have the following question about JPA: Can I save the order of the
Hi i have a following question. According to spring docs tx:annotation-driven only respects bean
I have the following question: I start my activity and i call bindService in
I have the following question on boost::iostreams . If someone is familiar with writing
I have the following question, and what I'm most confused on, is how to
I have the following question: If asked whether to use a shift vs a
i have following question. I tried assignment by value and by reference and as

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.