ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  VectorLines on an XYChart
Posted by Patrick Henderson on Apr-19-2018 10:01
Attachments:
I would like to create a few vector lines that originate from an X,Y position and "point" toward other X,Y positions, but don't connect to the other points. Can I achieve this with addVectorLineLayer? I've drawn a crude drawing of what I'm wanting to do.

I know how to draw a vector, but not how to reference another point, and specify the length to stop the vector at.

Thanks in advance!
IMG_4534.JPG

  Re: VectorLines on an XYChart
Posted by Peter Kwan on Apr-19-2018 16:37
Hi Patrick.

There are several methods, depending on how you want the length to be specified (eg. in pixel unit, or in data unit, or as percentage between the distance of the two points, etc).

I assume you already know you can create vectors that starts from one point and ends at the other point (use EndPoints as the length scale in addVectorLayer):

http://www.advsofteng.com/doc/cdnet.htm#XYChart.addVectorLayer.htm

There is an API VectorLayer.setVectorMargin that shortens the vector. For example, if the end point is a circle symbol of radius 13, and you want the vector to point to the perimeter of the circle instead of its center, then you can set the end point to the center and set an end margin to 13. In this case, the actual vector will be 13 pixels shorter at the arrow tip direction. See:

http://www.advsofteng.com/doc/cdnet.htm#VectorLayer.setVectorMargin.htm

If you want the length of the vector to be a percentage of the distance between the start and end points, you may simply compute the adjusted end points. For example:

// The length of the vector is 60% of the distance between the start and end points
double[] adjustedEndX = new ArrayMath(endX).sub(startX).mul(0.6).add(startX).result();
double[] adjustedEndY = new ArrayMath(endY).sub(startY).mul(0.6).add(startY).result();

... use startX, startY and adjustedEndX, adjustedEndY to create the vector ...

Hope this can help.

Regards
Peter Kwan