Page 1 of 1
number of ticks or tick frequency
Posted: Wed Jun 10, 2015 9:20 pm
by 16573450
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.
Re: number of ticks or tick frequency
Posted: Thu Jun 11, 2015 7:12 am
by narcis
Dear Nabil,
Yes, you can do that using axis
Increment property. You'll find more info about that in
tutorial 4.
Re: number of ticks or tick frequency
Posted: Thu Nov 26, 2015 4:12 pm
by 16573450
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
Re: number of ticks or tick frequency
Posted: Thu Nov 26, 2015 4:40 pm
by yeray
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);
Re: number of ticks or tick frequency
Posted: Thu Nov 26, 2015 5:01 pm
by 16573450
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
Re: number of ticks or tick frequency
Posted: Fri Nov 27, 2015 8:38 am
by 16573450
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
Re: number of ticks or tick frequency
Posted: Fri Nov 27, 2015 10:53 am
by yeray
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.
Re: number of ticks or tick frequency
Posted: Fri Nov 27, 2015 1:33 pm
by 16573450
OK, many thanks for the hint. I will digest your inputs and get back to you.