Board index » delphi » Highlight TChart with a solid line on X or Y axis

Highlight TChart with a solid line on X or Y axis


2004-04-06 10:21:21 PM
delphi155
In a TChart, is it possible to highlight the Y axis with a solid line ?
sort of like this ...
3 #
2 # # #
1 # # #
0 ==================== <== I want a solid line at the 0 axis
-1 # #
-2 #
-3
On a similar note: is it possible to put a solid vertical line
at any point of the X axis like the vertical line below.
Ideally, I'd like to be able to move the vertical line at runtime if possible
to another axis point (its is 3 in the diagram below)
3 |
2 |
1 |
0 =1==2==3===============
-1 |
-2 |
-3 |
Thanks a lot
Scott
 
 

Re:Highlight TChart with a solid line on X or Y axis

Scott H writes:
Quote

In a TChart, is it possible to highlight the Y axis with a solid line
? sort of like this ...


3 #
2 # # #
1 # # #
0 ==================== <== I want a solid line at the 0 axis
-1 # #
-2 #
-3



On a similar note: is it possible to put a solid vertical line
at any point of the X axis like the vertical line below.
Ideally, I'd like to be able to move the vertical line at runtime
if possible to another axis point (its is 3 in the diagram below)


3 |
2 |
1 |
0 =1==2==3===============
-1 |
-2 |
-3 |

Put something like this in the BeforeDrawValues of your first chart
series.
procedure TForm1.Series1BeforeDrawValues(Sender: TObject);
var
YPos, XPos, XValue: Integer;
begin
with Chart1, Chart1.Canvas do
begin
Ypos := Series[ 0 ].CalcYPosValue( 0 );
Pen.Color := clBlack;
Pen.Width := 2;
Pen.Style := psSolid;
MoveTo( ChartRect.Left, YPos );
LineTo( ChartRect.Right, YPos );
XValue := 3;
Xpos := Series[ 0 ].CalcXPosValue( XValue );
Pen.Color := clBlue;
Pen.Width := 1;
Pen.Style := psDot;
MoveTo( XPos, ChartRect.Bottom );
LineTo( XPos, ChartRect.Top );
end;
end;
John Leavey