A Simple Report
import ardi.util.mplreport
@mplreport.ardireport("Sample Report")
def CreateReport(report,args):
#Set up the report page
fig,ax = report.CreatePage(1)
report.Title()
#Fetch the report data
thedata = report.FetchHistory("'Temperature' PROPERTYEX ALLPOINTS")
#Check for incomplete data
if report.FetchFailure():
report.Failed("\n".join(report.errors))
frame = thedata.data
#Draw the lines
for colname in frame.columns:
ax.plot(frame[colname],label=colname)
#Setup the axes
ax.margins(x=0)
ax.grid()
ax.legend()
ax.set_xlabel("Time")
ax.set_ylabel("Temperature (Deg C)")
report.TimeAxis(ax.xaxis)
report.Save()
See the mplreport reference to learn more.
Notes
Note that scheduling transmission of the report is not set up at the individual-report level and is instead done using report bundles.
Creating Additional Files
You can create additional files along-side your reports. Simply save them to args.target, replacing the extension (ie. .pdf) with the target extension (ie. .xml).
These files will be available for download along-side your reports.
Creating Non-PDF Reports
If creating reports that are not PDF files, don't use the CreatePage, Title or Save functions and simply create your output file within the Python code.
Save your final output file to the path given by args.target. You can also optionally write a PNG file with the same name (replace the file extension with .png), which will be used as the thumbnail for the report.
If thumbnails aren't relevant or easy to produce, you can instead include a pre-made 'thumb.png' file in your report folder that will be used as a thumbnail for all of your reports.