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

Message ListMessage List     Post MessagePost Message

  Details of chart data point labeling and layout control
Posted by DC Kelley on Apr-04-2011 07:31
Attachments:
Two questions related to chart data point labeling.
The graphic below illustrates the current problem.

First
I have in general found the auto-scaling layout of the y axis to be wonderfull for our needs, but when a data point label is added it does not seem to take the space required to hold the label text into account when selecting the scale to be used.  See the below and note the very first data point where the label ("-4.84") extends beyond the plot area.  Can this be controlled in some way other then simple leaving room in the area above the plot?   I do not mind (and very much like) the logic that move the label for the axis point offset a bit, it is the vertical placement that is the issue.  [Aside the legend placement at the top of the plot area was on purpose here, but we may move it due to this issue]

Second
Is there a way to control the number of labels (label step rate) that issue short of providing an array of specific text to be used?   In this example it would be better to label only every nth time, or better yet to only label when the data point value changed.  I presume the latter is best handled by creating a custom array of label with the needed logic and that CD, for all its wonderful features, probably does not do that one.

I do not see any suitable object to use for a step rate, I presume the labels are text box objects but do not see how to get at them, code this might be
   // Any way to control data label steps on this to get every Nth point labeled?
   // pLayer->WHAT TEXT BOX OBJECT->setLabelStep(3); // Display every 3rd data point label
SavedScreenChart.png

  Re: Details of chart data point labeling and layout control
Posted by Peter Kwan on Apr-04-2011 14:09
Hi DC Kelley,

ChartDirector auto-scaling will only consider the position of the data points. It will not consider the text labels (which can be arbitrarily long and complex). When configuring the chart, you may need to reserve some margins if you would like to text labels to stay within the chart.

By default, ChartDirector auto-scaling will reserve at least 5% space at the top and bottom when determining the scale. This is configurable using Axis.setAutoScale. For a reasonably sized chart, 5% should be sufficient for a horizontal label, but it may be insufficient for a vertical label. Depending on how long the label can be, and how high is the plot area, you may need to reserve more spacing using Axis.setAutoScale.

To control the number of labels, you may use addCustomDataLabel (instead of setDataLabelFormat/setDataLabelStyle). For example, if you would like to add a label only when the value changes, you may use:

for (int i = 0; i < pointsCount; ++i) {
   if ((i == 0) || (myData[i] != myData[i - 1]))
      layer->addCustomDataLabel(0, i, "{value|2}", "arial.ttf", 8, 0x000000, 90);
}

Hope this can help.

Regards
Peter Kwan

  Re: Details of chart data point labeling and layout control
Posted by DC Kelley on Apr-05-2011 04:02
I am coming to depend on the auto scale quite all at present (we typically are forcing it to be fairly tight [ setAutoScale(.06,.04,0.3) ] but perhaps I can loop over the labels that I will now have to create each time to manage the axis placement better and come up with a multiplier for the Y margin that that would more or less work the same way Windows/Max allows retrieving a string/font pixel width.   Many thanks.  DCK