openoffice-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Semen Gubarev <mnog...@gmail.com>
Subject Creating Chart "com.sun.star.chart.XYDiagram"
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 =
oDoc.CreateInstance("com.sun.star.text.TextEmbeddedObject")
oEmbeddedObject.SetPropertyValue("CLSID",
"12dcae26-281f-416f-a234-c3086127382e")
oEmbeddedObject.Name = "ChartID"

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

'The first approach inserting data like this:
oDocChart.Diagram.DataRowSource = com.sun.star.chart.ChartDataRowSource.ROWS
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 =
oDocChart.FirstDiagram.GetCoordinateSystems()(0).GetChartTypes()(0)

Dim oDataProv
oDataProv = oDoc.createInstance( "com.sun.star.chart2.data.DataProvider" )

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

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?

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