[Solved] Multiple data series

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
ptsenter
Posts: 22
Joined: Thu Feb 21, 2008 9:02 pm

[Solved] Multiple data series

Post by ptsenter »

Hi,

I know how to create a chart with multiple data series in Calc 2.3.
But I've not been able to figure out how to do it within OOo Basic.
Any ideas?
Thank you.
Last edited by ptsenter on Tue May 27, 2008 7:23 pm, edited 1 time in total.
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: multiple data series

Post by Villeroy »

Search this forum for xray. Install it. Browse the collection of charts on a single spreasheet.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
pitonyak
Volunteer
Posts: 186
Joined: Sun Oct 07, 2007 9:13 pm
Location: Columbus, Ohio, USA

Re: multiple data series

Post by pitonyak »

Your post implies that you know how to do this with one data series... Is this correct?

http://www.oooforum.org/forum/viewtopic ... ight=chart
Andrew Pitonyak
http://www.pitonyak.org/oo.php
LO and AOO on Fedora
ptsenter
Posts: 22
Joined: Thu Feb 21, 2008 9:02 pm

[Solved]Re: multiple data series

Post by ptsenter »

Thank you, guys, for your responses. I'm sure I'll use Xray in the future. But I found two pretty simple solutions
(I actually need XY-diagram):

1. Fill cells like the following and select entire range

x aa bb cc
1 5
2 7
3 8
5 4
7 6
2 6 second number in this line and next three under header bb
4 4
6 7
8 8
1 3 second number in this line and next three under header cc
2 2
5 4
8 5

2. There is an example in Developer's Guide. p.748 (May 2005 edition, so to speak)

I would mark my question as solved if I knew how to do it.

Thanx again.
Last edited by ptsenter on Tue May 27, 2008 9:15 pm, edited 3 times in total.
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: multiple data series

Post by Villeroy »

I would mark my question as solved if I knew how to do it.
While beeing logged in, visit this thread, push the
 Edit:  button and add [Solved] to the subject line. 
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
ptsenter
Posts: 22
Joined: Thu Feb 21, 2008 9:02 pm

Re: [Solved]multiple data series

Post by ptsenter »

Apparently, solution 2 is too cumbersome.
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: [Solved]multiple data series

Post by Villeroy »

ptsenter wrote:Apparently, solution 2 is too cumbersome.
There are no simple OOo macros.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
pitonyak
Volunteer
Posts: 186
Joined: Sun Oct 07, 2007 9:13 pm
Location: Columbus, Ohio, USA

Re: [Solved]multiple data series

Post by pitonyak »

Code: Select all

Sub CreateChart
  Dim oSheet     'Sheet containing the chart
  Dim oRect      'How big is the chart
  Dim oCharts    'Charts in the sheet
  Dim oChart     'Created chart
  Dim oAddress   'Address of data to plot
  Dim sName$     'Chart name
  Dim oChartDoc  'Embedded chart object
  Dim oTitle     'Chart title object
  Dim oDiagram   'Inserted diagram (data).
  Dim sDataRng$  'Where is the data

  sName = "ADP_Chart"
  sDataRng = "A1:D6"
  'sDataRng = "A33:D38"

  oSheet = ThisComponent.sheets(0)
  oAddress = oSheet.getCellRangeByName( sDataRng ).getRangeAddress() 
  oCharts = oSheet.getCharts()
  If NOT oCharts.hasByName(sName) Then
    oRect       = createObject("com.sun.star.awt.Rectangle")
    oRect.X     = 10000
    oRect.Y     = 1000
    oRect.width = 10000
    oRect.Height= 10000

    ' The rectangle identifies the dimensions in 1/100 mm.
    ' The address is the location of the data.
    ' True indicates that column headings should be used.
    ' False indicates that Row headings should not be used.
    oCharts.addNewByName(sName, oRect, Array(oAddress), True, False)
  End If

  oChart = oCharts.getByName( sName )
  oChart.setRanges(Array(oAddress))
  oChartDoc = oChart.getEmbeddedObject()
  'oChartDoc.attachData(oAddress)
  oTitle = oChartDoc.getTitle()
  oTitle.String = "Andy - " & Now

  ' Create a diagram.
  oDiagram = oChartDoc.createInstance( "com.sun.star.chart.LineDiagram" )
  oChartDoc.setDiagram( oDiagram )
  oDiagram = oChartDoc.getDiagram()
  oDiagram.DataCaption = com.sun.star.chart.ChartDataCaption.VALUE
  oDiagram.DataRowSource = com.sun.star.chart.ChartDataRowSource.COLUMNS 
End Sub 
Andrew Pitonyak
http://www.pitonyak.org/oo.php
LO and AOO on Fedora
Post Reply