This Technical Tip is about the difference between sizing a container which contains one or more objects and sizing a single object. In 4D, both options to size the container and to size the objects inside the container are provided. The following example gives an idea of how it can be done.
The following blocks of code create a 4D offscreen area as a container, loads a 4D Chart object into the area, converts the object to a picture and then deletes the area.
Many people size the offscreen area and believe that the object placed in there will fit the size of the area. However, it does not work this way. A huge 4D Chart picture is displayed. The 4D Chart picture can only be correctly sized after resizing the object itself.
The following code sizes the 4D offscreen area only (4D Chart object is not correctly sized):
Area:=CT New offscreen area CT SET DOCUMENT SIZE(Area;300;280) //set the initial size of the doc before a chart is drawn vChart:=CT Chart arrays(Area;100;2;at_Category;at_Series;at_Values) vPict:=CT Area to picture(Area;vChart) CT DELETE OFFSCREEN AREA(Area) |
Use the CT SIZE command to correctly resize the 4D chart object.
Area:=CT New offscreen area vChart:=CT Chart arrays(Area;100;2;at_Category;at_Series;at_Values) CT SIZE(Area;vChart;250;250) //resize the 4D chart object vPict:=CT Area to picture(Area;vChart) CT DELETE OFFSCREEN AREA(Area) |
Note: Get the chart id by using the CT Chart arrays method, and then pass the id into the CT SIZE command to resize the object.
Here are the documentation links for CT Chart arrays and CT SIZE commands:
http://doc.4d.com/4D Chartv13/help/Command/en/page14526.html
http://doc.4d.com/4D Chartv13/help/Command/en/page14576.html