ArrowSeries->Add versus ArrowSeries->AddArrow

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
darcy
Newbie
Newbie
Posts: 16
Joined: Mon Sep 14, 2009 12:00 am

ArrowSeries->Add versus ArrowSeries->AddArrow

Post by darcy » Wed Jan 13, 2010 12:16 pm

Hi,
Forgive me if this sounds stupid. When using ArrowSeries can I custom position the arrow whilst I am populating the series with data or do I have to wait until the ArrowSeries has been populated first (using ArrowSeries->Add) and therefore use anAfterDraw event to position the arrows (ArrowSeries->AddArrow).

Additional Info supporting above query:
I have multiple series being drawn in one chart, some line series and some arrow series. In order to use AddArrow(X0,Y0,X1,Y1... ) do I need to have the series already populated with data i.e. position the arrows direction in an afterdraw event?

I am plotting wind speed and direction, and would like to have each speed point as an arrow which can then be customised to show direction. I also plan to modify each arrow colour if the wave direction goes outside a predefined range. If you foresee any problems with the latter please let me know.

Thanks
D'Arcy

Yeray
Site Admin
Site Admin
Posts: 9612
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: ArrowSeries->Add versus ArrowSeries->AddArrow

Post by Yeray » Wed Jan 13, 2010 4:31 pm

Hi darcy,

To add a new arrow to your arrow series I recommend you to use the AddArrow method because you can pass the 4 coordinates directly to it (double X0, double Y0, double X1, double Y1).
If you want to change later one of the arrows already present in your arrow series, you can use the StartXValues, StartYValues, EndXValues and EndYValues doubles lists. For example to change the third arrow:

Code: Select all

  Series1.StartXValues.Items[2]:=1;
  Series1.StartYValues.Items[2]:=1;
  Series1.EndXValues.Items[2]:=5;
  Series1.EndYValues.Items[2]:=1;
I don't recommend you to add values at OnAfterDraw event because you will be adding new points each time the chart is repainted. And it is repainted multiple times if you scroll, zoom,...

To change an arrow color you should use ValueColor array. For example, to change the second arrow.

Code: Select all

Series1.ValueColor[1]:=clRed;
I think that you would need to implement a procedure that would be executed each X seconds and would check if the arrow values need to be updated. Maybe some of the present arrows will need to be modified in direction, position and color (StartXValues, StartYValues,..., ValueColor as explained above) and maybe some new arrows will need to be added to the series (AddArrow method).

If you still have problems with it, please, try to explain what is your application exactly trying to do.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

darcy
Newbie
Newbie
Posts: 16
Joined: Mon Sep 14, 2009 12:00 am

Re: ArrowSeries->Add versus ArrowSeries->AddArrow

Post by darcy » Fri Jan 15, 2010 12:01 pm

Hi Yeray,
Thanks for the prompt reply and suggestions. I am still investigating the best way to display the arrows on the chart and would love to hear your recommendation. My application needs to plot wind speed and direction. I have an existing line series that plots the wind speed but I would like to draw arrows indicating direction (0-360deg) at each of the speed series points. I would like to be able to change the colour of each arrow if required also.

I have attempted the following but each have there pros and cons, in particular because I may be drawing 2 wind speeds and directions. I find some methods require an after draw event and am conscious about it being called on most over mouse events etc:
- Using ArrowSeries
- Using ImagePointSeries and loading bmps of arrows
- Drawing directly onto the canvas using Arrow( fill, Percentage, From, To, W, H...)

I have attached a screenshot of my app showing current speed and direction for reference. Although this does fulfull my requirements I would like to ensure i am using the best method.

A separate question (may be dumb), because I am drawing on the canvas is there an easy method of checking for overlap with the axes (as can be seen in the screenshot) or is it up to me to manage the drawing space.

Any help is greatly appreciated,

Thanks
D'Arcy
Attachments
GraphArrows.JPG
GraphArrows.JPG (44.77 KiB) Viewed 5650 times

Yeray
Site Admin
Site Admin
Posts: 9612
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: ArrowSeries->Add versus ArrowSeries->AddArrow

Post by Yeray » Tue Jan 19, 2010 5:05 pm

Hi D'Arcy,
darcy wrote:I have attempted the following but each have there pros and cons, in particular because I may be drawing 2 wind speeds and directions. I find some methods require an after draw event and am conscious about it being called on most over mouse events etc:
- Using ArrowSeries
- Using ImagePointSeries and loading bmps of arrows
- Drawing directly onto the canvas using Arrow( fill, Percentage, From, To, W, H...)
The simplest to use would probably be the ArrowSeries. Could you please tell us what contras have you found with that solution? If we can't tell you a way to solve the problems you found, it could give us ideas for a future version.
With ImagePointSeries I suppose the problem is that you have to assign a different image for each color and rotate the image everytime.
If the ArrowSeries doesn't offer a good solution for you, I'm afraid that I'd bet for the custom drawing, as you've already done if I'm not wrong.
darcy wrote:A separate question (may be dumb), because I am drawing on the canvas is there an easy method of checking for overlap with the axes (as can be seen in the screenshot) or is it up to me to manage the drawing space.
You could check if the arrow you are going to draw has any point out of the rectangle Chart1.ChartRect. You'll probably have to use windows' PtInRect(TRect,TPoint)

If you still find troubles with it, please, don't hesitate to let us know.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply