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

Message ListMessage List     Post MessagePost Message

  Auto resize plot area
Posted by Marko on May-16-2012 19:59
Attachments:
Hi

I'm searching for a way to automatically resize the chart plotArea width/height when axis data is taking too much space and axes titles are hidden (see attachment). As you can see, values are ranging from 0 to 40.000 and a part of 'Realizacija' is cropped. If data change, for example from 0 to 50, then the title is fully displayed.

Working with PHP, thanks.
plot_area_autoresize.png

  Re: Auto resize plot area
Posted by Peter Kwan on May-17-2012 04:18
HI Marko,

You may use the XYChart.packPlotArea method available since ChartDirector Ver 5.0. It will adjust the plot area size so that the axis labels and titles will stay within a bounding box specified by your code. See the "Multi-Symbol Line Chart" (you may look up "Multi-Symbol Line Chart" from the ChartDirector documentation index) for an example on using XYChart.pacKPlotArea.

Hope this can help.

Regards
Peter Kwan

  Re: Auto resize plot area
Posted by Marko on May-17-2012 15:34
Thanks Peter, this really helps me.

I have another question. I'm falling into an Error:
Fatal error: Error converting object pointer to type class Box *

when i try to get the width of a legend box that obvously isn't set. This is the object:

LegendBox Object ( [ptr] => $$pointer$$class LegendBox *@0 )

Is there any chance I could detect the legend box doesn't exist, something like $chart->hasLegend()? Maybe the zero value after @ in 'ptr'?

  Re: Auto resize plot area
Posted by Peter Kwan on May-18-2012 02:39
Hi Marko,

Since the legend box is always added by your code, your code can keep track of whether the legend box exists or not.

For example, instead of using the following code to add a legend box:

$c->addLegend(.....);

you may use:

$c->myLegendBox = $c->addLegend(.....);

Now you can check the existence of $c->myLegendBox (eg. using PHP isset function) to determine if your code has added the legend box.

Hope this can help.

Regards
Peter Kwan

  Re: Auto resize plot area
Posted by Marko on May-18-2012 03:54
Hi Peter

I can't replicate the error at the moment, I think there was a bar chart with legend turned on but with no plot data (SQL query returned 0 records). I took a shortcut and I added:
substr($layoutLegendBox->ptr, -2)!='@0' to the if clause you mentioned. It seems to work, however it is not very intuitive.
Thanks.