Page 1 of 1
ArrowSeries->Add versus ArrowSeries->AddArrow
Posted: Wed Jan 13, 2010 12:16 pm
by 10054230
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
Re: ArrowSeries->Add versus ArrowSeries->AddArrow
Posted: Wed Jan 13, 2010 4:31 pm
by yeray
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.
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.
Re: ArrowSeries->Add versus ArrowSeries->AddArrow
Posted: Fri Jan 15, 2010 12:01 pm
by 10054230
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
Re: ArrowSeries->Add versus ArrowSeries->AddArrow
Posted: Tue Jan 19, 2010 5:05 pm
by yeray
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.