Rockwell Automation 9307 FactoryTalk EnergyMetrix User Manual
Page 281

9
•
ReportsPlus
281
The script uses the Groups and Intervals collections and the Group, Report, Interval and
TrendChart objects. To use this script, check the Use Intervals checkbox on the MPR
script setup page. Select By Groups to run this report.
Sub Main()
Dim objGroup As Group
Dim intInterval As Interval
Dim consumption As Double
Dim trendChart As New TrendChart()
With trendChart
.XAxis.Title = Report.IntervalTypeString & " Ending
Date"
.YAxis.Title = "Consumption (kWh)"
'.XAxis.Step = 7
.XAxis.Format = AxisFormat.Date
.XAxis.CustomFormat = "MMM dd"
.YAxis.CustomFormat = "#"
.SeriesLegendBox = True
End With
For Each objGroup In Report.Groups
trendChart.SeriesLegend = objGroup.Name
For Each intInterval In Report.Intervals
consumption =
objGroup.Total(ValueType.RealEnergyNet, intInterval.StartDate,
intInterval.EndDate)
trendChart.AddData(intInterval.EndDate,
consumption)
Next intInterval
trendChart.NextSeries()
Next objGroup
Report.Add(trendChart, 0, 0, 7.5, 7.5)
End Sub
Consumption by Group Pie Chart
This sample MPR script generates a report with a pie chart showing real energy
consumption by group. It uses the Groups collection and the Group, PieChart and Report
objects. This script is set up to use Select by Groups.
Sub Main()
Dim objGroup As Group
Dim objPieChart As New PieChart()
objPieChart.Title.Text = "Consumption (kWh) by Group"
objPieChart.Border = True
For Each objGroup In Report.Groups
objPieChart.CustomFormat = objGroup.Name & " #"
objPieChart.AddData(objGroup.Name,
objGroup.Total(ValueType.RealEnergyNet))
Next
Report.Add(objPieChart , 0, 0, 4.5, 2.5)
End Sub
In this script, the group name is included in the custom format
just before each data slice is added to the pie chart. This
provide each slice with a unique label.