Hi Scott,
The API for auto-sizing is XYChart.packPlotArea. Basically, it adjusts the plot area (inclusive of axis labels) to fit a bounding box provided by you. The bounding box can be the entire chart, or part of the chart (you may reserve space for chart title, legend box, or just reserve empty space as margins, etc).
You still need to use setPlotArea to provide an intial plot area size, but the size only need to be approximate. The packPlotArea should be called after the entire chart is configured.
Many ChartDirector sample charts use packPlotArea. If you have the CHM documentation, you may search for "packPlotArea" for a number of sample charts. Examples are "Gradient Bar Shading", "Missing Data Points", "Bars with Marks", "Multi-Symbol Line Chart", etc..
In brief, you just create the chart as usual, using an approximate plot area size. Then after you have finished adding everything to the chart, call XYChart.packPlotArea to adjust the plot area size to fit the plot area (inclusive of axis labels) to a bounding box of your choice.
Hope this can help.
Regards
Peter Kwan |