Page 1 of 1

accomodating even y axis spacing & appropriate left marg

Posted: Fri Apr 11, 2008 2:59 am
by 9787981
Hello.

I'm battling with a functional issue that I can't seem to implement in
a predicatable manner. It relates to the placement of multiple custom y
axes on the left side of the chart, and adjusting the Panel left margin
to accomodate them. I have looked at several forum articles, one which
specifically talked about using units of pixels versus percentage,
although it seems that using pixels as the units results in only the top half
of the y-axis being utilized when series are drawn. These units I know
exist for both the chart Panel and the custom y axes.
What I would like to do is set the distance between the configured y
axes (there can be up to 12 y-axes configured) to be approximately 70
pixels. The rationale behind this is that there will be enough space
between y axes to display the y-axis labels (9 digits in total) and the
title, without adjacent y axis overlap occurring (given the default labels font used for the custom y axes).

I saw the method in the forum example that shows how to determine the 70 pixels as a percentage of the tchart.chart.chartrect width. Using this of course gives a value that I assign to the y axis RelativePosition property
(whos units are configured as a percentage, not in pixels).

So a question is, when setting the RelativePosition property (which will be negative values) to the
chart width percentage (that is equivalent to 70 pixels), does this
mean that when the chart is drawn, each y axis width will be set to the
calculated percentage? Or does the spacing for each configured y axis
get progressively smaller as each one is drawn (perhaps because of some
internal calculation that may do something like, applying the configured percentage of the new chart width after a y-axis has been drawn). Anyways next I need to set the Left margin (again units are percentage, not pixels) to accomodate each of the y-axes so that they are all visible. Of course by increasing the chart Panel left margin value, means that the chart rectangle width decreases, which in turn means that now the widths between each y-axis decreases because the percentage calculation decreases. This has been my experience anyway.

So to summarize. I'm looking for a predictable way to set the spacing
between all configured custom left y-axes to 70 pixels, and be able to
set the chart panel left margin value to show all configured y axes
(up to 12) so that the 70 pixel spacing is preserved and so that there
is not an excessive gap on the left size of the chart, which will allow the
chart rectangle width to be as wide as possible.

I cannot find a predictable way to do this because as explained above,
there is an 'inter-dependency' that exists between setting the custom
y-axis RelativePostion, the size of the chart rectangle width, which
seems to vary with the panel margin Left property setting.

Hopefully this makes sense. Can you please advise?

Thanks,
Ben.

Posted: Fri Apr 11, 2008 10:12 am
by narcis
Hi Ben,

You can do something as in Yeray's example here. This is a Delphi example using TeeChart Pro VCL. Something similar should be possible using .NET version.

Hope this helps!

Posted: Sun Apr 13, 2008 4:20 am
by 9787981
Hi NarcĂ­s.

Yes it did help, however there is still the issue that I mentioned in the original email, specifically, the axis StartPosition property being set at 0 and the EndPosition property being set at 100. Because the PostionUnits are set to pixels, then this results in the axis length being set to 100 pixels, which of course shows the pen trace at only the top part of the vertical space available.

I've tried to work around this by doing the following:

Bitmap bitmap = this.tChart.Bitmap;
yAxis.Axis.EndPosition = this.tChart.Chart.ChartRect.Height;

however, the right time to call this is after the chart has got it's data and has added it to the associated series so that the x-axes have been drawn and labelled (essentially when the final vertical length (i.e. height) has been established for the chart), otherwise the axis will still be shorter than the available chart height.

Is there a better way to determine what the custom y axis EndPosition property needs to be set to (in order for it to occupy the entire allocated chart height), in the case that PositionUnits.Pixels are used instead of PositionUnits.Percent?

thanks,
Ben.

Posted: Mon Apr 14, 2008 7:24 am
by narcis
Hi Ben,

I'm afraid not if you want to set the units to pixels. You can call Bitmap method to force TeeChart being internally repainted ant therefore have valid values for the properties you need to use, for example:

Code: Select all

Bitmap bmp = tChart1.Bitmap;