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

Message ListMessage List     Post MessagePost Message

  Help in Labeling XYChart
Posted by NewBie on Jan-21-2011 03:43
I am new to ChartDirector and need a little help in rendering my chart. I have a few issues
and concerns.
1. I am trying to draw a densely populated graph. I have used a Symbol XYChart and wish
to label each row. I have used a scatter layer and then added a text box to display the
label. However, inspite of all this, the labels are still overlapping. I can not explicitly change
the x/y values to avoid overlapping because that results in the labels being inconsistant and
it looks messy. Is there a way to work around this?
2. I wish to draw a dataset (curved line) on top of other lines. I have searched high and dry
but can not explicitly set the z-index value for a dataset. Perhaps i have missed out on
something. However, what i did was to draw a line for each connected points and set that
line's zorder. The line is now on top but unforunately the data point labels (DOT to
determine the point) are not on top :( Is there a zorder setting attribute for scatter layer?
(i have used scatter layer to plot the points). Any other work around would be highly
appreciated!
3. I wish to add labels to this XYChart with a line just like the bubble and label option given
for pie chart. Is there a way to achieve that?

Looking forward to any help and guidelines :)

  Re: Help in Labeling XYChart
Posted by Peter Kwan on Jan-21-2011 16:25
Hi,

1. In general, there is no way to avoid labels from overlapping. It is because it is not possible to put infinite or arbitrarily large amount of text labels in a finite space.

Unlike a web page or a word document, which is "infinite" in size (the web page can grow as large as it needs), a chart is usually finite in size, and the data points can be cluster together arbitrarily. So there is no general way to ensure that labels do not overlap.

If you have so many points in a small region so that the labels overlap, one method is to use a shorter label. For example, many people will just use a digit or an alphabet (like, A, B, C, D, ...) as the label. The user interface will include a text table so that people can use the A, B, C, D, ... to look up for the real label (which can be quite long). The A, B, C, D .... can be put inside the scatter symbol (use center alignment when adding the label). For example (in VB/VBScript):

Call layer.addExtraField(arrayOfAlphabets)
Call layer.setDataLabelFormat("{field0}")
Call layer.setDataLabelStyle("arial.ttf", 8, &H000000).setAlignment(cd.Center)


2. If you found a layer is below another layer, but you want the ordering to reverse, just reverse the order that you add the layer. For example, if you add layer A first, then layer B, you can change your code so that you add layer B first, then layer A. The ordering of the layer will then be reversed. By default, the layer that is adding first will stay on top.

You may also use the API Layer.moveFront to move a layer to the front. For example:

Call layer.moveFront()


3. I am not too sure where would you like to add the label. In general, you may use BaseChart.addText to add a label at any place you like, and use Box.setBackground to configure a box around it and use Box.setRoundedCorners to use rounded corners. For example:

Set t = c.addText(...........)
Call t.setBackground(&Hff6666, cd.Transparent, cd.glassEffect())
Call t.setRoundedCorners(5)

Hope this scan help.

Regards
Peter Kwan