number of ticks or tick frequency

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
cssesuc
Newbie
Newbie
Posts: 44
Joined: Wed Apr 08, 2015 12:00 am

number of ticks or tick frequency

Post by cssesuc » Wed Jun 10, 2015 9:20 pm

Dear support,
I am trying to fix the maximal number of ticks of the y axis for the attached plot for instance.
Is there some simple approach I could use here to control the number of ticks?
thanks in advance for the feedback.
Attachments
Capture.JPG
Capture.JPG (170 KiB) Viewed 13888 times
thanks,
Nabil Ghodbane (PhD. Habil)

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: number of ticks or tick frequency

Post by Narcís » Thu Jun 11, 2015 7:12 am

Dear Nabil,

Yes, you can do that using axis Increment property. You'll find more info about that in tutorial 4.
Best Regards,
Narcís Calvet / 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

cssesuc
Newbie
Newbie
Posts: 44
Joined: Wed Apr 08, 2015 12:00 am

Re: number of ticks or tick frequency

Post by cssesuc » Thu Nov 26, 2015 4:12 pm

Hi,
the issue I have here is that I would need to figure out some algorithm to compute the increment value.
Is there some other solution I could use here instead?
thanks
thanks,
Nabil Ghodbane (PhD. Habil)

Yeray
Site Admin
Site Admin
Posts: 9612
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: number of ticks or tick frequency

Post by Yeray » Thu Nov 26, 2015 4:40 pm

Hello,
cssesuc wrote:Is there some other solution I could use here instead?
TeeChart by default tries to calculate an increment to show the labels preventing the overlapping.
However, if you are using custom labels you should do this job. Some tips that may help you:

- Chart height. This is the height of the are where the series can be drawn:

Code: Select all

  tmpH:=Chart1.ChartRect.Bottom - Chart1.ChartRect.Top;
- Font height for the left axis labels:

Code: Select all

  Chart1.Canvas.Font.Assign(Chart1.Axes.Left.LabelsFont);
  tmpFontH:=Chart1.Canvas.TextHeight('Wj');
- To transform axis values to pixel screen coordinates:

Code: Select all

  tmpPos:=Chart1.Axes.Left.CalcPosValue(tmpValue);
- To transform pixel screen coortinates to axis values:

Code: Select all

  tmpValue:=Chart1.Axes.Left.CalcPosPoint(tmpPos);
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

cssesuc
Newbie
Newbie
Posts: 44
Joined: Wed Apr 08, 2015 12:00 am

Re: number of ticks or tick frequency

Post by cssesuc » Thu Nov 26, 2015 5:01 pm

hI?
many thanks for the prompt reply. Indeed I am not using custom labels. Could it be simply that in my case, since I am using log scale, the algorithm which computes the "optimal spacing " between two consecutive labels is not working.
thanks
thanks,
Nabil Ghodbane (PhD. Habil)

cssesuc
Newbie
Newbie
Posts: 44
Joined: Wed Apr 08, 2015 12:00 am

Re: number of ticks or tick frequency

Post by cssesuc » Fri Nov 27, 2015 8:38 am

Hi,
I might have replied too quickly here... What I understand from your email is the following
I need to compute:
1- the size in pixels for the Chart:
2- the number of items for the left axis
3- get the size in pixels of one of the items of the left axis,
I believe one could simply use:
TAxisItem(Chart1.LeftAxis.Items.First).Format.Height; or ???
4- compute the total size of all these items
5- if this size exceeds the size computed at step 1, then remove items from the left axis (or remove their label)
6- iterate until the computed size is smaller than the chart size
does this sound feasible with the 2013 release ?
And my second question: at which "event" do you advise me to implement this algorithm if you think it could work.
thanks
Last edited by cssesuc on Fri Nov 27, 2015 10:54 am, edited 1 time in total.
thanks,
Nabil Ghodbane (PhD. Habil)

Yeray
Site Admin
Site Admin
Posts: 9612
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: number of ticks or tick frequency

Post by Yeray » Fri Nov 27, 2015 10:53 am

Hi,
cssesuc wrote: 3- get the size in pixels of one of the items of the left axis,
I believe one could simply use:
TAxisItem(Chart1.LeftAxis.Items.First).Format.Height; or ???
This takes the first axis item. If it exists I don't see any problem with using it.
cssesuc wrote:4- compute the total size of all these items
5- if this size exceeds the size computed at step 1, then remove items from the left axis (or remove their label)
6- iterate until the computed size is smaller than the chart size
does this sound feasible with the 2013 release ?
The idea was a bit different.
I was thinking on clearing all the labels and adding those you want calculating how many can fit given the chart height and the labels height.
Your approach is also valid. I would use OnGetAxisLabel event to hide those you don't want, setting an empty LabelText string in that event.

Take a look at the examples at "All features\Welcome !\Axes\Labels\Custom Labels" and at "All features\Welcome !\Chart styles\Financial\Candle (OHLC)\Axis Labels no Weekends" to see simple examples of how to use Custom Labels and OnGetAxisLabel event respectively.
These examples are in the New Features Demo shipped with the binary installation.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

cssesuc
Newbie
Newbie
Posts: 44
Joined: Wed Apr 08, 2015 12:00 am

Re: number of ticks or tick frequency

Post by cssesuc » Fri Nov 27, 2015 1:33 pm

OK, many thanks for the hint. I will digest your inputs and get back to you.
thanks,
Nabil Ghodbane (PhD. Habil)

Post Reply