# Vision Chart - Category Chart & XTrace

**URL:** <https://forum.inductiveautomation.com/t/vision-chart-category-chart-xtrace/103363>\
**Category:** Ignition\
**Tags:** vision, ignition81, scripting\
**Created:** [March 6, 2025, 11:52pm UTC](https://forum.inductiveautomation.com/t/vision-chart-category-chart-xtrace/103363 "2025-03-06T23:52:17Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![AIO](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/aio/32/87549_2.png) [@AIO](https://forum.inductiveautomation.com/u/AIO)\
**Post date:** [March 7, 2025, 9:38pm UTC](https://forum.inductiveautomation.com/t/vision-chart-category-chart-xtrace/103363/2 "2025-03-07T21:38:54Z")

</div>

So, [this post from lrose](https://forum.inductiveautomation.com/t/jfree-chart-click-on-rendered-data-point/38066/20) and [this one from Travis](https://forum.inductiveautomation.com/t/adding-an-annotation-to-a-category-chart/6175/2) were very helpful in getting something working on the chart with only the category bars.

 ![Basic annotation](https://us1.discourse-cdn.com/inductiveautomation/original/3X/e/6/e6f6aa4a1d0c2a1aa5ed7bbc5d15efe628df6e9a.png)

```python
from org.jfree.chart import ChartMouseListener
from org.jfree.chart.annotations import CategoryTextAnnotation
	
chartObject = self
	
class CustomChartMouseListener(ChartMouseListener):
	def chartMouseMoved(self,e):
		pass
	def chartMouseClicked(self,e):
		# Get plot, remove previous annotations
		plot = chart.getPlot()
		plot.clearAnnotations()
		
		# get chart data & create annotation
		if e.getEntity(): 
			# Get dataset(s)
			dataset = chartObject.b_MonthlyWater
			colNames = dataset.getColumnNames()
			ds = system.dataset.toPyDataSet(dataset)
			
			# Wrap in try to prevent error clicking on axis
			try:
				# Get category from entity
				category = e.getEntity().columnKey
				for row in ds:
					if row[0] == category:
						rData = (row[1], row[2])
						y = max(rData)+100 #offset so annotation is above tallest bar
				
				# Add annotation
				annoStr = str(colNames[1])+": "+str(int(rData[0]))+", "+str(colNames[2])+": "+str(int(rData[1]))
				plot.addAnnotation(CategoryTextAnnotation(annoStr, category, y))
			
			except:
				pass
	
# Ensure only 1 listener running
for listener in self.getListeners(ChartMouseListener):
     self.removeChartMouseListener(listener)
	
# Run listener
self.addChartMouseListener(CustomChartMouseListener())

```

A couple outstanding issues:

- Adding the xy category overlay breaks the function, and clicking on the chart will not produce annotations.
- Documentation suggests the annotations will support HTML, but as of yet I've been unable to produce a multi-line entry.

Will update as I progress.

---

_[View the full topic](https://forum.inductiveautomation.com/t/vision-chart-category-chart-xtrace/103363)._
