1. Michael Johnson
  2. PowerBuilder
  3. Friday, 22 March 2019 18:17 PM UTC


How to change the graph line colors?

I have a datawindow that has a graph datawindow within it (composite).
example: using the dw_1.descripe("DataWindow.Objects") I get back the list of objects in the primary datawindow.

problem_desc
....
....
dw_graph
...etc...


I Would like to be able to set programatically the data line and series name colors.
If it was just a single datawindow graph I can call
dw_1.setdatastyle('gr_1', (series number), (data count#), foreground!, (color)
and that works.

However I cannot seem to grasp the dot notation to access a composite graph datawindow.
I've found that these dot notation statements work...
dw_1.object.dw_graph.object.gr_1.Values.AutoScale = 1
dw_1.object.dw_graph.object.gr_1.backcolor = rgb(255,0,255)
dw_1.object.dw_graph.object.gr_1.title = "test"

these do not work and I get a runtime error
integer li_seriescount
//li_seriescount = dw_1.object.dw_graph.object.gr_1.datacount //does not work
//li_seriescount = dw_1.object.dw_graph.object.gr_1.values.datacount //does not work
//li_seriescount = dw_1.object.dw_graph.object.categorycount //does not work
//li_seriescount = dw_1.object.dw_graph.categorycount //does not work
//dw_1.object.dw_graph.object.gr_1.visible = false //does not work
//dw_1.object.dw_graph.object.visible = false //does not work
//dw_1.object.dw_graph.visible = false //does not work

any help would be greatly appreciated.
mike

Brad Mettee Accepted Answer Pending Moderation
  1. Wednesday, 27 March 2019 14:18 PM UTC
  2. PowerBuilder
  3. # 1

There might be an easier way than working with an Active-X control. You can dynamically create a DWO in a PBL, add that PBL to the library path, and when you run the report, it'll find that copy of it.

Here are the basic steps we've used when overcoming similar issues (nested reports where we need to modify the retrieve or some other object, but can't get to it through other means):

First, save original datawindow you want to modify with different name, delete original (make sure it's in your PBR, or it won't be available at runtime)

At runtime:
- check to see if runtime work PBL exists (preferably in the user appdata directory, or similar "local" place), create it if it doesn't
- check to see if dwo in the pbl exists, delete it if it does (do this 2 times in a row, as the delete step sometimes fails to delete the object and doesn't report an error)
- create temporary datastore, load it with your newly named "original" DWO
- make changes to controls as needed
- use describe to get syntax (ds.describe("datawindow.syntax"))
- use LibraryImport to take the syntax and save it into the PBL with the object name used by the report
- run report and you should have your newly colored graph lines

It sounds like a lot of steps, but it lets you do all of your work in PB without involving other languages & objects.

 

Comment
  1. Chris Pollach @Appeon
  2. Wednesday, 27 March 2019 15:11 PM UTC
Very "Kool" suggestion Brad!
  1. Helpful
There are no comments made yet.
Michael Johnson Accepted Answer Pending Moderation
  1. Tuesday, 26 March 2019 16:34 PM UTC
  2. PowerBuilder
  3. # 2

Thanks to all the suggestions and replies.

The graph has to be on the datawindow as its a 'Work Order' showing trending data points on the work order asset.

I've already tested using the MS graph control and it still shows up and prints fine.

just have to figure how to populate it from the database now. LOL

thanks agaiin

Mike

Comment
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Tuesday, 26 March 2019 16:16 PM UTC
  2. PowerBuilder
  3. # 3

Hi Michael;

  Another approach that I have used when the graph is part of a standard report is if the App users would be OK with the report being in PDF format.

  If PDF is OK - then you can produce each part of the report as its own PDF file. Since the graph is now running 1:1 with its DC/DS, you can now do the colourization as required. Once the report PDF pieces are produced, I just merge the PDF files into one for the illusion of a Composite report.

  For the PDF merging, I use the free PDF ToolKit: https://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/

FYI: I have a demo App for the PDF file merging as an example.

HTH

Regards ... Chris

Comment
There are no comments made yet.
Michael Johnson Accepted Answer Pending Moderation
  1. Tuesday, 26 March 2019 15:50 PM UTC
  2. PowerBuilder
  3. # 4

Thanks Chris.

Guess I'll do a ole object using microsoft graph control.

Mike

Comment
  1. Miguel Leeuwe
  2. Tuesday, 26 March 2019 15:57 PM UTC
Hi Mike,

We also have created our own activeX using ms graph control, but if that's a valid option for you, than I assume that it means that you don't really need the graphs to be on a composite datawindow?

In other words you can just use individual dw controls (on a userobject or not) and then you would be able to change the colours with the pbm_... event. it'll save you a lot of time. HIH
  1. Helpful
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Monday, 25 March 2019 20:18 PM UTC
  2. PowerBuilder
  3. # 5

Hi Mike;

  That only works if the parent (or main DWO) is a graph. It does not fire for child DWO's.

Regards ... Chris

Comment
There are no comments made yet.
Michael Johnson Accepted Answer Pending Moderation
  1. Monday, 25 March 2019 14:14 PM UTC
  2. PowerBuilder
  3. # 6

Thanks all for there replies. :-)

Miguel

Added a ue event for pbm_dwngraphcreate but its not begin called.

could it be because it is a composite graph and is a child object of the main datawindow?

thanks

Mike

 

Comment
  1. Miguel Leeuwe
  2. Monday, 25 March 2019 16:50 PM UTC
Yes that's very likely, I'm sorry did not read your post very well, (I was more like answering Armeen if it was possible).



Can't you do something like a user object on which you put the dw control with the graph and not use a composite datawindow?
  1. Helpful
There are no comments made yet.
Miguel Leeuwe Accepted Answer Pending Moderation
  1. Monday, 25 March 2019 09:39 AM UTC
  2. PowerBuilder
  3. # 7

Yes previously it was also possible:

 

I've digged up some "old" code where in the pbm_dwnGraphCreate()  (add it manually if it's not present yet in the events list of the dw control):

// Just replace "gnv_app.il_CM_CREDICA_BLUE" with a call to the RGB() function to set your own colour

long ll_count, ll_data_count, ll_ret

ll_data_count = this.datacount("gr_effort","")
this.SetSeriesStyle ("gr_effort", "", linecolor!, gnv_app.il_CM_CREDICA_BLUE )
for ll_count = 1 to ll_data_count
  this.SetDataStyle ( "gr_effort", 1, ll_count, foreground!, gnv_app.il_CM_CREDICA_BLUE )
next

 

Comment
There are no comments made yet.
John Fauss Accepted Answer Pending Moderation
  1. Friday, 22 March 2019 22:53 PM UTC
  2. PowerBuilder
  3. # 8

Hi, Michael -

The errors you're getting is because you are trying to use methods (DataCount, CategoryCount, etc.) of a DataWindow Control as properties of a child DataWindow via dot notation.

Comment
There are no comments made yet.
Armeen Mazda @Appeon Accepted Answer Pending Moderation
  1. Friday, 22 March 2019 19:16 PM UTC
  2. PowerBuilder
  3. # 9

PowerBuilder 2019 allows you to do this using the new UI themes feature: https://community.appeon.com/index.php/blogs/recent-blogs/codeless-enhancement-of-your-app-s-ui-ux

I'm not aware that you can do this programmatically, but maybe somebody else here knows something I don't.

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.