Page 1 of 1

Incremented date and custom text in bottom axes label

Posted: Mon Mar 01, 2010 9:17 am
by 13047867
Hello,
i have you a technical question about chart. if you look example in below.
To add customXValue, i can make like below

Code: Select all

ch1.Axes.Bottom.Labels.Style = Steema.TeeChart.AxisLabelStyle.Text;
DateTime date = DateTime.Parse(xValue);
xValue = date.ToString("dd/MM");
series.Add(date, Convert.ToDouble(yValue), xValue + Environment.NewLine + customXValue);
ch1.Axes.Bottom.Increment = 7; // Steema.TeeChart.Utils.GetDateTimeStep(Steema.TeeChart.DateTimeSteps.HalfMonth);
ch1.Axes.Bottom.Labels.DateTimeFormat = "dd/MM";
ch1.Series.Add(series);

But when i want to show date in X axis relativly with 7 days increment. The code,which in above does not work. Increment is not right.

But when i make to TeeChart.AxisLabelStyle.Text to TeeChart.AxisLabelStyle.Value ,Increment works right, but customXValue is not shown in chart.
My question is that. How can i make my dates increment in X axis and also how can i show my customXValue next to increment date.

Thanks,
Aytaç Kargınoğlu

Re: Incremented date and custom text in bottom axes label

Posted: Tue Mar 02, 2010 3:25 pm
by yeray
Hi Aytaç Kargınoğlu,

The following seems to work fine for me here. Could you please modify it so that we can reproduce the problem here?

Code: Select all

            tChart1.Aspect.View3D = false;
            Steema.TeeChart.Styles.Points series = new Steema.TeeChart.Styles.Points(tChart1.Chart);
            tChart1.Axes.Bottom.Labels.Style = Steema.TeeChart.AxisLabelStyle.Text;

            Random rnd = new Random();
            for (int i = 0; i < 20; i++)
            {            
                DateTime xValue = DateTime.Parse((i + 1).ToString() + "/01/2010");                
                series.Add(xValue, rnd.Next(), xValue.ToString("dd/MM"));
            }            
            tChart1.Axes.Bottom.Increment = Steema.TeeChart.Utils.GetDateTimeStep(Steema.TeeChart.DateTimeSteps.OneWeek);
            tChart1.Axes.Bottom.Labels.DateTimeFormat = "dd/MM";
            tChart1.Series.Add(series);

Re: Incremented date and custom text in bottom axes label

Posted: Wed Mar 03, 2010 12:44 pm
by 13047867
Hi Yeray,

Firstly thank you for your responding. But i was not able to work my project. So i send you a file, which is in "http://www.steema.net/upload" and its name is "Test_Chart.rar". Please could you look my project and from where i make false?

from now thank you for interesting
Aytaç Kargınoğlu

Re: Incremented date and custom text in bottom axes label

Posted: Thu Mar 04, 2010 4:17 pm
by yeray
Hi Aytaç Kargınoğlu,

Excuse me, I've made a mistake in the previous message. Setting the axis labels style to show the labels, the increment doesn't recognize the dates, it only considers the points.
In your application, you add 12 points per day, so setting an increment of 7 you are forcing the points between valueindex 0 and 6 not to be shown, but both them are from the same day.
Changing the increment day for the following I think it works as you expected:

Code: Select all

ch1.Axes.Bottom.Increment = 7 * 12;
Of course this forces you to add always 12 points per day. Another solution would be working with custom labels. Here is a thread where you could find many examples with custom labels.