Charttool TRectagleTool - Copy!
Charttool TRectagleTool - Copy!
I use the Charttool TRectagleTool, which draws an editable rectangle on my chart.
Works fine.
I adjust the rectangle at runtime, what is done by the mouse. Works fine.
Then I WANT to right click it and choose "draw a twin rectangle slightly above or below of the first one and let me drag it to e.g. the other corner of the chart".
How to do this?
Thanks,
Cheryll
Works fine.
I adjust the rectangle at runtime, what is done by the mouse. Works fine.
Then I WANT to right click it and choose "draw a twin rectangle slightly above or below of the first one and let me drag it to e.g. the other corner of the chart".
How to do this?
Thanks,
Cheryll
Cheryll
Re: Charttool TRectagleTool - Copy!
Hello Cheryll,
I'm afraid you should do it manually. Here you have a simple example to start with:
I'm afraid you should do it manually. Here you have a simple example to start with:
Code: Select all
procedure TForm1.FormCreate(Sender: TObject);
begin
with Chart1.Tools.Add(TRectangleTool) as TRectangleTool do
begin
Text:='Rectangle Tool 1';
AutoSize:=true;
Shape.Transparency:=0;
Left:=100;
Top:=75;
OnClick:=RectClick;
end;
end;
procedure TForm1.RectClick(Sender:TAnnotationTool; Button:TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
if Button=mbRight then
begin
with Chart1.Tools.Add(TRectangleTool) as TRectangleTool do
begin
Text:=Sender.Text + ' (twin)';
AutoSize:=Sender.AutoSize;
Shape.Transparency:=Sender.Shape.Transparency;
Top:=Sender.Top+Sender.Height;
Left:=Sender.Left;
end;
end;
end;
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: Charttool TRectagleTool - Copy!
Hi Yeray,
thank you very much for the reply.
It looks very promising to me. Unfortunately I could not find a tutorial about those phantastic tools.
So my ideas about it are only rough and base on try and error.
I copied the code and managed my program do draw the original rectangle several times, what is a start and helps as first aid.
What I did not manage is to copy the size of the EDITED rectangle.
This is due to a problem in pasting the settings.
e.g. this line:
{ in my case: with DBChart_A_Kontrakt.Tools.Add(TRectangleTool) as TRectangleTool do begin }
" AutoSize:=Sender.AutoSize"
gives me the error message "unknown item Autosize " and does not allow compilation.
The moment I put the line into commentary, the new rectange is drawn fine, but with the original settings.
How can I make Delphi "know" those settings?
The "not know item"-error is true for all 4 lines:
{
Text:=Sender.Text + ' (twin)';
AutoSize:=Sender.AutoSize;
Shape.Transparency:=Sender.Shape.Transparency;
Top:=Sender.Top+Sender.Height;
Left:=Sender.Left;
}
I would be glad, to learn more about those tools by study a tutorial.
Kind Regards,
Cheryll
thank you very much for the reply.
It looks very promising to me. Unfortunately I could not find a tutorial about those phantastic tools.
So my ideas about it are only rough and base on try and error.
I copied the code and managed my program do draw the original rectangle several times, what is a start and helps as first aid.
What I did not manage is to copy the size of the EDITED rectangle.
This is due to a problem in pasting the settings.
e.g. this line:
{ in my case: with DBChart_A_Kontrakt.Tools.Add(TRectangleTool) as TRectangleTool do begin }
" AutoSize:=Sender.AutoSize"
gives me the error message "unknown item Autosize " and does not allow compilation.
The moment I put the line into commentary, the new rectange is drawn fine, but with the original settings.
How can I make Delphi "know" those settings?
The "not know item"-error is true for all 4 lines:
{
Text:=Sender.Text + ' (twin)';
AutoSize:=Sender.AutoSize;
Shape.Transparency:=Sender.Shape.Transparency;
Top:=Sender.Top+Sender.Height;
Left:=Sender.Left;
}
I would be glad, to learn more about those tools by study a tutorial.
Kind Regards,
Cheryll
Cheryll
Re: Charttool TRectagleTool - Copy!
Hi Cheryll,
However, they are focused on the general use of the majority of series, functions, tools and features. Note what you are asking for here is a quite specific feature.
Note in the code I posted above:
the properties that are being set (Text, AutoSize,...) are from the TRectangleTool just created in the line:
while the properties/values being taken (Sender.Text, Sender.AutoSize,...) are from Sender that is the object I created at the FormCreate method.
So, maybe you are doing the assignations out of the "with ... as TRectangleTool do" sentence so the properties in the left part can't be found.
Or maybe it's the other part where the compiler can't find; if you moved the code from the RectClick above to another method, Sender may be undefined or may be an instance of another class that doesn't have an AutoSize property.
The documentation, tutorials and examples are shipped with the binary installation. You should find them under the Docs and Examples folders in your installation. You should also find shortcuts to them in the Start Menu, under TeeChart's program group.Chartist wrote:It looks very promising to me. Unfortunately I could not find a tutorial about those phantastic tools.
So my ideas about it are only rough and base on try and error.
However, they are focused on the general use of the majority of series, functions, tools and features. Note what you are asking for here is a quite specific feature.
Difficult to say without the full code. It would be useful if you could arrange a simple example project we can run as-is to reproduce the problem here.Chartist wrote:I copied the code and managed my program do draw the original rectangle several times, what is a start and helps as first aid.
What I did not manage is to copy the size of the EDITED rectangle.
This is due to a problem in pasting the settings.
e.g. this line:gives me the error message "unknown item Autosize " and does not allow compilation.Code: Select all
{ in my case: with DBChart_A_Kontrakt.Tools.Add(TRectangleTool) as TRectangleTool do begin } " AutoSize:=Sender.AutoSize"
The moment I put the line into commentary, the new rectange is drawn fine, but with the original settings.
How can I make Delphi "know" those settings?
The "not know item"-error is true for all 4 lines:Code: Select all
{ Text:=Sender.Text + ' (twin)'; AutoSize:=Sender.AutoSize; Shape.Transparency:=Sender.Shape.Transparency; Top:=Sender.Top+Sender.Height; Left:=Sender.Left; }
Note in the code I posted above:
Code: Select all
procedure TForm1.RectClick(Sender:TAnnotationTool; Button:TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
if Button=mbRight then
begin
with Chart1.Tools.Add(TRectangleTool) as TRectangleTool do
begin
Text:=Sender.Text + ' (twin)';
AutoSize:=Sender.AutoSize;
Shape.Transparency:=Sender.Shape.Transparency;
Top:=Sender.Top+Sender.Height;
Left:=Sender.Left;
end;
end;
end;
Code: Select all
with Chart1.Tools.Add(TRectangleTool) as TRectangleTool do
So, maybe you are doing the assignations out of the "with ... as TRectangleTool do" sentence so the properties in the left part can't be found.
Or maybe it's the other part where the compiler can't find; if you moved the code from the RectClick above to another method, Sender may be undefined or may be an instance of another class that doesn't have an AutoSize property.
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: Charttool TRectagleTool - Copy!
Hi,
thank you for your reply.
Then the reason should be this: I have no button, which is clicked.
I do want to click the rectangle itsself. So I would need a mouse over or so.
But mouse move I cannot use, because it is taken for "big candle".
I want to use a context menu for the rectangle-copy-tool and a right click of the mouse.
In other words I would need this:
- recognize, that the pop-up-menu is clicked (I can to this by myself and land in the code of a method)
- find out, over which rectangle the mouse cursor is placed (I cannot do this)
- use the parameters of this "found" rectangle (I cannot do this) to copy it
- place the new rectangle in a way, that it is visible on the chart (so either above or below, right of left, depending)
Thanks,
Cheryll
thank you for your reply.
Then the reason should be this: I have no button, which is clicked.
I do want to click the rectangle itsself. So I would need a mouse over or so.
But mouse move I cannot use, because it is taken for "big candle".
I want to use a context menu for the rectangle-copy-tool and a right click of the mouse.
In other words I would need this:
- recognize, that the pop-up-menu is clicked (I can to this by myself and land in the code of a method)
- find out, over which rectangle the mouse cursor is placed (I cannot do this)
- use the parameters of this "found" rectangle (I cannot do this) to copy it
- place the new rectangle in a way, that it is visible on the chart (so either above or below, right of left, depending)
Thanks,
Cheryll
Cheryll
Re: Charttool TRectagleTool - Copy!
Hi Cheryll,
I think you just have to make the new TRectangleTool to use the same OnClick event than it's "parent".
This is the new code for a simple example:
I only added a line of code to the example I posted above.
If you still find problems with it, please try to arrange a simple example project we can run as-is to reproduce the problem here.
I think you just have to make the new TRectangleTool to use the same OnClick event than it's "parent".
This is the new code for a simple example:
Code: Select all
procedure TForm1.FormCreate(Sender: TObject);
begin
with Chart1.Tools.Add(TRectangleTool) as TRectangleTool do
begin
Text:='Rectangle Tool 1';
AutoSize:=true;
Shape.Transparency:=0;
Left:=100;
Top:=75;
OnClick:=RectClick;
end;
end;
procedure TForm1.RectClick(Sender:TAnnotationTool; Button:TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
if Button=mbRight then
begin
with Chart1.Tools.Add(TRectangleTool) as TRectangleTool do
begin
Text:=Sender.Text + ' (twin)';
AutoSize:=Sender.AutoSize;
Shape.Transparency:=Sender.Shape.Transparency;
Top:=Sender.Top+Sender.Height;
Left:=Sender.Left;
OnClick:=RectClick;
end;
end;
end;
If you still find problems with it, please try to arrange a simple example project we can run as-is to reproduce the problem here.
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: Charttool TRectagleTool - Copy!
Hi,
this brings me a huge step further.
A nice rectangle is created without errors.
Sorry for not being able to do it:
How can I manage, that is has the same size and style as its origin?
I tried something with height and width, but nothing worked.
I attach you a screenshot of the origin and new rectangle, which I see.
I wanted the new one (which looks similar to a balloon hint in our screenshot example) looking alike the old one.
Regards,
Cheryll
this brings me a huge step further.
A nice rectangle is created without errors.
Sorry for not being able to do it:
How can I manage, that is has the same size and style as its origin?
I tried something with height and width, but nothing worked.
I attach you a screenshot of the origin and new rectangle, which I see.
I wanted the new one (which looks similar to a balloon hint in our screenshot example) looking alike the old one.
Regards,
Cheryll
- Attachments
-
- creation works without errors.jpg (55.33 KiB) Viewed 9942 times
Cheryll
Re: Charttool TRectagleTool - Copy!
Hi Cheryll,
It seems to work fine for me here. Take a look at what I get: Find below the project I used to generate that image.
If you still find problems with it, please, modify the project so we can reproduce the problem here.
It seems to work fine for me here. Take a look at what I get: Find below the project I used to generate that image.
If you still find problems with it, please, modify the project so we can reproduce the problem here.
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: Charttool TRectagleTool - Copy!
yes!!!
Thank you so much for the demo, now it works.
What I changed:
OLD - worked, but only without format copy:
My original code added the rectangle tool at design time and I tried at runtime to add the new functionality and new rectangles.
The new rectangle was created fine, but in a surprising format. I have no idea, where its style and size came from.
NEW - works exactly as intended:
I deleted the prepared desing-time-rectangle-tool and now add everything at runtime: the tool, the very first rectangle and all copies.
The thing looks that nice!
Thanks.
Kind Regards,
Cheryll
Thank you so much for the demo, now it works.
What I changed:
OLD - worked, but only without format copy:
My original code added the rectangle tool at design time and I tried at runtime to add the new functionality and new rectangles.
The new rectangle was created fine, but in a surprising format. I have no idea, where its style and size came from.
NEW - works exactly as intended:
I deleted the prepared desing-time-rectangle-tool and now add everything at runtime: the tool, the very first rectangle and all copies.
The thing looks that nice!
Thanks.
Kind Regards,
Cheryll
Cheryll