Wind vector plot with TArrowSeries

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
jradke
Newbie
Newbie
Posts: 6
Joined: Fri Oct 25, 2019 12:00 am

Wind vector plot with TArrowSeries

Post by jradke » Thu Nov 14, 2019 4:22 pm

Hi,
is it possible to create a wind vector plot similiar to the attached picture?
Each arrow in the picture represents the wind speed and wind direction at a given time and height.
I tried a little bit using the TArrowSeries, but I did not get a satisfactory solution.

Has anyone good ideas for that problem?

Reagrds
jradke
Attachments
windvector.png
windvector.png (94.64 KiB) Viewed 10914 times
Kind regards
JRadke

Marc
Site Admin
Site Admin
Posts: 1272
Joined: Thu Oct 16, 2003 4:00 am
Location: Girona
Contact:

Re: Wind vector plot with TArrowSeries

Post by Marc » Thu Nov 14, 2019 6:00 pm

Hello jradke,

This code simplifies a how-to. Add 3 ArrowSeries to a Chart and run the code in a button. My example calculations aren't up to much, just to give an idea.

Y location ArrowStart gives height above sea-level, X ArrowStart location is the timestamp and the end of each arrow would be calculated as your take on wind-strength and direction.

Code: Select all

procedure TForm1.Button1Click(Sender: TObject);
Var i, a : Integer;
    aaX, aaY, f1,f2,f3, aDate : Double;
    point : TPoint;

  procedure getDirection(var aX, aY : double; aDate, force, direction : double);
  var opp, adj : double;
  Begin
    //trig val calculate using force and direction
    //direction here just as angle.
    //this is where the work is to calculate, Arrow Series fits to start and end x,y locations

    opp := force * Sin(DegToRad(direction));
    adj := force * Cos(DegToRad(direction));

    aX := aDate + adj;
    aY := opp;
  end;

begin
  For i:=0 to Chart1.SeriesCount-1 do
    Chart1.SeriesList[i].Clear;

  Chart1.LeftAxis.SetMinMax(0,5);

  aDate := 44173;      //simplifying a timestamp as double

  For a := 0 to 50 do
  Begin

    aDate := aDate + 1;

    f1 := Random(10) / 7 ;
    getDirection(aaX,aaY,aDate,f1,120 - random(90));
    Series1.AddArrow(aDate,1,aaX,1+aaY);

    f2 := Random(10) / 7;
    getDirection(aaX,aaY,aDate,f2,90 - random(90));
    Series2.AddArrow(aDate,2,aaX,2+aaY);

    f3 := Random(10) / 7;
    getDirection(aaX,aaY,aDate,f3,70 - random(90));
    Series3.AddArrow(aDate,3,aaX,3+aaY);
  end;
end;
WindChart.png
WindChart.png (43.44 KiB) Viewed 10912 times
I hope that helps.
Regards,
Marc Meumann
Steema Support

jradke
Newbie
Newbie
Posts: 6
Joined: Fri Oct 25, 2019 12:00 am

Re: Wind vector plot with TArrowSeries

Post by jradke » Fri Nov 15, 2019 1:42 pm

Hello Mark,

this seems to be an interesting approach, I will continue to work with it.
To calculate the correct length of the arrows I think I have to convert it to pixel size (depending on the screen resolution).

Thanks for the tip.

Best regards
jradke
Kind regards
JRadke

Post Reply