Making a diagram with a macro from an array, not from the cells in a calc sheet

Normally one makes a diagram from the values in the cells of a calc sheet.
In my macro I have the data in a three or more dimensional array and I want to make a “few” diagramms of this values. Is there a way to do this? I have spent a lot of time searching in the internet but I haven’t found nothing.
Writing the data partially from the array in a calc sheet and then taking the data from there to build the diagram is not so convenient.
When one copies a diagram from one calc-file to another the link to the sources get lost and there is a “datatable” with the diagram. Therefore I think that there will be a way to feed this “datatable” directly. But Which is this way? Thanks in advance.

Dada

  1. Creating a chart in a module other than Calc gives you the chart without a link to the sheet, but with an own data table. Then you may copy that chart to Calc, and use it there … but I fail to see how the internal data table would help you.

  2. Possibly you would want to consider a pivot chart.

You want to use the ChartDataArray service and its XChartDataArray interface at a stand-alone OLE-Chart. See also LibreOffice Developer’s Guide: Chapter 10 - Charts - Creating a Chart OLE Object and Data Access.

1 Like

Thanks for the clues.
As it seems, a pivot chart is based on a table of data in spreadsheet, too. This wouldn’t resolve my problem.
The “standalone OLE-Chart” seems to be a solution. But I have to read the instructions carefully. Unfortunately the examples in the wiki.documentfoundation are written in java and not in LO Basic; this makes it a bit more complicate.

Don’t use answers (“suggest a solution”) for comments or explanations. Either edit your original question to add clarifications, ort create a comment on a previous post.

Map the relevant selections of your data into a sheet, create the chart there.
Now copy every chart and paste it into a Writer document. Copy it again, and it will contain the data tables even if you paste it later into a Calc document again.
All the mentioned helper documents/sheets can be created by your macro and closed later without saving them.