How To Toggle Lines & Curves Names Visibility On Spotfire With Iron Python?












0















I've been trying to create an IronPython script to toggle my BarChart Horizontal Lines names with no luck.



I would like to achieve this with a button click:
enter image description here



The code I am currently using is:



from System.Drawing import Color
from Spotfire.Dxp.Application.Visuals import *

# vis parameter referencing an existing BarChart visualization
vis = vis.As[BarChart]()

# Read the document property with the toggle value (true/false)
Document.Properties['GenericToggleLineNames'] = not Document.Properties['GenericToggleLineNames']

#Loop through all the Lines & Curves collection
if Document.Properties['GenericToggleLineNames']:
for fm in vis.FittingModels:
if fm.Line.DisplayName == 'Defined Underload Limit':
fm.Line.CustomDisplayName = 'Defined Underload Limit'
elif fm.Line.DisplayName == 'Defined Warning Limit':
fm.Line.CustomDisplayName = 'Defined Warning Limit'
elif fm.Line.DisplayName == 'Defined Critical Limit':
fm.Line.CustomDisplayName = 'Defined Critical Limit'
else:
for fm in vis.FittingModels:
if fm.Line.DisplayName == 'Defined Underload Limit':
fm.Line.CustomDisplayName = ''
elif fm.Line.DisplayName == 'Defined Warning Limit':
fm.Line.CustomDisplayName = ''
elif fm.Line.DisplayName == 'Defined Critical Limit':
fm.Line.CustomDisplayName = ''


But, when I get to the "Show = true", the code does not change the CustomDisplayNames.



According to the Spotfire API, DisplayName only offers a get method, while
CustomDisplayName offers both get and set.



Does anyone know how to create this toggle?










share|improve this question



























    0















    I've been trying to create an IronPython script to toggle my BarChart Horizontal Lines names with no luck.



    I would like to achieve this with a button click:
    enter image description here



    The code I am currently using is:



    from System.Drawing import Color
    from Spotfire.Dxp.Application.Visuals import *

    # vis parameter referencing an existing BarChart visualization
    vis = vis.As[BarChart]()

    # Read the document property with the toggle value (true/false)
    Document.Properties['GenericToggleLineNames'] = not Document.Properties['GenericToggleLineNames']

    #Loop through all the Lines & Curves collection
    if Document.Properties['GenericToggleLineNames']:
    for fm in vis.FittingModels:
    if fm.Line.DisplayName == 'Defined Underload Limit':
    fm.Line.CustomDisplayName = 'Defined Underload Limit'
    elif fm.Line.DisplayName == 'Defined Warning Limit':
    fm.Line.CustomDisplayName = 'Defined Warning Limit'
    elif fm.Line.DisplayName == 'Defined Critical Limit':
    fm.Line.CustomDisplayName = 'Defined Critical Limit'
    else:
    for fm in vis.FittingModels:
    if fm.Line.DisplayName == 'Defined Underload Limit':
    fm.Line.CustomDisplayName = ''
    elif fm.Line.DisplayName == 'Defined Warning Limit':
    fm.Line.CustomDisplayName = ''
    elif fm.Line.DisplayName == 'Defined Critical Limit':
    fm.Line.CustomDisplayName = ''


    But, when I get to the "Show = true", the code does not change the CustomDisplayNames.



    According to the Spotfire API, DisplayName only offers a get method, while
    CustomDisplayName offers both get and set.



    Does anyone know how to create this toggle?










    share|improve this question

























      0












      0








      0








      I've been trying to create an IronPython script to toggle my BarChart Horizontal Lines names with no luck.



      I would like to achieve this with a button click:
      enter image description here



      The code I am currently using is:



      from System.Drawing import Color
      from Spotfire.Dxp.Application.Visuals import *

      # vis parameter referencing an existing BarChart visualization
      vis = vis.As[BarChart]()

      # Read the document property with the toggle value (true/false)
      Document.Properties['GenericToggleLineNames'] = not Document.Properties['GenericToggleLineNames']

      #Loop through all the Lines & Curves collection
      if Document.Properties['GenericToggleLineNames']:
      for fm in vis.FittingModels:
      if fm.Line.DisplayName == 'Defined Underload Limit':
      fm.Line.CustomDisplayName = 'Defined Underload Limit'
      elif fm.Line.DisplayName == 'Defined Warning Limit':
      fm.Line.CustomDisplayName = 'Defined Warning Limit'
      elif fm.Line.DisplayName == 'Defined Critical Limit':
      fm.Line.CustomDisplayName = 'Defined Critical Limit'
      else:
      for fm in vis.FittingModels:
      if fm.Line.DisplayName == 'Defined Underload Limit':
      fm.Line.CustomDisplayName = ''
      elif fm.Line.DisplayName == 'Defined Warning Limit':
      fm.Line.CustomDisplayName = ''
      elif fm.Line.DisplayName == 'Defined Critical Limit':
      fm.Line.CustomDisplayName = ''


      But, when I get to the "Show = true", the code does not change the CustomDisplayNames.



      According to the Spotfire API, DisplayName only offers a get method, while
      CustomDisplayName offers both get and set.



      Does anyone know how to create this toggle?










      share|improve this question














      I've been trying to create an IronPython script to toggle my BarChart Horizontal Lines names with no luck.



      I would like to achieve this with a button click:
      enter image description here



      The code I am currently using is:



      from System.Drawing import Color
      from Spotfire.Dxp.Application.Visuals import *

      # vis parameter referencing an existing BarChart visualization
      vis = vis.As[BarChart]()

      # Read the document property with the toggle value (true/false)
      Document.Properties['GenericToggleLineNames'] = not Document.Properties['GenericToggleLineNames']

      #Loop through all the Lines & Curves collection
      if Document.Properties['GenericToggleLineNames']:
      for fm in vis.FittingModels:
      if fm.Line.DisplayName == 'Defined Underload Limit':
      fm.Line.CustomDisplayName = 'Defined Underload Limit'
      elif fm.Line.DisplayName == 'Defined Warning Limit':
      fm.Line.CustomDisplayName = 'Defined Warning Limit'
      elif fm.Line.DisplayName == 'Defined Critical Limit':
      fm.Line.CustomDisplayName = 'Defined Critical Limit'
      else:
      for fm in vis.FittingModels:
      if fm.Line.DisplayName == 'Defined Underload Limit':
      fm.Line.CustomDisplayName = ''
      elif fm.Line.DisplayName == 'Defined Warning Limit':
      fm.Line.CustomDisplayName = ''
      elif fm.Line.DisplayName == 'Defined Critical Limit':
      fm.Line.CustomDisplayName = ''


      But, when I get to the "Show = true", the code does not change the CustomDisplayNames.



      According to the Spotfire API, DisplayName only offers a get method, while
      CustomDisplayName offers both get and set.



      Does anyone know how to create this toggle?







      python bar-chart ironpython spotfire tibco






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jan 2 at 8:03









      Oliver DrummondOliver Drummond

      360216




      360216
























          2 Answers
          2






          active

          oldest

          votes


















          0














          I wrote a blog post on how to do this. Please go here -- https://datashoptalk.com/ironpython-in-spotfire-turning-lines-curves-on-and-off/. The code will vary depending on what you have on the page. Please upvote if you get to the right answer with this post.






          share|improve this answer
























          • Hi @JulieBMA, I've seen your blog post yesterday (by the way, I've been helped by many of your blog posts in the past :) ) but in this case, I would like to keep displaying the line, but only hide its title. Thanks.

            – Oliver Drummond
            Jan 2 at 23:20











          • Can you tell me what Document Property and data type you have setup.

            – JulieBMA
            Jan 3 at 16:54











          • The only Document Property that I'm using for that is GenericToggleLineNames', which is a Boolean. The vis parameter is a Visualization input.

            – Oliver Drummond
            Jan 3 at 23:04





















          0














          I've managed to get it working in a hideous way. Will share it here if anyone needs it, but please, would love to find a proper way to do it.



          Even though Spotfire API documentation mentions that the
          ReferenceCurve.DisplayName is a read-only Property (only have the get method), it looks like it's being changed when CustomDisplayName is updated.



          With that in mind, I've created another set of IFs, looking for the "new" DisplayName and replacing them with the old ones.



          # Imports
          from System.Drawing import Color
          from Spotfire.Dxp.Application.Visuals import *

          #Add a vis parameter referencing an existing LineChart visualization
          vis = vis.As[BarChart]()

          #Loop through all the Lines & Curves collection
          Document.Properties['GenericVisualisationDescriptions'] = not Document.Properties['GenericVisualisationDescriptions']

          if Document.Properties['GenericVisualisationDescriptions']:
          for fm in vis.FittingModels:
          if fm.Line.DisplayName == ' ':
          fm.Line.CustomDisplayName = 'Defined Underload Limit'
          elif fm.Line.DisplayName == ' ':
          fm.Line.CustomDisplayName = 'Defined Warning Limit'
          elif fm.Line.DisplayName == ' ':
          fm.Line.CustomDisplayName = 'Defined Critical Limit'
          else:
          for fm in vis.FittingModels:
          print fm.Line.DisplayName
          print fm.Line.CustomDisplayName
          if fm.Line.DisplayName == 'Defined Underload Limit':
          fm.Line.CustomDisplayName = ' '
          elif fm.Line.DisplayName == 'Defined Warning Limit':
          fm.Line.CustomDisplayName = ' '
          elif fm.Line.DisplayName == 'Defined Critical Limit':
          fm.Line.CustomDisplayName = ' '





          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54003060%2fhow-to-toggle-lines-curves-names-visibility-on-spotfire-with-iron-python%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            I wrote a blog post on how to do this. Please go here -- https://datashoptalk.com/ironpython-in-spotfire-turning-lines-curves-on-and-off/. The code will vary depending on what you have on the page. Please upvote if you get to the right answer with this post.






            share|improve this answer
























            • Hi @JulieBMA, I've seen your blog post yesterday (by the way, I've been helped by many of your blog posts in the past :) ) but in this case, I would like to keep displaying the line, but only hide its title. Thanks.

              – Oliver Drummond
              Jan 2 at 23:20











            • Can you tell me what Document Property and data type you have setup.

              – JulieBMA
              Jan 3 at 16:54











            • The only Document Property that I'm using for that is GenericToggleLineNames', which is a Boolean. The vis parameter is a Visualization input.

              – Oliver Drummond
              Jan 3 at 23:04


















            0














            I wrote a blog post on how to do this. Please go here -- https://datashoptalk.com/ironpython-in-spotfire-turning-lines-curves-on-and-off/. The code will vary depending on what you have on the page. Please upvote if you get to the right answer with this post.






            share|improve this answer
























            • Hi @JulieBMA, I've seen your blog post yesterday (by the way, I've been helped by many of your blog posts in the past :) ) but in this case, I would like to keep displaying the line, but only hide its title. Thanks.

              – Oliver Drummond
              Jan 2 at 23:20











            • Can you tell me what Document Property and data type you have setup.

              – JulieBMA
              Jan 3 at 16:54











            • The only Document Property that I'm using for that is GenericToggleLineNames', which is a Boolean. The vis parameter is a Visualization input.

              – Oliver Drummond
              Jan 3 at 23:04
















            0












            0








            0







            I wrote a blog post on how to do this. Please go here -- https://datashoptalk.com/ironpython-in-spotfire-turning-lines-curves-on-and-off/. The code will vary depending on what you have on the page. Please upvote if you get to the right answer with this post.






            share|improve this answer













            I wrote a blog post on how to do this. Please go here -- https://datashoptalk.com/ironpython-in-spotfire-turning-lines-curves-on-and-off/. The code will vary depending on what you have on the page. Please upvote if you get to the right answer with this post.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Jan 2 at 15:40









            JulieBMAJulieBMA

            162




            162













            • Hi @JulieBMA, I've seen your blog post yesterday (by the way, I've been helped by many of your blog posts in the past :) ) but in this case, I would like to keep displaying the line, but only hide its title. Thanks.

              – Oliver Drummond
              Jan 2 at 23:20











            • Can you tell me what Document Property and data type you have setup.

              – JulieBMA
              Jan 3 at 16:54











            • The only Document Property that I'm using for that is GenericToggleLineNames', which is a Boolean. The vis parameter is a Visualization input.

              – Oliver Drummond
              Jan 3 at 23:04





















            • Hi @JulieBMA, I've seen your blog post yesterday (by the way, I've been helped by many of your blog posts in the past :) ) but in this case, I would like to keep displaying the line, but only hide its title. Thanks.

              – Oliver Drummond
              Jan 2 at 23:20











            • Can you tell me what Document Property and data type you have setup.

              – JulieBMA
              Jan 3 at 16:54











            • The only Document Property that I'm using for that is GenericToggleLineNames', which is a Boolean. The vis parameter is a Visualization input.

              – Oliver Drummond
              Jan 3 at 23:04



















            Hi @JulieBMA, I've seen your blog post yesterday (by the way, I've been helped by many of your blog posts in the past :) ) but in this case, I would like to keep displaying the line, but only hide its title. Thanks.

            – Oliver Drummond
            Jan 2 at 23:20





            Hi @JulieBMA, I've seen your blog post yesterday (by the way, I've been helped by many of your blog posts in the past :) ) but in this case, I would like to keep displaying the line, but only hide its title. Thanks.

            – Oliver Drummond
            Jan 2 at 23:20













            Can you tell me what Document Property and data type you have setup.

            – JulieBMA
            Jan 3 at 16:54





            Can you tell me what Document Property and data type you have setup.

            – JulieBMA
            Jan 3 at 16:54













            The only Document Property that I'm using for that is GenericToggleLineNames', which is a Boolean. The vis parameter is a Visualization input.

            – Oliver Drummond
            Jan 3 at 23:04







            The only Document Property that I'm using for that is GenericToggleLineNames', which is a Boolean. The vis parameter is a Visualization input.

            – Oliver Drummond
            Jan 3 at 23:04















            0














            I've managed to get it working in a hideous way. Will share it here if anyone needs it, but please, would love to find a proper way to do it.



            Even though Spotfire API documentation mentions that the
            ReferenceCurve.DisplayName is a read-only Property (only have the get method), it looks like it's being changed when CustomDisplayName is updated.



            With that in mind, I've created another set of IFs, looking for the "new" DisplayName and replacing them with the old ones.



            # Imports
            from System.Drawing import Color
            from Spotfire.Dxp.Application.Visuals import *

            #Add a vis parameter referencing an existing LineChart visualization
            vis = vis.As[BarChart]()

            #Loop through all the Lines & Curves collection
            Document.Properties['GenericVisualisationDescriptions'] = not Document.Properties['GenericVisualisationDescriptions']

            if Document.Properties['GenericVisualisationDescriptions']:
            for fm in vis.FittingModels:
            if fm.Line.DisplayName == ' ':
            fm.Line.CustomDisplayName = 'Defined Underload Limit'
            elif fm.Line.DisplayName == ' ':
            fm.Line.CustomDisplayName = 'Defined Warning Limit'
            elif fm.Line.DisplayName == ' ':
            fm.Line.CustomDisplayName = 'Defined Critical Limit'
            else:
            for fm in vis.FittingModels:
            print fm.Line.DisplayName
            print fm.Line.CustomDisplayName
            if fm.Line.DisplayName == 'Defined Underload Limit':
            fm.Line.CustomDisplayName = ' '
            elif fm.Line.DisplayName == 'Defined Warning Limit':
            fm.Line.CustomDisplayName = ' '
            elif fm.Line.DisplayName == 'Defined Critical Limit':
            fm.Line.CustomDisplayName = ' '





            share|improve this answer




























              0














              I've managed to get it working in a hideous way. Will share it here if anyone needs it, but please, would love to find a proper way to do it.



              Even though Spotfire API documentation mentions that the
              ReferenceCurve.DisplayName is a read-only Property (only have the get method), it looks like it's being changed when CustomDisplayName is updated.



              With that in mind, I've created another set of IFs, looking for the "new" DisplayName and replacing them with the old ones.



              # Imports
              from System.Drawing import Color
              from Spotfire.Dxp.Application.Visuals import *

              #Add a vis parameter referencing an existing LineChart visualization
              vis = vis.As[BarChart]()

              #Loop through all the Lines & Curves collection
              Document.Properties['GenericVisualisationDescriptions'] = not Document.Properties['GenericVisualisationDescriptions']

              if Document.Properties['GenericVisualisationDescriptions']:
              for fm in vis.FittingModels:
              if fm.Line.DisplayName == ' ':
              fm.Line.CustomDisplayName = 'Defined Underload Limit'
              elif fm.Line.DisplayName == ' ':
              fm.Line.CustomDisplayName = 'Defined Warning Limit'
              elif fm.Line.DisplayName == ' ':
              fm.Line.CustomDisplayName = 'Defined Critical Limit'
              else:
              for fm in vis.FittingModels:
              print fm.Line.DisplayName
              print fm.Line.CustomDisplayName
              if fm.Line.DisplayName == 'Defined Underload Limit':
              fm.Line.CustomDisplayName = ' '
              elif fm.Line.DisplayName == 'Defined Warning Limit':
              fm.Line.CustomDisplayName = ' '
              elif fm.Line.DisplayName == 'Defined Critical Limit':
              fm.Line.CustomDisplayName = ' '





              share|improve this answer


























                0












                0








                0







                I've managed to get it working in a hideous way. Will share it here if anyone needs it, but please, would love to find a proper way to do it.



                Even though Spotfire API documentation mentions that the
                ReferenceCurve.DisplayName is a read-only Property (only have the get method), it looks like it's being changed when CustomDisplayName is updated.



                With that in mind, I've created another set of IFs, looking for the "new" DisplayName and replacing them with the old ones.



                # Imports
                from System.Drawing import Color
                from Spotfire.Dxp.Application.Visuals import *

                #Add a vis parameter referencing an existing LineChart visualization
                vis = vis.As[BarChart]()

                #Loop through all the Lines & Curves collection
                Document.Properties['GenericVisualisationDescriptions'] = not Document.Properties['GenericVisualisationDescriptions']

                if Document.Properties['GenericVisualisationDescriptions']:
                for fm in vis.FittingModels:
                if fm.Line.DisplayName == ' ':
                fm.Line.CustomDisplayName = 'Defined Underload Limit'
                elif fm.Line.DisplayName == ' ':
                fm.Line.CustomDisplayName = 'Defined Warning Limit'
                elif fm.Line.DisplayName == ' ':
                fm.Line.CustomDisplayName = 'Defined Critical Limit'
                else:
                for fm in vis.FittingModels:
                print fm.Line.DisplayName
                print fm.Line.CustomDisplayName
                if fm.Line.DisplayName == 'Defined Underload Limit':
                fm.Line.CustomDisplayName = ' '
                elif fm.Line.DisplayName == 'Defined Warning Limit':
                fm.Line.CustomDisplayName = ' '
                elif fm.Line.DisplayName == 'Defined Critical Limit':
                fm.Line.CustomDisplayName = ' '





                share|improve this answer













                I've managed to get it working in a hideous way. Will share it here if anyone needs it, but please, would love to find a proper way to do it.



                Even though Spotfire API documentation mentions that the
                ReferenceCurve.DisplayName is a read-only Property (only have the get method), it looks like it's being changed when CustomDisplayName is updated.



                With that in mind, I've created another set of IFs, looking for the "new" DisplayName and replacing them with the old ones.



                # Imports
                from System.Drawing import Color
                from Spotfire.Dxp.Application.Visuals import *

                #Add a vis parameter referencing an existing LineChart visualization
                vis = vis.As[BarChart]()

                #Loop through all the Lines & Curves collection
                Document.Properties['GenericVisualisationDescriptions'] = not Document.Properties['GenericVisualisationDescriptions']

                if Document.Properties['GenericVisualisationDescriptions']:
                for fm in vis.FittingModels:
                if fm.Line.DisplayName == ' ':
                fm.Line.CustomDisplayName = 'Defined Underload Limit'
                elif fm.Line.DisplayName == ' ':
                fm.Line.CustomDisplayName = 'Defined Warning Limit'
                elif fm.Line.DisplayName == ' ':
                fm.Line.CustomDisplayName = 'Defined Critical Limit'
                else:
                for fm in vis.FittingModels:
                print fm.Line.DisplayName
                print fm.Line.CustomDisplayName
                if fm.Line.DisplayName == 'Defined Underload Limit':
                fm.Line.CustomDisplayName = ' '
                elif fm.Line.DisplayName == 'Defined Warning Limit':
                fm.Line.CustomDisplayName = ' '
                elif fm.Line.DisplayName == 'Defined Critical Limit':
                fm.Line.CustomDisplayName = ' '






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Jan 3 at 23:14









                Oliver DrummondOliver Drummond

                360216




                360216






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54003060%2fhow-to-toggle-lines-curves-names-visibility-on-spotfire-with-iron-python%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Monofisismo

                    Angular Downloading a file using contenturl with Basic Authentication

                    Olmecas