In version 2.7 of CCNet graphs I made some further improvements to the manner in which graphs are configured. Now any customisations that need to be done are housed in the
GraphConfiguration.js file (in the webdashboard\javascript folder). The logic in the graph generation is now also resilient to problems such as blank or non-numeric data in the custom nodes.
If you want to include custom data in your report you should read the
Statistics Publisher Wiki page to get the it included in the report.xml file (which you will find in your artifacts folder for each project).
Configuration Setup
There are 3 areas of configuration, the:
- Recent Graphs Tab - the details of which are stored in the _recentGraphConfigurations array of configuration/option objects. The datasource of each refers to the _recentStatistics object array, that contains up to the last 20 build statistics.
- Manner in which Summary Data is calculated - this is stored in the _summaryConfiguration object that contains functions that accept successful and failed build arrays for a day and return an numeric value for each.
- Historic Builds Tab - is configured in the same way as the Recent Graphs Tab, except is defined in the _historicGraphConfigurations array and each configuration object uses the _summarisedStatistics datasource. This datasource contains, the item index, DurationInSeconds, TestsPassed (calculated properties not present in the report.xml file) and the summary data properties defined in _summaryConfiguration.
Example Customisation
Lets say that one wanted to add a complexity graph to the recent and historic tabs, the changes required would be this:
- One would edit the _recentGraphConfigurations array and add the following (assuming that the xml element node [in the report.xml file] that contains the data is called AverageComplexity):
var _recentGraphConfigurations =
[
//... Other configuration objects excluded for brevity
{
graphName: "Complexity",
dataSource: _recentStatistics,
numXTicks: _numberRecentGraphXTicks,
series: [
{ name: "Average Complexity", attributeName: "AverageComplexity", color: "blue" }
]
}
];
- Then the manner in which you want to summarise the data on a daily basis needs to be defined in summaryConfiguration. Note that all the standard summary functions are contained in the QueryFunctions.js file and include methods such as (getLastValue, select, distinct, sum, average, count, min and max). Say we wanted to display the average complexity value for the day, the configuration would be defined like this:
var _summaryConfiguration =
{
//Other attributes...
averageComplexity: function(successfulBuilds, failedBuilds) { return average(successfulBuilds, "AverageComplexity") }
};
- Lastly the summarised data collected by the function above for each day must be configured for the history tab, like this:
var _historicGraphConfigurations =
[
//Other configuration objects...
{
graphName: "Complexity",
dataSource: _summarisedStatistics,
numXTicks: _numberHistoricGraphXTicks,
series: [
{ name: "Average Complexity", attributeName: "averageComplexity", color: "blue" }
]
}
];
Note how the attribute name here corresponds to the attribute name defined in _summaryConfiguration and not the original statistic configuration element.
Hopefully the rest is self explanatory. If something does not make sense or I need to explain the configuration approach in more detail, please leave a message on this post.
Update: 7 July 2007 - Clarified some points of confusion around the source of some of the data.