21.08.2013 Views

OpenOffice.org BASIC Guide.pdf - OpenOffice.org wiki

OpenOffice.org BASIC Guide.pdf - OpenOffice.org wiki

OpenOffice.org BASIC Guide.pdf - OpenOffice.org wiki

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Using Charts in Spreadsheets 182<br />

RangeAddress(0).EndRow = 12<br />

Charts.addNewByName("MyChart", Rect, RangeAddress(), True, True)<br />

Although the code used in the example may appear to be complex, the central processes<br />

are limited to three lines. The first central line creates the Doc document variable, which<br />

references the current spreadsheet document (Doc line = StarDesktop.CurrentComponent).<br />

The code used in the example then creates a list containing all charts of the first<br />

spreadsheet (Charts line = Doc.Sheets(0).Charts). Finally, in the last line, a new chart is<br />

added to this list using the addNewByName method. This new chart is then visible to the<br />

user. The variable RangeAddress determines the assigned cell range whose data will be<br />

displayed within the chart. The variable Rect determines the position and size of the chart<br />

within the first sheet in the spreadsheet document.<br />

The previous example creates a bar chart. If a different chart type is needed, then the bar<br />

chart must be explicitly 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<br />

chart with a new one — in this example, a line chart.<br />

In Microsoft Excel, a distinction is made between charts which have been inserted as a separate page in<br />

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><br />

Basic, because charts in <strong>OpenOffice</strong>.<strong>org</strong> Calc are always created as embedded objects of a table page.<br />

The charts are always accessed using the Charts list of the associated Sheet object.<br />

Source: http:/ / <strong>wiki</strong>. services. openoffice. <strong>org</strong>/ w/ index. php? title=Documentation/ <strong>BASIC</strong>_<br />

<strong>Guide</strong>/ Charts_ in_ Spreadsheets&oldid=96887<br />

Principal Authors: Fpe, Ccornell, Iha<br />

The Structure of Charts<br />

The structure of a chart, and therefore the list of services and interfaces supported by it,<br />

depends on the chart type. For example, the methods and properties of the Z-axis, are<br />

available in 3D charts, but not in 2D charts, and in pie charts, there are no interfaces for<br />

working with axes.<br />

Title, Subtitle and Legend<br />

Title, subtitle and legend are basic elements provided for every chart. The Chart object<br />

provides the following properties for administrating these elements:<br />

HasMainTitle (Boolean)

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!