# Chart (not EasyChart) min & max with label

**URL:** <https://forum.inductiveautomation.com/t/chart-not-easychart-min-max-with-label/45870>\
**Category:** Ignition\
**Tags:** ignition79, vision\
**Created:** [April 21, 2021, 3:52pm UTC](https://forum.inductiveautomation.com/t/chart-not-easychart-min-max-with-label/45870 "2021-04-21T15:52:18Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [April 21, 2021, 9:33pm UTC](https://forum.inductiveautomation.com/t/chart-not-easychart-min-max-with-label/45870/2 "2021-04-21T21:33:35Z")

</div>

I used separate datasets for min and max, that I could use different shapes and renderers for the labels. Screen shots below to help illustrate.  
propertryChange script:

```auto
if event.propertyName == 'Data':
	from org.jfree.chart.labels import StandardXYItemLabelGenerator
	from org.jfree.chart.renderer.xy import XYItemRenderer
	from org.jfree.chart.labels import ItemLabelPosition
	from org.jfree.chart.labels import ItemLabelAnchor
	from org.jfree.ui import TextAnchor

	dataIn = event.source.Data
	
	#Initialize min/max values
	minDate = maxDate = dataIn.getValueAt(0,'t_stamp')
	minValue = maxValue = dataIn.getValueAt(0,'Output Temp')
	
	# Iterate throu data for min and max values and t_stamp
	for i in xrange(dataIn.rowCount):
		date = dataIn.getValueAt(i,'t_stamp')
		value = dataIn.getValueAt(i,'Output Temp')
		if value < minValue:
			minDate = date
			minValue = value
		if value > maxValue:
			maxDate = date
			maxValue = value
	
	# Write min and max values to their respecitve datasets
	# We use separate datasets to have flexibility in
	# the label positions
	headers = ['t_stamp', 'value']
	event.source.Min = system.dataset.toDataSet(headers, [[minDate, minValue]])
	event.source.Max = system.dataset.toDataSet(headers, [[maxDate, maxValue]])

	plot = event.source.chart.plot
	
	# Create a dictionary to tie dataset names to indexes.
	# This is so we can refer to them by name later,
	# just in case they're not in the same order.
	datasetNames = {}
	for i in xrange(plot.datasetCount):
		datasetNames[str(plot.getDataset(i))] = i

	# Define label anchors
	labelAnchors = {'Min':[ItemLabelAnchor.OUTSIDE5, TextAnchor.TOP_LEFT],
	                'Max':[ItemLabelAnchor.OUTSIDE1, TextAnchor.BOTTOM_LEFT]
	               }
	
	# Create labels for min and max datasets.
	for key in labelAnchors.keys():
		renderIndex, ila, ta = datasetNames[key], labelAnchors[key][0], labelAnchors[key][1]
		renderer = plot.getRenderer(renderIndex)
		renderer.setItemLabelGenerator(StandardXYItemLabelGenerator())
		renderer.setBasePositiveItemLabelPosition(ItemLabelPosition(ila, ta))
		renderer.setBaseItemLabelsVisible(True)
		plot.setRenderer(datasetNames[key], renderer)

```

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/3/1334ff5cd8b82864a0a1f2cace2f4e41cff9cd15.png)  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/8/f84ee0e135b8d0510b90a6c9dcf3e7e5abc88cf8.png)  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/3/b3363b84d3b8ad862cdf5b93206bf7b6edfb3ff8.png)  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/4/2451a6db07c405897c8cb77501465253a7cf09ae.png)  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/9/7/97ea11afc4b47391ed5797c0c4fa40f9e620ac6f.png)

---

_[View the full topic](https://forum.inductiveautomation.com/t/chart-not-easychart-min-max-with-label/45870)._
