Hi,

You didn't add any data series to the chart type so far, so there is nothing to display. For the roles of the different data sequences for the stock chart have a look here:
http://api.openoffice.org/docs/common/ref/com/sun/star/chart2/data/DataSequenceRole.html

Kind regards,
Ingrid

othman wrote:
Hi Ingrid,
I wrote below java code to change chart type with chart2 API. However this
code doesn't work !
can you please look at it and tell me what I'm doing wrong ?

thanks.
othman


Code:
    XMultiComponentFactory xMCF = null;
           XEmbeddedObjectSupplier xEmbeddedObjSupplier =
(XEmbeddedObjectSupplier)
UnoRuntime.queryInterface(XEmbeddedObjectSupplier.class, xtablechart);
            XInterface xInterface =
xEmbeddedObjSupplier.getEmbeddedObject();

            com.sun.star.chart2.XChartDocument oChart =
(com.sun.star.chart2.XChartDocument) UnoRuntime.queryInterface(
            com.sun.star.chart2.XChartDocument.class, xInterface);
System.out.println("com.sun.star.chart2.XChartDocument="+oChart);
        /* let the Calc document create a data provider, set it at the
chart*/
            com.sun.star.chart2.data.XDataProvider oDataProv =
oChart.getDataProvider();
com.sun.star.chart2.XDiagram oDiagram=oChart.getFirstDiagram(); System.out.println("com.sun.star.chart2.XDiagram="+oDiagram.toString());
           //insert a coordinate system into the diagram
com.sun.star.chart2.XCoordinateSystemContainer oCoordSysCnt= (com.sun.star.chart2.XCoordinateSystemContainer)UnoRuntime.queryInterface(com.sun.star.chart2.XCoordinateSystemContainer.class,
oDiagram);
           com.sun.star.chart2.XCoordinateSystem[] oCoordSys=
oCoordSysCnt.getCoordinateSystems();
System.out.println("com.sun.star.chart2.XCoordinateSystem[0]="+oCoordSys[0].toString());
          com.sun.star.chart2.XChartTypeContainer oChartTypeCnt=
(com.sun.star.chart2.XChartTypeContainer)UnoRuntime.queryInterface(com.sun.star.chart2.XChartTypeContainer.class,
oCoordSys[0]);
// get the service manager from the office
            xMCF = xContext.getServiceManager();
Object object = xMCF.createInstanceWithContext(
                "com.sun.star.chart2.CandleStickChartType", xContext);
       com.sun.star.chart2.XChartType
oChartType=(com.sun.star.chart2.XChartType) UnoRuntime.queryInterface(
            com.sun.star.chart2.XChartType.class, object);
System.out.println("com.sun.star.chart2.XChartType="+oChartType.toString());
       oChartTypeCnt.addChartType(oChartType);


Ingrid Halama wrote:
Hi othman,

othman wrote:
Sorry, i hope you bare with me & be patient answering my questions about
the
chart2 API.
i wrote a java code to change the type of my chart from default LineType
to
candlestick type.
However this code doesn't work with chart2 .but if i change to standar
com.sun.star.chart and use type "com.sun.star.StockDiagram" it does work
perfectly.
what is wrong with the chart2 code (or how to change my chart2 type to
candlestick )?

Instances of chart2 chart types (e.g. com.sun.star.chart2.CandleStickChartType) do support service com::sun::star::chart2::ChartType. Look at the corresponding idl file. They do not support the interface com::sun::star::chart2::XDiagram, but instead they support interface com::sun::star::chart2::XChartType. They need to be added to the com::sun::star::chart2::XChartTypeContainer as shown in my mail from August 18th.

In general both APIs do not have the same structure. The only touch point is the chart document itself which does support both interfaces com::sun::star::chart2::XChartDocument and com::sun::star::chart::XChartDocument. Starting from there both APIs from different object trees.

Kind regards,
Ingrid

thanks.

code :

XEmbeddedObjectSupplier xEmbeddedObjSupplier = (XEmbeddedObjectSupplier)
            UnoRuntime.queryInterface(XEmbeddedObjectSupplier.class,
xtablechart);
        XInterface xInterface = xEmbeddedObjSupplier.getEmbeddedObject();
com.sun.star.chart2.XChartDocument xChartDoc =
(com.sun.star.chart2.XChartDocument)UnoRuntime.queryInterface(
            com.sun.star.chart2.XChartDocument.class, xInterface);
        com.sun.star.chart2.XDiagram xDiagram =
(com.sun.star.chart2.XDiagram) xChartDoc.getFirstDiagram();
        XMultiServiceFactory xMSF = (XMultiServiceFactory)
            UnoRuntime.queryInterface( XMultiServiceFactory.class,
xChartDoc
);
        Object object = xMSF.createInstance(
"com.sun.star.chart2.CandleStickChartType" );
        xDiagram = (com.sun.star.chart2.XDiagram)
UnoRuntime.queryInterface(com.sun.star.chart2.XDiagram.class, object);
XPropertySet xPropSet = (XPropertySet) UnoRuntime.queryInterface( XPropertySet.class, xDiagram ); xChartDoc.setFirstDiagram(xDiagram);



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