Difference between revisions of "Documentation/DevGuide/Charts/Setting the Chart Type"
OOoWikiBot (Talk | contribs) m (Robot: Changing Category:Documentation/Developers Guide/Charts) |
m |
||
Line 12: | Line 12: | ||
In the following example, we change the chart type to a <idl>com.sun.star.chart.XYDiagram</idl>, also known as a scatter chart. We have assumed that there is a chart document in the variable <code>aChartDoc</code> already. The previous sections described how to create a document. | In the following example, we change the chart type to a <idl>com.sun.star.chart.XYDiagram</idl>, also known as a scatter chart. We have assumed that there is a chart document in the variable <code>aChartDoc</code> already. The previous sections described how to create a document. | ||
− | + | <source lang="java"> | |
// let aChartDoc be a valid XChartDocument | // let aChartDoc be a valid XChartDocument | ||
Line 25: | Line 25: | ||
// now we have an xy-chart | // now we have an xy-chart | ||
+ | </source> | ||
Revision as of 12:19, 20 January 2009
The default when creating a chart is a bar diagram with vertical bars. If a different chart type is required, apply a different diagram type to this initial chart. For example, to create a pie chart, insert the default bar chart and change it to a pie chart.
To change the type of a chart, create an instance of the required diagram service by its service name using the service factory provided by the com.sun.star.chart.XChartDocument. This interface is available at the chart document model. After this service instance is created, set it using the setDiagram()
method of the chart document.
In the following example, we change the chart type to a com.sun.star.chart.XYDiagram, also known as a scatter chart. We have assumed that there is a chart document in the variable aChartDoc
already. The previous sections described how to create a document.
// let aChartDoc be a valid XChartDocument // get the factory that can create diagrams XMultiServiceFactory aFact = (XMultiServiceFactory) UnoRuntime.queryInterface( XMultiServiceFactory.class, aChartDoc); XDiagram aDiagram = (XDiagram) UnoRuntime.queryInterface( XDiagram.class, aFact.createInstance("com.sun.star.chart.XYDiagram")); aChartDoc.setDiagram(aDiagram); // now we have an xy-chart
Diagram Service Names |
---|
com.sun.star.chart.BarDiagram
|
com.sun.star.chart.AreaDiagram
|
com.sun.star.chart.LineDiagram
|
com.sun.star.chart.PieDiagram
|
com.sun.star.chart.DonutDiagram
|
com.sun.star.chart.NetDiagram
|
com.sun.star.chart.XYDiagram
|
com.sun.star.chart.StockDiagram
|
Content on this page is licensed under the Public Documentation License (PDL). |