OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

Simple chart from data array

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Code Snippets
View previous topic :: View next topic  
Author Message
rebelxt
OOo Enthusiast
OOo Enthusiast


Joined: 10 Dec 2006
Posts: 114
Location: StLouis

PostPosted: Sun Aug 03, 2008 6:09 pm    Post subject: Simple chart from data array Reply with quote

This is a small subroutine designed to demonstrate a chart created from data in an array rather than cells in a spreadsheet. The objective was the fewest number of lines possible.
Code:
Sub SimpleChart
 Dim aData(4,0)
 aData(0,0) = 1
 aData(1,0) = 2
 aData(2,0) = 3
 aData(3,0) = 2.5
 aData(4,0) = .8
 MakeChartZ(aData)
End Sub


Sub MakeChartZ(oData)   ' oData is an array of numbers.
 Dim oSheet, oCharts, oChartDoc
 Dim aRect as new com.sun.star.awt.Rectangle

 oSheet = ThisComponent.Sheets.getByIndex(0)
 oCharts = oSheet.Charts
 oCharts.addNewByName("chart1", aRect, Array(), False, True)
 oChartDoc = oCharts.getByName( "chart1" ).EmbeddedObject
 oChartDoc.lockControllers()
 oChartDoc.setDiagram( oChartDoc.createInstance("com.sun.star.chart.LineDiagram") )
 oChartDoc.Data.setData(oData())
 oChartDoc.unlockControllers()
 MsgBox("Close it")
 oSheet.Charts.RemoveByName( "chart1" )
End Sub
Back to top
View user's profile Send private message
BDRJ
General User
General User


Joined: 02 Jul 2008
Posts: 18
Location: Italy

PostPosted: Fri Jul 24, 2009 12:39 am    Post subject: Reply with quote

Is this really possible?
When I try to execute this code OpenOffice crash and I have to restore file in use.
Debugging code I have noticed that is the line
oChartDoc.Data.setData(oData())
that made the program crash.

It's only my problem or it's the same for you?
Thanks
Back to top
View user's profile Send private message
rebelxt
OOo Enthusiast
OOo Enthusiast


Joined: 10 Dec 2006
Posts: 114
Location: StLouis

PostPosted: Fri Jul 24, 2009 5:51 am    Post subject: Reply with quote

This little routine was developed under OOo 2.x, and still works in that version. If someone knows why the setData method would fail in 3.1 under these circumstances, please tell.
Back to top
View user's profile Send private message
ms777
Super User
Super User


Joined: 07 Feb 2004
Posts: 1355

PostPosted: Tue Sep 15, 2009 3:27 pm    Post subject: Reply with quote

... maybe this issue: http://qa.openoffice.org/issues/show_bug.cgi?id=103984
Back to top
View user's profile Send private message
rebelxt
OOo Enthusiast
OOo Enthusiast


Joined: 10 Dec 2006
Posts: 114
Location: StLouis

PostPosted: Tue Sep 15, 2009 4:07 pm    Post subject: Reply with quote

I think you're right. I am watching that fix, which is scheduled to be implemented in the 3.2 release.
Back to top
View user's profile Send private message
ntvinh986
Newbie
Newbie


Joined: 03 Nov 2009
Posts: 1
Location: bfjwefhueiwh

PostPosted: Tue Nov 03, 2009 12:02 am    Post subject: Reply with quote

BDRJ wrote:
Is this really possible?
When I try to execute this code OpenOffice crash and I have to restore file in use.
Debugging code I have noticed that is the line
oChartDoc.Data.setData(oData())
that made the program crash.

It's only my problem or it's the same for you?
Thanks


Hi guys, Im a newbie. Nice to join this forum.


__________________
Watch Anime Episodes
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
rebelxt
OOo Enthusiast
OOo Enthusiast


Joined: 10 Dec 2006
Posts: 114
Location: StLouis

PostPosted: Thu Feb 11, 2010 9:05 am    Post subject: It's working now Reply with quote

This routine is working in release 3.2
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Code Snippets All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group