Difference between revisions of "Documentation/BASIC Guide/Structure of Charts"

From Apache OpenOffice Wiki
Jump to: navigation, search
m (ThisComponent everywhere)
(46 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{Documentation/NeedsRework}}
 
 
{{Documentation/BASICGuideTOC/v2
 
{{Documentation/BASICGuideTOC/v2
 
|ShowPrevNext=block
 
|ShowPrevNext=block
Line 8: Line 7:
 
}}
 
}}
 
{{DISPLAYTITLE:The Structure of Charts}}
 
{{DISPLAYTITLE:The Structure of Charts}}
 +
__NOTOC__
 +
The structure of a chart, and therefore the list of services and interfaces supported by it, depends on the chart type. For example, the methods and properties of the Z-axis, are available in 3D charts, but not in 2D charts, and in pie charts, there are no interfaces for working with axes.
  
The structure of a chart — and therefore the list of services and interfaces supported by it — depends on its type. The methods and properties of the Z-axis, are, for example, only available in 3D charts, but not in 2D charts. In pie charts, there are no interfaces for working with axes.
+
== Title, Subtitle and Legend ==
  
== The Individual Elements of a Chart ==
+
Title, subtitle and legend are basic elements provided for every chart. The <tt>Chart</tt> object provides the following properties for administrating these elements:
  
=== Title, Sub-title and Key ===
+
;<tt>HasMainTitle (Boolean)</tt>:activates the title
 +
;<tt>Title (Object)</tt>:object with detailed information about the chart title (supports the <idl>com.sun.star.chart.ChartTitle</idl> service)
 +
;<tt>HasSubTitle(Boolean)</tt>:activates the subtitle
 +
;<tt>Subtitle (Object)</tt>:object with detailed information about the chart subtitle (supports the <idl>com.sun.star.chart.ChartTitle</idl> service)
 +
;<tt>HasLegend (Boolean)</tt>:activates the legend
 +
;<tt>Legend (Object)</tt>:object with detailed information about the legend (supports the <idl>com.sun.star.chart.ChartLegend</idl> service)
  
A title, sub-title and key form part of the basic elements of every chart. Charts provide their own objects for each of these elements. The <tt>Chart</tt> object provides the following properties for administrating these elements:
+
Both services <tt>com.sun.star.chart.ChartTitle</tt> and <tt>com.sun.star.chart.ChartLegend</tt> do support the service <tt>com.sun.star.drawing.Shape</tt>. This allows to determine the position and size of the elements using the <tt>Position</tt> and <tt>Size</tt> properties. As the size of the legend and the titles is calculated automatically based on the current content and the character height for example, the size property provides read access only.
  
;<tt>HasMainTitle (Boolean)</tt>:activates the title.
+
Fill and line properties (<idl>com.sun.star.drawing.FillProperties</idl> and <idl>com.sun.star.drawing.LineProperties</idl> services) as well as the character properties (<idl>com.sun.star.style.CharacterProperties</idl> service) are provided for further formatting of the elements.
;<tt>Title (Object)</tt>:object with detailed information about the chart title (supports the <tt>com.sun.star.chart.ChartTitle</tt> service).
+
;<tt>HasSubTitle(Boolean)</tt>:activates the sub-title.
+
;<tt>Subtitle (Object)</tt>:object with detailed information about the chart sub-title (supports the <tt>com.sun.star.chart.ChartTitle</tt> service).
+
;<tt>HasLegend (Boolean)</tt>:activates the key.
+
;<tt>Legend (Object)</tt>:object with detailed information about the key to the chart (supports the <tt>com.sun.star.chart.ChartLegendPosition</tt> service).
+
  
In many respects, the elements specified correspond to a drawing element. This is due to the fact that both the <tt>com.sun.star.chart.ChartTitle</tt> service and the <tt>com.sun.star.chart.ChartLegendPosition</tt> support the <tt>com.sun.star.drawing.Shape</tt> service, which forms the technical program basis for drawing elements.
+
<idl>com.sun.star.chart.ChartTitle</idl> contains not only the listed formatting properties, but also two other properties:
  
Users therefore have the opportunity to determine the position and size of the element using the <tt>Size</tt> and <tt>Position</tt> properties.
+
;<tt>String (String)</tt>:text which to be displayed as the title or subtitle
 +
;<tt>TextRotation (Long)</tt>:angle of rotation of text in 100ths of a degree
  
The other fill and line properties (<tt>com.sun.star.drawing.FillProperties</tt> and <tt>com.sun.star.drawing.LineStyle</tt> services) as well as the character properties (<tt>com.sun.star.style.CharacterProperties</tt> service) are provided for formatting the elements.
+
The legend (<idl>com.sun.star.chart.ChartLegend</idl>) contains the following additional property:
  
<tt>com.sun.star.chart.ChartTitle</tt> contains not only the named format properties, but also two other properties:
+
;<tt>Alignment (Enum)</tt>:position at which the legend appears (value of type <idl>com.sun.star.chart.ChartLegendPosition</idl>)
  
;<tt>TextRotation (Long)</tt>:angle of rotation of text in 100ths of a degree.
+
The following example creates a chart with a title "Main Title String", a subtitle "Subtitle String" and a legend. The legend has a gray background color, is placed at the bottom of the chart, and has a character size of 7 points.
;<tt>String (String)</tt>:text which to be displayed as the title or sub-title.
+
  
The chart key (<tt>com.sun.star.chart.ChartLegend</tt> service) contains the following additional property:
+
<source lang="oobas">
 +
Dim Doc As Object
 +
Dim Charts As Object
 +
Dim Chart as Object
 +
Dim Rect As New com.sun.star.awt.Rectangle
 +
Dim RangeAddress(0) As New com.sun.star.table.CellRangeAddress
  
;<tt>Alignment (Enum)</tt>:position at which the key appears (default value in accordance with <tt>com.sun.star.chart.ChartLegendPosition</tt> ).
+
Rect.X = 8000
 +
Rect.Y = 1000
 +
Rect.Width = 10000
 +
Rect.Height = 7000
 +
RangeAddress(0).Sheet = 0
 +
RangeAddress(0).StartColumn = 0
 +
RangeAddress(0).StartRow = 0
 +
RangeAddress(0).EndColumn = 2
 +
RangeAddress(0).EndRow = 12
  
The following example creates a chart and assigns it the title "Test", the sub-title "Test 2" and a key. The key has a gray background color, is placed at the bottom of the chart, and has a character size of 7 points.
+
Doc = ThisComponent
  
Dim Doc As Object
+
Charts = Doc.Sheets(0).Charts
Dim Charts As Object
+
Charts.addNewByName("MyChart", Rect, RangeAddress(), True, True)
Dim Chart as Object
+
Chart = Charts.getByName("MyChart").EmbeddedObject
Dim Rect As New com.sun.star.awt.Rectangle
+
Chart.HasMainTitle = True
Dim RangeAddress(0) As New com.sun.star.table.CellRangeAddress
+
Chart.Title.String = "Main Title String"
+
Chart.HasSubTitle = True
Rect.X = 8000
+
Chart.Subtitle.String = "Subtitle String"
Rect.Y = 1000
+
Chart.HasLegend = True  
Rect.Width = 10000
+
Chart.Legend.Alignment = com.sun.star.chart.ChartLegendPosition.BOTTOM
Rect.Height = 7000
+
Chart.Legend.FillStyle = com.sun.star.drawing.FillStyle.SOLID
RangeAddress(0).Sheet = 0
+
Chart.Legend.FillColor = RGB(210, 210, 210)
RangeAddress(0).StartColumn = 0
+
Chart.Legend.CharHeight = 7
RangeAddress(0).StartRow = 0
+
</source>
RangeAddress(0).EndColumn = 2
+
RangeAddress(0).EndRow = 12
+
+
Doc = StarDesktop.CurrentComponent
+
+
Charts = Doc.Sheets(0).Charts
+
Charts.addNewByName("MyChart", Rect, RangeAddress(), True, True)
+
Chart = Charts.getByName("MyChart").EmbeddedObject
+
Chart.HasMainTitle = True
+
Chart.Title.String = "Test"
+
Chart.HasSubTitle = True
+
Chart.Subtitle.String = "Test 2"
+
Chart.HasLegend = True  
+
Chart.Legend.Alignment = com.sun.star.chart.ChartLegendPosition.BOTTOM
+
Chart.Legend.FillStyle = com.sun.star.drawing.FillStyle.SOLID
+
Chart.Legend.FillColor = RGB(210, 210, 210)
+
Chart.Legend.CharHeight = 7
+
  
=== Background ===
+
== Background ==
  
Every chart has a background area. Every area has an object, which can be accessed using the following properties of the chart object:
+
Every chart has a background area. The <tt>Chart</tt> object provides the property <tt>Area</tt> to format the background:
  
;<tt>Area (Object)</tt>:background area of the chart (supports <tt>com.sun.star.chart.ChartArea</tt> service).
+
;<tt>Area (Object)</tt>:background area of the chart (supports <idl>com.sun.star.chart.ChartArea</idl> service)
  
The background of a chart covers its complete area, including the area under the title, sub-title and chart key. The associated <tt>com.sun.star.chart.ChartArea</tt> service supports line and fill properties and provides no more extensive properties.
+
The background of a chart covers its complete area, including the area under the title, subtitle and legend. The associated <idl>com.sun.star.chart.ChartArea</idl> service supports line and fill properties.
  
=== Chart Walls and Floors ===
+
== Diagram ==
  
Although the chart background covers the entire area of the chart, the chart back wall is limited to the area directly behind the data area.
+
The <tt>Chart</tt> object provides the property <tt>Diagram</tt> which forms the coordinate system with axes and grids, where the data finally is displayed:
  
Two chart walls usually exist for 3D charts: one behind the data area and one as the left-hand demarcation to the Y-axis. 3D charts usually also have a floor.
+
;<tt>Diagram (Object)</tt>:object forming the coordinate system where the data is plotted.  It supports <idl>com.sun.star.chart.Diagram</idl> service and:
 +
:* <idl>com.sun.star.chart.StackableDiagram</idl>
 +
:* <idl>com.sun.star.chart.ChartAxisXSupplier</idl>
 +
:* <idl>com.sun.star.chart.ChartAxisYSupplier</idl>
 +
:* <idl>com.sun.star.chart.ChartAxisZSupplier</idl>
 +
:* <idl>com.sun.star.chart.ChartTwoAxisXSupplier</idl>
 +
:* <idl>com.sun.star.chart.ChartTwoAxisYSupplier</idl>
  
;<tt>Floor (Object)</tt>:floor panel of the chart (only for 3D charts, supports <tt>com.sun.star.chart.ChartArea</tt> service).
+
Different services are supported depending on the chart type (see
;<tt>Wall (Object)</tt>:chart walls (only for 3D charts, supports <tt>com.sun.star.chart.ChartArea</tt> service).
+
[[Documentation/BASIC_Guide/Chart_Types|Chart Types]]).
  
The specified objects support the <tt>com.sun.star.chart.ChartArea</tt> service, which in turn provides the usual fill and line properties <tt>(com.sun.star.drawing.FillProperties</tt> and <tt>com.sun.star.drawing.LineStyle</tt> services, refer to [html/p27.html Chapter 8, Drawings and Presentations]).
+
== Wall and Floor ==
  
The chart walls and floor are accessed through the <tt>Chart</tt> object, which in turn is part of the Chart object:
+
The chart wall is the background of the coordinate system where the data is plotted.
 +
Two chart walls usually exist for 3D charts: one behind the plotted data and one as the left-hand or right-hand demarcation. This depends on the rotation of the chart. 3D charts usually also have a floor.
  
Chart.Area.FillBitmapName = "Sky" 
+
The <tt>Diagram</tt> object provides the properties Wall and Floor:
  
The following example shows how graphics (named Sky) already contained in {{OOo}} can be used as a background to a chart.
+
;<tt>Wall (Object)</tt>:background wall of the coordinate system (supports <idl>com.sun.star.chart.ChartArea</idl> service)
 +
;<tt>Floor (Object)</tt>:floor panel of coordinate system (only for 3D charts, supports <idl>com.sun.star.chart.ChartArea</idl> service)
  
Dim Doc As Object
+
The specified objects support the <tt>com.sun.star.chart.ChartArea</tt> service, which provides the usual fill and line properties (<idl>com.sun.star.drawing.FillProperties</idl> and <idl>com.sun.star.drawing.LineProperties</idl> services, refer to [[Documentation/BASIC_Guide/Drawings_Presentations|Drawings and Presentations]]).
Dim Charts As Object
+
Dim Chart as Object
+
Dim Rect As New com.sun.star.awt.Rectangle
+
Dim RangeAddress(0) As New com.sun.star.table.CellRangeAddress
+
+
Rect.X = 8000
+
Rect.Y = 1000
+
Rect.Width = 10000
+
Rect.Height = 7000
+
RangeAddress(0).Sheet = 0
+
RangeAddress(0).StartColumn = 0
+
RangeAddress(0).StartRow = 0
+
RangeAddress(0).EndColumn = 2
+
RangeAddress(0).EndRow = 12
+
+
Doc = StarDesktop.CurrentComponent
+
+
Charts = Doc.Sheets(0).Charts
+
Charts.addNewByName("MyChart", Rect, RangeAddress(), True, True)
+
Chart = Charts.getByName("MyChart").EmbeddedObject
+
Chart.Area.FillStyle = com.sun.star.drawing.FillStyle.BITMAP
+
Chart.Area.FillBitmapName = "Sky"
+
Chart.Area.FillBitmapMode = com.sun.star.drawing.BitmapMode.REPEAT
+
  
=== Axes ===
+
The following example shows how graphics (named Sky) already contained in {{OOo}} can be used as a background for a chart. The wall is set to be blue.
 +
 
 +
<source lang="oobas">
 +
Dim Doc As Object
 +
Dim Charts As Object
 +
Dim Chart as Object
 +
Dim Rect As New com.sun.star.awt.Rectangle
 +
Dim RangeAddress(0) As New com.sun.star.table.CellRangeAddress
 +
 
 +
Rect.X = 8000
 +
Rect.Y = 1000
 +
Rect.Width = 10000
 +
Rect.Height = 7000
 +
RangeAddress(0).Sheet = 0
 +
RangeAddress(0).StartColumn = 0
 +
RangeAddress(0).StartRow = 0
 +
RangeAddress(0).EndColumn = 2
 +
RangeAddress(0).EndRow = 12
 +
 
 +
Doc = ThisComponent
 +
 
 +
Charts = Doc.Sheets(0).Charts
 +
Charts.addNewByName("MyChart", Rect, RangeAddress(), True, True)
 +
Chart = Charts.getByName("MyChart").EmbeddedObject
 +
Chart.Area.FillStyle = com.sun.star.drawing.FillStyle.BITMAP
 +
Chart.Area.FillBitmapName = "Sky"
 +
Chart.Area.FillBitmapMode = com.sun.star.drawing.BitmapMode.REPEAT
 +
 
 +
Chart.Diagram.Wall.FillStyle = com.sun.star.drawing.FillStyle.SOLID
 +
Chart.Diagram.Wall.FillColor = RGB(00,132,209)
 +
</source>
 +
 
 +
== Axes ==
  
 
{{OOo}} recognizes five different axes that can be used in a chart. In the simplest scenario, these are the X and Y-axes. When working with 3D charts, a Z-axis is also sometimes provided. For charts in which the values of the various rows of data deviate significantly from one another, {{OOo}} provides a second X and Y-axis for second scaling operations.
 
{{OOo}} recognizes five different axes that can be used in a chart. In the simplest scenario, these are the X and Y-axes. When working with 3D charts, a Z-axis is also sometimes provided. For charts in which the values of the various rows of data deviate significantly from one another, {{OOo}} provides a second X and Y-axis for second scaling operations.
  
=== First X, Y and Z-Axis ===
+
The <tt>Diagram</tt> object provides the following properties to access the axes:
  
In addition to the actual axis, for each of the first X, Y, and Z-axes there can also be a title, a description, a grid, and an auxiliary grid. There is an option for displaying and concealing all of these elements. The chart object provides the following properties for administration of these features (taking the example of a X-axis; properties for Y and Z-axis are structured in the same way):
+
;<tt>HasXAxis (Boolean)</tt>:activates the X-axis
 +
;<tt>XAxis (Object)</tt>:object with detailed information about the X-axis (supports <idl>com.sun.star.chart.ChartAxis</idl> service)
 +
;<tt>HasXAxisDescription (Boolean)</tt>:activates the labels for the interval marks for the X-axis
  
;<tt>HasXAxis (Boolean)</tt>:activates the X-axis.
+
;<tt>HasYAxis (Boolean)</tt>:activates the Y-axis
;<tt>XAxis (Object)</tt>:object with detailed information about the X-axis (supports <tt>com.sun.star.chart.ChartAxis</tt> service).
+
;<tt>YAxis (Object)</tt>:object with detailed information about the Y-axis (supports <idl>com.sun.star.chart.ChartAxis</idl> service)
;<tt>HasXAxisDescription (Boolean)</tt>:activates description for the X-axis.
+
;<tt>HasYAxisDescription (Boolean)</tt>:activates the labels for the interval marks for the Y-axis
;<tt>HasXAxisGrid (Boolean)</tt>:activates main grid for X-axis.
+
;<tt>XMainGrid (Object)</tt>:object with detailed information about main grid for X-axis (supports <tt>com.sun.star.chart.ChartGrid</tt> service).
+
;<tt>HasXAxisHelpGrid (Boolean)</tt>:activates auxiliary grid for X-axis.
+
;<tt>XHelpGrid (Object)</tt>:object with detailed information about auxiliary grid for X-axis (supports <tt>com.sun.star.chart.ChartGrid</tt> service).
+
;<tt>HasXAxisTitle (Boolean)</tt>:activates title of X-axis.
+
;<tt>XAxisTitle (Object)</tt>:object with detailed information about title of X-axis (supports <tt>com.sun.star.chart.ChartTitle</tt> service).
+
  
=== Second X and Y-Axis ===
+
;<tt>HasZAxis (Boolean)</tt>:activates the Z-axis
 +
;<tt>ZAxis (Object)</tt>:object with detailed information about the Z-axis (supports <idl>com.sun.star.chart.ChartAxis</idl> service)
 +
;<tt>HasZAxisDescription (Boolean)</tt>:activates the labels for the interval marks for the Z-axis
  
The following properties are available for the second X and Y-axes (properties taking example of the second X-axis):
+
;<tt>HasSecondaryXAxis (Boolean)</tt>:activates the secondary X-axis
 +
;<tt>SecondaryXAxis (Object)</tt>:object with detailed information about the secondary X-axis (supports <idl>com.sun.star.chart.ChartAxis</idl> service)
 +
;<tt>HasSecondaryXAxisDescription (Boolean)</tt>:activates the labels for the interval marks for the secondary X-axis
  
;<tt>HasSecondaryXAxis (Boolean)</tt>:activates the second X-axis.
+
;<tt>HasSecondaryYAxis (Boolean)</tt>:activates the secondary Y-axis
;<tt>SecondaryXAxis (Object)</tt>:object with detailed information about the second X-axis (supports <tt>com.sun.star.chart.ChartAxis</tt> service).
+
;<tt>SecondaryYAxis (Object)</tt>:object with detailed information about the secondary Y-axis (supports <idl>com.sun.star.chart.ChartAxis</idl> service)
;<tt>HasSecondaryXAxisDescription (Boolean)</tt>:activates description of X-axis.
+
;<tt>HasSecondaryYAxisDescription (Boolean)</tt>:activates the labels for the interval marks for the secondary Y-axis
  
=== Properties of the Axes ===
+
== Properties of Axes ==
  
The axis objects of a {{OOo}} chart support the <tt>com.sun.star.chart.ChartAxis</tt> service. In addition to the properties for characters <tt>(com.sun.star.style.CharacterProperties</tt> service, refer to [html/p19.html Chapter 6, Text Documents]) and lines <tt>(com.sun.star.drawing.LineStyle</tt> service, refer to [html/p27.html Chapter 8, Drawings and Presentations]), it provides the following properties:
+
The axis objects of a {{OOo}} chart support the <idl>com.sun.star.chart.ChartAxis</idl> service. In addition to the properties for characters <idl>(com.sun.star.style.CharacterProperties</idl> service, refer to [[Documentation/BASIC_Guide/Text_Documents|Text Documents]]) and lines <idl>(com.sun.star.drawing.LineStyle</idl> service, refer to [[Documentation/BASIC_Guide/Drawings_Presentations|Drawings and Presentations]]), it provides the following properties:
  
;<tt>Max (Double)</tt>:maximum value for axis.
+
===Scaling properties:===
;<tt>Min (Double)</tt>:minimum value for axis.
+
;<tt>Max (Double)</tt>:maximum value for axis
;<tt>Origin (Double)</tt>:point of intersect for crossing axes.
+
;<tt>Min (Double)</tt>:minimum value for axis
;<tt>StepMain (Double)</tt>:distance between two primary lines of the axis.
+
;<tt>Origin (Double)</tt>:point of intersect for crossing axes
;<tt>StepHelp (Double)</tt>:distance between two secondary lines of the axis.
+
;<tt>StepMain (Double)</tt>:distance between the major interval marks
;<tt>AutoMax (Boolean)</tt>:automatically determines maximum value for axis.
+
;<tt>StepHelp (Double)</tt>:distance between the minor interval marks (deprecated since OpenOffice.org 3.0; Use property StepHelpCount instead)
;<tt>AutoMin (Boolean)</tt>:automatically determines minimum value for axis.
+
;<tt>StepHelpCount (Long)</tt>:Contains the number of minor intervals within a major interval. E.g. a StepHelpCount of 5 divides the major interval into 5 pieces and thus produces 4 minor tick marks. (available since OpenOffice.org 3.0)
;<tt>AutoOrigin (Boolean)</tt>:automatically determines point of intersect for crossing axes.
+
;<tt>AutoMax (Boolean)</tt>:the maximum value for the axis is calculated automatically when set to true
;<tt>AutoStepMain (Boolean)</tt>:automatically determines distance between primary lines of an axis.
+
;<tt>AutoMin (Boolean)</tt>:the minimum value for the axis is calculated automatically when set to true
;<tt>AutoStepHelp (Boolean)</tt>:automatically determines distance between secondary lines of an axis.
+
;<tt>AutoOrigin (Boolean)</tt>:the origin is determined automatically when set to true
;<tt>Logarithmic (Boolean)</tt>:scales the axes in logarithmic manner (rather than linear manner).
+
;<tt>AutoStepMain (Boolean)</tt>:StepMain is determined automatically when set to true
;<tt>DisplayLabels (Boolean)</tt>:activates the text label for axes.
+
;<tt>AutoStepHelp (Boolean)</tt>:StepHelpCount is determined automatically when set to true
;<tt>TextRotation (Long)</tt>:angle of rotation of text label of axes in 100ths of a degree.
+
;<tt>Logarithmic (Boolean)</tt>:scales the axes in logarithmic manner (rather than linear)
;<tt>Marks (Const)</tt>:constant that specifies whether the primary lines of the axis should be inside or outside the chart area (default values in accordance with <tt>com.sun.star.chart.ChartAxisMarks</tt> )
+
;<tt>ReverseDirection (Boolean)</tt>:determines if the axis orientation is mathematical or reversed. (available since OpenOffice.org 2.4)
;<tt>HelpMarks (Const)</tt>:constant that specifies whether the secondary lines of the axis should be inside and/or outside the chart area (default values in accordance with <tt>com.sun.star.chart.ChartAxisMarks</tt> )
+
;<tt>Overlap (Long)</tt>:percentage which specifies the extent to which the bars of different sets of data may overlap (at 100%, the bars are shown as completely overlapping, at -100%, there is a distance of the width of one bar between them).
+
;<tt>GapWidth (long)</tt>:percentage which specifies the distance there may be between the different groups of bars of a chart (at 100%, there is a distance corresponding to the width of one bar).
+
;<tt>ArrangeOrder (enum)</tt>:details of position of inscription; in addition to positioning on a line, there is also the option of splitting the label alternately over two lines (default value according to <tt>com.sun.star.chart.ChartAxisArrangeOrderType</tt>)
+
;<tt>TextBreak (Boolean)</tt>:permits line breaks.
+
;<tt>TextCanOverlap (Boolean)</tt>:permits text overlaps.
+
;<tt>NumberFormat (Long)</tt>:number format (refer to [html/p24.html#fapcj Number, Date and Text Format] section)
+
  
=== Properties of the axis grid ===
+
===Label properties:===
 +
;<tt>DisplayLabels (Boolean)</tt>:activates the text label at the interval marks
 +
;<tt>TextRotation (Long)</tt>:angle of rotation of text label in 100ths of a degree
 +
;<tt>ArrangeOrder (enum)</tt>:the label may be staggered, thus they are positioned alternately over two lines (values according to <idl>com.sun.star.chart.ChartAxisArrangeOrderType</idl>)
 +
;<tt>TextBreak (Boolean)</tt>:permits line breaks within the axes labels
 +
;<tt>TextCanOverlap (Boolean)</tt>:permits an overlap of the axes labels
 +
;<tt>NumberFormat (Long)</tt>:number format to be used with the axes labels
 +
;<tt>LinkNumberFormatToSource (Boolean)</tt>:determines whether to use the number format given by the container document, or from the property <tt>NumberFormat</tt>. (since OpenOffice.org 2.3)
  
The object for the axis grid is based on the <tt>com.sun.star.chart.ChartGrid</tt> service, which in turn supports the line properties of the <tt>com.sun.star.drawing.LineStyle</tt> support service (refer to [html/p27.html Chapter 8, Drawings and Presentations]).
+
===Interval mark properties:===
 +
;<tt>Marks (Const)</tt>:determines the position of the major interval marks (values in accordance with <idl>com.sun.star.chart.ChartAxisMarks</idl>)
 +
;<tt>HelpMarks (Const)</tt>:determines the position of the minor interval marks (values in accordance with <idl>com.sun.star.chart.ChartAxisMarks</idl>)
  
=== Properties of the axis title ===
+
===Only for bar charts:===
 +
;<tt>Overlap (Long)</tt>:percentage which specifies the extent to which the bars of different sets of data may overlap (at 100%, the bars are shown as completely overlapping, at -100%, there is a distance of the width of one bar between them)
 +
;<tt>GapWidth (long)</tt>:percentage which specifies the distance there may be between the different groups of bars of a chart (at 100%, there is a distance corresponding to the width of one bar)
  
The objects for formatting the axis title are based on the <tt>com.sun.star.chart.ChartTitle</tt> service, which is also used for chart titles.
+
== Grids ==
  
== Example ==
+
For the primary axes grids and sub grids can be displayed, matching to the major and minor intervals.
 +
The <tt>Diagram</tt> object provides the following properties to access the grids:
  
The following example creates a line chart. The color for the rear wall of the chart is set to white. Both the X and Y-axes have a gray auxiliary grid for visual orientation. The minimum value of the Y-axis is fixed to 0 and the maximum value is fixed to 100 so that the resolution of the chart is retained even if the values are changed.
+
;<tt>HasXAxisGrid (Boolean)</tt>:activates major grid for X-axis
 +
;<tt>XMainGrid (Object)</tt>:object with detailed information about the major grid for X-axis (supports <idl>com.sun.star.chart.ChartGrid</idl> service)
 +
;<tt>HasXAxisHelpGrid (Boolean)</tt>:activates minor grid for X-axis
 +
;<tt>XHelpGrid (Object)</tt>:object with detailed information about the minor grid for X-axis (supports <idl>com.sun.star.chart.ChartGrid</idl> service)
  
Dim Doc As Object
+
the same for y and z:
Dim Charts As Object
+
 
Dim Chart as Object
+
;<tt>HasYAxisGrid (Boolean)</tt>:activates major grid for Y-axis
Dim Rect As New com.sun.star.awt.Rectangle
+
;<tt>YMainGrid (Object)</tt>:object with detailed information about the major grid for Y-axis (supports <idl>com.sun.star.chart.ChartGrid</idl> service)
Dim RangeAddress(0) As New com.sun.star.table.CellRangeAddress
+
;<tt>HasYAxisHelpGrid (Boolean)</tt>:activates minor grid for Y-axis
+
;<tt>YHelpGrid (Object)</tt>:object with detailed information about the minor grid for Y-axis (supports <idl>com.sun.star.chart.ChartGrid</idl> service)
Doc = StarDesktop.CurrentComponent
+
 
Charts = Doc.Sheets(0).Charts
+
;<tt>HasZAxisGrid (Boolean)</tt>:activates major grid for Z-axis
+
;<tt>ZMainGrid (Object)</tt>:object with detailed information about the major grid for Z-axis (supports <idl>com.sun.star.chart.ChartGrid</idl> service)
Rect.X = 8000
+
;<tt>HasZAxisHelpGrid (Boolean)</tt>:activates minor grid for Z-axis
Rect.Y = 1000
+
;<tt>ZHelpGrid (Object)</tt>:object with detailed information about the minor grid for Z-axis (supports <idl>com.sun.star.chart.ChartGrid</idl> service)
Rect.Width = 10000
+
 
Rect.Height = 7000
+
The grid object is based on the <idl>com.sun.star.chart.ChartGrid</idl> service, which in turn supports the line properties of the <idl>com.sun.star.drawing.LineStyle</idl> support service (refer to [[Documentation/BASIC_Guide/Drawings_Presentations|Drawings and Presentations]]).
RangeAddress(0).Sheet = 0
+
 
RangeAddress(0).StartColumn = 0  
+
== Axes Title ==
RangeAddress(0).StartRow = 0
+
 
RangeAddress(0).EndColumn = 2
+
For all axes an additional title can be displayed.
RangeAddress(0).EndRow = 12
+
The <tt>Diagram</tt> object provides the following properties to access the axes title:
+
 
Charts.addNewByName("MyChart", Rect, RangeAddress(), True, True)
+
;<tt>HasXAxisTitle (Boolean)</tt>:activates title of X-axis
Chart = Charts.getByName("MyChart").embeddedObject
+
;<tt>XAxisTitle (Object)</tt>:object with detailed information about title of the X-axis (supports <idl>com.sun.star.chart.ChartTitle</idl> service)
Chart.Diagram = Chart.createInstance("com.sun.star.chart.LineDiagram")
+
 
Chart.Diagram.Wall.FillColor = RGB(255, 255, 255)
+
same y and z:
Chart.Diagram.HasXAxisGrid = True
+
 
Chart.Diagram.XMainGrid.LineColor = RGB(192, 192, 192)
+
;<tt>HasYAxisTitle (Boolean)</tt>:activates title of Y-axis
Chart.Diagram.HasYAxisGrid = True
+
;<tt>YAxisTitle (Object)</tt>:object with detailed information about title of the Y-axis (supports <idl>com.sun.star.chart.ChartTitle</idl> service)
Chart.Diagram.YMainGrid.LineColor = RGB(192, 192, 192)
+
 
Chart.Diagram.YAxis.Min = 0  
+
;<tt>HasZAxisTitle (Boolean)</tt>:activates title of Z-axis
Chart.Diagram.YAxis.Max = 100
+
;<tt>ZAxisTitle (Object)</tt>:object with detailed information about title of the Z-axis (supports <idl>com.sun.star.chart.ChartTitle</idl> service)
 +
 
 +
and for the secondary axes (available since OpenOffice.org 3.0):
 +
 
 +
;<tt>HasSecondaryXAxisTitle (Boolean)</tt>:activates title of the secondary X-axis.
 +
;<tt>SecondXAxisTitle (Object)</tt>:object with detailed information about title of the secondary X-axis (supports <idl>com.sun.star.chart.ChartTitle</idl> service)
 +
 
 +
;<tt>HasSecondaryYAxisTitle (Boolean)</tt>:activates title of the secondary Y-axis.
 +
;<tt>SecondYAxisTitle (Object)</tt>:object with detailed information about title of the secondary Y-axis (supports <idl>com.sun.star.chart.ChartTitle</idl> service)
 +
 
 +
The objects for formatting the axes title are based on the <idl>com.sun.star.chart.ChartTitle</idl> service, which is also used for chart titles.
 +
 
 +
=== Example ===
 +
 
 +
The following example creates a line chart. The color for the rear wall of the chart is set to white. Both the X and Y-axes have a gray grid for visual orientation. The minimum value of the Y-axis is fixed to 0 and the maximum value is fixed to 100 so that the resolution of the chart is retained even if the values are changed. The X-axis points in reverse direction from right to left. And a title for the X-axis was added.
 +
 
 +
<source lang="oobas">
 +
Dim Doc As Object
 +
Dim Charts As Object
 +
Dim Chart as Object
 +
Dim Rect As New com.sun.star.awt.Rectangle
 +
Dim RangeAddress(0) As New com.sun.star.table.CellRangeAddress
 +
 
 +
Doc = ThisComponent
 +
Charts = Doc.Sheets(0).Charts
 +
 
 +
Rect.X = 8000
 +
Rect.Y = 1000
 +
Rect.Width = 10000
 +
Rect.Height = 7000
 +
RangeAddress(0).Sheet = 0
 +
RangeAddress(0).StartColumn = 0  
 +
RangeAddress(0).StartRow = 0
 +
RangeAddress(0).EndColumn = 2
 +
RangeAddress(0).EndRow = 12
 +
 
 +
Charts.addNewByName("MyChart", Rect, RangeAddress(), True, True)
 +
Chart = Charts.getByName("MyChart").embeddedObject
 +
Chart.Diagram = Chart.createInstance("com.sun.star.chart.LineDiagram")
 +
Chart.Diagram.Wall.FillColor = RGB(255, 255, 255)
 +
Chart.Diagram.HasXAxisGrid = True
 +
Chart.Diagram.XMainGrid.LineColor = RGB(192, 192, 192)
 +
Chart.Diagram.HasYAxisGrid = True
 +
Chart.Diagram.YMainGrid.LineColor = RGB(192, 192, 192)
 +
Chart.Diagram.YAxis.Min = 0  
 +
Chart.Diagram.YAxis.Max = 100
 +
 
 +
Chart.Diagram.XAxis.ReverseDirection = true 'needs OpenOffice.org 2.4 or newer
 +
Chart.Diagram.HasXAxisTitle = true
 +
Chart.Diagram.XAxisTitle.String = "Reversed X Axis Example"
 +
</source>
  
 
== 3D Charts ==
 
== 3D Charts ==
  
Most charts in {{OOo}} can also be displayed with 3D graphics. All chart types that provide this option support the <tt>com.sun.star.chart.Dim3DDiagram.</tt> service. The service provides just one property:
+
Most charts in {{OOo}} can also be displayed with 3D graphics. The following properties are provided for 3D charts at the <tt>Diagram</tt> object:
  
;<tt>Dim3D (Boolean)</tt>:activates 3D display.
+
;<tt>Dim3D (Boolean)</tt>:activates 3D display
 +
;<tt>Deep (Boolean)</tt>:the series will be arranged behind each other in z-direction
 +
;<tt>RightAngledAxes (Boolean)</tt>:activates a 3D display mode where X- and Y-axes form a right angle within the projection. (available since OpenOffice.org 2.3)
 +
;<tt>D3DScenePerspective (Enum)</tt>:defines whether the 3D objects are to be drawn in perspective or parallel projection.(values according to <idl>com.sun.star.drawing.ProjectionMode</idl>)
 +
;<tt>Perspective (Long)</tt>:Perspective of 3D charts ( [0,100] ) (available since OpenOffice.org 2.4.1)
 +
;<tt>RotationHorizontal (Long)</tt>:Horizontal rotation of 3D charts in degrees ( [-180,180] ) (available since OpenOffice.org 2.4.1)
 +
;<tt>RotationVertical (Long)</tt>:Vertical rotation of 3D charts in degrees ( [-180,180] ) (available since OpenOffice.org 2.4.1)
 +
 
 +
The following example creates a 3D area chart.
 +
 
 +
<source lang="oobas">
 +
Dim Doc As Object
 +
Dim Charts As Object
 +
Dim Chart as Object
 +
Dim Rect As New com.sun.star.awt.Rectangle
 +
Dim RangeAddress(0) As New com.sun.star.table.CellRangeAddress
 +
 
 +
Doc = ThisComponent
 +
Charts = Doc.Sheets(0).Charts
 +
 
 +
Rect.X = 8000
 +
Rect.Y = 1000
 +
Rect.Width = 10000
 +
Rect.Height = 7000
 +
RangeAddress(0).Sheet = 0
 +
RangeAddress(0).StartColumn = 0
 +
RangeAddress(0).StartRow = 0
 +
RangeAddress(0).EndColumn = 2
 +
RangeAddress(0).EndRow = 12
 +
 
 +
Charts.addNewByName("MyChart", Rect, RangeAddress(), True, True)
 +
Chart = Charts.getByName("MyChart").embeddedObject
 +
Chart.Diagram = Chart.createInstance("com.sun.star.chart.AreaDiagram")
 +
Chart.Diagram.Dim3D = true
 +
Chart.Diagram.Deep = true
 +
Chart.Diagram.RightAngledAxes = true 'needs OpenOffice.org 2.3 or newer
 +
Chart.Diagram.D3DScenePerspective = com.sun.star.drawing.ProjectionMode.PERSPECTIVE
 +
Chart.Diagram.Perspective = 100 'needs OpenOffice.org 2.4.1 or newer
 +
Chart.Diagram.RotationHorizontal = 60 'needs OpenOffice.org 2.4.1 or newer
 +
Chart.Diagram.RotationVertical = 30 'needs OpenOffice.org 2.4.1 or newer
 +
</source>
  
 
== Stacked Charts ==
 
== Stacked Charts ==
Line 226: Line 338:
 
Stacked charts are charts that are arranged with several individual values on top of one another to produce a total value. This view shows not only the individual values, but also an overview of all the values.
 
Stacked charts are charts that are arranged with several individual values on top of one another to produce a total value. This view shows not only the individual values, but also an overview of all the values.
  
In {{OOo}}, various types of charts can be displayed in a stacked form. All of these charts support the <tt>com.sun.star.chart.StackableDiagram</tt> service, which in turn provides the following properties:
+
In {{OOo}}, various types of charts can be displayed in a stacked form. All of these charts support the <idl>com.sun.star.chart.StackableDiagram</idl> service, which in turn provides the following properties:
 
+
;<tt>Stacked (Boolean)</tt>:activates the stacked viewing mode.
+
;<tt>Percent (Boolean)</tt>:rather than absolute values, displays their percentage distribution.
+
  
 +
;<tt>Stacked (Boolean)</tt>:activates the stacked viewing mode
 +
;<tt>Percent (Boolean)</tt>:rather than absolute values, displays their percentage distribution
  
 +
{{InterWiki Languages BasicGuide|articletitle=Documentation/BASIC Guide/Structure of Charts}}
 
{{PDL1}}
 
{{PDL1}}

Revision as of 09:16, 1 November 2009


The structure of a chart, and therefore the list of services and interfaces supported by it, depends on the chart type. For example, the methods and properties of the Z-axis, are available in 3D charts, but not in 2D charts, and in pie charts, there are no interfaces for working with axes.

Title, Subtitle and Legend

Title, subtitle and legend are basic elements provided for every chart. The Chart object provides the following properties for administrating these elements:

HasMainTitle (Boolean)
activates the title
Title (Object)
object with detailed information about the chart title (supports the com.sun.star.chart.ChartTitle service)
HasSubTitle(Boolean)
activates the subtitle
Subtitle (Object)
object with detailed information about the chart subtitle (supports the com.sun.star.chart.ChartTitle service)
HasLegend (Boolean)
activates the legend
Legend (Object)
object with detailed information about the legend (supports the com.sun.star.chart.ChartLegend service)

Both services com.sun.star.chart.ChartTitle and com.sun.star.chart.ChartLegend do support the service com.sun.star.drawing.Shape. This allows to determine the position and size of the elements using the Position and Size properties. As the size of the legend and the titles is calculated automatically based on the current content and the character height for example, the size property provides read access only.

Fill and line properties (com.sun.star.drawing.FillProperties and com.sun.star.drawing.LineProperties services) as well as the character properties (com.sun.star.style.CharacterProperties service) are provided for further formatting of the elements.

com.sun.star.chart.ChartTitle contains not only the listed formatting properties, but also two other properties:

String (String)
text which to be displayed as the title or subtitle
TextRotation (Long)
angle of rotation of text in 100ths of a degree

The legend (com.sun.star.chart.ChartLegend) contains the following additional property:

Alignment (Enum)
position at which the legend appears (value of type com.sun.star.chart.ChartLegendPosition)

The following example creates a chart with a title "Main Title String", a subtitle "Subtitle String" and a legend. The legend has a gray background color, is placed at the bottom of the chart, and has a character size of 7 points.

Dim Doc As Object
Dim Charts As Object
Dim Chart as Object
Dim Rect As New com.sun.star.awt.Rectangle
Dim RangeAddress(0) As New com.sun.star.table.CellRangeAddress
 
Rect.X = 8000
Rect.Y = 1000
Rect.Width = 10000
Rect.Height = 7000
RangeAddress(0).Sheet = 0
RangeAddress(0).StartColumn = 0 
RangeAddress(0).StartRow = 0
RangeAddress(0).EndColumn = 2
RangeAddress(0).EndRow = 12
 
Doc = ThisComponent
 
Charts = Doc.Sheets(0).Charts
Charts.addNewByName("MyChart", Rect, RangeAddress(), True, True)
Chart = Charts.getByName("MyChart").EmbeddedObject
Chart.HasMainTitle = True
Chart.Title.String = "Main Title String"
Chart.HasSubTitle = True
Chart.Subtitle.String = "Subtitle String"
Chart.HasLegend = True 
Chart.Legend.Alignment = com.sun.star.chart.ChartLegendPosition.BOTTOM
Chart.Legend.FillStyle = com.sun.star.drawing.FillStyle.SOLID
Chart.Legend.FillColor = RGB(210, 210, 210)
Chart.Legend.CharHeight = 7

Background

Every chart has a background area. The Chart object provides the property Area to format the background:

Area (Object)
background area of the chart (supports com.sun.star.chart.ChartArea service)

The background of a chart covers its complete area, including the area under the title, subtitle and legend. The associated com.sun.star.chart.ChartArea service supports line and fill properties.

Diagram

The Chart object provides the property Diagram which forms the coordinate system with axes and grids, where the data finally is displayed:

Diagram (Object)
object forming the coordinate system where the data is plotted. It supports com.sun.star.chart.Diagram service and:

Different services are supported depending on the chart type (see Chart Types).

Wall and Floor

The chart wall is the background of the coordinate system where the data is plotted. Two chart walls usually exist for 3D charts: one behind the plotted data and one as the left-hand or right-hand demarcation. This depends on the rotation of the chart. 3D charts usually also have a floor.

The Diagram object provides the properties Wall and Floor:

Wall (Object)
background wall of the coordinate system (supports com.sun.star.chart.ChartArea service)
Floor (Object)
floor panel of coordinate system (only for 3D charts, supports com.sun.star.chart.ChartArea service)

The specified objects support the com.sun.star.chart.ChartArea service, which provides the usual fill and line properties (com.sun.star.drawing.FillProperties and com.sun.star.drawing.LineProperties services, refer to Drawings and Presentations).

The following example shows how graphics (named Sky) already contained in Apache OpenOffice can be used as a background for a chart. The wall is set to be blue.

Dim Doc As Object
Dim Charts As Object
Dim Chart as Object
Dim Rect As New com.sun.star.awt.Rectangle
Dim RangeAddress(0) As New com.sun.star.table.CellRangeAddress
 
Rect.X = 8000
Rect.Y = 1000
Rect.Width = 10000
Rect.Height = 7000
RangeAddress(0).Sheet = 0
RangeAddress(0).StartColumn = 0 
RangeAddress(0).StartRow = 0
RangeAddress(0).EndColumn = 2
RangeAddress(0).EndRow = 12
 
Doc = ThisComponent
 
Charts = Doc.Sheets(0).Charts
Charts.addNewByName("MyChart", Rect, RangeAddress(), True, True)
Chart = Charts.getByName("MyChart").EmbeddedObject
Chart.Area.FillStyle = com.sun.star.drawing.FillStyle.BITMAP
Chart.Area.FillBitmapName = "Sky"
Chart.Area.FillBitmapMode = com.sun.star.drawing.BitmapMode.REPEAT
 
Chart.Diagram.Wall.FillStyle = com.sun.star.drawing.FillStyle.SOLID
Chart.Diagram.Wall.FillColor = RGB(00,132,209)

Axes

Apache OpenOffice recognizes five different axes that can be used in a chart. In the simplest scenario, these are the X and Y-axes. When working with 3D charts, a Z-axis is also sometimes provided. For charts in which the values of the various rows of data deviate significantly from one another, Apache OpenOffice provides a second X and Y-axis for second scaling operations.

The Diagram object provides the following properties to access the axes:

HasXAxis (Boolean)
activates the X-axis
XAxis (Object)
object with detailed information about the X-axis (supports com.sun.star.chart.ChartAxis service)
HasXAxisDescription (Boolean)
activates the labels for the interval marks for the X-axis
HasYAxis (Boolean)
activates the Y-axis
YAxis (Object)
object with detailed information about the Y-axis (supports com.sun.star.chart.ChartAxis service)
HasYAxisDescription (Boolean)
activates the labels for the interval marks for the Y-axis
HasZAxis (Boolean)
activates the Z-axis
ZAxis (Object)
object with detailed information about the Z-axis (supports com.sun.star.chart.ChartAxis service)
HasZAxisDescription (Boolean)
activates the labels for the interval marks for the Z-axis
HasSecondaryXAxis (Boolean)
activates the secondary X-axis
SecondaryXAxis (Object)
object with detailed information about the secondary X-axis (supports com.sun.star.chart.ChartAxis service)
HasSecondaryXAxisDescription (Boolean)
activates the labels for the interval marks for the secondary X-axis
HasSecondaryYAxis (Boolean)
activates the secondary Y-axis
SecondaryYAxis (Object)
object with detailed information about the secondary Y-axis (supports com.sun.star.chart.ChartAxis service)
HasSecondaryYAxisDescription (Boolean)
activates the labels for the interval marks for the secondary Y-axis

Properties of Axes

The axis objects of a Apache OpenOffice chart support the com.sun.star.chart.ChartAxis service. In addition to the properties for characters (com.sun.star.style.CharacterProperties service, refer to Text Documents) and lines (com.sun.star.drawing.LineStyle service, refer to Drawings and Presentations), it provides the following properties:

Scaling properties:

Max (Double)
maximum value for axis
Min (Double)
minimum value for axis
Origin (Double)
point of intersect for crossing axes
StepMain (Double)
distance between the major interval marks
StepHelp (Double)
distance between the minor interval marks (deprecated since OpenOffice.org 3.0; Use property StepHelpCount instead)
StepHelpCount (Long)
Contains the number of minor intervals within a major interval. E.g. a StepHelpCount of 5 divides the major interval into 5 pieces and thus produces 4 minor tick marks. (available since OpenOffice.org 3.0)
AutoMax (Boolean)
the maximum value for the axis is calculated automatically when set to true
AutoMin (Boolean)
the minimum value for the axis is calculated automatically when set to true
AutoOrigin (Boolean)
the origin is determined automatically when set to true
AutoStepMain (Boolean)
StepMain is determined automatically when set to true
AutoStepHelp (Boolean)
StepHelpCount is determined automatically when set to true
Logarithmic (Boolean)
scales the axes in logarithmic manner (rather than linear)
ReverseDirection (Boolean)
determines if the axis orientation is mathematical or reversed. (available since OpenOffice.org 2.4)

Label properties:

DisplayLabels (Boolean)
activates the text label at the interval marks
TextRotation (Long)
angle of rotation of text label in 100ths of a degree
ArrangeOrder (enum)
the label may be staggered, thus they are positioned alternately over two lines (values according to com.sun.star.chart.ChartAxisArrangeOrderType)
TextBreak (Boolean)
permits line breaks within the axes labels
TextCanOverlap (Boolean)
permits an overlap of the axes labels
NumberFormat (Long)
number format to be used with the axes labels
LinkNumberFormatToSource (Boolean)
determines whether to use the number format given by the container document, or from the property NumberFormat. (since OpenOffice.org 2.3)

Interval mark properties:

Marks (Const)
determines the position of the major interval marks (values in accordance with com.sun.star.chart.ChartAxisMarks)
HelpMarks (Const)
determines the position of the minor interval marks (values in accordance with com.sun.star.chart.ChartAxisMarks)

Only for bar charts:

Overlap (Long)
percentage which specifies the extent to which the bars of different sets of data may overlap (at 100%, the bars are shown as completely overlapping, at -100%, there is a distance of the width of one bar between them)
GapWidth (long)
percentage which specifies the distance there may be between the different groups of bars of a chart (at 100%, there is a distance corresponding to the width of one bar)

Grids

For the primary axes grids and sub grids can be displayed, matching to the major and minor intervals. The Diagram object provides the following properties to access the grids:

HasXAxisGrid (Boolean)
activates major grid for X-axis
XMainGrid (Object)
object with detailed information about the major grid for X-axis (supports com.sun.star.chart.ChartGrid service)
HasXAxisHelpGrid (Boolean)
activates minor grid for X-axis
XHelpGrid (Object)
object with detailed information about the minor grid for X-axis (supports com.sun.star.chart.ChartGrid service)

the same for y and z:

HasYAxisGrid (Boolean)
activates major grid for Y-axis
YMainGrid (Object)
object with detailed information about the major grid for Y-axis (supports com.sun.star.chart.ChartGrid service)
HasYAxisHelpGrid (Boolean)
activates minor grid for Y-axis
YHelpGrid (Object)
object with detailed information about the minor grid for Y-axis (supports com.sun.star.chart.ChartGrid service)
HasZAxisGrid (Boolean)
activates major grid for Z-axis
ZMainGrid (Object)
object with detailed information about the major grid for Z-axis (supports com.sun.star.chart.ChartGrid service)
HasZAxisHelpGrid (Boolean)
activates minor grid for Z-axis
ZHelpGrid (Object)
object with detailed information about the minor grid for Z-axis (supports com.sun.star.chart.ChartGrid service)

The grid object is based on the com.sun.star.chart.ChartGrid service, which in turn supports the line properties of the com.sun.star.drawing.LineStyle support service (refer to Drawings and Presentations).

Axes Title

For all axes an additional title can be displayed. The Diagram object provides the following properties to access the axes title:

HasXAxisTitle (Boolean)
activates title of X-axis
XAxisTitle (Object)
object with detailed information about title of the X-axis (supports com.sun.star.chart.ChartTitle service)

same y and z:

HasYAxisTitle (Boolean)
activates title of Y-axis
YAxisTitle (Object)
object with detailed information about title of the Y-axis (supports com.sun.star.chart.ChartTitle service)
HasZAxisTitle (Boolean)
activates title of Z-axis
ZAxisTitle (Object)
object with detailed information about title of the Z-axis (supports com.sun.star.chart.ChartTitle service)

and for the secondary axes (available since OpenOffice.org 3.0):

HasSecondaryXAxisTitle (Boolean)
activates title of the secondary X-axis.
SecondXAxisTitle (Object)
object with detailed information about title of the secondary X-axis (supports com.sun.star.chart.ChartTitle service)
HasSecondaryYAxisTitle (Boolean)
activates title of the secondary Y-axis.
SecondYAxisTitle (Object)
object with detailed information about title of the secondary Y-axis (supports com.sun.star.chart.ChartTitle service)

The objects for formatting the axes title are based on the com.sun.star.chart.ChartTitle service, which is also used for chart titles.

Example

The following example creates a line chart. The color for the rear wall of the chart is set to white. Both the X and Y-axes have a gray grid for visual orientation. The minimum value of the Y-axis is fixed to 0 and the maximum value is fixed to 100 so that the resolution of the chart is retained even if the values are changed. The X-axis points in reverse direction from right to left. And a title for the X-axis was added.

Dim Doc As Object
Dim Charts As Object
Dim Chart as Object
Dim Rect As New com.sun.star.awt.Rectangle
Dim RangeAddress(0) As New com.sun.star.table.CellRangeAddress
 
Doc = ThisComponent
Charts = Doc.Sheets(0).Charts
 
Rect.X = 8000
Rect.Y = 1000
Rect.Width = 10000
Rect.Height = 7000
RangeAddress(0).Sheet = 0
RangeAddress(0).StartColumn = 0 
RangeAddress(0).StartRow = 0
RangeAddress(0).EndColumn = 2
RangeAddress(0).EndRow = 12
 
Charts.addNewByName("MyChart", Rect, RangeAddress(), True, True)
Chart = Charts.getByName("MyChart").embeddedObject
Chart.Diagram = Chart.createInstance("com.sun.star.chart.LineDiagram")
Chart.Diagram.Wall.FillColor = RGB(255, 255, 255)
Chart.Diagram.HasXAxisGrid = True
Chart.Diagram.XMainGrid.LineColor = RGB(192, 192, 192)
Chart.Diagram.HasYAxisGrid = True
Chart.Diagram.YMainGrid.LineColor = RGB(192, 192, 192)
Chart.Diagram.YAxis.Min = 0 
Chart.Diagram.YAxis.Max = 100
 
Chart.Diagram.XAxis.ReverseDirection = true 'needs OpenOffice.org 2.4 or newer
Chart.Diagram.HasXAxisTitle = true
Chart.Diagram.XAxisTitle.String = "Reversed X Axis Example"

3D Charts

Most charts in Apache OpenOffice can also be displayed with 3D graphics. The following properties are provided for 3D charts at the Diagram object:

Dim3D (Boolean)
activates 3D display
Deep (Boolean)
the series will be arranged behind each other in z-direction
RightAngledAxes (Boolean)
activates a 3D display mode where X- and Y-axes form a right angle within the projection. (available since OpenOffice.org 2.3)
D3DScenePerspective (Enum)
defines whether the 3D objects are to be drawn in perspective or parallel projection.(values according to com.sun.star.drawing.ProjectionMode)
Perspective (Long)
Perspective of 3D charts ( [0,100] ) (available since OpenOffice.org 2.4.1)
RotationHorizontal (Long)
Horizontal rotation of 3D charts in degrees ( [-180,180] ) (available since OpenOffice.org 2.4.1)
RotationVertical (Long)
Vertical rotation of 3D charts in degrees ( [-180,180] ) (available since OpenOffice.org 2.4.1)

The following example creates a 3D area chart.

Dim Doc As Object
Dim Charts As Object
Dim Chart as Object
Dim Rect As New com.sun.star.awt.Rectangle
Dim RangeAddress(0) As New com.sun.star.table.CellRangeAddress
 
Doc = ThisComponent
Charts = Doc.Sheets(0).Charts
 
Rect.X = 8000
Rect.Y = 1000
Rect.Width = 10000
Rect.Height = 7000
RangeAddress(0).Sheet = 0
RangeAddress(0).StartColumn = 0 
RangeAddress(0).StartRow = 0
RangeAddress(0).EndColumn = 2
RangeAddress(0).EndRow = 12
 
Charts.addNewByName("MyChart", Rect, RangeAddress(), True, True)
Chart = Charts.getByName("MyChart").embeddedObject
Chart.Diagram = Chart.createInstance("com.sun.star.chart.AreaDiagram")
Chart.Diagram.Dim3D = true
Chart.Diagram.Deep = true
Chart.Diagram.RightAngledAxes = true 'needs OpenOffice.org 2.3 or newer
Chart.Diagram.D3DScenePerspective = com.sun.star.drawing.ProjectionMode.PERSPECTIVE
Chart.Diagram.Perspective = 100 'needs OpenOffice.org 2.4.1 or newer
Chart.Diagram.RotationHorizontal = 60 'needs OpenOffice.org 2.4.1 or newer
Chart.Diagram.RotationVertical = 30 'needs OpenOffice.org 2.4.1 or newer

Stacked Charts

Stacked charts are charts that are arranged with several individual values on top of one another to produce a total value. This view shows not only the individual values, but also an overview of all the values.

In Apache OpenOffice, various types of charts can be displayed in a stacked form. All of these charts support the com.sun.star.chart.StackableDiagram service, which in turn provides the following properties:

Stacked (Boolean)
activates the stacked viewing mode
Percent (Boolean)
rather than absolute values, displays their percentage distribution


Content on this page is licensed under the Public Documentation License (PDL).
Personal tools