I have a chart (not easyChart) in Ignition 7.9 in Vision.
And I need to display some kind of marker (shape, triangle preferable) where the min and max Y values are and a text with these min and max values. Like on this picture (edited in gimp):
I was searching the forum and was able to find the “plot.addRangeMarker(ValueMarker(0.05, Color.RED, stroke))” which I’m using for showing the upper and lower limit (tolerance), but I can’t find anything about how to show this shapes and labels…
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:
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)