Subplots are not generating, Colors are hidden but generating randomly - V8.1.32

Hi Everyone,
I’ve written a script to load some tag pens onto an Easy Chart. I want subplots to be generated based on the available unit of measures. While the axes are being generated correctly from the unit of measures, the subplots are being ignored. Can anyone explain why this is happening? When I use the Easy Chart Customizer, all my tags are placed on subplot 1, even though I’m passing in a dataset that defines the subplot column.

I left the color column empty for all tag pens and selected auto colors on the Easy Chart. Visually, the Easy Chart displays tag pens with different colors. However, when I open the Easy Chart Customizer, all the colors appear the same, making it difficult to identify which colors belong to which tag pens. Can anyone help explain this?

tagPenHeader = ["Parent_Window", "Name", "Current_Value","Tag_Path","Sub_Plot","Axis","Enabled","Hidden","Color","Group_Name",
				"Dash_Pattern","Render_Style","Line_Weight", "Shape", "Fill_Shape","Aggregation_Mode","Labels","Digital", "Override_Autocolor",
				"User_Selectable","Sort_Order", "User_Removable","UOM"]

axisHeader = ["Name","Label","Type","Label_Color","Tick_Label_Color", "Tick_Mark_Color","Position","Invert","Auto_Range","Auto_Range_Incl_Zero","Auto_Range_Margin",
				"Lower_Bound","Upper_Bound","Auto_Tick_Units","Tick_Unit", "Grid_Unit","Number_Format", "Log_Label_Style","Symbol_String", "Grid_Bands_Visible", 
				"Grid_Band_Color","Grid_Band_Alternate_Color"]				

subplotHeader = ["Weight","Override_Background","Override_Background_Color"]
				

dataset = event.source.parent.parent.getComponent('ExpandedViewGroup').getComponent('Table').data
tableDataset = system.dataset.toPyDataSet(dataset)

easyChartList = []
axisList = []
subplotList = []

#Easy Chart constants

enabled = True
hidden = False
color = None
groupName = ""
dashPattern = ""
renderStyle = 4
lineWeight = 1
shape = ""
fillShape = 1
aggregationMode = "MinMax"
labels = True
digital = False
overrideAutoColor = False
userSelectable = False
sortOrder = ""
userRemovable = False

#Axis Constants
axisType = "Numeric"
labelColor = None
tickLabelColor = None
tickMarkColor = None
position = None
invert = True
autoRange = True
autoRangeWithZero = False
autoRangeMargin = .05
lowerBound = None
upperBound = None
autoTickUnits = True
tickUnit = None
gridUnit = None
numberFormat = None
labelStyle = None
symbolString = None
gridBandsVisible = None
gridBandColor = None
gridBandAltColor = None

#Subplot Constants
weight = 1
overrideColor = None
overrideBackground = False



#first find all unit of measures
def unitOfMeasures(dataset):
	uomList = []
	for row in dataset:
		uom = row["UOM"]
		uomList.append(uom)
	return uomList
	
uomList = list(set(item.upper() for item in unitOfMeasures(tableDataset))) #Remove duplicates, and ignore case

def createAxis(numberOfAxis, uomList):
	for item in range(len(uomList)):
		name = numberOfAxis[item+1]
		uomLabel = uomList[item]
		temp = [name,uomLabel,axisType,labelColor,tickLabelColor, tickMarkColor,position,invert,autoRange,autoRangeWithZero,autoRangeMargin,
						lowerBound,upperBound,autoTickUnits,tickUnit, gridUnit,numberFormat, labelStyle,symbolString, gridBandsVisible, 
						gridBandColor,gridBandAltColor]
		axisList.append(temp)
	return axisList
	
def createSubplots(numberOfSubplots, uomList):
	for item in range(len(uomList)):
		name = numberOfSubplots[item+1]
		uomLabel = uomList[item]
		temp = [weight,overrideBackground, overrideColor]
		subplotList.append(temp)
	return subplotList

#Number of Axis and subplots
numberOfAxis = list(range(len(uomList)+1))
numberOfSubplots = list(range(len(uomList)+1))

axisList = createAxis(numberOfAxis, uomList)
axisData = system.dataset.toDataSet(axisHeader, axisList)

subplotList = createSubplots(numberOfSubplots, uomList)
subplotData = system.dataset.toDataSet(subplotHeader, subplotList)


for index,uomValue in enumerate(uomList):
	axis = numberOfAxis[index]+1
	subplot = numberOfSubplots[index]+1
	for rows in tableDataset:
		uom = rows["UOM"]
		uom = uom.upper()
		parentWindow = rows["Parent Window"]
		tagPath = rows["Tag Path"]
		deviceLabel = rows["Device Label"]
		print uom
		print uomValue
		if uom == uomValue:
			temp = [parentWindow, deviceLabel, 0.0,tagPath,subplot,axis,enabled,hidden,color,groupName,
							dashPattern,renderStyle,lineWeight, shape, fillShape,aggregationMode,labels,digital, overrideAutoColor,
							userSelectable,sortOrder, userRemovable,uom]
			print len(temp)
			easyChartList.append(temp)

easyChartData = system.dataset.toDataSet(tagPenHeader,easyChartList)

window = system.nav.openWindow('Trending/Quick Chart', {"allTagPens": easyChartData, "axisData":axisData, "subplotData":subplotData})
#system.nav.closeParentWindow(event)

Did you define subplots in the customizer? Only defined subplot numbers are honored. (You can also generate the subplots config dataset dynamically.)

Hi Phil, I want all this stuff to be dynamic. I am defining the subplots when I pass in the tag pen Dataset.
image

The subplots have a binding that points to my root container custom properties.

That doesn't exactly answer my question. Do the subplot numbers in the pens exist in the subplots dataset?

(Show them to us, perhaps?)

Sorry about that. Yes, the tag pen dataset looks correct:

In the easy chart customizer, the tag pens do not match this dataset.

And what's in the subplots dataset?

Consider making your bindings to your root container datasets bidirectional, so changes from the customizers will propagate and can be easily transferred to whatever calls this window.

I used the columns it had by default. Here is a snippet of the dataset, and what the subplots look like in the easy chart customizer:


Are you sure the tag pens dataset is showing an integer column type for the subplot column?

(When dynamically creating datasets for the chart components, it is usually wise to explicitly set the right column types with the DatasetBuilder instead of system.dataset.toDataSet().)

Yes, I am truly baffled.

Copy your datasets to the clipboard and paste that text here, formatted as code. (The Preformatted text button in the comment editor.)

A simple example of tag pens:

"#NAMES"
"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_REMOVABLE"
"#TYPES"
"str","str","str","str","I","B","clr","str","I","F","I","B","B","str","B","B","B","B","I","B"
"#ROWS","2"
"CPU","[Forum12main/superm81x:system]gateway/performance/cpu usage","MinMax","Default Axis","1","true","color(85,85,255,255)","","1","1.0","0","true","false","","false","false","false","true",,"false"
"Mem","[Forum12main/superm81x:system]gateway/performance/memory utilization","MinMax","Default Axis","2","true","color(85,255,85,255)","","1","1.0","0","true","false","","false","false","false","true",,"false"

and corresponding subplots:

"#NAMES"
"WEIGHT","OVERRIDE_BACKGROUND","OVERRIDE_BACKGROUND_COLOR"
"#TYPES"
"I","B","clr"
"#ROWS","2"
"1","false","color(255,255,255,255)"
"1","false","color(255,255,255,255)"

Tag Pen Dataset

"#NAMES"
"Parent_Window","Name","Current_Value","Tag_Path","Sub_Plot","Axis","Enabled","Hidden","Color","Group_Name","Dash_Pattern","Render_Style","Line_Weight","Shape","Fill_Shape","Aggregation_Mode","Labels","Digital","Override_Autocolor","User_Selectable","Sort_Order","User_Removable","UOM"
"#TYPES"
"str","str","D","str","I","I","B","B","str","str","str","I","I","str","I","str","B","B","B","B","str","B","str"
"#ROWS","12"
"Blender Graphics","FT103082 GPM","0.0","[IgnitionHistorical]Instruments/BS103/FT103082/VolumeFlowrate","1","1","true","false",,"","","4","1","","1","MinMax","true","false","false","false","","false","GPM"
"Blender Graphics","FT103059 GPM","0.0","[IgnitionHistorical]Instruments/BS103/FT103059/VolumeFlowrate","1","1","true","false",,"","","4","1","","1","MinMax","true","false","false","false","","false","GPM"
"Blender Graphics","FT103099 GPM","0.0","[IgnitionHistorical]Instruments/BS103/FT103099/VolumeFlowrate","1","1","true","false",,"","","4","1","","1","MinMax","true","false","false","false","","false","GPM"
"Blender Graphics","FT103437 GPM","0.0","[IgnitionHistorical]Instruments/BS103/FT103437/VolumeFlowrate","1","1","true","false",,"","","4","1","","1","MinMax","true","false","false","false","","false","GPM"
"CIP 1 Graphics","FT501003 gpm","0.0","[IgnitionHistorical]Instruments/CIP1/FT501003/Reading","1","1","true","false",,"","","4","1","","1","MinMax","true","false","false","false","","false","GPM"
"CIP 1 Graphics","CT501008 mS","0.0","[IgnitionHistorical]Instruments/CIP1/CT501008/Reading","2","2","true","false",,"","","4","1","","1","MinMax","true","false","false","false","","false","MS"
"CIP 1 Graphics","PT501002 psi","0.0","[IgnitionHistorical]Instruments/CIP1/PT501002/Reading","3","3","true","false",,"","","4","1","","1","MinMax","true","false","false","false","","false","PSI"
"Blender Graphics","PU103430 Hz","0.0","[IgnitionHistorical]Devices/BS103/PU103430/VFD/ActualSpeed","4","4","true","false",,"","","4","1","","1","MinMax","true","false","false","false","","false","HZ"
"Blender Graphics","TT103557 °F","0.0","[IgnitionHistorical]Instruments/BS103/TT103557/Reading","5","5","true","false",,"","","4","1","","1","MinMax","true","false","false","false","","false","°F"
"Blender Graphics","FT103059 °F","0.0","[IgnitionHistorical]Instruments/BS103/FT103059/Temperature","5","5","true","false",,"","","4","1","","1","MinMax","true","false","false","false","","false","°F"
"Blender Graphics","FT103099 °F","0.0","[IgnitionHistorical]Instruments/BS103/FT103099/Temperature","5","5","true","false",,"","","4","1","","1","MinMax","true","false","false","false","","false","°F"
"CIP 1 Graphics","TT501004 °F","0.0","[IgnitionHistorical]Instruments/CIP1/TT501004/Reading","5","5","true","false",,"","","4","1","","1","MinMax","true","false","false","false","","false","°F"

Axis Dataset

"#NAMES"
"Name","Label","Type","Label_Color","Tick_Label_Color","Tick_Mark_Color","Position","Invert","Auto_Range","Auto_Range_Incl_Zero","Auto_Range_Margin","Lower_Bound","Upper_Bound","Auto_Tick_Units","Tick_Unit","Grid_Unit","Number_Format","Log_Label_Style","Symbol_String","Grid_Bands_Visible","Grid_Band_Color","Grid_Band_Alternate_Color"
"#TYPES"
"I","str","str","str","str","str","str","B","B","B","D","str","str","B","str","str","str","str","str","str","str","str"
"#ROWS","5"
"1","GPM","Numeric",,,,,"true","true","false","0.05",,,"true",,,,,,,,
"2","MS","Numeric",,,,,"true","true","false","0.05",,,"true",,,,,,,,
"3","PSI","Numeric",,,,,"true","true","false","0.05",,,"true",,,,,,,,
"4","HZ","Numeric",,,,,"true","true","false","0.05",,,"true",,,,,,,,
"5","°F","Numeric",,,,,"true","true","false","0.05",,,"true",,,,,,,,

SubPlots Dataset:

"#NAMES"
"Weight","Override_Background","Override_Background_Color"
"#TYPES"
"I","B","str"
"#ROWS","5"
"1","false",
"1","false",
"1","false",
"1","false",
"1","false",

Your subplots dataset is supplying a string column where the component expects a java color column.

In your tag pens dataset, your subplot column name has an underscore.

I am going to give these edits a try. One moment please.

The component let me delete the override Color and override background columns. The new dataset looks like this:

"#NAMES"
"Weight"
"#TYPES"
"I"
"#ROWS","5"
"1"
"1"
"1"
"1"
"1"

I updated the column name to "SubPlot". It is working now. Thank you Phil!

1 Like