Assets Across Multiple Pages
This code sample of a line-graph report.
It shows information from several different assets - every asset of a specific type - and shows two properties per asset.
Each asset is displayed on its own page.
Customising
Element | Replace With |
---|---|
[TYPE] | The asset type you want to search for |
[PROPERTY1] etc | The names of the properties you want to report on |
The Code
import os import sys sys.path.insert(0,os.path.dirname(os.path.dirname(__file__))) import mplreport import datetime @mplreport.ardireport("Sample Report") def CreateReport(report,args): #List of properties to show properties = ['[PROPERTY1]','[PROPERTY2]'] #Format the list for the query... proplist = [] for prp in properties: proplist.append("'" + prp + "'") #Our AQL query goes here query = "'[TYPE]' OFTYPE (" + ",".join(prp) + ") PROPERTY VALUES" #Get the pandas data-frame with the results. df = report.GetHistory(query) assetnames = [] #Get list of assets... for n in df.columns: if properties[0] in n: nm = n.replace(properties[0],"").strip() if nm not in assetnames: assetnames.append(nm) #Work with the first set of axes for ast in assetnames: #Create a page containing a single plot. fig,axes = report.CreatePage(len(properties)) #Print a title block for the page. report.Title(override="Bridle " + ast) for x in range(0,len(properties)): ax = axes[x] for k in df.columns: if ast in k: if properties[x] in k: ax.plot(df[k],label=k.replace(ast + " ","")) #Clean up and prettify ax.margins(x=0) ax.set_xlabel("Time") ax.set_ylabel(properties[x]) ax.legend(loc='lower right') report.TimeAxis(ax.xaxis) report.Grid(ax) #Save this report out. report.Save()