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

Message ListMessage List     Post MessagePost Message

  autogrid legend problem with fontsize
Posted by Dave Doyle on Jan-20-2011 07:10
Attachments:
When I create a legend with an AutoGrid layout and reduce the font size, I get weird layout/clipping problems (see attachment).

I can't post all the code, but the relevant legend code in PHP is:

$legend = $c->addLegend2(0, 0, AutoGrid, "helvR09.pcf");
$legend->setBackground(0x99ffffff, Transparent);
$legend->setFontSize(8);
$legend->setMargin(5);
$legend->setKeySize(15, 5);
$legend->setKeyborder(Transparent);


If I remove the setFontSize command everything works fine, and the final entry is wrapped to the next row.

Any idea how to fix this?
legend_problems.gif

  Re: autogrid legend problem with fontsize
Posted by Peter Kwan on Jan-21-2011 01:57
Hi Dave,

To perform AutoGrid, ChartDirector must first know the total width of the legend box, so that it can predict the size of the cells. For example, if the total legend box width is 600 pixels, and each legend entry requires 140 pixels, ChartDirector knows it can fit 4 legends in the same line. On the other hand, if each legend entry requires 160 pixels, ChartDirector knows it can only fit 3 legends in the same line.

For you case, for small fonts, ChartDirector probably thinks it can fit 4 legend on the same line. The reason is probably because ChartDirector thinks the legend box total width is very wide, so wide that part of it is outside the chart. As a result, part of the last legend is outside the chart.

So the issue is, why does ChartDirector thinks the legend box is so wide? Without your complete and exact code, it is hard to know. Some possibilities are:

(a) Your code instructs ChartDirector to use a certain width for the legend box (eg. using setWidth), but the wide is so wide that part of it is outside the chart.

(b) The legend box width should be correct and not outside the chart, but then after ChartDirector decides to put 4 legends in the same line, your code move the legend box to another place (eg. using setPos), so part of the legend box falls outside the chart.

Have you code performs the above?

If the above still cannot solve the problem, would you mind to inform me of your complete charting code?

Regards
Peter Kwan

  Re: autogrid legend problem with fontsize
Posted by Dave Doyle on Jan-21-2011 02:36
Ah, there was indeed a setPos shifting the legend into the PlotArea.  So, I take it this means that I need to set the legend width overtly then, to compensate?

  Re: autogrid legend problem with fontsize
Posted by Peter Kwan on Jan-21-2011 03:28
Hi Dave,

You can set legend position before the chart is layout. However, if you must modify the legend position after the chart has already been layout, you would need to provide a legend box width (using setWidth) in advance.

Hope this can help.

Regards
Peter Kwan