Powerchart - Add pens via script

Hi,
Is there a possible way to add pens to a powerchart via a script.
e.g list of tagpaths?

2 Likes

Itā€™ll be more than just a list of tagpaths, but have a look at the props.pens property.
props.pens[x].data.source is where the tagpath would go.

Does someone have a script example for creating a loadable list of tags. Not sure how to best handle this but would be a nice feature to make a selectable list of preconfigured tags that can be loaded via a drop down. Thanks,

in the tagpens properties of easy chart, select the cell that contains the path, then in ā€˜cell updateā€™ you must put the ā€˜selected stringā€™ property of the drop-down component

Adhoc Trends in Ignition Exchange.

Hi All, I wonder whether anybody has got any progress on adding pens via drop-down component on Power Chart. It seems that each pen should be added by a JSON. Is it correct?
Thanks.

You'll need to add an object of this form to the pens property:

click for code
{
  "name": tag_name,
  "visible": true,
  "enabled": true,
  "selectable": true,
  "axis": "",
  "plot": 0,
  "display": {
    "type": "line",
    "interpolation": "curveLinear",
    "breakLine": true,
    "radius": 3,
    "styles": {
      "normal": {
        "stroke": {
          "color": "#63BEA2",
          "width": 1,
          "dashArray": 0,
          "opacity": 0.8
        },
        "fill": {
          "color": "#63BEA2",
          "opacity": 0.8
        }
      },
      "highlighted": {
        "stroke": {
          "color": "#63BEA2",
          "width": 1,
          "dashArray": 0,
          "opacity": 1
        },
        "fill": {
          "color": "#63BEA2",
          "opacity": 1
        }
      },
      "selected": {
        "stroke": {
          "color": "#63BEA2",
          "width": 1,
          "dashArray": 0,
          "opacity": 1
        },
        "fill": {
          "color": "#63BEA2",
          "opacity": 1
        }
      },
      "muted": {
        "stroke": {
          "color": "#63BEA2",
          "width": 1,
          "dashArray": 0,
          "opacity": 0.4
        },
        "fill": {
          "color": "#63BEA2",
          "opacity": 0.4
        }
      }
    }
  },
  "data": {
    "source": "histprov:provider:/drv:driver:/tag:tag_path",
    "aggregateMode": "default"
  }
}

But what do you need that for ? Isn't the tag browser enough ?
If you want to restrict available tags, keep in mind that the path can be changed through the pen configuration panel to display any tag, so you'll need to also disable it if you want to make sure only pre-selected tags can be displayed.

Hi Pascal,

Thanks for your reply. That is good question. Please, let me try to explain the scenario. In essence, the requirement involves some features such as:

  • Create/ Manage/ view charts (power charts), select & add tags to the chart, modify pens features. and save the charts. This is ok, as usual work.
  • In the creation chart stage, only specific tags will be shown -on the tree-, where visible tags only pertain to its department, which ultimately pertains to the userā€™s department who is defining/ selecting tags. There is a requirement, where tags pertain to different department (tag department is not a relation one to one to the tag).

Initially, we were thinking to use tag browser, which is fine as long as there arenā€™t external features (in this case department, which come from a database), that links to tags visibility/ filtering [if our exploration is not wrong]. Therefore, whether we are not wrong, we are intending to do a pre-work (tags, department, user) and show the specific tags on 1) a table or 2) a drop down box, thus these can be appended to a power chart.

I assume that the following statement is more related to the pen availability on the chart rather the tag selection on the tag browser, right?

I hope that I have explained clear enough.

Thanks.

That statement meant that in the powerchart, a user can click the little cogwheel on the top right to access a configuration panel, in which he can access pen settings, which has this:
image

Changing things there allows users to display other tags, tags that might outside of their scope.

You can use an external Tag Browse Tree Component, in conjunction with the filter extension function, to filter the tags. Just not the one that is embedded in the Power Chart. You have yet to explain how the Tag knows what department it belongs to, or how that can be determined other than just "its in a database".

You will also need to hide the Chart Settings as @pascal.fragnoud points out because from there, if a user knows the path to a tag, even one that is outside of their "department" they can access that tag.

Once you have selected a tag, through whatever method, you will need to use a script to add a new pen to the chart.

Link to their other post, with some more details.

I have this } .psc-hide_powerchart_tagpath .ia_powerChartComponent__settings__tab__content div:nth-child(22) { display: none !important; } {} { in a style class called "hide_powerchart_tagpath", that I add to powercharts' styles to hide that tag path thing.
It can be reverted by the user from the browser's tools, it's simply a matter of disabling the display: none style, but we decided it was enough and that we needed the configuration panel enough to take that chance: one would need to know this thing exists, go and find it in the css of the page, remove the property, then figure out the path to tags he shouldn't have access to.

Hi Irose, the scope/ features are little bit wider, but in summary, there are two databases, 1) which contains devices name, for us ā€œtagsā€, and its data that is already stored/ storing in a SQL database from a third party system- 2) an existing - second data base with Departments and Tags assignment. Thus, this information is intended to be append/ bulked to tag historian-Ignition in a new data base (historian). Also, user assignment is intended to be identified in this database.
Therefore, the idea is by gathering/ checking Ignition TagNames-Users Vs Tags-Department-users from database, permit to display and select tags, create and save charts.

Hello Pascal and thank you very much for the contribution, I have a question about how is the syntax to execute the action to add or remove the props.pends object from the script, I am programming a button to add a path of history from a table already configured, what I fata is to add this path to the pen, and likewise remove it, could you please give me an idea, is that so far I am starting on this topic.
Thank you very much