2 Replies Latest reply on Jul 17, 2017 11:51 PM by CareyTilden

    Configure data sources with PI Vision custom symbol

    CareyTilden

      I have a custom symbol that allows multiple data sources.  Sometimes I want to remove a data source I have added to the custom symbol.  I currently implement this via the right click configOptions menu (see below for sample code), but I would prefer to use the config panel, if possible.  My ideal solution would look like the Trace Options section in the Trend symbol.  Is there any way to accomplish this?

       

              configOptions: function (context, clickedElement) {

                  var menuItems = [];

       

                  menuItems.push({ title: 'Format Symbol', mode: 'format' });

       

                  context.symbol.DataSources.forEach(function (item, idx) {

                      menuItems.push({

                          title: 'Remove data source #' + (idx + 1),

                          action: function () {

                              context.symbol.DataSources.splice(idx, 1);

                          }

                      });

                  })

       

                  return menuItems;

              }

        • Re: Configure data sources with PI Vision custom symbol
          pmartin

          Hi Carey,

           

          I just created a simple symbol that can remove DataSources via the config pane.  This is the simplest example possible - it chops off the last entry.  You could easily make it more complex/robust.  If you want to replicate the behavior and look in Trace Options, I would suggest looking at the config for the Trend symbol in "PIVision\Scripts\app\editor\symbols".

           

          Anyway, the config file is:

           

          <button ng-click="config.removeDatasource()" > Remove </button>
          

           

          and the removeDatasource function is in the init function as:

           

          scope.config.removeDatasource = function(){
              var ds = scope.symbol.DataSources;
              var removed = ds.splice(-1,1);
              alert("Removing " + removed);
              console.log(ds);
          }
          

           

          Hopefully this helps!