6 Replies Latest reply on Nov 9, 2012 9:09 PM by sovain

    Active View on HTML Page / methods

    sovain

      Hi All,

       

       

       

      Currently, I am working on a Web-version of a application using ActiveView.

       

       

       

      AV documentation provided me with some general rules of how to insert a AV-object on a html- page.

       

       

       

      In fact, I need to call some specific functions/events/methods of the ActiveView ActiveX component.

       

       

       

      For example, I added to my page this code:

       

      -------------

       

      <object ID="Pbd1" WIDTH="351px" HEIGHT="298px"  CLASSID="CLSID:4F26B906-2854-11D1-9597-00A0C931BFC8">

       

      <param name = "DisplayUrl" value="......../pdi/trend1.pdi"/> </object>

       

      -------------

       

       

       

       

       

      1. Upon initializing I get sometimes Javascript error Object is Null in the line

       

            document.getElementById('axPbd1').Display.Symbols.Item('Trend1').AddTrace('sinusoid') 

       

           

       

      Null object is document.getElementById('axPbd1').Display

       

      My question is how properly initialize AV object on HTML page using ReadyState or any other callback ?

       

       

       

      The solution for now is I make a delay for 2 seconds before I do "AddTrace" - this is trick and incorrect. Some good solution for that is needed.

       

       

       

      2. I do not know which VB/Javascript function to use something similar I do in C#:

       

      trend.BeforeDoubleClick

       

      or

       

      trend.BeforeDoubleClick += delegate(ref bool notDoBClick, int VarX, int VarY) { notDoBClick = true; };

       

       

       

       

       

      So I want to disable function when doubleclick on a trend in HTML page.

       

       

       

       

       

        

       

      3. I do not know how to get to JS DOM to change something like:

       

                     mytrendFormat.ShowTitle = true;

       

                     mytrendFormat.ShowTagName = false;

       

                     mytrendFormat.ShowServerName = false;

       

                     mytrendFormat.ShowDescription = false; or to change this:

       

                 foreach (PBSymLib.TrendElement Curel in mytrendFormat.Elements)  

       

                        if (Curel.Name.Equals("Pen 1")) Curel.Color = 0x00ff00u;

       

       

       

       

       

      4. Very important(!)

       

      How to put a XY plot on a HTML-page like I did in C#:

       

            SampleTrend = (XYPlot.XYPlot)SampleTrendDisplay.Symbols.Add(PBObjLib.pbSYMBOLTYPE.pbSymbolXYPlot);

       

            temp_Tag.SetTimeRange(false, "04/20/2011 8:31:07", "04/20/2011 22:31:07");

       

            temp_Tag = xydefinition.Tags.Add("sinusoid",  false);

       

            xydefinition.XYTitle = "Sample";

       

            SampletrendFormat.ShowTagName = tagname;

       

                  SampletrendFormat.ShowServerName = servername;

       

                  SampletrendFormat.ShowDescription = description;

       

                  SampletrendFormat.ShowValue = value;

       

                  SampletrendFormat.ShowEngUnits = engunits;

       

                  SampletrendFormat.ShowTitle = plottitle;

       

                  SampletrendFormat.DisplayScaleInside = valuescaleinsideaxis;

       

                  SampletrendFormat.ShowGrids = grids;

       

                  SampletrendFormat.ShowConnectingLines = connectinglines;

       

                  SampletrendFormat.ShowCoefficient = coefficient;

       

                  SampletrendFormat.ShowLinearCorrelation = linearcorrelation;

       

       

       

      Any help would be very helpful.

       

      Thank you 

       

      Oleg

       

       

        • Re: Active View on HTML Page / methods
          sovain

          Forgot to tell that I cannot use AV in Firefox and investigate the AV object with Firebug.

           

          Internet Explorer is quite poor for developers to debug.

            • Re: Active View on HTML Page / methods
              dhollebeek

              1. I believe the new AV that is coming soon has a ReadyState property to deal with these timing issues.

               

              2. In VBA, you can do "Dim WithEvents t as trend" then you can define event handlers like "trend_BeforeDoubleClick".  I'm sorry, I don't know javascript well enough to know what the equivalent is.

               

              3.  Could you explain what you're doing here and what problem you are running into?  I don't quite follow.

               

              4.  Again, my familiarity with web dev falls short here ... too much working in C++ client code!

               

              In general, have you considered doing all you're coding in VBA inside the display rather than try to do it in HTML?  This would also solve you're initialization issue (1) because the VBA won't run until the display loads.

                • Re: Active View on HTML Page / methods
                  sovain

                  Hi David,

                   

                  Thanks for reply.

                   

                  1. In regards to "ReadyState", I just make a delay before work with object .Display. This is the only way it works for me.

                   

                  The most important for me is next issues.

                   

                  2. I will try to use your suggestion about Double Click.

                   

                  3. I found all properties/methods I needed. It is ok.

                   

                  4. This is a real problem as I could not find any way to plot a XY Trend.

                   

                  The XY ActiveView object in HTML looks :

                   

                   <object ID="lifing_trend_operating" WIDTH="390px" HEIGHT="248px" CLASSID="CLSID:4F26B906-2854-11D1-9597-00A0C931BFC8" >

                   

                     <param name = "DisplayUrl" value="...../pdi/trend_lifing_operating.pdi"/>

                   

                    </object>

                   

                  Using Javascript I am trying to plot :

                   

                  function lifing_trend_operate() {

                   

                      if (document.getElementById('lifing_trend_operating').ReadyState ==4 ){

                   

                         var trend_operating_xydefinition =document.getElementById('lifing_trend_operating').Display.Symbols.Item('Trend1').GetDefinition();

                   

                             trend_operating_xydefinition.XYTitle = "Sum EOH (Y-axis) vs. Operating Hours (X-axis)"; ...........

                   

                  I got an Error in the string:

                   

                        var trend_operating_xydefinition = document.getElementById('lifing_trend_operating').Display.Symbols.Item('Trend1').GetDefinition();

                   

                  When I trace the object:

                   

                  document.getElementById('lifing_trend_operating').Display.Symbols.Item('Trend1')     - it is fine and I can  get the object ...Item('Trend1')  .

                   

                  But the problem is in method: ... .GetDefinition().

                   

                  It says that there is no method GetDefinition that is necessary for XY trend.

                   

                  Maybe I need to use different CLASSID ?   CLASSID="CLSID:4F26B906-2854-11D1-9597-00A0C931BFC8"

                   

                  Please see attached for details.

                   

                  5545.1.JPG

                   

                  If you have any idea about XY - trend in HTML  that would help a lot.

                   

                  Thank you

                   

                  Oleg

                    • Re: Active View on HTML Page / methods
                      dhollebeek

                      It may be (and this is just a guess) that dynamic typing isn't working right in javascript.  Item('Trend1') returns an object of type Symbol, and GetDefinition is defined at the XYPlot level.

                       

                      Try:

                       

                      XYPlot plot = xxx.Item('Trend1');

                       

                      var def = plot.GetDefinition();

                       

                      The GUID is the guid of the PBDCtrl, so I don't think that's the problem (essentially there's only one choice).

                        • Re: Active View on HTML Page / methods
                          ADowney

                          Hi Oleg,

                           

                           

                           

                          Here’s a simpler example (using VBScript – JavaScript similar - not using the DOM) that may help you and some comments:

                           

                           

                           

                          <html>

                           

                          <SCRIPT LANGUAGE="VBScript">

                           

                          <!--

                           

                          Sub window_onload

                           

                                  Pbd1.DisplayURL = "http://adowney2/workfiles/sinusoid.pdi"  

                           

                          End Sub

                           

                           

                           

                          Sub Pbd1_ReadyStateChange(nReadyState)

                           

                               dim ptrend

                           

                               dim pformat

                           

                           

                           

                               if (nReadyState = 4) and (Not (Pbd1.display is nothing)) then

                           

                                     set ptrend = pbd1.display.symbols.item("Trend1")

                           

                                     if ptrend.tracecount =  1 then

                           

                                          ptrend.addtrace("cdt158")

                           

                           

                           

                                          set pformat = ptrend.getformat

                           

                                          pformat.Elements.Item(13).Color = RGB(255,0,0)

                           

                                          ptrend.setformat pformat

                           

                           

                           

                                     end if

                           

                               end if

                           

                          End Sub

                           

                           

                           

                          -->

                           

                          </SCRIPT>

                           

                           

                           

                          <body><p>

                           

                          <object ID      = "Pbd1"

                           

                                  WIDTH   = "100%"

                           

                                  HEIGHT  = "100%"

                           

                                  CLASSID = "CLSID:4F26B906-2854-11D1-9597-00A0C931BFC8"

                           

                                  Events = "true">  

                           

                          </object>

                           

                          </p></body>

                           

                          </html>

                           

                           

                           

                          1.       Sinusoid.pdi has a single trace using sinusoid (you can create a trend/xyplot with no traces)

                           

                          2.       The ReadyState event, with a value of 4 (complete), may fire multiple times – here we use the TraceCount as a secondary check

                           

                          3.       And we check that there is a display object because there are known issues when the object is not really ready

                           

                          4.       ActiveView is defined as a “Read Only” environment so the creation of symbols is mostly blocked, by design

                           

                          5.       What you can do is have invisible symbols whose visibility property is toggled

                           

                          6.       (if you do that then the TraceCount check could be replaced with ptrend.visibility = false)

                           

                          7.       Had to use the Object Browser to find that pbText = 13 (pformat.Elements.Item(13))

                           

                          8.       Expect the trend GetFormat (in the example) to work like xy’s GetDefinition

                           

                           

                           

                          If you really want to dynamically build a display the CreateObject or an add-in would be the best route.

                           

                           

                           

                          HTH, Andre Downey

                           

                           

                            • Re: Active View on HTML Page / methods
                              sovain

                              Thank to all of you.

                               

                              I found solutions for all issues I described above.

                               

                              Unfortunately, none of them were documented in ActiveView User Guide.

                               

                              Having not enough time to wait for reply, I investigated the AV ActiveX deeply and, hope, nobody else will get the same tasks :)

                               

                              When initializing <object...>, property ReadyState returns 4 even if a Display object is still null.

                               

                              You have to make a pause before working with Display.Symbol etc