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 6214347
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:51:37+00:00 2026-05-24T06:51:37+00:00

In ZedGraph, how do I draw a time (like 00:00, 02:00, 04:00, etc.) on

  • 0

In ZedGraph, how do I draw a time (like 00:00, 02:00, 04:00, etc.) on the Y axis and date (like 12-Apr-11, 13-Apr-11, 14-Apr-11, etc.) on the X axis?
The bar settings has been set to BarType.Stack.

Sample code will be very helpful.

  • 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-05-24T06:51:38+00:00Added an answer on May 24, 2026 at 6:51 am

    Here is a sample that I constructed. I was not sure what sort of data you would plot along the Y Axis using a time format except for something like an accrued amount of time (such as number of hours employees worked).

    ZedGraph uses an XDate format for time along the axes, which are doubles converted from datetimes. However in a stacked bar, I am not sure if ZedGraph can aggregate the times properly (I couldn’t get it to work). Thus, in my example I used a Linear type for the Y Axis and changed the format so that it displays as hours and minutes.

    Note that the min and max of both axes’ scales have been set. This is especially important along the X axis, as the auto setting gets it wrong. Some of the other settings I specify clean up the minor tic marks, etc.

    Here’s an example showing a stacked bar graph for number of hours worked by three employees during each day:

    const int NumberOfBars = 5;
    
    GraphPane myPane = zedGraphControl1.GraphPane;
    myPane.Title.Text = "Employee Hours";
    myPane.BarSettings.Type = BarType.Stack;
    myPane.BarSettings.ClusterScaleWidth = 1D;
    
    // X AXIS SETTINGS
    myPane.XAxis.Title.Text = "Date";
    myPane.XAxis.Type = AxisType.Date;
    myPane.XAxis.Scale.Format = "dd-MMM-yy";
    myPane.XAxis.Scale.MajorUnit = DateUnit.Day;
    myPane.XAxis.Scale.MajorStep = 1;
    myPane.XAxis.Scale.Min = new XDate(DateTime.Now.AddDays(-NumberOfBars));
    myPane.XAxis.Scale.Max = new XDate(DateTime.Now);
    myPane.XAxis.MajorTic.IsBetweenLabels = true;
    myPane.XAxis.MinorTic.Size = 0;
    myPane.XAxis.MajorTic.IsInside = false;
    myPane.XAxis.MajorTic.IsOutside = true;
    
    // Y AXIS SETTINGS
    myPane.YAxis.Title.Text = "Hours Worked";
    myPane.YAxis.Type = AxisType.Linear;
    myPane.YAxis.Scale.Format = @"00:\0\0";
    myPane.YAxis.Scale.Min = 0;
    myPane.YAxis.Scale.Max = 24;
    myPane.YAxis.Scale.MajorStep = 1;
    myPane.YAxis.MinorTic.Size = 0;
    
    // Construct some sample data
    Random r = new Random();
    List<double> DatesX = new List<double>();
    double[] JohnHours = new double[NumberOfBars];
    double[] JoanHours = new double[NumberOfBars];
    double[] JaneHours = new double[NumberOfBars];
    
    for (int i = 0; i < NumberOfBars; i++)
    {
        DatesX.Add(new XDate(DateTime.Today.AddDays(-i)));
        JohnHours[i] = r.Next(1, 9);
        JoanHours[i] = r.Next(1, 9);
        JaneHours[i] = r.Next(1, 9);
    }
    myPane.AddBar("John", DatesX.ToArray(), JohnHours, Color.Red);
    myPane.AddBar("Joan", DatesX.ToArray(), JoanHours, Color.Blue);
    myPane.AddBar("Jane", DatesX.ToArray(), JaneHours, Color.Green);
    

    Stacked Hours Bar Chart

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using zedgraph to draw bar chart in my vb.net project. The bar
I use zedgraph to draw figures in my vb.net project. The x axis of
How to draw triangle wave (symmetrical) using ZedGraph ? alt text http://img101.imageshack.us/img101/8482/okr20troj.jpg Preferably with
I would like to draw a realtime chart on a WindowsForm. My platform is
In ZedGraph, I had to convert my date to XDate in order to plot
When you use Zedgraph for linegraphs and set IsSmooth to true, the lines are
Using the ZedGraph control, say I am plotting data that has Y values of
How to set max and min values manually on the Axis scale in the
I have a ZedGraph stacked bar graph, and I want each bar to show
I got a histogram drawn in ZedGraph. And I have to set the specific

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.