Comments (9)
I think I can help you. Give me some time, I will come back to you within the next days.
from reportgenerator.
Thanks for your quick and supportive response. 😄
Thanks for the help.
from reportgenerator.
@arpitgold:
I created a plugin for you, that renders the chart.
Please download this project, and place the compiled DLL next to ReportGenerator.exe. Then call ReportGenerator.exe with -reporttypes:HtmlChart.
This will create a single file report that contains the chart (and unfortunately the footer).
In Jenkins you can publish this file as an artifact or with the HTML Publisher Plugin.
Then you could create a simple HTML page, that embeds the charts from all of your projects as iframes.
This is the code of the plugin:
using System;
using System.Collections.Generic;
using System.Linq;
using Palmmedia.ReportGenerator.Parser.Analysis;
using Palmmedia.ReportGenerator.Properties;
using Palmmedia.ReportGenerator.Reporting;
using Palmmedia.ReportGenerator.Reporting.Rendering;
namespace MyCompany.CustomReportTypes
{
/// <summary>
/// Creates HTML with chart component only (no reports for classes are generated).
/// </summary>
[System.ComponentModel.Composition.Export(typeof(IReportBuilder))]
public class HtmlChartReportBuilder : HtmlSummaryReportBuilder
{
/// <summary>
/// Gets the report type.
/// </summary>
/// <value>
/// The report type.
/// </value>
public override string ReportType
{
get { return "HtmlChart"; }
}
/// <summary>
/// Creates the summary report.
/// </summary>
/// <param name="reportRenderer">The report renderer.</param>
/// <param name="summaryResult">The summary result.</param>
public override void CreateSummaryReport(IReportRenderer reportRenderer, SummaryResult summaryResult)
{
if (reportRenderer == null)
{
throw new ArgumentNullException("reportRenderer");
}
if (summaryResult == null)
{
throw new ArgumentNullException("summaryResult");
}
this.TargetDirectory = System.IO.Path.Combine(this.TargetDirectory, "chart");
System.IO.Directory.CreateDirectory(this.TargetDirectory);
reportRenderer.BeginSummaryReport(this.TargetDirectory, ReportResources.Summary);
var historicCoverages = this.GetOverallHistoricCoverages(summaryResult.Assemblies.SelectMany(a => a.Classes));
if (historicCoverages.Any(h => h.CoverageQuota.HasValue || h.BranchCoverageQuota.HasValue))
{
reportRenderer.Chart(historicCoverages);
}
reportRenderer.CustomSummary(summaryResult.Assemblies);
reportRenderer.SaveSummaryReport(this.TargetDirectory);
}
/// <summary>
/// Gets the overall historic coverages from all classes.
/// </summary>
/// <param name="classes">The classes.</param>
/// <returns>
/// The overall historic coverages from all classes.
/// </returns>
private IEnumerable<HistoricCoverage> GetOverallHistoricCoverages(IEnumerable<Class> classes)
{
var historicCoverages = classes
.SelectMany(c => c.HistoricCoverages);
var executionTimes = historicCoverages
.Select(h => h.ExecutionTime)
.Distinct();
var result = new List<HistoricCoverage>();
foreach (var executionTime in executionTimes)
{
var historicCoveragesOfExecutionTime = historicCoverages
.Where(h => h.ExecutionTime.Equals(executionTime))
.ToArray();
result.Add(new HistoricCoverage(executionTime)
{
CoveredLines = historicCoveragesOfExecutionTime.Sum(h => h.CoveredLines),
CoverableLines = historicCoveragesOfExecutionTime.Sum(h => h.CoverableLines),
CoveredBranches = historicCoveragesOfExecutionTime.Sum(h => h.CoveredBranches),
TotalBranches = historicCoveragesOfExecutionTime.Sum(h => h.TotalBranches),
TotalLines = historicCoveragesOfExecutionTime.Sum(h => h.TotalLines)
});
}
return result;
}
}
}
from reportgenerator.
Thanks @danielpalme , 👍
A big thank for your support and fast response.
I will check it and get back to you if I need any further assistance.
from reportgenerator.
Hi @danielpalme,
It works as exactly as I required.
But the issue is I am calling as -reporttypes:Html;XmlSummary;HtmlChart .
Html and HtmlChart both creates index.htm. Html report's "index.htm" file get overriden.
Can we create seperate files for each report?
from reportgenerator.
Easiest solution would be, to save the HtmlChart report to a different directory.
Just add the following lines to the CreateSummaryReport method:
this.TargetDirectory = System.IO.Path.Combine(this.TargetDirectory, "chart");
System.IO.Directory.CreateDirectory(this.TargetDirectory);
from reportgenerator.
Thanks @danielpalme, its works like a charm.
Again thanks for all your support. 👍
from reportgenerator.
I am getting unknown Report Type - I added the dll MyCompany.ReportGeneratorExtensions.dll next to the ReportGenerator.exe - can you help?
from reportgenerator.
Please use latest version 2.3.2. Custom report types are only supported with version >2
from reportgenerator.
Related Issues (20)
- Issue with -reporttypes field HOT 1
- Wiki Edit HOT 1
- Unable to convert opencoverxml file into corbertura.xml file using ReportGenerator in Azure Devops Pipeline HOT 3
- Release notice confuses me. HOT 1
- Why is the reportgenerator command installed using the dotent not working? HOT 2
- Report generated is always at version 5.1.14.0 on AzureDevops HOT 1
- Allow to specify the root path HOT 1
- Question: Is the format created by the CTC++ tool supported as input for report generator? HOT 2
- MS Coverage output isn't cleaning compiler generated methods/types HOT 13
- Ability to exclude classes from Risk Hotspots HOT 6
- Error while converting jacoco report to cobertura HOT 12
- Suggestion for new report type: MarkdownTableShortSummary HOT 2
- Sonarqube format clashes with DeterministicSourcePaths=true HOT 5
- Azure DevOps task option publishCodeCoverageResults doesn't work with relative targetdir path HOT 2
- Azure pipeline failure due to dependency on NodeJS version 6 HOT 3
- Docs/readmes: add info about `minimumCoverageThresholds` HOT 2
- ReportGenerator 5.3.1 fails on self hosted azure devops agent running on Amazon Linux 2 arm64 instance (t4g) HOT 2
- Question about lcov conversion HOT 4
- Strange source file references in a HTML report from dotnet-coverage on Linux HOT 1
- 5.3.5 has broken the pipeline due to "New Exception" being thrown due to `rawName` HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from reportgenerator.