# Overlaying non-associated Alarms on Trends

**URL:** <https://forum.inductiveautomation.com/t/overlaying-non-associated-alarms-on-trends/103813>\
**Category:** Ignition\
**Tags:** perspective, ignition81, vision\
**Created:** [March 17, 2025, 11:21pm UTC](https://forum.inductiveautomation.com/t/overlaying-non-associated-alarms-on-trends/103813 "2025-03-17T23:21:56Z")\
**Posts on this page:** 1\
**Showing post:** 6

<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:** [April 11, 2025, 3:29pm UTC](https://forum.inductiveautomation.com/t/overlaying-non-associated-alarms-on-trends/103813/6 "2025-04-11T15:29:39Z")

</div>

If you're just wanting a visual reference when a tag was in an alarmed state, I imagine the simplest solution would be to place some value and interval markers on the easy chart.

**Example:**  
• Add a button to the window, and give it two custom properties: alarmPath and journalData  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/f/0f743cb82efc1c8320e268853126bebeb182140b.png)

• Perform a journal query from the button's action performed event handler using the easyChart's start and end date as well as the button's alarmPath property to filter the data:

```python
easyChart = event.source.parent.getComponent('Easy Chart')
startDate = easyChart.startDate
endDate = easyChart.endDate
alarmPath = event.source.alarmPath
def getJournalData(start = startDate, end = endDate, alarm = alarmPath):
	journalData = system.alarm.queryJournal(journal = 'Journal', startDate = start, endDate = end, path = alarm).dataset
	def setJournalData():
		event.source.journalData = journalData
	system.util.invokeLater(setJournalData)
system.util.invokeAsynchronous(getJournalData)

```

• Create a couple of custom methods _[or library scripts]_ for adding markers to the chart's plot:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/e/8/e83bc179470a0025584f71ce9d6077cdceb1a2e8.png)

_addIntervalMarker custom method_

```python
#def addIntervalMarker(self, startDate, endDate):
	from org.jfree.chart.plot import IntervalMarker
	faultColor = system.gui.color(255, 0, 0, 100)
	plot = self.parent.getComponent('Easy Chart').getComponent(0).getComponent(0).chart.plot
	plot.addDomainMarker(IntervalMarker(system.date.toMillis(startDate), system.date.toMillis(endDate), faultColor))

```

_addValueMarker custom method_

```python
#def addValueMarker(self, date):
	from org.jfree.chart.plot import ValueMarker
	from java.awt import BasicStroke
	chartX = system.date.toMillis(date)
	plot = self.parent.getComponent('Easy Chart').getComponent(0).getComponent(0).chart.plot
	faultColor = system.gui.color('red')
	valueMarker = ValueMarker(chartX)
	valueMarker.setStroke(BasicStroke(3))
	valueMarker.setPaint(faultColor)
	plot.addDomainMarker(valueMarker)

```

• Finally, add the markers to the chart using the journalData property change event in the `propertyChange` event handler:

```python
if event.propertyName == 'journalData':
	easyChart = event.source.parent.getComponent('Easy Chart')
	
	# Reset existing domain markers
	plot = easyChart.getComponent(0).getComponent(0).chart.plot
	plot.clearDomainMarkers()
	
	# Locate all the active to not active intervals,
	# and put the start and end of each in a list
	journalData = event.newValue
	intervalList = []
	currentStartDate = None
	for row in xrange(journalData.rowCount):
		eventTime = journalData.getValueAt(row, 'EventTime')
		eventState = journalData.getValueAt(row, 'EventState')
		if eventState > 1 and not currentStartDate:
			currentStartDate = eventTime
		elif eventState < 2 and currentStartDate is not None:
			intervalList.append([currentStartDate, eventTime])
			currentStartDate = None
	
	# If the last entry is alarmed, extend the alarm to the end of the chart
	if currentStartDate:
		intervalList.append([currentStartDate, easyChart.endDate])
	
	# Iterate through the intervals and mark the chart
	for interval in intervalList:
		alarmStart, alarmEnd = interval
		event.source.addIntervalMarker(alarmStart, alarmEnd)
		event.source.addValueMarker(alarmStart)
		event.source.addValueMarker(alarmEnd)

```

**Result:**

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/b/4b95f6f48d62170a37e9063178386c769a5d9806.png)

**Edit:** Improved interval segmenting logic

---

_[View the full topic](https://forum.inductiveautomation.com/t/overlaying-non-associated-alarms-on-trends/103813)._
