OpenOffice.org BASIC Guide - OpenOffice.org wiki
OpenOffice.org BASIC Guide - OpenOffice.org wiki
OpenOffice.org BASIC Guide - OpenOffice.org wiki
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Using Charts in Spreadsheets<br />
The previous example creates a bar chart. If a different chart type is needed, then the bar chart must be explicitly<br />
replaced:<br />
Chart = Charts.getByName("MyChart").embeddedObject<br />
Chart.Diagram = Chart.createInstance("com.sun.star.chart.LineDiagram")<br />
The first line defines the corresponding chart object. The second line replaces the current chart with a new one —<br />
in this example, a line chart.<br />
Note – VBA : In Microsoft Excel, a distinction is made between charts which have been inserted as a separate<br />
page in a Microsoft Excel document and charts which are embedded in a table page. Correspondingly, two<br />
different access methods are defined there for charts. This distinction is not made in <strong>OpenOffice</strong>.<strong>org</strong> Basic,<br />
because charts in <strong>OpenOffice</strong>.<strong>org</strong> Calc are always created as embedded objects of a table page. The charts are<br />
always accessed using the Charts list of the associated Sheet object.<br />
The Structure of Charts<br />
The structure of a chart, and therefore the list of services and interfaces supported by it, depends on the chart<br />
type. For example, the methods and properties of the Z-axis, are available in 3D charts, but not in 2D charts, and<br />
in pie charts, there are no interfaces for working with axes.<br />
Title, Subtitle and Legend<br />
Title, subtitle and legend are basic elements provided for every chart. The Chart object provides the following<br />
properties for administrating these elements:<br />
HasMainTitle (Boolean)<br />
activates the title<br />
Title (Object)<br />
object with detailed information about the chart title (supports the com.sun.star.chart.ChartTitle service)<br />
HasSubTitle(Boolean)<br />
activates the subtitle<br />
Subtitle (Object)<br />
object with detailed information about the chart subtitle (supports the com.sun.star.chart.ChartTitle<br />
service)<br />
HasLegend (Boolean)<br />
activates the legend<br />
Legend (Object)<br />
object with detailed information about the legend (supports the com.sun.star.chart.ChartLegend service)<br />
Both services com.sun.star.chart.ChartTitle and com.sun.star.chart.ChartLegend do support the<br />
service com.sun.star.drawing.Shape. This allows to determine the position and size of the elements using<br />
the Position and Size properties. As the size of the legend and the titles is calculated automatically based on<br />
the current content and the character height for example, the size property provides read access only.<br />
Fill and line properties (com.sun.star.drawing.FillProperties and com.sun.star.drawing.LineProperties services) as<br />
well as the character properties (com.sun.star.style.CharacterProperties service) are provided for further<br />
formatting of the elements.<br />
com.sun.star.chart.ChartTitlecontains not only the listed formatting properties, but also two other properties:<br />
String (String)<br />
text which to be displayed as the title or subtitle<br />
132 <strong>OpenOffice</strong>.<strong>org</strong> 3.2 <strong>BASIC</strong> <strong>Guide</strong> · March 2010