# Preload pens on button parameters - Vision Ad Hoc Trend Chart

**URL:** <https://forum.inductiveautomation.com/t/preload-pens-on-button-parameters-vision-ad-hoc-trend-chart/58563>\
**Category:** Ignition Exchange\
**Created:** [April 18, 2022, 6:11pm UTC](https://forum.inductiveautomation.com/t/preload-pens-on-button-parameters-vision-ad-hoc-trend-chart/58563 "2022-04-18T18:11:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mattn1](https://avatars.discourse-cdn.com/v4/letter/m/54ee81/32.png) [@mattn1](https://forum.inductiveautomation.com/u/mattn1)\
**Post date:** [April 18, 2022, 6:11pm UTC](https://forum.inductiveautomation.com/t/preload-pens-on-button-parameters-vision-ad-hoc-trend-chart/58563/1 "2022-04-18T18:11:28Z")

</div>

First of all I love Travis’s Vision Ad Hoc Trend chart. It is flexible and a great asset to my projects.

Has anyone figure out a way to preload pens for the Ad Hoc chart. Like set a list of tagpaths as a parameter on a button so that when launching the Ad Hoc chart window the tagpaths already exist as pens on the chart?

Or if there would be someway to have it pass a saved graph when the trend page is launched?

I would appreciate any direction!

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [April 18, 2022, 7:12pm UTC](https://forum.inductiveautomation.com/t/preload-pens-on-button-parameters-vision-ad-hoc-trend-chart/58563/2 "2022-04-18T19:12:38Z")

</div>

Vision? If your trend is a popup window, try this:

> [@Indirect Tag in Easy Chart in a Popup](https://forum.inductiveautomation.com/t/indirect-tag-in-easy-chart-in-a-popup/17485/4):
>
> Even better would be to create a dataset property for tagPens in the root container of your popup window, and uni-directionally bind the easychart’s tagPens to it. Then you can pass in a tagPens dataset with your openWindow() call with any desired number of pens to display.

If your trend is in the same window with the buttons, try this:

> [@Send different parameters to an Easy Chart](https://forum.inductiveautomation.com/t/send-different-parameters-to-an-easy-chart/21007/3):
>
> Yes. The simplest way would be to create custom dataset properties on each button with the same names as the configuration properties on the EasyChart (pens, tagPens, axes…). Then in the button’s actionPerformed event, copy the datasets from the button to the chart. Set the datasets up by copy/paste in each property’s dataset editor. (Set the chart the way you want, then copy its config datasets to the corresponding button.) The actionPerformed events would look something like this: ec = e…

With Perspective, you'll want to perform a similar assignment, possibly with a script transform.

---

<div class="post-metadata">

**Author:** ![mattn1](https://avatars.discourse-cdn.com/v4/letter/m/54ee81/32.png) [@mattn1](https://forum.inductiveautomation.com/u/mattn1)\
**Post date:** [April 27, 2022, 8:55pm UTC](https://forum.inductiveautomation.com/t/preload-pens-on-button-parameters-vision-ad-hoc-trend-chart/58563/3 "2022-04-27T20:55:23Z")

</div>

Though I appreciate ptrumel’s responses, I think he may have missed what I had asked here.

I am using Travis’s Vision Ad Hoc Trend chart. Which is available in the ignition exchange.

The question was how do I navigate to a windows with his Ad Hoc Trend Template, and have it load a predetermined group of pens.

After some digging I found the existing load pens function on the load graph button. My solution was create all of the desired graphs and save them publicly using the save graph button. I added a custom property on the Ad Hoc Trend template, graphID. The graphID corresponds to the database id column. I also placed a graphID property on the window and bound the template to it. This id is the passed parameter on the navigation button that opens the trend.

I then added a script on the templates property change:

```auto
if event.propertyName == "ancestor":
	id=int(event.source.graphID)
	if id!=0:
		import system
		database = ""
		info = system.db.runPrepQuery("SELECT title, tagpens, axes FROM saved_graphs WHERE id = ?", [id], database)
		if len(info):
			chart = event.source.getComponent('Easy Chart')
			chart.title = info[0][0]
			chart.tagPens = system.dataset.fromCSV(info[0][1])
			chart.axes = system.dataset.fromCSV(info[0][2])
			chart.updateMinMaxAvg()

```

Seems to work well.
