in trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/ApacheChart.js [2575:2750]
ApachePieChart.prototype._draw3DPies = function(
pieContainer, quadWidth,
quadHeight, iGroup)
{
var svgDoc = this._svgDoc, model = this._model, yValues = model.getYValues();
var groupLabels = model.getGroupLabels(), seriesColors = model.getSeriesColors();
var pieSize = Math.min(quadWidth/2, quadHeight/2);
var pieTotal = 0;
if(iGroup == -1)
iGroup = 0;
var nPies = yValues[iGroup].length;
for (var i = 0; i < nPies; ++i)
{
pieTotal += yValues[iGroup][i];
}
var perspectiveHeight = pieSize/4, pieElems = new Array(nPies),
ringElems = new Array(nPies), edgeElems = new Array(nPies);
var dataElems = this._dataElems, animate = (this._animDuration>0);
if( perspectiveHeight> ApachePieChart._MAX_PERSPECTIVE_HEIGHT )
perspectiveHeight = ApachePieChart._MAX_PERSPECTIVE_HEIGHT;
var pathElem = svgDoc.getElementById("piePathPrototype"), pieStart = 0;
var gradientsUsed = this._gradientsUsed;
var defaultTransform = "translate(-10000, -10000)", pieAnimAngles = this._pieAnimAngles;
for (var i = 0; i < nPies; ++i)
{
pathElem = pathElem.cloneNode(false);
var valueRatio = 1 - (yValues[iGroup][i])/(pieTotal);
if(animate)
{
dataElems.push(pathElem);
pathElem.setAttribute("transform",defaultTransform);
pieAnimAngles.push(pieStart+valueRatio/2);
}
var arcBeginX, arcBeginY, arcEndX, arcEndY;
arcBeginX = pieSize*Math.cos(pieStart*Math.PI*2);
arcBeginY = pieSize*Math.sin(pieStart*Math.PI*2);
var sb = new ApacheChartBuffer();
sb.append("M0,0L").append(arcBeginX).append(",").append(arcBeginY);
arcEndX = pieSize*Math.cos((pieStart+valueRatio)*Math.PI*2);
arcEndY = pieSize*Math.sin((pieStart+valueRatio)*Math.PI*2);
if (valueRatio >= .5)
{
sb.append("A").append(pieSize).append(" ").append(pieSize).append(" 1 0 0 ");
}
else
{
sb.append("A").append(pieSize).append(" ").append(pieSize).append(" 1 1 0 ");
}
sb.append(arcEndX).append(",").append(arcEndY);
sb.append("z");
// set the centroid as expandos
if(this._tooltipsVisible)
{
pathElem.setAttribute("_apcGx", Math.round((arcBeginX+arcEndX)/3));
pathElem.setAttribute("_apcGy", Math.round((arcBeginY+arcEndY)/3));
}
if(gradientsUsed)
pathElem.setAttribute("fill", "url(#gradient"+i+")");
else
pathElem.setAttribute("fill", seriesColors[i]);
pathElem.setAttribute("stroke", seriesColors[i]);
pathElem.setAttribute("stroke-width", 1);
pathElem.setAttribute("yValueIndex", iGroup);
pathElem.setAttribute("seriesIndex", i);
if(this._tooltipsVisible)
{
pathElem.addEventListener("mouseover",this.ShowToolTipCallback,false);
pathElem.addEventListener("mouseout",this.HideToolTipCallback,false);
}
pathElem.addEventListener("click",this.ClickCallback,false);
var pathRingElem = pathElem.cloneNode(false);
var pathEdgeElem = pathElem.cloneNode(false);
if(animate)
{
dataElems.push(pathRingElem);
pathRingElem.setAttribute("transform",defaultTransform);
dataElems.push(pathEdgeElem);
pathEdgeElem.setAttribute("transform",defaultTransform);
}
pathElem.setAttribute("d", sb.toString());
sb = new ApacheChartBuffer();
sb.append("M").append(arcBeginX).append(",").append(arcBeginY);
if (valueRatio >= .5) // major arc
{
sb.append("A").append(pieSize).append(" ").append(pieSize).append(" 1 0 0 ");
}
else
{
sb.append("A").append(pieSize).append(" ").append(pieSize).append(" 1 1 0 ");
}
sb.append(arcEndX).append(",").append(arcEndY);
sb.append("v").append(perspectiveHeight);
if (valueRatio >= .5) // major arc
{
sb.append("A").append(pieSize).append(" ").append(pieSize).append(" 1 0 1 ");
}
else
{
sb.append("A").append(pieSize).append(" ").append(pieSize).append(" 1 1 1 ");
}
sb.append(arcBeginX).append(",").append(arcBeginY+perspectiveHeight);
sb.append("z");
pathRingElem.setAttribute("d", sb.toString());
sb = new ApacheChartBuffer();
sb.append("M0,0L");
sb.append(arcBeginX).append(",").append(arcBeginY);
sb.append("v").append(perspectiveHeight);
sb.append("L").append(0).append(",").append(perspectiveHeight);
sb.append("z");
sb.append("M0,0L");
sb.append(arcEndX).append(",").append(arcEndY);
sb.append("v").append(perspectiveHeight);
sb.append("L").append(0).append(",").append(perspectiveHeight);
sb.append("z");
pathEdgeElem.setAttribute("d", sb.toString());
pieStart += valueRatio;
pieElems[i] = pathElem;
ringElems[i] = pathRingElem;
edgeElems[i] = pathEdgeElem;
}
// For the top half, edges have preference over rings
var totalRatio = 0;
for (var i = 0; i< nPies; ++i)
{
if(totalRatio <= .5)
pieContainer.appendChild(ringElems[i]);
totalRatio += (yValues[iGroup][i])/(pieTotal);
}
totalRatio = 0;
for (var i = 0; i< nPies; ++i)
{
if(totalRatio <= .5)
pieContainer.appendChild(edgeElems[i]);
totalRatio += (yValues[iGroup][i])/(pieTotal);
}
// For the bottom half, rings have preference over edges
totalRatio = 0;
for (var i = 0; i< nPies; ++i)
{
if(totalRatio > .5)
pieContainer.appendChild(edgeElems[i]);
totalRatio += (yValues[iGroup][i])/(pieTotal);
}
totalRatio = 0;
for (var i = 0; i< nPies; ++i)
{
if(totalRatio > .5)
pieContainer.appendChild(ringElems[i]);
totalRatio += (yValues[iGroup][i])/(pieTotal);
}
for (var i = 0; i< nPies; ++i)
{
pieContainer.appendChild(pieElems[i]);
}
}