Hi othman,

othman wrote:
Hi Ingrid,
I wrote the below java code to insert a new chart from which i'll later
extract the XChartDocument instance.
the below java code works ok . however i noticed a couple of things :

1) i need to specify a XCellRange and get the CellRangeAddress . for this i
used :
 XCellRange myRange = oRange.getCellRangeByName("A1:E1740");
        XCellRangeAddressable oRangeAddr = (XCellRangeAddressable)
            UnoRuntime.queryInterface(XCellRangeAddressable.class, myRange);
        CellRangeAddress myAddr = oRangeAddr.getRangeAddress();
is there a way to format this XCellRange Object so i can specify min  , max
and step range for both x and y axis ?


I suggest to use the standard API wherever possible. The developers guide shows you an example how to access the y axis:
http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/Charts/Common_Parts_of_all_Chart_Types
Have a look at the idl files and you will find the properties that are supported by the ChartAxis service:
http://api.openoffice.org/source/browse/api/offapi/com/sun/star/chart/ChartAxis.idl?rev=1.21&view=markup
Min, Max and StepMain are what you are looking for.


2) i got a chart drawn even though i didn't specified the chart type in
below java code .i suppose there is a default charttype in chart2 module
that is used if no other charttype is specified . what is the default
charttype for chart2 module ?

Bar Chart is default. How to change the type is also explained in the devolopers guide.


3) for chart module i know there are the following charttype services :
                "com.sun.star.chart.LineDiagram",
                "com.sun.star.chart.BarDiagram",
                "com.sun.star.chart.PieDiagram",
                "com.sun.star.chart.NetDiagram",
                "com.sun.star.chart.XYDiagram",
                "com.sun.star.chart.StockDiagram",
                "com.sun.star.chart.AreaDiagram"
what are the corresponding charttype services for chart2 module ? i'm
specially interested in CandleStick & Line chart type from chart2 module.


See Daniels mail.

Kind regards,
Ingrid

thanks for your patience & further help.
othman

code :

XSpreadsheet xSheet = //here i get an instance of my XSpreadsheet;
// insert new chart.
        // get the CellRange which holds the data for the chart and its
RangeAddress
        // get the TableChartSupplier from the sheet and then the
TableCharts from it.
        // add a new chart based on the data to the TableCharts.
Rectangle oRect = new Rectangle();
        oRect.X = 500;
        oRect.Y = 3000;
        oRect.Width = 25000;
        oRect.Height = 11000;
XCellRange oRange = (XCellRange)UnoRuntime.queryInterface(
            XCellRange.class, xSheet);
        XCellRange myRange = oRange.getCellRangeByName("A1:E1740");
        XCellRangeAddressable oRangeAddr = (XCellRangeAddressable)
            UnoRuntime.queryInterface(XCellRangeAddressable.class, myRange);
        CellRangeAddress myAddr = oRangeAddr.getRangeAddress();
CellRangeAddress[] oAddr = new CellRangeAddress[1];
        oAddr[0] = myAddr;
        XTableChartsSupplier oSupp =
(XTableChartsSupplier)UnoRuntime.queryInterface(
            XTableChartsSupplier.class, xSheet);
XTableChart oChart = null; System.out.println("Insert new Chart"); XTableCharts oCharts = oSupp.getCharts();
        oCharts.addNewByName("combined chart", oRect, oAddr, true, true);





Ingrid Halama wrote:
Hi othman,

Have a look at the developers guides:
Adding a chart to a spreadsheet is explained here including a java
example:
http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/Charts/Creating_and_Adding_a_Chart_to_a_Spreadsheet

To get an existing chart within a sheet, look at the same example. Use the method getByName() at the XTableCharts interface. Where com.sun.star.chart.XChartDocument is used in the example you can use com.sun.star.chart2.XChartDocument instead.

Kind regards,
Ingrid

othman wrote:
Hi Ingrid,
Sorry i encountered a first problem .
in last email you said:
Ingrid Halama wrote:
Query your chart document for interface com::sun::star::chart2::XChartDocument

Well I'm not sure how i can get an instance to chart document.
at the beginning there are no charts attached to current spreadsheet .so
should i create an empty com::sun::star::chart2::XChartDocument ? i'm not sure if i misunderstood your statement . my problem is from where
i
can get an instance to com::sun::star::chart2::XChartDocument . i only
have
reference to current spreadsheet document (XSpreadSheetDocument) .is it
possible to create a new chart document from my spreadsheet document ? if
yes how to do that ?

thanks for helping.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]






---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to