===Basic Area Chart=== This [[code:reports|code sample]] of a area chart report. It shows the value of a single property for a single asset. {{area_basic.png|400}} ==Customising== ^Element^Replace With^ |[ASSET]|The asset you want to report on| |[PROPERTY]|The name of the property you want to report on| |[MEASUREMENT]|The name of the measurement (ie. Temperature)| |[UNIT]|The units the measurement is in| ==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() assetname = "[ASSET]" #Our AQL query goes here query = "'" + assetname + "' ASSET ('[PROPERTY]') PROPERTY VALUES" #Get the pandas data-frame with the results. df = report.GetHistory(query) #Get the name of the column colname = df.columns[0] #Draw the area chart ax.fill_between(df.index,[0] * len(df.index),df[colname],label=colname.replace(assetname + " ",""),color='g') #Set the minimum Y value to 0 ax.set_ylim(0) #Clean up and prettify ax.margins(x=0) ax.set_xlabel("Time") ax.set_ylabel("[UNIT NAME] ([UNIT])") ax.legend(loc='lower right') report.TimeAxis(ax.xaxis) report.Grid(ax) #Save this report out. report.Save()