labels ammount

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Igor G
Newbie
Newbie
Posts: 16
Joined: Thu Dec 11, 2008 12:00 am

labels ammount

Post by Igor G » Sun Jun 28, 2009 11:56 am

Hi
I need to control how much labels I want to show.
I have an X axis (DateTime) and I need to show grid lines every week.
How can I do this?

Thanks a lot

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: labels ammount

Post by Sandra » Mon Jun 29, 2009 9:04 am

Hello Igor G,

I make a simple example that you can use similar code for your application,think solve your problem using property of Bottom.Increment and Steema.TeeChart.Utils.GetDateTimeSteps(Steema.TeeChart.DateTimeSteps.OneWeek). Also you can use more type DateTimeSteps for increment axes labels for example: oneday, twodays, onemonth etc. DateTimeSteps as you see is using when you would increment DateTime for differents days,month,years etc.

Code: Select all

     private Steema.TeeChart.Styles.Line line1;
        private void InitializeChart()
        {
            line1 = new Steema.TeeChart.Styles.Line(tChart1.Chart);
            line1.FillSampleValues();
            line1.XValues.DateTime = true;
            tChart1.Axes.Bottom.Labels.DateTimeFormat = "dd/MM/yyyy";
            tChart1.Axes.Bottom.Increment = Steema.TeeChart.Utils.GetDateTimeStep(Steema.TeeChart.DateTimeSteps.OneWeek);
        }
I hope that will helps

Thanks,

Igor G
Newbie
Newbie
Posts: 16
Joined: Thu Dec 11, 2008 12:00 am

Re: labels ammount

Post by Igor G » Mon Jun 29, 2009 9:12 am

Hi
This is not so good - this will decrease a total ammount of labels.
I will describe my situation:
I have a graph with 720 x values (increment is 2 hours).
I want to stay at 2 hours resolution but when I display this graph I just want the grid lines to be drawn every week.
Thats all:)
Thanks

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: labels ammount

Post by Sandra » Tue Jun 30, 2009 9:17 am

Hello Igor G,

I make a simple example, that I think solve your problem. Please check next code works fine.

Code: Select all

  private Steema.TeeChart.Styles.Line line1;
        private void InitializeChart()
        {
          
            line1 = new Steema.TeeChart.Styles.Line(tChart1.Chart);
            tChart1.Dock = DockStyle.Fill;

            Random y = new Random();

            for (int i = 0; i < 720; i++)
            {
                line1.Add(DateTime.Now.AddHours(i*2), y.Next());
            }
            line1.XValues.DateTime = true;
            tChart1.Axes.Bottom.Labels.DateTimeFormat = "dd/MM/yyyy hh:mm";
            tChart1.Axes.Bottom.Increment = Steema.TeeChart.Utils.GetDateTimeStep(Steema.TeeChart.DateTimeSteps.TwoHours);
            tChart1.Axes.Bottom.Labels.Angle = 90;
            tChart1.Axes.Left.Grid.Visible = false;
            tChart1.Axes.Bottom.Grid.Visible = false;

            tChart1.AfterDraw += new Steema.TeeChart.PaintChartEventHandler(tChart1_AfterDraw);
        }

        void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
        {
            int tmp = (int)Math.Ceiling(line1.XValues[0]);

            for (int i = tmp; i < line1.MaxXValue(); i=i+7)
            {
                int tmpX = tChart1.Axes.Bottom.CalcPosValue(i);
                Rectangle rect = tChart1.Chart.ChartRect;

                g.Pen.Color = Color.Red;
                g.Pen.Style = System.Drawing.Drawing2D.DashStyle.Dash;
                g.Line(tmpX, rect.Bottom, tmpX, rect.Top);        
            }
        }
I hope that will helps.


Thanks,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply