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

impossible to update chart by changing data

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
marc_the_french
Guest





PostPosted: Wed Nov 26, 2003 2:46 am    Post subject: impossible to update chart by changing data Reply with quote

I try to update the a chart by changing data in a macro, but it just doesn't work: I mean nothing is updated.

I use this code:
dim param_graph(3) as new com.sun.star.beans.PropertyValue
param_graph(0).Name = "Name"
param_graph(0).Value = object_graph
param_graph(1).Name = "Range"
' range of cells to update the chart *****
param_graph(1).Value = val_range
param_graph(2).Name = "ColHeaders"
param_graph(2).Value = false
param_graph(3).Name = "RowHeaders"
param_graph(3).Value = false
dispatcher.executeDispatch(document, ".uno:ChangeChartData", "", 0, param_graph())

If I try to record this with the macro recorder, I get the same code. When I run again this code (made by the recorder, but with change of range !), it's the same result: nothing is updated. Why ???

Can anyone help me ?
Back to top
SergeM
Super User
Super User


Joined: 09 Sep 2003
Posts: 3211
Location: Troyes France

PostPosted: Wed Nov 26, 2003 5:36 am    Post subject: Reply with quote

I don't understand why do you want to update a chart because it's done automaticaly if it is in a sheet, but this is not your question.
Can you give precision on your object val_range in your code ?
_________________
Linux & Windows OOo3.0
UNO & C++ : WIKI
http://wiki.services.openoffice.org/wiki/Using_Cpp_with_the_OOo_SDK
In French
http://wiki.services.openoffice.org/wiki/Documentation/FR/Cpp_Guide
Back to top
View user's profile Send private message Visit poster's website
marc_the_french
Guest





PostPosted: Wed Nov 26, 2003 6:32 am    Post subject: reply to SergeM Reply with quote

The cells range grows each day (I have to record the cheques I paid each day). When the new cells are inserted in the sheet, I run a macro :
- to select the new cells range (but not contiguous)
- to update the cells range of the chart

Normally, the chart should be automatically updated after that, but I have nothing.
Am I clear enough ?
Back to top
SergeM
Super User
Super User


Joined: 09 Sep 2003
Posts: 3211
Location: Troyes France

PostPosted: Wed Nov 26, 2003 11:10 pm    Post subject: Reply with quote

OK, I see now, but have no solution
The chart is updated when data in the rang of cells is updated. But when the range of cell change ?
I think you have to read the chapiter 10 (on charts) of the developperGuide and particulary
10.3.2 Data access.
The problem of developperGuide is that it show us example in Java. I have some difficulties to read Java. To access to the chart in OOoBasic is not hard. I show you sothing (far for your subject) but only as an example.
Code:

Sub RegressionLineON()
  Dim chartxy,diagram
  chartxy=Thiscomponent.sheets(0).charts(0).embeddedobject
  diagram = chartxy.getdiagram
  diagram.RegressionCurves=com.sun.star.chart.ChartRegressionCurveType.LINEAR
  'diagram.RegressionCurves=1 do the same as the previous line
End Sub

When you execute this macro a Regression line appears in your chart (only if it's a xychart).
This code only works when you have already a chart in your sheet. If you want to erase the line :
Code:

Sub RegressionLineOFF()
  Dim chartxy,diagram
  chartxy=Thiscomponent.sheets(0).charts(0).embeddedobject
  diagram = chartxy.getdiagram
  diagram.RegressionCurves=0
End Sub

This code acceed only a property of a chart but shows you how you can do that.
_________________
Linux & Windows OOo3.0
UNO & C++ : WIKI
http://wiki.services.openoffice.org/wiki/Using_Cpp_with_the_OOo_SDK
In French
http://wiki.services.openoffice.org/wiki/Documentation/FR/Cpp_Guide
Back to top
View user's profile Send private message Visit poster's website
SergeM
Super User
Super User


Joined: 09 Sep 2003
Posts: 3211
Location: Troyes France

PostPosted: Wed Dec 03, 2003 12:30 pm    Post subject: Reply with quote

See the old post :
http://www.oooforum.org/forum/viewtopic.php?t=2405
_________________
Linux & Windows OOo3.0
UNO & C++ : WIKI
http://wiki.services.openoffice.org/wiki/Using_Cpp_with_the_OOo_SDK
In French
http://wiki.services.openoffice.org/wiki/Documentation/FR/Cpp_Guide
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API 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