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.
number of ticks or tick frequency
number of ticks or tick frequency
- Attachments
-
- Capture.JPG (170 KiB) Viewed 14130 times
thanks,
Nabil Ghodbane (PhD. Habil)
Nabil Ghodbane (PhD. Habil)
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Re: number of ticks or tick frequency
Dear Nabil,
Yes, you can do that using axis Increment property. You'll find more info about that in tutorial 4.
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 |
Instructions - How to post in this forum |
Re: number of ticks or tick frequency
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
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)
Nabil Ghodbane (PhD. Habil)
Re: number of ticks or tick frequency
Hello,
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:
- Font height for the left axis labels:
- To transform axis values to pixel screen coordinates:
- To transform pixel screen coortinates to axis values:
TeeChart by default tries to calculate an increment to show the labels preventing the overlapping.cssesuc wrote:Is there some other solution I could use here instead?
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;
Code: Select all
Chart1.Canvas.Font.Assign(Chart1.Axes.Left.LabelsFont);
tmpFontH:=Chart1.Canvas.TextHeight('Wj');
Code: Select all
tmpPos:=Chart1.Axes.Left.CalcPosValue(tmpValue);
Code: Select all
tmpValue:=Chart1.Axes.Left.CalcPosPoint(tmpPos);
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: number of ticks or tick frequency
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
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)
Nabil Ghodbane (PhD. Habil)
Re: number of ticks or tick frequency
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
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)
Nabil Ghodbane (PhD. Habil)
Re: number of ticks or tick frequency
Hi,
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.
This takes the first axis item. If it exists I don't see any problem with using it.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 ???
The idea was a bit different.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 ?
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,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: number of ticks or tick frequency
OK, many thanks for the hint. I will digest your inputs and get back to you.
thanks,
Nabil Ghodbane (PhD. Habil)
Nabil Ghodbane (PhD. Habil)