Page 1 of 1

how to change am-pm to 24 hr

Posted: Wed Feb 09, 2011 4:37 am
by 15656586
hi
i want to display Axes.Bottom from am-pm to 24 hrs. when i was zooming . How do I ?


Image

Re: how to change am-pm to 24 hr

Posted: Wed Feb 09, 2011 4:53 am
by 15656586
i mean in normal state show only date and when zoom in one day show only time in 24 hour not am/pm...

Re: how to change am-pm to 24 hr

Posted: Wed Feb 09, 2011 4:56 am
by 15656586
and show full date and time when mouse is over chart

Re: how to change am-pm to 24 hr

Posted: Wed Feb 09, 2011 12:58 pm
by 10050769
Hello aonzuza,

I have made a simple code using Events Zoomed and UndoneZoom and I think you can do something similar as next:

Code: Select all

        private void InitializeChart()
        {  //var
            Random rnd = new Random();
            DateTime today = DateTime.Today;
            TimeSpan oneDay = TimeSpan.FromDays(1);
            //Initialize
            tChart1.Aspect.View3D = false;
            tChart1.Dock = DockStyle.Fill;
            Steema.TeeChart.Styles.FastLine series1 = new Steema.TeeChart.Styles.FastLine(tChart1.Chart);
            Steema.TeeChart.Styles.FastLine series2 = new Steema.TeeChart.Styles.FastLine(tChart1.Chart);
            //Series Data
            series1.XValues.DateTime = true;
            series2.XValues.DateTime = true;
            for (int i = 1; i <= 5; ++i)
            {
                series1.Add(today, rnd.Next(100), Color.Red);
                series2.Add(today, rnd.Next(100), Color.Blue);
                today += oneDay;
            }
            //Axes
            tChart1.Zoomed += new EventHandler(tChart1_Zoomed);
            tChart1.UndoneZoom += new EventHandler(tChart1_UndoneZoom);
        }

        void tChart1_UndoneZoom(object sender, EventArgs e)
        {
            tChart1.Axes.Bottom.Labels.DateTimeFormat = "dd/MM/yyyy";
            tChart1.Axes.Bottom.Increment = Steema.TeeChart.Utils.GetDateTimeStep(Steema.TeeChart.DateTimeSteps.OneDay);
        }
       void tChart1_Zoomed(object sender, EventArgs e)
        {
            tChart1.Axes.Bottom.Labels.DateTimeFormat = "HH:mm";
            tChart1.Axes.Bottom.Increment = Steema.TeeChart.Utils.GetDateTimeStep(Steema.TeeChart.DateTimeSteps.SixHours);
        }
Could you tell us if previous code works as you want?

I hope will helps.

Thanks,