Page 1 of 1

controlling the space between the ticks

Posted: Tue Jul 01, 2008 11:35 am
by 9526439
Hi,

I am plotting a line series. After that, I am plotting another line series on the same graph. The bottom axis has dates, but the dates are not equally spaced. I want to modify the ticks and the labels on the bottom axis so that they look nice.

I want to equally space them so that the distance between two ticks is 1 year. Please help.

Regards,

Amol

Posted: Tue Jul 01, 2008 11:50 am
by narcis
Hi Amol,

You could try setting DateTime axis increment as told in Tutorial 4 - Axis Control. Tutorials can be found at TeeChart's program group.

Displaying selected labels

Posted: Tue Jul 01, 2008 12:48 pm
by 9526439
Hi Narcis,

Thanks for the prompt reply. I want to add data for every month for 50 years. However, I want to display only 50 labels on the bottom axis. One label per year.

How do I do this?

Thanks.

Amol

Posted: Tue Jul 01, 2008 2:11 pm
by narcis
Hi Amol,

Code below does what you request:

Code: Select all

Private Sub Form_Load()
    TeeCommander1.Chart = TChart1
    
    TChart1.Aspect.View3D = False
    
    TChart1.AddSeries scPoint
    TChart1.Series(0).XValues.DateTime = True
    
    TChart1.Axis.Bottom.Labels.Angle = 90
    TChart1.Axis.Bottom.Increment = TChart1.GetDateTimeStep(dtOneMonth)
    
    NumberOfPoints = 12 * 50 '12 months per 50 years.
    Today = Now
    
    For i = 0 To NumberOfPoints
        TChart1.Series(0).AddXY Today + i * 30, Rnd, "", clTeeColor
    Next
End Sub
However, TeeChart automatically draws the labels in the desired increment provided they fit in given axis space. Otherwise draws the minimum increment that makes labels not overlapping. If you use code above and zoom in the series you'll see that a label every month is plotted.

How to cover the gap in labels when displaying two series

Posted: Tue Jul 01, 2008 7:13 pm
by 9526439
Hey Narcis,

BTW, Congrats on Spain's victory in the EURO CUP!! That's wonderful!

I am having problem when I am trying to display two different series on the same graph. I want to send you a word document that has a screenshot that displays the problem and the code snippet. I made changes as per your suggestion. However, my problem is when I am trying to display more than one series, the continuity in the labels breaks even though the series are one after the other.

Please help!

Regards,

Amol[/img][/list]

File uploaded

Posted: Tue Jul 01, 2008 7:18 pm
by 9526439
Hey Narcis,

I was able to upload the file containing the screenshot that describes my problem. I have uploaded this from the web based upload page.

Regards,

Amol

Posted: Wed Jul 02, 2008 9:24 am
by narcis
Hi Amol,
BTW, Congrats on Spain's victory in the EURO CUP!! That's wonderful!
Thanks for the sentiment. Hope this will be good for spanish football since my favourite team (F.C. Barcelona) plays in the spanish league:

http://en.wikipedia.org/wiki/FCBarcelona
http://www.fcbarcelona.com/web/english/

However, Steema Software is based in Catalonia:

http://en.wikipedia.org/wiki/Catalonia
http://www.gencat.cat/catalunya/eng/

I was also born in Catalonia in a Catalan family and thus my mother tongue is Catalan so you may understand that I don't feel identified with Spain. I wonder if this is a common feeling in Steema Software :wink:
I am having problem when I am trying to display two different series on the same graph. I want to send you a word document that has a screenshot that displays the problem and the code snippet. I made changes as per your suggestion. However, my problem is when I am trying to display more than one series, the continuity in the labels breaks even though the series are one after the other.
This could be that you are using series text labels as bottom axis labels. You could try setting axis labels style like this:

Code: Select all

    TChart1.Axis.Bottom.Labels.Style = talValue
If this doesn't help, could you please send us a simple example project we can run "as-is" to reproduce the problem here?

Thanks in advance.

Issue still unresolved

Posted: Fri Jul 18, 2008 3:10 pm
by 9526439
Dear Narcis,

Sorry about the late response. The solution you provided brought me closer to solving my problem, however, there is a new issue. I am sure you can help me with this. Now, when I use: m_ChartRate.GetAxis().GetBottom().GetLabels().SetStyle(talValue); as per your instructions, TeeChart places the labels at equal intervals. However, my labels are dates, which are being fed to TeeChart as strings as:

m_ChartRate.Series(4).AddXY(t,propVal,datestring,clTeeColor);

Where:
t is the time value in double
propVal is the property value to be displayed on Y axis
datestring is the date in string format corresponding to the t (described above)
and then the color.

I have uploaded the screenshot on: http://www.steema.net/upload/Default.aspx

Can you please guide me on how to display the date strings on the X axis (Bottom axis) in a format: mm/yyyy

Thanks for your kind help.

Best regards,

Amol

Posted: Mon Jul 21, 2008 8:28 am
by narcis
Dear Amol,

Yes, in that case you'd need to set series' X values as being DateTime, for example:

Code: Select all

	m_Chart1.Series(0).GetXValues().SetDateTime(true);
Hope this helps!

Getting there

Posted: Tue Jul 22, 2008 6:19 am
by 9526439
Hey Narcis,

I think with your kind help, I'll soon get there and resolve my problem. Now, I am getting some dates that range from 1900 to 1916. However, the corresponding dates should ideally range from: 1992 to 2007

I am enclosing the data here. The X values are the ones that I get after doing the conversion using the function that you had provided. The data shown under the header Text is the data that I should get on the X axis. The text data is the one that I am getting after converting the double values to date-time format in my code and then converting it to text for the labels purpose. I am also uploading the screen-shot of the issue. Please help me in resolving this problem.

Best regards,

Amol

Text X Data
01/1992 11/1/1900 142.838709677419
02/1992 12/3/1900 831.214285714286
03/1992 12/31/1900 1542.41935483871
04/1992 1/31/1901 1103.46666666667
05/1992 3/2/1901 848.41935483871
06/1992 4/2/1901 859.366666666667
07/1992 5/2/1901 778.677419354839
08/1992 6/2/1901 539.064516129032
09/1992 7/3/1901 245.166666666667
10/1992 8/2/1901 515.903225806452
11/1992 9/2/1901 540
12/1992 10/2/1901 640.129032258065
01/1993 11/2/1901 479.58064516129
02/1993 12/3/1901 646.535714285714
03/1993 12/31/1901 671.483870967742
04/1993 1/31/1902 840.6
05/1993 3/2/1902 936.161290322581
06/1993 4/2/1902 1033.33333333333
07/1993 5/2/1902 805.806451612903
08/1993 6/2/1902 395.354838709677
09/1993 7/3/1902 892.9
10/1993 8/2/1902 860.290322580645
11/1993 9/2/1902 787.8
12/1993 10/2/1902 718.838709677419
01/1994 11/2/1902 636.096774193548
02/1994 12/3/1902 742.642857142857
03/1994 12/31/1902 429.193548387097
04/1994 1/31/1903 725.166666666667
05/1994 3/2/1903 687.645161290323
06/1994 4/2/1903 433.033333333333
07/1994 5/2/1903 904.064516129032
08/1994 6/2/1903 817.322580645161
09/1994 7/3/1903 908.966666666667
10/1994 8/2/1903 859.903225806452
11/1994 9/2/1903 552.5
12/1994 10/2/1903 654.516129032258
01/1995 11/2/1903 631.322580645161
02/1995 12/3/1903 464.857142857143
03/1995 12/31/1903 675.258064516129
04/1995 1/31/1904 592.166666666667
05/1995 3/1/1904 596.870967741935
06/1995 4/1/1904 724.833333333333
07/1995 5/1/1904 640.322580645161
08/1995 6/1/1904 300.387096774194
09/1995 7/2/1904 565.5
10/1995 8/1/1904 661.193548387097
11/1995 9/1/1904 662.5
12/1995 10/1/1904 610.677419354839
01/1996 11/1/1904 450.387096774194
02/1996 12/3/1904 488.035714285714
03/1996 12/31/1904 470.032258064516
04/1996 1/31/1905 659.4
05/1996 3/2/1905 546.935483870968
06/1996 4/2/1905 862.366666666667
07/1996 5/2/1905 901.516129032258
08/1996 6/2/1905 1033.67741935484
09/1996 7/3/1905 661.7
10/1996 8/2/1905 812.258064516129
11/1996 9/2/1905 515.433333333333
12/1996 10/2/1905 462.935483870968
01/1997 11/2/1905 426.903225806452
02/1997 12/3/1905 444
03/1997 12/31/1905 503.41935483871
04/1997 1/31/1906 446.766666666667
05/1997 3/2/1906 271.741935483871
06/1997 4/2/1906 261.266666666667
07/1997 5/2/1906 17.3225806451613
08/1997 6/2/1906 15.9032258064516
09/1997 7/3/1906 15.9
10/1997 8/2/1906 18.0967741935484
11/1997 9/2/1906 17.1333333333333
12/1997 10/2/1906 14.2258064516129
01/1998 11/2/1906 16.5806451612903
02/1998 12/3/1906 53.6785714285714
03/1998 12/31/1906 43.4838709677419
04/1998 1/31/1907 144.9
05/1998 3/2/1907 24.3225806451613
06/1998 4/2/1907 20.2
07/1998 5/2/1907 102.064516129032
08/1998 6/2/1907 12.8064516129032
09/1998 7/3/1907 0.666666666666667
10/1998 8/2/1907 0.387096774193548
11/1998 9/2/1907 0
12/1998 10/2/1907 0
01/1999 11/2/1907 0
02/1999 12/3/1907 0
03/1999 12/31/1907 0
04/1999 1/31/1908 0
05/1999 3/1/1908 0
06/1999 4/1/1908 1.56666666666667
07/1999 5/1/1908 174.967741935484
08/1999 6/1/1908 0
09/1999 7/2/1908 8.33333333333333
10/1999 8/1/1908 0
11/1999 9/1/1908 10.2
12/1999 10/1/1908 6.32258064516129
01/2000 11/1/1908 344.387096774194
02/2000 12/3/1908 16.1785714285714
03/2000 12/31/1908 13.0322580645161
04/2000 1/31/1909 455.7
05/2000 3/2/1909 0
06/2000 4/2/1909 257.733333333333
07/2000 5/2/1909 237.064516129032
08/2000 6/2/1909 181.709677419355
09/2000 7/3/1909 569.033333333333
10/2000 8/2/1909 550.677419354839
11/2000 9/2/1909 400.8
12/2000 10/2/1909 230.516129032258
01/2001 11/2/1909 21.4193548387097
02/2001 12/3/1909 18.8571428571429
03/2001 12/31/1909 24.6774193548387
04/2001 1/31/1910 50.2666666666667
05/2001 3/2/1910 44.3225806451613
06/2001 4/2/1910 46.7666666666667
07/2001 5/2/1910 188.516129032258
08/2001 6/2/1910 183.870967741935
09/2001 7/3/1910 47.6666666666667
10/2001 8/2/1910 200.870967741935
11/2001 9/2/1910 47.8333333333333
12/2001 10/2/1910 238.709677419355
01/2002 11/2/1910 100.741935483871
02/2002 12/3/1910 108.178571428571
03/2002 12/31/1910 70.741935483871
04/2002 1/31/1911 669.966666666667
05/2002 3/2/1911 662.935483870968
06/2002 4/2/1911 605.466666666667
07/2002 5/2/1911 611.354838709677
08/2002 6/2/1911 677.548387096774
09/2002 7/3/1911 329.166666666667
10/2002 8/2/1911 339.903225806452
11/2002 9/2/1911 510.866666666667
12/2002 10/2/1911 0
01/2003 11/2/1911 0
02/2003 12/3/1911 0
03/2003 12/31/1911 0
04/2003 1/31/1912 1051.36666666667
05/2003 3/1/1912 1017.41935483871
06/2003 4/1/1912 744.666666666667
07/2003 5/1/1912 710.612903225806
08/2003 6/1/1912 1259.06451612903
09/2003 7/2/1912 1293.23333333333
10/2003 8/1/1912 0
11/2003 9/1/1912 0
12/2003 10/1/1912 0
01/2004 11/1/1912 0
02/2004 12/3/1912 506.107142857143
03/2004 12/31/1912 1247.83870967742
04/2004 1/31/1913 528.466666666667
05/2004 3/2/1913 442.935483870968
06/2004 4/2/1913 717.433333333333
07/2004 5/2/1913 577.967741935484
08/2004 6/2/1913 798.709677419355
09/2004 7/3/1913 775.433333333333
10/2004 8/2/1913 582.4
11/2004 9/2/1913 471.666666666667
12/2004 10/2/1913 406.654838709677
01/2005 11/2/1913 475.02
02/2005 12/3/1913 410.578214285714
03/2005 12/31/1913 580.72
04/2005 1/31/1914 586.291666666667
05/2005 3/2/1914 588.09064516129
06/2005 4/2/1914 535.965
07/2005 5/2/1914 501.303225806452
08/2005 6/2/1914 1.97
09/2005 7/3/1914 2.24
10/2005 8/2/1914 2.33
11/2005 9/2/1914 512.130333333333
12/2005 10/2/1914 533.633870967742
01/2006 11/2/1914 501.553225806452
02/2006 12/3/1914 287.608571428571
03/2006 12/31/1914 657.373225806452
04/2006 1/31/1915 717.086
05/2006 3/2/1915 750.472258064516
06/2006 4/2/1915 734.912666666667
07/2006 5/2/1915 716.977096774194
08/2006 6/2/1915 659.979032258064
09/2006 7/3/1915 490.830333333333
10/2006 8/2/1915 575.452903225806
11/2006 9/2/1915 586.016666666667
12/2006 10/2/1915 209.06
01/2007 11/2/1915 184.145806451613
02/2007 12/3/1915 363.716071428571
03/2007 12/31/1915 492.584516129032
04/2007 1/31/1916 506.979333333333
05/2007 3/1/1916 403.35064516129
06/2007 4/1/1916 507.570666666667
07/2007 5/1/1916 463.188709677419
08/2007 6/1/1916 373.998387096774
09/2007 7/2/1916 455.682333333333
10/2007 8/1/1916 675.248709677419
11/2007 9/1/1916 599.4
12/2007 10/1/1916 533.433225806452

Posted: Tue Jul 22, 2008 8:51 am
by narcis
Hi Amol,

Could you also please attach a simple example project we can run "as-is" to reproduce the problem here and showing how do you convert DateTime data?

Thanks in advance.