TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
-
hexfhhu
- Newbie

- Posts: 21
- Joined: Thu Dec 07, 2006 12:00 am
Post
by hexfhhu » Fri Dec 08, 2006 7:30 am
Hello.
I want get the result as the result as examples 'opaque zones' ,I build a new form and put on a Tchart component ,a Tcheck component and a TScrollBar component , then copy the source code to my new project. But When I Compile Error notice :"Field TAxisOpaqueZone.ChartTool1 does not a correspondind component . Remove the Declaration?" How can i do?
my environment is BD7 and Teechart 7.06

-
Pep
- Site Admin

- Posts: 3312
- Joined: Fri Nov 14, 2003 5:00 am
-
Contact:
Post
by Pep » Fri Dec 08, 2006 1:08 pm
Hi,
using the same code as in the example should work fine, most likely the error is related with the ColorLine Tools which you must add, at runtime or at design time.
-
hexfhhu
- Newbie

- Posts: 21
- Joined: Thu Dec 07, 2006 12:00 am
Post
by hexfhhu » Sat Dec 09, 2006 2:40 am
Hi Jorge
I want add the TColorLineTool component on the form ,but do not find it on the toolbar or through :View-->Component List-->Search by name;
why ?What I missed?
-
Marjan
- Site Admin

- Posts: 745
- Joined: Fri Nov 07, 2003 5:00 am
- Location: Slovenia
-
Contact:
Post
by Marjan » Mon Dec 11, 2006 7:24 am
Hi.
To add a chart tool to specific chart, do the following:
1. Add a TChart on the form.
2. Select tChart with left mouse button.
3) Press right mouse button to bring up chart editor.
4) Select the "Tools" tab.
5) Press the "+" sign button
6) Select "Axis" tab
7) Double click the "color line" tool icon.
-
hexfhhu
- Newbie

- Posts: 21
- Joined: Thu Dec 07, 2006 12:00 am
Post
by hexfhhu » Mon Dec 11, 2006 8:31 am
Hi Marjan
Thank you for your help!
I have another problem :
How to Build a Legend runtime and can move the legend to anywhere on the chart according to custom needs. I want to build more than one legend on the same chart run time, becuse I have four group series on the chart.
Best Regards
hexfhhu
-
Pep
- Site Admin

- Posts: 3312
- Joined: Fri Nov 14, 2003 5:00 am
-
Contact:
Post
by Pep » Tue Dec 12, 2006 2:50 pm
Hi,
you could make use of the ExtraLegend Tool which allows you to display one Legend for each Series, and then use similar code to the following which allow to move them with the mouse :
Code: Select all
procedure TForm1.Chart1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
If Button = mbLeft Then
begin
If iDragged = -1 Then
begin
Chart1.Cursor := 2020;
iDragged := Chart1.Legend.Clicked(X, Y);
If iDragged <> -1 Then
begin
With Chart1.Legend do
begin
xDisp := X - ShapeBounds.Left;
yDisp := Y - ShapeBounds.Top
End;
End
else begin
i2Dragged := charttool1.Legend.Clicked(X, Y);
If i2Dragged <> -1 Then
begin
With Charttool1.Legend do
begin
xDisp := X - Charttool1.legend.ShapeBounds.Left;
yDisp := Y - Charttool1.legend.ShapeBounds.Top
End;
End
else begin
i2Dragged:=-1;
Chart1.Cursor := 0;
end;
end;
end
Else
begin
iDragged := -1;
Chart1.Cursor := 0
End;
End;
end;
procedure TForm1.Chart1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
If iDragged <> -1 Then
begin
With Chart1.Legend do
begin
Left := X - xDisp;
Top := Y - yDisp
End;
End;
if i2Dragged <> -1 then
begin
with ChartTool1.Legend do
begin
Left:=X-xDisp;
Top:=Y-yDisp
end;
end;
end;
procedure TForm1.Chart1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
iDragged := -1;
i2Dragged := -1;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
iDragged := -1;
i2Dragged := -1;
Chart1.Zoom.Allow:=false;
end;
-
hexfhhu
- Newbie

- Posts: 21
- Joined: Thu Dec 07, 2006 12:00 am
Post
by hexfhhu » Wed Dec 13, 2006 1:10 pm
Hi Jorge
thank you for your help!
I can move the legend with your code .
But I have not mastered how to arrange 40 series to four different legend. can you give me a example?
-
Narcís
- Site Admin

- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
-
Contact:
Post
by Narcís » Wed Dec 13, 2006 2:19 pm
Hi hexfhhu,
To achieve that you'll need to add one extra legend tool for each series in the chart, for example:
Code: Select all
uses Series, TeeExtraLegendTool;
procedure TForm1.FormCreate(Sender: TObject);
var
i: Integer;
tmpTool: TExtraLegendTool;
begin
for i:=0 to 40 do
begin
Chart1.AddSeries(TLineSeries.Create(self));
tmpTool:=TExtraLegendTool.Create(self);
Chart1.Tools.Add(tmpTool);
tmpTool.Series:=Chart1[i];
Chart1[i].FillSampleValues();
end;
end;
After that you'll have to make some changes in the OnMouseDown event Pep posted. You'll have to change this:
Code: Select all
i2Dragged := charttool1.Legend.Clicked(X, Y);
If i2Dragged <> -1 Then
begin
With Charttool1.Legend do
begin
xDisp := X - Charttool1.legend.ShapeBounds.Left;
yDisp := Y - Charttool1.legend.ShapeBounds.Top
End;
End
else begin
i2Dragged:=-1;
Chart1.Cursor := 0;
end;
For something like this:
Code: Select all
for i:=0 to Chart1.Tools.Count do
begin
if (Chart1.Tools.Items[i] is TExtraLegendTool) then
begin
tmpTool := (Chart1.Tools.Items[i] as TExtraLegendTool);
i2Dragged := tmpTool.Legend.Clicked(X, Y);
end;
if (i2Dragged <> -1 ) then
begin
With tmpTool.Legend do
begin
xDisp := X - tmpTool.legend.ShapeBounds.Left;
yDisp := Y - tmpTool.legend.ShapeBounds.Top
end;
break;
end
else begin
i2Dragged:=-1;
Chart1.Cursor := 0;
end;
end;
And also some similar changes in the OnMouseMove event when ChartTool1 is used you should replace it by tmpTool.
-
hexfhhu
- Newbie

- Posts: 21
- Joined: Thu Dec 07, 2006 12:00 am
Post
by hexfhhu » Wed Dec 13, 2006 3:04 pm
Hi Narcís
I will try it tomorry , thank you !
Best Regard
hexfhhu

-
hexfhhu
- Newbie

- Posts: 21
- Joined: Thu Dec 07, 2006 12:00 am
Post
by hexfhhu » Fri Dec 15, 2006 7:03 am
Hi Narcís
I get the legend for every series , but the legend style is set to the series value automatically. I want to change the legend style to seriesname for erery legend, how can I do it?
By the way, I wonder whether the legend can show one or several series names that i want it to show, not just show all the series names. If it can do that, could give me a samlpe program? thank you very much.
just
Best Regard
hexfhhu
-
Narcís
- Site Admin

- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
-
Contact:
Post
by Narcís » Fri Dec 15, 2006 9:35 am
Hi hexfhhu,
I get the legend for every series , but the legend style is set to the series value automatically. I want to change the legend style to seriesname for erery legend, how can I do it?
You can do something like this:
Code: Select all
for i:=0 to Chart1.Tools.Count do
if (Chart1.Tools.Items[i] is TExtraLegendTool) then
(Chart1.Tools.Items[i] as TExtraLegendTool).Legend.LegendStyle:=lsSeries;
By the way, I wonder whether the legend can show one or several series names that i want it to show, not just show all the series names. If it can do that, could give me a samlpe program? thank you very much.
You may want to do something as in the
All Features\Welcome!\Miscellaneous\Legend\Drawing more text example in the features demo. You'll find the demo at TeeChart's program group.
-
hexfhhu
- Newbie

- Posts: 21
- Joined: Thu Dec 07, 2006 12:00 am
Post
by hexfhhu » Mon Dec 18, 2006 8:32 am
Hi Narcís
Thank you for your help.The demo' All Features\Welcome!\Miscellaneous\Legend\Drawing more text example' is not
what I want. I have sended my example to your email.
_________________
Best Regards
hexfhhu
-
Narcís
- Site Admin

- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
-
Contact:
Post
by Narcís » Mon Dec 18, 2006 9:19 am
Hi hexfhhu,
Thanks for the image. According to it I think that would be most suitable for your needs is using ChartListBox component as shown in the All Features\Welcome!\Components\Chart ListBox examples at the features demo.
-
hexfhhu
- Newbie

- Posts: 21
- Joined: Thu Dec 07, 2006 12:00 am
Post
by hexfhhu » Mon Dec 18, 2006 1:58 pm
Hi Narcís
When i use chartlistbox and set chart property is my chart name, the problem is still .My example picture is one chart ,not three chart.
why?
_________________
Best Regards
hexfhhu
-
Pep
- Site Admin

- Posts: 3312
- Joined: Fri Nov 14, 2003 5:00 am
-
Contact:
Post
by Pep » Sat Dec 23, 2006 3:04 pm
Hi hexfhhu,
I've not seen the image you sent to my colleague Narcis (as he is at this moment on holidays), but seeing at your post as he said using ChartListBox should be the best way. You can use some ChartListBox component, assign to all the same Chart and then customize which Series (items) must be displayed. To remove items you can use :
ChartListBox1.Items.Delete(1); // Delete Series index 1
If this still not help please send me the image directly to my mail (
pep@steema.com).