# Stacked Easy Charts and Tag Browse Tree

**URL:** <https://forum.inductiveautomation.com/t/stacked-easy-charts-and-tag-browse-tree/73881>\
**Category:** Ignition\
**Tags:** vision\
**Created:** [May 18, 2023, 3:57am UTC](https://forum.inductiveautomation.com/t/stacked-easy-charts-and-tag-browse-tree/73881 "2023-05-18T03:57:53Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nick\_Martin](https://avatars.discourse-cdn.com/v4/letter/n/85e7bf/32.png) [@Nick\_Martin](https://forum.inductiveautomation.com/u/Nick_Martin)\
**Post date:** [May 18, 2023, 3:57am UTC](https://forum.inductiveautomation.com/t/stacked-easy-charts-and-tag-browse-tree/73881/1 "2023-05-18T03:57:53Z")

</div>

I want to have two or more stacked Easy Charts that share the same time axis and allow pens to be dragged in from the Tag Browse Tree to any of the charts. I can't use sub plots because they only allow tags to be added to the first plot from the Browse Tree.

I thought I would use two separate Easy Charts but the Pens Control box resizes depending on the tags added and this resizes the chart area so that it no longer matches the other chart. I don't want to hide the Pen Control box because I want operators to be able to hide or remove pens as needed.

Any tips?

---

<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:** [May 18, 2023, 12:03pm UTC](https://forum.inductiveautomation.com/t/stacked-easy-charts-and-tag-browse-tree/73881/2 "2023-05-18T12:03:06Z")

</div>

Use subplots. Override the onTagsDropped method to handle the pen placement yourself.

---

<div class="post-metadata">

**Author:** ![Raymondeverling](https://avatars.discourse-cdn.com/v4/letter/r/3be4f8/32.png) [@Raymondeverling](https://forum.inductiveautomation.com/u/Raymondeverling)\
**Post date:** [May 18, 2023, 1:27pm UTC](https://forum.inductiveautomation.com/t/stacked-easy-charts-and-tag-browse-tree/73881/3 "2023-05-18T13:27:37Z")

</div>

I have recently done this exact thing. I used a template repeater to hold the charts. I stored each chart to a udt tag and each repeaters template data to tags as well. I used a Tree View instead of the Tag Tree object and wrote custom functions to load the tags into the charts. Syncing the times is the hardest part as you need to write the times out to the repeater Template Parameters and then handle the property change on the chart template itself. If you receive the change on the originating chart, you don't want to fire it's property change again. This is not an easy task.

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [May 18, 2023, 1:32pm UTC](https://forum.inductiveautomation.com/t/stacked-easy-charts-and-tag-browse-tree/73881/4 "2023-05-18T13:32:21Z")

</div>

> [@Nick\_Martin](#):
>
> I can't use sub plots because they only allow tags to be added to the first plot from the Browse Tree.

Not true, you just have to override the onTagsDropped method as @pturmel says.

Subplots is definitely the way to go.

---

<div class="post-metadata">

**Author:** ![Nick\_Martin](https://avatars.discourse-cdn.com/v4/letter/n/85e7bf/32.png) [@Nick\_Martin](https://forum.inductiveautomation.com/u/Nick_Martin)\
**Post date:** [May 21, 2023, 10:48pm UTC](https://forum.inductiveautomation.com/t/stacked-easy-charts-and-tag-browse-tree/73881/5 "2023-05-21T22:48:59Z")

</div>

Thanks everyone! I guess my next task is to figure out how to override methods in Ignition...

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [May 22, 2023, 1:00am UTC](https://forum.inductiveautomation.com/t/stacked-easy-charts-and-tag-browse-tree/73881/6 "2023-05-22T01:00:00Z")

</div>

> [@Nick\_Martin](#):
>
> my next task is to figure out how to override method

It's easy. Just right click on the chart and select scripting. Then, enable the onTagsDropped extension function.  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/8/885674aecf45c73399fd2b051074a2b990a8d725.png)

You will need to develop a script that looks something like this:

```auto
#def onTagsDropped(self, paths):
	def setColor(row):
		colors = ['red', 'blue', 'green', 'yellow', 'orange', 'purple', 'pink', 'brown', 'cyan', 'magenta']
		colorIndex = row % len(colors)
		return colors[colorIndex]
	def setPlot():
		WEIGHT = 1
		OVERRIDE_BACKGROUND = True
		BACKGROUND_COLOR = system.gui.color(setColor(self.subplots.rowCount))
		subplotData = [WEIGHT, OVERRIDE_BACKGROUND, BACKGROUND_COLOR]
		self.subplots = system.dataset.addRow(self.subplots, self.subplots.rowCount, subplotData)
	def setTag(path):
		NAME = path.split('/')[-1]
		TAG_PATH = path
		AGGREGATION_MODE = 'MinMax'
		AXIS = 'Default Axis'
		SUBPLOT = self.tagPens.rowCount
		ENABLED = True
		COLOR = system.gui.color(setColor(self.tagPens.rowCount + 1))
		DASH_PATTERN = ''
		RENDER_STYLE = 1
		LINE_WEIGHT = 1
		SHAPE = 0
		FILL_SHAPE = True
		LABELS = False
		GROUP_NAME = ''
		DIGITAL = False
		OVERRIDE_AUTOCOLOR = True
		HIDDEN = False
		USER_SELECTABLE = True
		SORT_ORDER = ''
		USER_REMOVEABLE = False
		tagData = [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_REMOVEABLE]
		self.tagPens = system.dataset.addRow(self.tagPens, self.tagPens.rowCount, tagData)
	newPlot = []
	for path in paths:
		setPlot()
		setTag(path)

```

---

<div class="post-metadata">

**Author:** ![Nick\_Martin](https://avatars.discourse-cdn.com/v4/letter/n/85e7bf/32.png) [@Nick\_Martin](https://forum.inductiveautomation.com/u/Nick_Martin)\
**Post date:** [May 22, 2023, 8:14pm UTC](https://forum.inductiveautomation.com/t/stacked-easy-charts-and-tag-browse-tree/73881/7 "2023-05-22T20:14:05Z")

</div>

Wow, thanks so much guys. I'll have a play over the next few days and let you know how I get on.

---

<div class="post-metadata">

**Author:** ![Nick\_Martin](https://avatars.discourse-cdn.com/v4/letter/n/85e7bf/32.png) [@Nick\_Martin](https://forum.inductiveautomation.com/u/Nick_Martin)\
**Post date:** [May 24, 2023, 3:58am UTC](https://forum.inductiveautomation.com/t/stacked-easy-charts-and-tag-browse-tree/73881/8 "2023-05-24T03:58:27Z")

</div>

Thanks again for this. I tweaked the code @justinedwards.jle posted and now the chart checks the data type of the pens as they are dropped and puts Booleans on sub plot 2 and everything else on the sub plot 1. Works great 🙂

```auto
def onTagsDropped(self, paths):
		
	def setColor(row):
		colors = ['red', 'blue', 'green', 'yellow', 'orange', 'purple', 'pink', 'brown', 'cyan', 'magenta']
		colorIndex = row % len(colors)
		return colors[colorIndex]
	
	def setTag(path):
		NAME = path.split('/')[-1]
		TAG_PATH = path
		AGGREGATION_MODE = 'MinMax'
		AXIS = 'Default Axis'
		tagValue = system.tag.read(path).value
		dataType = type(tagValue). __name__
		if dataType == "bool":
			SUBPLOT = 2
		else:
			SUBPLOT = 1
		ENABLED = True
		COLOR = system.gui.color(setColor(self.tagPens.rowCount + 1))
		DASH_PATTERN = ''
		RENDER_STYLE = 1
		LINE_WEIGHT = 1
		SHAPE = 0
		FILL_SHAPE = True
		LABELS = False
		GROUP_NAME = ''
		DIGITAL = False
		OVERRIDE_AUTOCOLOR = True
		HIDDEN = False
		USER_SELECTABLE = True
		SORT_ORDER = ''
		USER_REMOVEABLE = True
		tagData = [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_REMOVEABLE]
		self.tagPens = system.dataset.addRow(self.tagPens, tagData)
	
	for path in paths:
		setTag(path) 

```
