How-to
Easy Chart pen names come from the leaf tag name
Short answer
Every Easy Chart pen takes its default display name from the last element of the tag path, so dropping Gallons from TK1, TK2 and TK3 yields Gallons, Gallons 1 and Gallons 2. The tag paths stay correct; only the labels collide. Implement the onTagsDropped extension function and build each pen name from the UDT instance element of the path, for example TK1 Gallons.
On this page
Easy Chart pens take their default display name from the last element of the tag path, so dropping Gallons from TK1, TK2 and TK3 of a Storage_Tank UDT puts three pens named Gallons on one chart. The chart de-duplicates the identical names by appending an index: Gallons, Gallons 1, Gallons 2. The tag paths stay unique and every pen plots the correct tank; only the labels collide. The fix is to implement the onTagsDropped extension function on the chart and write the UDT instance element of the path into the pen name, so the legend reads TK1 Gallons, TK2 Gallons, TK3 Gallons.
Why the chart numbers identical pens #
The Easy Chart is documented to add pens automatically when tags are dropped from the tag tree, and it names each pen after the tag's leaf element. Your UDT definition gives every instance the same member name, so the leaf element is Gallons in every path, and the chart's de-duplication appends 1, 2, 3 to keep the legend entries distinct.
This is a chart display issue, not a tag fault or a historian fault. The dropped paths look like [default]Tanks/TK1/Gallons and [default]Tanks/TK2/Gallons, so they remain unique, and the instance name you want is already inside the path. The pen name is a separate property of the pen, which means you can rebuild it from the path at drop time.
Keep the two faults apart: a pen with a good name but no trace at all is a data problem, covered in the article on an Easy Chart pen that shows no historian data. Here the trace is correct and only the label is wrong.
Choose between a manual rename and the drop script #
| Approach | Where it lives | Effect on runtime drops | Use when |
|---|---|---|---|
| Manual pen rename | Chart customizer, pen name field | None; new pens still get leaf-name defaults | A fixed pen set you configure in the Designer |
| onTagsDropped extension function | Easy Chart component, extension functions | Every dropped pen is named from the path | Operators drag tags onto the chart at runtime |
Commit to the extension function whenever operators build their own trends by drag-and-drop. It is the only option that keeps the label correct after the chart is deployed, and it costs one small script on one component. Use a manual rename only for pens you pre-configure yourself, and expect those labels to survive because nothing re-creates them at runtime.
Build the pen name from the tag path #
Strip the provider prefix, split on the slash, and join the last two elements: the UDT instance and the member tag. This helper turns [default]Tanks/TK1/Gallons into TK1 Gallons. The folder layout is an illustration; substitute your own.
def penNameFromPath(tagPath):
# '[default]Tanks/TK1/Gallons' -> 'TK1 Gallons'
parts = str(tagPath).split(']')[-1].split('/')
if len(parts) < 2:
return parts[-1]
return parts[-2] + ' ' + parts[-1]
Count elements from the end of the path, not the beginning. Folder depth above the instance varies between sites and areas, but the instance is always the parent of the member tag. If your member sits one level deeper, for example a nested Gallons inside a sub-folder of the UDT, read the element at the third position from the end instead.
Wire it into the Easy Chart #
- Open the Vision window containing the Easy Chart in the Designer and open the component's extension functions.
- Select onTagsDropped. Use the argument names the editor template gives you for the list of dropped tag paths; the names below assume the template calls it
tagPaths. - Paste the helper function from the previous section above your row-building code.
- Build each new pen row from the chart defaults. The reference pattern for this function starts from a default row of 20 fields in this order: name, tag_path, aggregation_mode, axis, subplot, enabled, color, dash_pattern, render_style, line_weight, shape, fill_shape, labels, group_name, digital, override_autocolor, hidden, user_selectable, sort_order, user_removable. Verify that order against the tagPens property in the Property Editor of your installed version before indexing into it.
- Overwrite field 0 with the derived name and field 1 with the dropped path, then add the row to the dataset:
def onTagsDropped(self, tagPaths):
default = ['DefaultName', '[~]DefaultPath', 'MinMax', 'Default Axis', 1,
True, 'color(255,0,0,255)', '', 1, 1.0, 0, True, False, '',
False, False, False, True, None, False]
for path in tagPaths:
row = list(default)
row[0] = penNameFromPath(path) # name
row[1] = str(path) # tag_path
self.tagPens = system.dataset.addRow(self.tagPens, row)
system.dataset.addRow returns the updated dataset, so assign it back to self.tagPens as shown. Keep the default aggregation, axis and color values unless you have a reason to change them, because implementing this function suppresses the chart's automatic pen creation entirely: from then on, every pen on this chart comes from your script.
If your display layer is Perspective rather than Vision, the equivalent component is the Power Chart, and its pen behavior is configured in a different place; the page on configuring Ignition Perspective Power Chart pen control defaults covers those settings.
Where this naming still breaks #
| Symptom | Cause | Correction |
|---|---|---|
| Pen named Tanks Gallons or Gallons Gallons | Wrong index taken from the end of the split path | Print the parts list to the console and pick the element holding the instance |
Name shows a [default]TK1 style prefix |
Provider bracket not stripped before splitting | Split on the closing bracket first, as the helper does |
| Script error on drop, no new pen added | Row length or value type does not match the tagPens columns | Compare the row length with the dataset column count and check each field's type |
| Pens still read Gallons 1 | Function saved on a different chart instance than the one operators use | Check the extension function on the component in the window the client actually opens |
| Two tanks share an instance name in different areas | A two-element name is not unique across the site | Add a third path element, the area folder, to the name |
Prove each pen plots the right tank #
- Run the window in the Vision Client or the Designer preview and drag Gallons from TK1, TK2 and TK3 onto the chart.
- Read the legend: each pen must show TK1 Gallons, TK2 Gallons, TK3 Gallons, with no numeric suffixes.
- Open each pen's settings and compare its tag path with its name. The TK2 pen must point at the TK2 path, not the first path the chart found.
- Change one tank's level, or pick tanks known to sit at different levels, and confirm the trace behind each labeled pen moves as that tank moves.
When all four checks pass, the label and the data agree, and the numbering problem is gone for every future drop on that chart.
Questions asked
How do I show the UDT instance name on an Easy Chart pen?
Implement the onTagsDropped extension function on the Vision Easy Chart component. In that function, derive the pen name from the dropped tag path instead of accepting the default leaf name: split the path, take the element that holds the UDT instance, and write it into field 0 of the new pen row before adding it to the tagPens dataset.
Why does the chart label my pens Gallons 1 and Gallons 2?
The suffix is the chart's de-duplication of identical leaf names. Each Storage_Tank instance carries a member named Gallons, so every dropped pen would share one display name and the chart appends an index. Give each pen a unique name at drop time, such as TK1 Gallons, and the index is no longer added.
Where is the onTagsDropped signature documented?
In the Vision Easy Chart section of the Ignition User Manual, under the scripting or extension function pages. The manual states the function is called when tags are dropped from the tag tree onto the chart, and that implementing it suppresses the default automatic pen creation. Use the argument names shown in the function editor template in your Designer version.
How do I get the instance name from a tag path in a script?
Convert the path to a string, split it on the closing bracket of the provider prefix and keep the part after it, then split that on the slash and read the second element from the end. That element is the folder holding the member tag. Adjust the index if your UDT nests the member inside sub-folders.
Does renaming the pen change what gets stored?
No. The pen name is a display property of the chart only. The tag path, the history enablement on the tag and what the historian stores are all unchanged. Renaming fixes the legend and the pen settings dialog; it does not touch the recorded data or the tag configuration.