How to NAME a charttool?
How to NAME a charttool?
Hi,
I added a charrtool at runtume:
Form1.Chart1.Tools.Add(TCursorTool);
(Chart1.Tools.Items[1] as TCursorTool).Series:=line1;
Fine.
How to NAME my tool?
I want to address it by e.g.
Form1.MyFunnyCursor. ..... := *anything *
in other words: How to encode, that "Chart1.Tools.Items[1]" is known as "MyFunnyCursor"?
(or Chart1.Tools.MyFunnyCursor)
Thanks!
Cheryll
I added a charrtool at runtume:
Form1.Chart1.Tools.Add(TCursorTool);
(Chart1.Tools.Items[1] as TCursorTool).Series:=line1;
Fine.
How to NAME my tool?
I want to address it by e.g.
Form1.MyFunnyCursor. ..... := *anything *
in other words: How to encode, that "Chart1.Tools.Items[1]" is known as "MyFunnyCursor"?
(or Chart1.Tools.MyFunnyCursor)
Thanks!
Cheryll
Cheryll
Re: How to NAME a charttool?
Hello Cheryll,
To encode a tool is added directly to the chart, you must do the same as code below:
Hoping it will help.
Thanks in advance,
To encode a tool is added directly to the chart, you must do the same as code below:
Code: Select all
procedure TForm1.FormShow(Sender: TObject);
var MyCursor :TCursorTool;
begin
Chart1.Tools.Add(TCursorTool);
MyCursor := Chart1.Tools.Items[0] as TCursorTool;
Self.MyCursor := Series1;
end;
Thanks in advance,
Best Regards,
Sandra Pazos / 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 |
Re: How to NAME a charttool?
Hi Sandra,
thank you!
This works nicely.
Unfortunately it causes 2 add-on questions.
(is "Sandra" German? in case not: "Fadenkreuz" = "Crosshair")
So this works fine in my code:
Chart_MP.Tools.Add(TCursorTool);
Fadenkreuz:= Chart_MP.Tools.Items[0] as TCursorTool;
Fadenkreuz.Series:=candle1;
non of this attempts works:
// Chart_MP.Fadenkreuz:=candle1;
// Chart_MP.Tools.Fadenkreuz:=candle1;
// Fadenkreuz.ParentChart:=Chart_MP;
// Chart_MP.Tools.Item.Fadenkreuz:= candle1;
// Fadenkreuz.Parent:=Form_MPs; {Form_MPs is the container}
The error-message keeps saying "Fadenkreuz is not known".
I declared all Vars in the interface part oy my unit Form_MPs.
So my addon-questions:
1) How can I addres "Fadenkreuz" from another unit?
2) How can I find out the items number (in our case zero) of Fadenkreuz later on?
(in my software there will be checkboxes to check and uncheck different drawing tools).
I use both types TChart and TDBChart.
Thank you!
Cheryll
thank you!
This works nicely.
Unfortunately it causes 2 add-on questions.
(is "Sandra" German? in case not: "Fadenkreuz" = "Crosshair")
So this works fine in my code:
Chart_MP.Tools.Add(TCursorTool);
Fadenkreuz:= Chart_MP.Tools.Items[0] as TCursorTool;
Fadenkreuz.Series:=candle1;
non of this attempts works:
// Chart_MP.Fadenkreuz:=candle1;
// Chart_MP.Tools.Fadenkreuz:=candle1;
// Fadenkreuz.ParentChart:=Chart_MP;
// Chart_MP.Tools.Item.Fadenkreuz:= candle1;
// Fadenkreuz.Parent:=Form_MPs; {Form_MPs is the container}
The error-message keeps saying "Fadenkreuz is not known".
I declared all Vars in the interface part oy my unit Form_MPs.
So my addon-questions:
1) How can I addres "Fadenkreuz" from another unit?
2) How can I find out the items number (in our case zero) of Fadenkreuz later on?
(in my software there will be checkboxes to check and uncheck different drawing tools).
I use both types TChart and TDBChart.
Thank you!
Cheryll
Cheryll
Re: How to NAME a charttool?
Hello Cheryll,
We are working with it, we will try to give you a good answer in short time as possible.
Thanks in advance,
We are working with it, we will try to give you a good answer in short time as possible.
Thanks in advance,
Best Regards,
Sandra Pazos / 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 |
Re: How to NAME a charttool?
Hallo,
thank you.
To add: I would need an OnChange event on my "Fadenkreuz" to synchronzise it with a subchart crosshair.
The procedure is ready and looks fine, but I have no idea, how to fit the onChange event.
At the moment I am not able to pass on "Fadenkreuz" with proper values. They stay zero.
The call would be:
(The content is taken from the Steema help and will probably work fine:
Procedure TZeichenTools.CursorSynchronize( Source, Dest: TCursorTool );
Dest.ParentChart.AutoRepaint:=False; // stop repainting
Dest.RedrawCursor; // hide cursor
Dest.YValue := Source.YValue;
Dest.XValue := Source.XValue;
Dest.RedrawCursor; // draw cursor again
Dest.ParentChart.AutoRepaint:=True; // enable repainting)
Warm Regards,
Cheryll
thank you.
To add: I would need an OnChange event on my "Fadenkreuz" to synchronzise it with a subchart crosshair.
The procedure is ready and looks fine, but I have no idea, how to fit the onChange event.
At the moment I am not able to pass on "Fadenkreuz" with proper values. They stay zero.
The call would be:
Code: Select all
Zeichentools.CursorSynchronize(Fadenkreuz1,Fadenkreuz);
Procedure TZeichenTools.CursorSynchronize( Source, Dest: TCursorTool );
Dest.ParentChart.AutoRepaint:=False; // stop repainting
Dest.RedrawCursor; // hide cursor
Dest.YValue := Source.YValue;
Dest.XValue := Source.XValue;
Dest.RedrawCursor; // draw cursor again
Dest.ParentChart.AutoRepaint:=True; // enable repainting)
Warm Regards,
Cheryll
Cheryll
Re: How to NAME a charttool?
Hello Cheryll,
Sorry for the delay. We have been investigating how you can do as you want, but I am afraid we need your code. Could you please, send us your project because we can try to find a good solution for you?
Thanks in advance,
Sorry for the delay. We have been investigating how you can do as you want, but I am afraid we need your code. Could you please, send us your project because we can try to find a good solution for you?
Thanks in advance,
Best Regards,
Sandra Pazos / 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 |
Re: How to NAME a charttool?
Hi Sandra,
the code is linked to a DB, which unfortunately cannot be sent.
And why do you need my code? This question has nothing to do with my code.
We want to know, how to address "Fadenkreuz" (or however you will name the runtime-created CursorTool) in a plain "Form1" (see above).
"Form1.Fadenkreuz" does not work.
What works?
Thanks.
Regards,
Cheryll
the code is linked to a DB, which unfortunately cannot be sent.
And why do you need my code? This question has nothing to do with my code.
We want to know, how to address "Fadenkreuz" (or however you will name the runtime-created CursorTool) in a plain "Form1" (see above).
"Form1.Fadenkreuz" does not work.
What works?
Thanks.
Regards,
Cheryll
Cheryll
-
- Newbie
- Posts: 60
- Joined: Fri Nov 22, 2013 12:00 am
Re: How to NAME a charttool?
I'm confused. The cursor tool is a regular component, just like the chart itself, a button or whatever. You can rename it to whatever you like:
This also enables you to use this reference in code (like "myFancyFadenkreuz.Active := checkItsRainingOutside();") without having to introduce another variable or do any casting.Re: How to NAME a charttool?
Hi Jens,
thank you for your reply.
Are we talking about the same?
The topic is a cursor tool named and added at RUNTIME.
(see above code in the thread)
Regards,
Cheryll
thank you for your reply.
Are we talking about the same?
The topic is a cursor tool named and added at RUNTIME.
(see above code in the thread)
Regards,
Cheryll
Cheryll
Re: How to NAME a charttool?
Hello Cheryll,
Sorry for the dealy.
Tool declaration:
Call the tool from other unit:
Firstly, add the unit1 in the uses clause on the unit where you want to access the tool. The lines code below show how you can do it:
Then you need only call the tool as do next:
Also, I would like inform you that "Tools" are small objects that perform additional charting functionality, like interactive drawing of lines, mouse rotation, etc. Therefore, you don’t have access to own tools through Chart and the code you use in the lines below is incorrect:
The only code line you have attached me that should work without problems is next:
There is more information about TeeChart tools in the help documentation. You find the help documentation in a similar path as next:
%Program Files%\ Steema Software\TeeChart 2014 for RAD XE6\Docs
Sorry for the dealy.
We wanted see the code are you using, because it would be very useful for us to find an accurate solution based in your code.And why do you need my code? This question has nothing to do with my code.
To address your cursor from another unit, you have to declare the tool as public in your unit and add this unit in the uses clause on the unit where you want to access the tool.You can do something as next:1) How can I addres "Fadenkreuz" from another unit?
Tool declaration:
Code: Select all
unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs,Chart, CandleCh, Series, TeeTools;
type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
MyCursor:TCursorTool;
end;
Firstly, add the unit1 in the uses clause on the unit where you want to access the tool. The lines code below show how you can do it:
Code: Select all
uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs,Unit1...
Code: Select all
procedure TForm2.FormCreate(Sender: TObject);
begin
Form1.MyCursor.Pen.Color := clRed;
End;
The best way to get the tools indexes there are in Chart, is use a loop to search tool index you want; in your case, cursor tool. The code below shows how you can do it.2) How can I find out the items number (in our case zero) of Fadenkreuz later on?
(in my software there will be checkboxes to check and uncheck different drawing tools).
Code: Select all
procedure TForm1.FormCreate(Sender: TObject);
var i,indexCursor:Integer;
begin
Chart1:=TChart.Create(Self);
Chart1.Parent:=Self;
Chart1.Align:=alClient;
Chart1.View3D:=false;
Chart1.Legend.Visible:=false;
candle1:=Chart1.AddSeries(TCandleSeries) as TCandleSeries;
candle1.FillSampleValues;
line1:=Chart1.AddSeries(TLineSeries) as TLineSeries;
rsiFunc1:=TRSIFunction.Create(Self);
line1.SetFunction(rsiFunc1);
line1.DataSource:=candle1;
Chart1.Tools.Add(TDrawLineTool);
Chart1.Tools.Add(TCursorTool);
for i := 0 to Chart1.Tools.Count-1 do
If Chart1.Tools[i] is TCursorTool then
indexCursor:= i;
MyCursor := Chart1.Tools.Items[indexCursor] as TCursorTool;
MyCursor.Series := line1;
end;
Code: Select all
// Chart_MP.Fadenkreuz:=candle1;
// Chart_MP.Tools.Fadenkreuz:=candle1;
// Chart_MP.Tools.Item.Fadenkreuz:= candle1;
Code: Select all
Fadenkreuz.ParentChart:=Chart_MP;
%Program Files%\ Steema Software\TeeChart 2014 for RAD XE6\Docs
I would like inform you that when you create an own tool that is based in a specifically tool, you can use same methods and events there are implemented in base tool. Therefore, you should use OnChange event and do the same as do in Demo example All Features\Tools\Cursor\Synchronizing Two.I would need an OnChange event on my "Fadenkreuz" to synchronzise it with a subchart crosshair.The procedure is ready and looks fine, but I have no idea, how to fit the onChange event. At the moment I am not able to pass on "Fadenkreuz" with proper values. They stay zero.
Best Regards,
Sandra Pazos / 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 |
Re: How to NAME a charttool?
Hi Sandra,
thank you very much for your reply.
It starts to work now.
The origin of the problem was, that we want to synchronise 2 CursorTools.
So about this code ("finding the crosshair = fadenkreuz"):
perhaps I split the problem:
a) FINDING myCursor by name
your posting was:
As far as I understand it, this will give a match for the second added cursor tool, but not for the first one.
I need both of them to synchronize them.
Is it a good idea to look for "MyCursor"?
Unfortunately ...Tools.Items[indexCursor] .name"
has the value ' '.
So '.name' seems not the correct choice?
In other words:
How can I "catch" my both CursorTools in a way, that allows me to say,
"SynchroniceMyCursorTools(mycursortool1, mycursortool2);"
and send e.g. the thing to a function
The thing is, we never know, if and how many subcharts with crosshairs the user has asked for.
May be there is none, maybe 5 of them.
b)
Assigning the thing.
To declare the item from within my Form would work nicely. Unfortunately I am asked every little scratch again,
"this...has no assigned component. Do you like to remove it"?
Is there a way to teach the compiler, not to ask anymore?
It is nagging and sooner or later I hit "yes" by mistake.
Thank you,
Cheryll
thank you very much for your reply.
It starts to work now.
The origin of the problem was, that we want to synchronise 2 CursorTools.
So about this code ("finding the crosshair = fadenkreuz"):
perhaps I split the problem:
a) FINDING myCursor by name
your posting was:
Code: Select all
for i := 0 to Chart1.Tools.Count-1 do
If Chart1.Tools[i] is TCursorTool then
indexCursor:= i;
MyCursor := Chart1.Tools.Items[indexCursor] as TCursorTool;
I need both of them to synchronize them.
Is it a good idea to look for "MyCursor"?
Unfortunately ...Tools.Items[indexCursor] .name"
has the value ' '.
So '.name' seems not the correct choice?
In other words:
How can I "catch" my both CursorTools in a way, that allows me to say,
"SynchroniceMyCursorTools(mycursortool1, mycursortool2);"
and send e.g. the thing to a function
The thing is, we never know, if and how many subcharts with crosshairs the user has asked for.
May be there is none, maybe 5 of them.
b)
Assigning the thing.
To declare the item from within my Form would work nicely. Unfortunately I am asked every little scratch again,
"this...has no assigned component. Do you like to remove it"?
Is there a way to teach the compiler, not to ask anymore?
It is nagging and sooner or later I hit "yes" by mistake.
Thank you,
Cheryll
Cheryll
Re: How to NAME a charttool?
Hello Cherryll,
Thanks in advance,
As I have told you previously, we would like see the code are you using, because it would be very useful for us to find an accurate solution for you. Therefore, could you please send us a simple code where we can see, exactly, what are you doing, because we try to find a good solution for you?a) FINDING myCursor by name.....
I am afraid I don’t understand what you want achieve, the explanation you have posted is very generic. We need a more specific explanation, so we can offer you a good answer. Could you please explain exactly what do you want achieve?b) Assigning the thing.
To declare the item from within my Form would work nicely. Unfortunately I am asked every little scratch again,
"this...has no assigned component. Do you like to remove it"?
Is there a way to teach the compiler, not to ask anymore?
It is nagging and sooner or later I hit "yes" by mistake.
Thanks in advance,
Best Regards,
Sandra Pazos / 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 |
Re: How to NAME a charttool?
Hi,
thank you for your answer.
SHORT VERSION:
I need a crosshair, which shows up at all my chart's series from top to bottom.
LONG VERSION:
It is not bad will, that I do not add my code. The code is connected to a DB.
Obviously I cannot publish the DB.
So you want me to me to build an easy version of the problem?
- Well, this is what I have tried all the time.
The base problem is a ridicoulous little line, I cannot grab.
Some code done by the support and me you will find here:
http://www.teechart.net/support/viewtop ... =3&t=14908
The story behind is this:
I have several series and several axis. The annoying thing: The crosshair does not show all over these series, ....
(see the old topic and screenshot).
So the old solution / workaround was: 'add 2 crosshairs and "synchronize" them.'
Adding is easy, but how to synchronize them? The point is, that I do not know, how many series/crosshairs there will be at runtime.
So I cannot use the synchronize example from the help directly.
I tried it in a function where I wanted to send both the cursors to.
like:
procedure MyDrawingToolUnit . MySynchronizeGenie(cursor1,cursor2);
Did not work for me, because I could not ADRESS my crosshairs "anytime at runtime".
So: This was the beginning of "our story" / thread.
If you need some code example, please look at the source codes and screenshots of the old thread.
For the "new" problem, I do not have an example.
If I had it, there would be not need to ask for it any more.
Thank you for having read down to here.
Regards,
Cheryll
thank you for your answer.
SHORT VERSION:
I need a crosshair, which shows up at all my chart's series from top to bottom.
LONG VERSION:
It is not bad will, that I do not add my code. The code is connected to a DB.
Obviously I cannot publish the DB.
So you want me to me to build an easy version of the problem?
- Well, this is what I have tried all the time.
The base problem is a ridicoulous little line, I cannot grab.
Some code done by the support and me you will find here:
http://www.teechart.net/support/viewtop ... =3&t=14908
The story behind is this:
I have several series and several axis. The annoying thing: The crosshair does not show all over these series, ....
(see the old topic and screenshot).
So the old solution / workaround was: 'add 2 crosshairs and "synchronize" them.'
Adding is easy, but how to synchronize them? The point is, that I do not know, how many series/crosshairs there will be at runtime.
So I cannot use the synchronize example from the help directly.
I tried it in a function where I wanted to send both the cursors to.
like:
procedure MyDrawingToolUnit . MySynchronizeGenie(cursor1,cursor2);
Did not work for me, because I could not ADRESS my crosshairs "anytime at runtime".
So: This was the beginning of "our story" / thread.
If you need some code example, please look at the source codes and screenshots of the old thread.
For the "new" problem, I do not have an example.
If I had it, there would be not need to ask for it any more.
Thank you for having read down to here.
Regards,
Cheryll
Cheryll
Re: How to NAME a charttool?
Hi Cheryll,
Find below a simple example, based on the last code at the thread you've just referenced showing how to put your TCursorTools in an array as you create them and how to use the TCursorTools OnChange event to synchronize all the TCursorTools in the array:
Find below a simple example, based on the last code at the thread you've just referenced showing how to put your TCursorTools in an array as you create them and how to use the TCursorTools OnChange event to synchronize all the TCursorTools in the array:
Code: Select all
uses Chart, CandleCh, Series;
var MyCursorTools: array of TCursorTool;
procedure TForm1.FormCreate(Sender: TObject);
var
Chart_MP: TChart;
candle1: TCandleSeries;
line1: TLineSeries;
rsiFunc1: TRSIFunction;
MyAxis : TChartAxis;
begin
Chart_MP:=TChart.Create(Self);
Chart_MP.Parent:=Self;
Chart_MP.Align:=alClient;
Chart_MP.View3D:=false;
Chart_MP.Legend.Visible:=false;
candle1:=Chart_MP.AddSeries(TCandleSeries) as TCandleSeries;
candle1.FillSampleValues;
line1:=Chart_MP.AddSeries(TLineSeries) as TLineSeries;
rsiFunc1:=TRSIFunction.Create(Self);
line1.SetFunction(rsiFunc1);
line1.DataSource:=candle1;
MyAxis := TChartAxis.Create(Chart_MP);
line1.CustomVertAxis := MyAxis;
MyAxis.StartPosition:=95;
MyAxis.EndPosition:=100;
Chart_MP.Axes.Left.EndPosition:=95;
with AddCursorToArray((Chart_MP.Tools.Add(TCursorTool) as TCursorTool)) do
begin
OnChange:=CursorChange;
Series:=candle1;
end;
with AddCursorToArray((Chart_MP.Tools.Add(TCursorTool) as TCursorTool)) do
begin
OnChange:=CursorChange;
Series:=line1;
end;
end;
function TForm1.AddCursorToArray(ACursor: TCursorTool): TCursorTool;
var i: Integer;
begin
result:=nil;
for i:=Low(MyCursorTools) to High(MyCursorTools) do
if ACursor = MyCursorTools[i] then
exit;
SetLength(MyCursorTools, Length(MyCursorTools)+1);
MyCursorTools[length(MyCursorTools)-1]:=ACursor;
result:=ACursor;
end;
procedure TForm1.CursorChange(Sender:TCursorTool; x,y:Integer; Const XValue,YValue:Double; Series:TChartSeries; ValueIndex:Integer);
var i: Integer;
begin
for i:=Low(MyCursorTools) to High(MyCursorTools) do
if Sender <> MyCursorTools[i] then
begin
MyCursorTools[i].XValue:=XValue;
MyCursorTools[i].YValue:=YValue;
end;
end;
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: How to NAME a charttool?
Hello Yeray,
thank you so much!
This solution is genius.
Warm Regards,
Cheryll
thank you so much!
This solution is genius.
Warm Regards,
Cheryll
Cheryll