Problem writing to four named 2D graphs


Gammatech

Recommended Posts

Hi

I have come across a problem building a 2D graph component entirely from script.

I have four similar pages (slightly different views of the data) All four have the same 2D graph component in the same place with the same component name. Dependent on the user input via a pop up page the graph component can have a single trace two traces or three traces. The Title and sub title are set according to the selected data set and the period for display.

It is the same pop up page that builds the graph but the outcome in the four instances of the graph component differ!

In all 4 instances the title and subtitle are written correctly together with the Y axis title and scaling. In three instances a single trace is inserted correctly whilst on the fourth there is no trace with the component properties showing Y expression as "New Trace"

When the user tries to set two traces, one instance has two traces correctly whilst two others have only one and the fourth (same one as before) just has "New trace" for the Y expression. In all four the title reflects that there are two variables.

The results are similar when setting three variables. It is always the same instance that behaves in the same way so it must be something in the properties of the particular instance of the graph component but I have not been able to find it as yet. I have tried wiping the component name and renaming all four again to the same thing but this has not worked (I hardly expected it would as the script changes the titles correctly)

All four have both axes frozen set to false and I explicitly set both frozen to false in the script. I had run out of ideas except to delete the 3 errant copies and replace them with a copy of the one that works and lo and behold it now all works! I am at a loss to find anything different in the properties of any of the graph components old or new.

Martin

Link to comment
Share on other sites

Using the same name for multiple controls can have mixed effects. It works pretty well for properties (variables) that you set in the controls, but not so well for function calls. I recommend simply naming the four graphs something different and duplicate your code.

Or, alternatively, make it so you only have one graph instead of 4 and use overlaid pages to make that graph appear on four pages.

Link to comment
Share on other sites

Right, I renamed the other three 2D graph components and Quadrupled the parts of code that were addressing the original component to reflect that there were now 4 different components and much as before the results are inconsistent. All four components always have the titles and subtitles changed correctly but one, (the original that all others were copied from) works correctly, two have the Yexpression set only to "New Trace" and the fourth has three "New Trace" entries as well as the one that should be there.

Your second suggestion was to use overlaid pages. The graph I want to show is always in exactly the same position in the lower left quarter of the screen on each of the four pages and I use that same area to pop up any pages for user interaction. So can you explain in a bit more detail how I can arrange overlays? I used to draw the graph on a pop up page but that occasionally caused DF to hang so I moved to the current system. I assume if I overlay pages I have to make the bottom left quarter in some way "transparent" so that the graph underneath can still be seen? I do not know how to do this.

Martin

Link to comment
Share on other sites

Unless you put a panel or big colored symbol component across the whole page, a page is transparent by default. So, all you have to do is leave that area of the screen white. Then you can overlay the pages by doing something like:

page.strCurrentPage = "page1, page2"

Check out the AshlandWater.ctl sample. It uses overlaid pages extensively. The map is a single page, and clicking in various areas overlays the detail at the right.

Link to comment
Share on other sites

  • 4 weeks later...

Duplication of all the code to write to the separately named graphs didn't work reliably either so I have tried your suggestion of an overlaid page with a single graph. Dependent on the particular data view that is required I set

Page.StrCurrentPage = "mainpage, TrendViewOverlay"

where main page is the required data view that is required. My page 'TrendViewOverlay' has a 2D graph component named as 'TrendDisplayChart' located so that it will show correctly when the two pages are displayed together. This works well.

When I try to set the 2D graph component from a sequence or button action I find that I can set the Title, the Sub Title, the Axis Label, the Y scaling,Trace colour and most other requirements with the exception of the Y expression. Viewing the properties of the graph shows everything set up but just 'New Trace' under the Traces box and displayed in the Y expression window.

From the command line I can Add("MainTrace") and Delete("MainTrace") or deleteAll() and although MainTrace comes and goes in the list available there is no obvious change to the properties view of the component.

If after I have added the named trace I attempt to set its Y Expression no errors are shown but there is no change in the graph component either. I always DeleteAll() first so have

Component.TrendDisplayChart.DeleteAll()
Component.TrendDisplayChart.AddTrace("MainTrace")
Component.TrendDisplayChart.LeftAxis1.StrLabel = "Gamma"

I then call a sequence to set the Y Expression with

Dummy = SetGammaTrendTrace(TrendStart,TrendEnd,Type)

where the first two arguments are the start and end of the trend and the third signifies whether it is the MainTrace, the first overlay trace or the second. These named traces are added as above.

Dependent on the period for the trace (difference between TrendStart and TrendEnd) and which of the three named traces I am trying to define the Y Expression for my code boils down to

Component.TrendDisplayChart.MainTrace.StrYExpression = "Smooth(Gamma[TrendStart,TrendEnd],Smoothing)"

So why doesn't the Y Expression get set up in the graph? It is not on the page that is displayed at that time, the two overlaid pages are only shown after the whole graph has been built, and the user presses a button labeled "Display". One of my earlier iterations had the graph component on a separate page that was popped up by the Display button and that generally set up correctly but not absolutely reliably so you steered me away from graphs on popups but at least this wrote the Y Expression most of the time.

What am I doing wrong?

Martin

Link to comment
Share on other sites

further:

I have entered an expression manually to the TrendDisplayChart component and no matter whether I invoke Component.TrendDisplayChart.DeleteAll() from the command line or via my sequences this expression remains. The only way to remove it is to highlight it and press delete when it is replaced with 'New Trace' which, as it has a space between 'New' and 'Trace' cannot be a DAQFactory name and as such cannot be accessed by the sequence code.

Martin

Link to comment
Share on other sites

At the same time I build the graph that is to be displayed on the overlaid screen I build an identical one that can be sent to the printer. This builds correctly with up to the three possible traces. I have even tried deleting the 2D graph component on the overlay page and then replacing it but to no avail. I can fully program one 2D component on my page TrendPrint (which occupies most of the page) but on my page that will be overlaid I cannot set the Y Expression whilst I can set everything else! (all with the same sequences)

Martin

Link to comment
Share on other sites

Yet another addition:

As the 2D chart that I print builds perfectly (Named TrendPrintChart) I renamed the chart on my page that is overlaid to be the same, namely TrendPrintChart. Running the build process still populates the actual 2D component that would print but STILL does not load the Y Expression on the renamed overlay chart.

I then deleted the graph component on the overlay page and copied the actual component from the working print page to my now nearly empty overlay page. I corrected the position and size and ran the build sequence again with a single trace and it worked. Flushed with success I reran the build sequence for two traces and although title and other variables reflected a graph with two traces there was only one shown. The Print version of the graph remains perfect, in this case with two traces.

So now I am utterly lost.

Martin

Link to comment
Share on other sites

I am not completely sure. I have never had problems dynamically adding traces to graphs. A few things:

1) what release of DF are you running

2) you might try doing page.xxx.component.yyy.zzz instead of component.yyy.zzz to ensure that the command is getting through to the correct component. Its important to note that having two components with the same name, even if they are on different pages, can cause issues. I believe you can set properties of multiple components, but if you call a member function of those components, it will only be called on one of the components, not all of them. Its possible you have another component with the same name and its calling addtrace() on that component and not the graph you want it to.

Link to comment
Share on other sites

I am using Release 5.84 build 1636 on a vista system with the licence in a silver key. The problems show up exactly the same on a system running XP pro with the silver key and a system running XP pro but with a run time licence.

I will try adding the page reference to all of the commands and report the results to this thread.

Martin

Link to comment
Share on other sites

I originally had:

Component.TrendDisplayChart.MainTrace.StrYExpression = "Smooth(Ash[TrendStart,TrendEnd],ResponseTime)"
Component.TrendPrintChart.MainTrace.StrYExpression = "Smooth(Ash[TrendStart,TrendEnd],ResponseTime)"

and as it was only writing to the TrendDisplayChart that was giving problems as writing to TrendPrintChart worked without fail I added your suggested page referencing just for the TrendDisplayChart, so now I have:

Page.TrendDisplayOverlay.Component.TrendDisplayChart.MainTrace.StrYExpression = "Smooth(Ash[TrendStart,TrendEnd],ResponseTime)"
Component.TrendPrintChart.MainTrace.StrYExpression = "Smooth(Ash[TrendStart,TrendEnd],ResponseTime)"

And this seems to work as intended with the TrendDisplayChart component being able to have one, two or three traces out of a possible nine built by the user.

I don't understand why the TrendDisplayChart component required referencing by page whilst the TrendPrintChart was ok but I suppose that is half the "fun" of programming! I am loathe to add page referencing to the TrendPrintChart component in case it disturbs the now satisfactory system.

Do you have any timescale for the update to the graphics as I expect that will require a lot of recoding? (apart from all the efforts you guys will have to put in!)

Martin

Link to comment
Share on other sites

No timescale I'm afraid, though it looks like we are going to do small releases more often rather than waiting and doing a big release. We'll have 5.85 available in the next week which adds some useful functions. The update to the graphics is, unfortunately, more involved and will take a bit longer.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.