TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
-
jradke
- Newbie
- Posts: 6
- Joined: Fri Oct 25, 2019 12:00 am
Post
by jradke » Tue Dec 03, 2019 8:54 am
Hi!
To plot a time series of wind vectors I use TArrowSeries (see attached sample).
In order to point the arrowhead always to the respective time on the x-axis I draw the arrow inverted:
Unfortunately the OnGetMarkText event delivers wrong value for ValueIndex because it is related to x+dx instead of x.
My question: Is it possible to draw inverted arrows using AddArrow in the normal form:
Regards
Jürgen
-
Attachments
-
- ArrowChart.jpg (23.16 KiB) Viewed 13335 times
Kind regards
JRadke
-
jradke
- Newbie
- Posts: 6
- Joined: Fri Oct 25, 2019 12:00 am
Post
by jradke » Wed Dec 04, 2019 7:42 pm
Ok, meanwhile I have found out, that after creating a series the XValueList is sorted automatically.
By setting
everything works fine.
Kind regards
JRadke
-
Yeray
- Site Admin
- Posts: 9617
- Joined: Tue Dec 05, 2006 12:00 am
- Location: Girona, Catalonia
-
Contact:
Post
by Yeray » Thu Dec 05, 2019 8:08 am
Hello,
If I'm understanding you correctly, you can get your ArrowSeries' EndXValues at OnGetMarkText. Ie:
Code: Select all
uses VCLTee.ArrowCha, DateUtils;
procedure TForm1.FormCreate(Sender: TObject);
var x, dx: TDateTime;
y, dy: double;
begin
Chart1.View3D:=False;
Chart1.Legend.Hide;
x:=IncHour(Today, 10);
dx:=DateTimeStep[dtOneHour];
y:=10;
dy:=1;
Chart1.Axes.Left.SetMinMax(8, 13);
Chart1.Axes.Bottom.SetMinMax(IncHour(x,-2), IncHour(x,3));
with TArrowSeries(Chart1.AddSeries(TArrowSeries)) do
begin
AddArrow(x+dx,y+dy,x,y);
//AddArrow(x,y,x+dx,y+dy);
OnGetMarkText:=ArrowGetMarkText;
Marks.Visible:=True;
Marks.Style:=smsXValue;
end;
end;
procedure TForm1.ArrowGetMarkText(Sender: TChartSeries; ValueIndex: Integer; var MarkText: string);
begin
if (ValueIndex>-1) and (Sender is TArrowSeries) then
MarkText:=FormatDateTime('hh:mm', TArrowSeries(Sender).EndXValues[ValueIndex]);
end;
-
jradke
- Newbie
- Posts: 6
- Joined: Fri Oct 25, 2019 12:00 am
Post
by jradke » Thu Dec 05, 2019 10:30 am
Hello Yeray,
Thank you for your answer.
Indeed I am using the OnGetMarkText event to display some additional information that is stored in an external data array.
Therefore I needed the correct ValueIndex. By setting XValues.Order to loNone all values will remain at their original positions.
By the way:
How can I format the MarkText? I always get a shadowed silver rectangle with black font color, no matter how I set the Marks property of the series.
Regards.
Kind regards
JRadke
-
Yeray
- Site Admin
- Posts: 9617
- Joined: Tue Dec 05, 2006 12:00 am
- Location: Girona, Catalonia
-
Contact:
Post
by Yeray » Tue Dec 10, 2019 1:14 pm
Hello,
jradke wrote: ↑Thu Dec 05, 2019 10:30 am
How can I format the MarkText? I always get a shadowed silver rectangle with black font color, no matter how I set the Marks property of the series.
A simple example seems to work fine for me here:
Code: Select all
uses VCLTee.ArrowCha;
procedure TForm1.FormCreate(Sender: TObject);
begin
Chart1.View3D:=False;
Chart1.Legend.Hide;
with TArrowSeries(Chart1.AddSeries(TArrowSeries)) do
begin
FillSampleValues(5);
Marks.Visible:=True;
Marks.Transparent:=False;
Marks.Pen.Show;
Marks.Pen.Color:=clRed;
Marks.BackColor:=clGreen;
Marks.Font.Color:=clWhite;
Marks.Font.Size:=14;
end;
end;
- Project1_2019-12-10_14-12-48.png (10.49 KiB) Viewed 13215 times
If you still find problems with it, could you please arrange a simple example project we can run as-is to reproduce the problem here?
Thanks in advance.