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

Message ListMessage List     Post MessagePost Message

  VectorLayer with text
Posted by HANSOO KIM on Apr-29-2022 23:07
Hi, I'm trying to put the text on the VectorLayer, but can't find any function on it. thanks in advance.


  Re: VectorLayer with text
Posted by Peter Kwan on Apr-30-2022 02:11

You can use Layer.setDataLabelFormat, Layer.setDataLabelStyle or Layer.addCustomDataLabel to add labels to the vector arrows. The labels will be added to the stating point (the tail point) of the arrow. The text will be positioned either above or below the tail point depending on the arrow direction, so that the text does not overlap with the arrow.

An example (in C#) is like:

// Add label to the first arrow in the vector layer
myVectorLayer.addCustomDataLabel(0, 0, "My Label", "Arial Bold", 10, 0xcc0000, 0);

If you want to put labels in some other place, you may use a scatter layer and set the scatter symbol to transparent, so only the label remains. The following is an example:

The following is an example to put a label center aligned to the point x = 50.0, y = 20.0.

// Add a scatter layer with 1 transparent symbol at (50, 20)
ScatterLayer labelLayer = c.addScatterLayer(new double[] { 50.0 }, new double[] { 20.0 }, "", Chart.SquareSymbol, 1, Chart.Transparent, Chart.Transparent);

// Add a label center aligned with the first symbol in the scatter layer
labelLayer.addCustomDataLabel(0, 0, "My Label", "Arial Bold", 10, 0xcc0000, 0).setAlignment(Chart.Center);

You can add more points to the scatter layer if you have more than one labels.

Hope this can help.

Peter Kwan