Custom Axis Position
Custom Axis Position
I added three custom vertical axes in the project and switch between the standard RightAxis and these custom vertical axes. The x position (horizontal position) of the right axis will change automatically according to the length of the right axis label text, but the custom axes always stay in the same x position so sometimes the label text and title are not visible. Which property in the TChartAxis or TChart can be used to set the x position of the Axis to fix or auto change?
Thanks
Xia
Thanks
Xia
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Xia,
It's most likely that you need to set chart's margins as custom axes don't calculate them automatically. For example:
Using percent (default setting):
Using pixels:
It's most likely that you need to set chart's margins as custom axes don't calculate them automatically. For example:
Using percent (default setting):
Code: Select all
TChart1.Panel.MarginLeft = 5
TChart1.Panel.MarginRight = 5
Code: Select all
TChart1.Panel.MarginUnits = muPixels
TChart1.Panel.MarginLeft = 50
TChart1.Panel.MarginRight = 50
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 |
Hi Narcis,
Thanks for your email.
I have set the panel MarginRight to 50, but I noticed that the margin for the custom axes is calculated from the vertical axis itself not from the postion of the axis label and title as for the RightAxis. So I have to change the MarginRight when switching from RightAxis to custom axes.
For the RightAxis, is it possible to have the vertical Axis line kept in the same position and not affected by the axis scale or title change? I want to keep the size and position of the ChartRect the same when scrolling the graph vertically .
One more question, I added a vertical TChartScrollBar to scroll custom axes. How to link the scrollbar to one of the custom axes or assosciated data series?
Thanks in advance.
Xia
Thanks for your email.
I have set the panel MarginRight to 50, but I noticed that the margin for the custom axes is calculated from the vertical axis itself not from the postion of the axis label and title as for the RightAxis. So I have to change the MarginRight when switching from RightAxis to custom axes.
For the RightAxis, is it possible to have the vertical Axis line kept in the same position and not affected by the axis scale or title change? I want to keep the size and position of the ChartRect the same when scrolling the graph vertically .
One more question, I added a vertical TChartScrollBar to scroll custom axes. How to link the scrollbar to one of the custom axes or assosciated data series?
Thanks in advance.
Xia
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Xia,
1. Use PositionPercent:
2. Set a margin wider than the axes would need.
You could try one of those 2 options:For the RightAxis, is it possible to have the vertical Axis line kept in the same position and not affected by the axis scale or title change? I want to keep the size and position of the ChartRect the same when scrolling the graph vertically .
1. Use PositionPercent:
Code: Select all
TChart1.Axis.Right.PositionUnits = puPixels
TChart1.Axis.Right.PositionPercent = 50
The easiest way to achieve what you request is using AxisScroll tool.One more question, I added a vertical TChartScrollBar to scroll custom axes. How to link the scrollbar to one of the custom axes or assosciated data series?
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 |
Hi Narcis,
Thanks.
I have added TAxisScrollTool to the chart. I can now scroll grpahs for both bottom axis and vertical custom axes. But when I use the axis scroll for the bottom axis, it can scroll to negative values. Because I am using the time for the bottom axis, I don't want to show negative value (time). How can I restrict the horizontal scroll to the minimum of 0 when scrolling the bottom axis? I added codes to Chart->OnScroll event to restrict the bottom axis from 0 and it works when using dragging the right mouse inside the chart space, but dragging the bottom axis did not triger the Chart->OnScroll event.
Also, when scroll the graph, the number of the axis's labels (scales) or the inner ticks varies from 5 to 12. Is it possible to have the fixed number of labels (or inner ticks) for the bottom axis displayed?
Regards
Xia
Thanks.
I have added TAxisScrollTool to the chart. I can now scroll grpahs for both bottom axis and vertical custom axes. But when I use the axis scroll for the bottom axis, it can scroll to negative values. Because I am using the time for the bottom axis, I don't want to show negative value (time). How can I restrict the horizontal scroll to the minimum of 0 when scrolling the bottom axis? I added codes to Chart->OnScroll event to restrict the bottom axis from 0 and it works when using dragging the right mouse inside the chart space, but dragging the bottom axis did not triger the Chart->OnScroll event.
Also, when scroll the graph, the number of the axis's labels (scales) or the inner ticks varies from 5 to 12. Is it possible to have the fixed number of labels (or inner ticks) for the bottom axis displayed?
Regards
Xia
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Xia,
You can do something like the code below in the OnAfterDraw event.I have added TAxisScrollTool to the chart. I can now scroll grpahs for both bottom axis and vertical custom axes. But when I use the axis scroll for the bottom axis, it can scroll to negative values. Because I am using the time for the bottom axis, I don't want to show negative value (time). How can I restrict the horizontal scroll to the minimum of 0 when scrolling the bottom axis? I added codes to Chart->OnScroll event to restrict the bottom axis from 0 and it works when using dragging the right mouse inside the chart space, but dragging the bottom axis did not triger the Chart->OnScroll event.
Code: Select all
Private Sub TChart1_OnAfterDraw()
If TChart1.Axis.Bottom.Minimum < 0 Then
TChart1.Axis.Bottom.Minimum = 0
End If
End Sub
You can try manually setting Increment and ticks. For more information on how to do that please read Tutorial 4 - Axis Control. Tutorials can be found at TeeChart's program group.Also, when scroll the graph, the number of the axis's labels (scales) or the inner ticks varies from 5 to 12. Is it possible to have the fixed number of labels (or inner ticks) for the bottom axis displayed?
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 |
Hi Narcis,
I added the code as you suggested for the OnAfterDraw event to overcome the problem of negative time axis. It works to some extent. Just when you drag the bottom axis quickly, it shows the negative time axis sometimes. Is there anything I can do to improve this?
For my initial question (see my first email), I have added another custom vertical axis instead of using the standard RightAxis, so the position of the vertical axes will not change when switching from the multi axes (three custom vertical axes in this case) to a single axis (new full range custom vertical axis). This was done by the codes below;
if ( MultiAxes Display )
{
Series1->CustomVertAxis = CustomVertAxis1 // 0-33%
Series2->CustomVertAxis = CustomVertAxis2 // 33-66%
Series3->CustomVertAxis = CustomVertAxis3 // 66-100%
}
else
{
Series1->CustomVertAxis = CustomVertAxis4 // 0-100%
Series2->CustomVertAxis = CustomVertAxis4 // 0-100%
Series3->CustomVertAxis = CustomVertAxis4 // 0-100%
}
I have added codes for OnZoom and OnUndoZoom so it can zoom in/out for the individual custom vertical axis (Axis1-4) by using Chart->Zoom->Y0 and Y1. But I have a problem when scrolling the chart by dragging the right mouse button inside the chart space. Scrolling the chart in the single axis mode (i.e. CustomVertAxis4) will also change CustomVertAxis1-3 in the multi-axis mode. Is it possible to add some codes for OnScroll event so the vertical axes 1-3 in the multi-axes display will not be affected when scrolling chart in the single axis display?
I have also checked your TChart Pro V8 New Features Demo program, All features/Axes/Multiple at Runtime. If you click the Single Axis first and then drag the right mouse button inside the chart space. When you unclick the Single Axis, the vertical axes for series 2 and 3 show as zero. In my program, it sometimes causes Invalid floating point operation error. How can I fix this problem?
Your help would be very much appreciated.
Xia
[/code]
I added the code as you suggested for the OnAfterDraw event to overcome the problem of negative time axis. It works to some extent. Just when you drag the bottom axis quickly, it shows the negative time axis sometimes. Is there anything I can do to improve this?
For my initial question (see my first email), I have added another custom vertical axis instead of using the standard RightAxis, so the position of the vertical axes will not change when switching from the multi axes (three custom vertical axes in this case) to a single axis (new full range custom vertical axis). This was done by the codes below;
if ( MultiAxes Display )
{
Series1->CustomVertAxis = CustomVertAxis1 // 0-33%
Series2->CustomVertAxis = CustomVertAxis2 // 33-66%
Series3->CustomVertAxis = CustomVertAxis3 // 66-100%
}
else
{
Series1->CustomVertAxis = CustomVertAxis4 // 0-100%
Series2->CustomVertAxis = CustomVertAxis4 // 0-100%
Series3->CustomVertAxis = CustomVertAxis4 // 0-100%
}
I have added codes for OnZoom and OnUndoZoom so it can zoom in/out for the individual custom vertical axis (Axis1-4) by using Chart->Zoom->Y0 and Y1. But I have a problem when scrolling the chart by dragging the right mouse button inside the chart space. Scrolling the chart in the single axis mode (i.e. CustomVertAxis4) will also change CustomVertAxis1-3 in the multi-axis mode. Is it possible to add some codes for OnScroll event so the vertical axes 1-3 in the multi-axes display will not be affected when scrolling chart in the single axis display?
I have also checked your TChart Pro V8 New Features Demo program, All features/Axes/Multiple at Runtime. If you click the Single Axis first and then drag the right mouse button inside the chart space. When you unclick the Single Axis, the vertical axes for series 2 and 3 show as zero. In my program, it sometimes causes Invalid floating point operation error. How can I fix this problem?
Your help would be very much appreciated.
Xia
[/code]
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Xia,
I'm sorry but I don't understand which is the exact problem. Would you be so kind to send us a simple example project we can run "as-is" to reproduce the issue too?
You can either post your files at news://www.steema.net/steema.public.attachments newsgroup or at our upload page.
Thanks in advance.
I'm not able to reproduce the problem here. Could you please let us know the exact steps we should follow or send us a simple example project we can run "as-is" to reproduce the problem here?I added the code as you suggested for the OnAfterDraw event to overcome the problem of negative time axis. It works to some extent. Just when you drag the bottom axis quickly, it shows the negative time axis sometimes. Is there anything I can do to improve this?
I have added codes for OnZoom and OnUndoZoom so it can zoom in/out for the individual custom vertical axis (Axis1-4) by using Chart->Zoom->Y0 and Y1. But I have a problem when scrolling the chart by dragging the right mouse button inside the chart space. Scrolling the chart in the single axis mode (i.e. CustomVertAxis4) will also change CustomVertAxis1-3 in the multi-axis mode. Is it possible to add some codes for OnScroll event so the vertical axes 1-3 in the multi-axes display will not be affected when scrolling chart in the single axis display?
I'm sorry but I don't understand which is the exact problem. Would you be so kind to send us a simple example project we can run "as-is" to reproduce the issue too?
You can either post your files at news://www.steema.net/steema.public.attachments newsgroup or at our upload page.
Thanks in advance.
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 |
Dear Narcis,
I have sent a test program to your upload page. Hopefully, you will be able to reproduce the problems I described, i.e.
1) time scale<0 when dragging the bottom axis quickly.
2) scroll the chart in single-axis display by dragging the right-mouse will also scroll the vertical axes for the multi-axes mode and show axis labels as zero, or visa verse.
One more question, when close or exit the TeeChart program, do I need to delete TeeChart components such as TChartTools, TChartSeries, etc. to free the used memory space?
Looking forwar to hearing from you
Xia
I have sent a test program to your upload page. Hopefully, you will be able to reproduce the problems I described, i.e.
1) time scale<0 when dragging the bottom axis quickly.
2) scroll the chart in single-axis display by dragging the right-mouse will also scroll the vertical axes for the multi-axes mode and show axis labels as zero, or visa verse.
One more question, when close or exit the TeeChart program, do I need to delete TeeChart components such as TChartTools, TChartSeries, etc. to free the used memory space?
Looking forwar to hearing from you
Xia
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Xia,
Thanks for the example project.
First of all, please notice that I moved this thread from the TeeChart ActiveX forum to the TeeChart VCL one since I've seen you are using TeeChart VCL.
Please find below the answers to your questions:
No, there's no need to free memory. VCL framework and TeeChart do this automatically.
Thanks for the example project.
First of all, please notice that I moved this thread from the TeeChart ActiveX forum to the TeeChart VCL one since I've seen you are using TeeChart VCL.
Please find below the answers to your questions:
Ok, then moving the code from the OnAfterDraw event to the OnBeforeDrawChart event works fine.1) time scale<0 when dragging the bottom axis quickly.
In that case you could save axes minimun and maximum values before scrolling the chart and restoring them after having scrolled it. Something similar to the code below which does a similar process for zoom.2) scroll the chart in single-axis display by dragging the right-mouse will also scroll the vertical axes for the multi-axes mode and show axis labels as zero, or visa verse.
Code: Select all
procedure TForm1.Chart1Zoom(Sender: TObject);
begin
if Series1Region then
begin
With Series1.GetVertAxis do
SetMinMax(CalcPosPoint(Chart1.Zoom.Y1),CalcPosPoint(Chart1.Zoom.Y0));
With Series1.GetHorizAxis do
SetMinMax(CalcPosPoint(Chart1.Zoom.X1),CalcPosPoint(Chart1.Zoom.X0));
end
else
begin
With Series2.GetVertAxis do
SetMinMax(CalcPosPoint(Chart1.Zoom.Y1),CalcPosPoint(Chart1.Zoom.Y0));
With Series2.GetHorizAxis do
SetMinMax(CalcPosPoint(Chart1.Zoom.X1),CalcPosPoint(Chart1.Zoom.X0));
Series1.GetVertAxis.Automatic:=true;
Series1.GetHorizAxis.Automatic := true;
end;
end;
procedure TForm1.Chart1UndoZoom(Sender: TObject);
begin
Series1.GetVertAxis.Automatic:=true;
Series1.GetHorizAxis.Automatic := true;
Series2.GetVertAxis.Automatic:=true;
Series2.GetHorizAxis.Automatic := true;
end;
procedure TForm1.Chart1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if (Y <= Series1.GetVertAxis.IEndPos) then
Series1Region:=true
else
Series1Region:=false;
end;
One more question, when close or exit the TeeChart program, do I need to delete TeeChart components such as TChartTools, TChartSeries, etc. to free the used memory space?
No, there's no need to free memory. VCL framework and TeeChart do this automatically.
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 |
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Xia,
You're welcome.Thanks. It works fine.
Thank you very much .I am impressed by your technical support.
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 |