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)