Jump to content
  • IronPython Masthead for TIBCO Spotfire

    An IronPython script that allows you to replicate a visual across all pages. Useful when creating headers, top navigation bars or mastheads for a guided analysis or dashboard.

    A masthead is an imprint located at the top of a web page. The imprint may be a graphic image or line of text that identifies the website or a specific section of the site. A masthead may also include navigation links. They are also know as top bar navigation, top banner or page header. 


    page_parts.thumb.png.b9fed57984f3c3a7d3101b09a13090dc.png? Masthead ?page_example.thumb.png.3af12cf22bca9beda26f4f5b2ac41cd5.png

    When developing a guided analysis or dashboard in TIBCO Spotfire that contains several tabs, it can be time consuming to create a masthead on every page, not to mention making changes on all of them to keep consistency


    With IronPython you can automate almost anything. With this script we can select a blueprint visualization that can be copied across all pages for a specific analysis or dashboard. 




    The IronPython script is short, but it is also very powerful. It takes vis as a visualization script parameter. The script creates a copy of the selected visual on every page. If the visualization already exists, it will replace it. All script associated with the template visualization is carried over. In simple words, it automates the tedious task of copying and pasting the visual over and ove.r

     #vis is a script parameter indicating the blueprint visual to copy (or replace) across all pages  #options # skipPages: Array of string, numbers or both representing pages to ignore. First page is index 1) #             No need to include the page where the blueprint visualization is from # keepOld: Array of mixed string or numbers to indicate which page to keep the old visual.  #           This is useful when pages are not replaced on the same place and the layout is messed up,  #           so you have to manually swap the new visual with the old visual and delete the old visual to preserve the layout" skipPages=["Config"] #page number or title to ignore keepOld=[] #page number or title to keep the old version (it will keep adding a copy every time)  i=0 for p in Document.Pages:     i+=1     if not p.Visuals.Contains(vis) and not (p.Title in skipPages or i in skipPages):         v2 = p.Visuals.AddDuplicate(vis)         v2.Title = vis.Title+"_copy"         for v in p.Visuals:             if v.Title == vis.Title and not (p.Title in keepOld or i in keepOld):                     p.Visuals.Remove(v)         v2.Title = vis.Title               



    The first time the script runs, the visualization copy is placed at a certain location on each page, thus you need to place the new visualization property on each page. The second time the script it runs, it updates the visualization without affecting the layout In most cases. If it does, then undo and either skip the page by providing a value to the skipPages variable or try using the keepOld array by providing the page title or page number to have a duplicate on the same place where the visualization is to be replaced.




    See also theJavaScript Masthead for TIBCO Spotfire, a way to create mastheads very quickly with minimal coding keeping clean html code by just having the Spotfire relevant Spotfire Controls markup. You put the content, we take care of the layout. Check it out!



    User Feedback

    Recommended Comments

    There are no comments to display.

  • Create New...