openoffice-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Semen Gubarev <>
Subject Creating Chart ""
Date Mon, 01 Dec 2014 10:52:20 GMT
Hello Everyone!
I read a lot of documentation about creation charts using macro BASIC
And I still can't create chart in Writer (almost all documentation describe
how to create chart in Calc). The problem with inserting series XY data
into chart (separate X values and separate Y values)

First of all I create a chart object like this:

'Prepare embedded object
Dim oEmbeddedObject
oEmbeddedObject =
oEmbeddedObject.Name = "ChartID"

'Insert chart in document
oCursor.GetText().InsertTextContent(oCursor, oEmbeddedObject, False)

'The first approach inserting data like this:
oDocChart.Diagram.DataRowSource =
Dim aData(1, 3)
aData(0, 0) = 10
aData(0, 1) = 20
aData(0, 2) = 30
aData(1, 0) = 10
aData(1, 1) = 40
aData(1, 2) = 90
Dim oData as Object
oData = oDocChart.Data
oData.Data = aData
for this case I get 2 series Y data, but I need 1 series with data X-Y

'The second approach inserting data using Writer table as datasource
'I'will miss a lot of code

Dim oChartType
oChartType =

Dim oDataProv
oDataProv = oDoc.createInstance( "" )

Dim oDataSeries
oDataSeries = CreateDataSeries_XYDiagram(oDataProv, "table1.A1:A10",

Dim oNewDataSeriesList(0) as Object 'new data series
oNewDataSeriesList(0) = oDataSeries

'Correspond with last approach I get good chart, but after reopening the
document Y values become to X values

The question is, how to right create a X-Y chart?

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message