All Downloads are FREE. Search and download functionalities are using the official Maven repository.

templates.default.pie_chart.ftlh Maven / Gradle / Ivy

Go to download

The part of the Cucumber Reports library directly responsible for reports generation.

There is a newer version: 1.3.5
Show newest version
<#assign Math=statics['java.lang.Math'] >
<#assign  scale = 0.2 >
<#assign centerScale = 3 >
<#function sum values>
	<#assign result = 0>
	<#list values as value>
		<#assign result = result + value>
	
	<#return result>


<#macro drawPieChart id width height values labels colors shadowColors pieThickness shift>
<@drawPieLayers width=width height=height values=values colors=shadowColors pieVOffset=pieThickness shift=shift /> <@drawPieBorders width=width height=height values = values colors = shadowColors pieVOffset = pieThickness shift=shift /> <@drawPieLayers width=width height=height values=values colors=colors pieVOffset=0 shift=shift /> <#assign total=sum(values)> <#list values as value> <#assign xShiftScale = 0.6> <#assign yShiftScale = 0.15> <#assign xOffset = 10> <#assign yHeight = 30> <#if total == 0> <#assign ratio="N/A"> <#else> <#assign ratio="#{100 * value / total; M0}"> ${ratio}% (${value}) ${labels[value?index]}
<#macro drawPieBorders width height values colors pieVOffset shift> <#assign total=sum(values)> <#assign accumulated = 0 > <#if total == 0> <#return> <#list values as value> <#if value gt 0> <#assign l_shift = shift> <#if value?counter == total> <#assign l_shift = 0> <#assign startAngle = 2 * Math.PI * accumulated / total > <#assign endAngle = 2 * Math.PI * (accumulated + value) / total > <#assign shiftAngle = (startAngle + endAngle) / 2 > <#assign centerX = width / centerScale + l_shift * Math.sin(shiftAngle)> <#assign centerY = height / centerScale - l_shift * Math.cos(shiftAngle)> <#assign startX = centerX + (scale * width) * Math.sin(startAngle) + shift * Math.sin(shiftAngle) > <#assign startY = centerY - (scale * height) * Math.cos(startAngle) - shift * Math.cos(shiftAngle) > <#assign accumulated = accumulated + value > <#assign accumulated = 0 > <#list values as value> <#assign startAngle = 2 * Math.PI * accumulated / total > <#assign endAngle = 2 * Math.PI * (accumulated + value) / total > <#assign shiftAngle = (startAngle + endAngle) / 2 > <#assign centerX = width / centerScale + shift * Math.sin(shiftAngle)> <#assign centerY = height / centerScale - shift * Math.cos(shiftAngle)> <#assign endX = 0> <#assign endY = 0> <#if value?index lt (values?size - 1)> <#assign endX = centerX + (scale * width) * Math.sin(endAngle) + shift * Math.sin(shiftAngle) > <#assign endY = centerY - (scale * height) * Math.cos(endAngle) - shift * Math.cos(shiftAngle) > <#else> <#assign endX = centerX + shift * Math.sin(shiftAngle) > <#assign endY = centerY - scale * height - shift * Math.cos(shiftAngle) > <#assign accumulated = accumulated + value > <#macro drawPieLayers width height values colors pieVOffset shift> <#assign total=sum(values)> <#assign accumulated = 0 > <#if total == 0> <#return> <#list values as value> <#if value gt 0> <#assign l_shift = shift> <#if value?counter == total> <#assign l_shift = 0> <#assign startAngle = 2 * Math.PI * accumulated / total > <#assign endAngle = 2 * Math.PI * (accumulated + value) / total > <#assign shiftAngle = (startAngle + endAngle) / 2 > <#assign centerX = width / centerScale + l_shift * Math.sin(shiftAngle)> <#assign centerY = height / centerScale - l_shift * Math.cos(shiftAngle)> <#assign radiusX = scale * width> <#assign radiusY = scale * height> <#assign pieParts = 5> <#list 0..(pieParts - 1) as j> <#assign angleDiff = endAngle - startAngle > <#assign startX = centerX + (scale * width) * Math.sin(startAngle + j * angleDiff / pieParts) + l_shift * Math.sin(shiftAngle) > <#assign startY = centerY - (scale * height) * Math.cos(startAngle + j * angleDiff / pieParts) - l_shift * Math.cos(shiftAngle) > <#assign endX = centerX + (scale * width) * Math.sin(startAngle + (j + 1) * angleDiff / pieParts) + l_shift * Math.sin(shiftAngle) > <#assign endY = centerY - (scale * height) * Math.cos(startAngle + (j + 1) * angleDiff / pieParts) - l_shift * Math.cos(shiftAngle) > <#assign accumulated = accumulated + value >




© 2015 - 2024 Weber Informatics LLC | Privacy Policy