Line Graph of One Property on One Asset

This code sample of a line-graph report.

It contains a single property from a single asset, displayed over time.

400

Customising
ElementReplace With
[ASSET]The name of the property you want to report on
[PROPERTY]The name of the property you want to report on
[UNIT NAME]The name of the units (ie. Temperature)
[UNIT]The actual unit of measurement (ie. Deg C)
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):    
    #Create a page containing a single plot.
    fig,ax = report.CreatePage(1)
 
    #Print a title block for the page.
    report.Title()
 
    #Our AQL query goes here
    query = "('[ASSET]') ASSET ('[PROPERTY]') PROPERTY VALUES"
 
    #Get the pandas data-frame with the results.
    df = report.GetHistory(query)
 
    for k in df.columns:
        ax.plot(df[k],label=k)     
 
    #Clean up and prettify
    ax.margins(x=0)
    ax.set_xlabel("Time")    
    ax.set_ylabel("[UNIT NAME] [UNIT]")
    ax.legend()
 
    report.TimeAxis(ax.xaxis)
    report.Grid(ax)
 
    #Save this report out.
    report.Save()