X Axis point offset
Joined: 11 Jul 2010
Topic: X Axis point offset
Posted: 07 Jan 2016 at 3:22pm
Good afternoon to all,
j'm new with this component and before repleace my teechart work, j'm trying to create e new form with new chart.
I have a little problem with pane X axsis value offset while use number and the chart is setted to show a bars in only one serie.
In the component the x axis have 0,1,2,...n and j chenge the number with a string via
Now in order to avoid collision with the string j need to increase the "point" offset in this way
(Component default x axis offset)
0 1 2 3 4
Result to obtain
0 1 2 3 4
My first priority is the problem above, but it's is also desirable get this kind of result, always, on x axis something like this (odd value have the string up and even have the string x pixel bottom)
0 2 4
j tried with
DrawXAxisValue(Sender: TObject; Serie: TChartSerie; Canvas: TCanvas;
ARect: TRect; ValueIndex: Integer; XMarker: Integer;
Top: Boolean; var defaultdraw: Boolean);
without a result
There's a way to get this ???
Thank's in advance for your reply
Joined: 18 May 2010
|Post Options Quote Reply Posted: 08 Jan 2016 at 12:32pm|
The distance between X-Axis values is determined by the X-Scale, which is calculated based on the RangeFrom and RangeTo properties on pane level. Additionally, the X-Axis can display major units and minor units with their own font size. The top spacing between the X-Axis values cannot be changed, unless you want to draw using the OnXAxisDrawValue event. Below is a sample that demonstrates this.
procedure TForm127.DrawXAxisValue(Sender: TObject; Serie: TChartSerie;
Canvas: TCanvas; ARect: TRect; ValueIndex, XMarker: integer; Top: Boolean;
var defaultdraw: Boolean);
if Odd(ValueIndex) then
DefaultDraw := False;
s := IntToStr(ValueIndex);
tw := Canvas.TextWidth(s);
Canvas.Pen.Color := clRed;
Canvas.LineTo(XMarker, ARect.Top + 15);
Canvas.Font.Color := clRed;
Canvas.TextOut(XMarker - tw div 2, ARect.Top + 17, s);
procedure TForm127.FormCreate(Sender: TObject);
AdvGDIPChartView1.Panes.Range.RangeTo := 15;
AdvGDIPChartView1.Panes.XAxis.AutoSize := True;
AdvGDIPChartView1.Panes.Series.AutoRange := arEnabled;
AdvGDIPChartView1.Panes.Series.XAxis.AutoUnits := False;
AdvGDIPChartView1.Panes.Series.XAxis.MajorUnit := 2;
AdvGDIPChartView1.Panes.Series.XAxis.MinorUnit := 1;
AdvGDIPChartView1.Panes.Series.OnXAxisDrawValue := DrawXAxisValue;
for I := 0 to 14 do
Joined: 11 Jul 2010
|Post Options Quote Reply Posted: 08 Jan 2016 at 2:11pm|
thank's for your reply and thank's for your code in order to draw, on X axis, the text in that way.
I solve the distance between the bar, as you suggest, via RangeTo; i change the dimension of the form/frame in accordance with my need, now j have the correct number of the bar (4-5) and the correct space.
Now j have some new trouble, but are topics posted in another message.
Thank's again for your support
|Forum Jump||Forum Permissions
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum