Commit d621e895 authored by GoshaZotov's avatar GoshaZotov

changed code (+delete unused)

parent d4b33c51
......@@ -5937,7 +5937,6 @@ drawAreaChart.prototype =
{
//ширина линии
var brush;
var FillUniColor;
var pen;
var seria, dataSeries;
......@@ -7081,7 +7080,6 @@ drawHBarChart.prototype =
_DrawBars3D: function()
{
var t = this;
var processor3D = this.cChartDrawer.processor3D;
var drawVerges = function(i, j, paths, onlyLessNull, k, isNotPen, isNotBrush)
{
......@@ -7483,16 +7481,16 @@ drawPieChart.prototype =
if(this.cChartDrawer.processor3D.view3D.rAngAx)
{
this.properties3d = this.cChartDrawer.processor3D.calculatePropertiesForPieCharts();
this._reсalculatePie3D();
this._recalculatePie3D();
}
else
{
this._reсalculatePie3DPerspective();
this._recalculatePie3DPerspective();
}
}
else
{
this._reсalculatePie();
this._recalculatePie();
}
},
......@@ -7512,92 +7510,7 @@ drawPieChart.prototype =
}
},
_drawPie3D_Slow: function ()
{
var numCache = this._getFirstRealNumCache();
var props = this.cChartSpace.getParentObjects();
var brush, pen, val;
var path;
for(var n = 0; n < this.paths.series.length; n++)
{
for (var i = 0, len = numCache.length; i < len; i++) {
val = numCache[i];
brush = val.brush;
if(n === 0 || n === this.paths.series.length - 1)
{
pen = val.pen;
}
else
{
pen = null;
}
path = this.paths.series[n][i];
var duplicateBrush = brush;
if(n !== this.paths.series.length - 1)
{
var duplicateBrush = brush.createDuplicate();
var cColorMod = new AscFormat.CColorMod;
cColorMod.val = 35000;
cColorMod.name = "shade";
duplicateBrush.addColorMod(cColorMod);
duplicateBrush.calculate(props.theme, props.slide, props.layout, props.master, new AscFormat.CUniColor().RGBA);
}
this.cChartDrawer.drawPath(path, pen, duplicateBrush);
}
}
},
_reсalculatePie3D_Slow: function ()
{
var trueWidth = this.chartProp.trueWidth;
var trueHeight = this.chartProp.trueHeight;
var numCache = this._getFirstRealNumCache();
var sumData = this.cChartDrawer._getSumArray(numCache, true);
var radius = Math.min(trueHeight, trueWidth) / 2;
if(radius < 0)
radius = 0;
var xCenter = this.chartProp.chartGutter._left + trueWidth/2;
var yCenter = this.chartProp.chartGutter._top + trueHeight/2;
var startAngle = this.cChartDrawer.processor3D.angleOy ? this.cChartDrawer.processor3D.angleOy : 0;
var startAngle3D = startAngle !== 0 && startAngle !== undefined ? this._changeAngle(radius, Math.PI/2, startAngle, xCenter, yCenter, this.properties3d) : 0;
this.tempAngle = Math.PI/2 + startAngle;
this.angleFor3D = Math.PI/2 - startAngle3D;
//рисуем против часовой стрелки, поэтому цикл с конца
var depth = this.properties3d.depth;
for(var n = 0; n < depth; n++)
{
if(!this.paths.series)
this.paths.series = [];
for (var i = numCache.length - 1; i >= 0; i--)
{
var angle = Math.abs((parseFloat(numCache[i].val / sumData)) * (Math.PI * 2));
if(!this.paths.series[n])
this.paths.series[n] = [];
if(sumData === 0)//TODO стоит пересмотреть
this.paths.series[n][i] = this._calculateEmptySegment(radius, xCenter, yCenter);
else
this.paths.series[n][i] = this._calculateSegment3D(angle, radius, xCenter, yCenter, n, i);
}
}
},
_reсalculatePie: function ()
_recalculatePie: function ()
{
var trueWidth = this.chartProp.trueWidth;
var trueHeight = this.chartProp.trueHeight;
......@@ -7622,7 +7535,7 @@ drawPieChart.prototype =
this.paths.series[i] = this._calculateEmptySegment(radius, xCenter, yCenter);
else
this.paths.series[i] = this._calculateSegment(angle, radius, xCenter, yCenter);
};
}
},
_getFirstRealNumCache: function()
......@@ -7656,22 +7569,6 @@ drawPieChart.prototype =
return path;
},
_calculateSegment3D_Slow: function (angle, radius, xCenter, yCenter, depth, i)
{
if(isNaN(angle))
return null;
var startAngle = (this.tempAngle);
var swapAngle = angle;
var endAngle = startAngle + angle;
var path = this._calculateArc3D(radius, startAngle, swapAngle, xCenter, yCenter, depth, i);
this.tempAngle += angle;
return path;
},
_calculateEmptySegment: function(radius, xCenter, yCenter)
{
var path = new Path();
......@@ -7726,68 +7623,6 @@ drawPieChart.prototype =
return path;
},
_calculateArc3D_Slow : function(radius, stAng, swAng, xCenter, yCenter, depth, seriaNum)
{
var radius1 = this.properties3d.radius1;
var radius2 = this.properties3d.radius2;
var pxToMm = this.chartProp.pxToMM;
var t = this;
var x0, y0, radiusSpec;
var calculateProps = function()
{
if(t.usually3dPropsCalc && t.usually3dPropsCalc[seriaNum])
{
swAng = t.usually3dPropsCalc[seriaNum].swAng;
stAng = t.usually3dPropsCalc[seriaNum].stAng;
radiusSpec = t.usually3dPropsCalc[seriaNum].radiusSpec;
x0 = t.usually3dPropsCalc[seriaNum].x0;
yCenter = yCenter + t.properties3d.depth / 2 - depth;
y0 = (yCenter - radiusSpec*Math.sin(stAng));
}
else
{
swAng = t._changeAngle(radius, stAng, swAng, xCenter, yCenter, t.properties3d);
stAng = t.angleFor3D;
//корректируем центр
yCenter = yCenter + t.properties3d.depth / 2 - depth;
radiusSpec = (radius1 * radius2) / Math.sqrt(Math.pow(radius2, 2) * Math.pow((Math.cos(stAng)), 2) + Math.pow(radius1, 2) * Math.pow(Math.sin(stAng),2));
x0 = (xCenter + radiusSpec*Math.cos(stAng));
y0 = (yCenter - radiusSpec*Math.sin(stAng));
}
};
var path = new Path();
var pathH = this.chartProp.pathH;
var pathW = this.chartProp.pathW;
var gdLst = [];
path.pathH = pathH;
path.pathW = pathW;
gdLst["w"] = 1;
gdLst["h"] = 1;
calculateProps();
path.moveTo(xCenter /pxToMm * pathW, yCenter / pxToMm * pathH);
path.lnTo(x0 /pxToMm * pathW, y0 / pxToMm * pathH);
path.arcTo(radius1 / pxToMm * pathW, radius2 / pxToMm * pathH, -1 * stAng*cToDeg, -1 * swAng*cToDeg);
path.lnTo(xCenter /pxToMm * pathW, yCenter / pxToMm * pathH);
path.recalculate(gdLst);
this.angleFor3D += swAng;
if(!this.usually3dPropsCalc[seriaNum])
this.usually3dPropsCalc[seriaNum] = {swAng: swAng, stAng: stAng, xCenter: xCenter, x0: x0, radiusSpec: radiusSpec};
return path;
},
_changeAngle: function(radius, stAng, swAng, xCenter, yCenter, depth, radius1, radius2)
{
//корректируем центр
......@@ -7861,373 +7696,26 @@ drawPieChart.prototype =
return res;
},
_calculateBestFitPosition: function(fStartAngle, fSweepAngle, fRadius, fWidth, fHeight, fCenterX, fCenterY, bLayout){
var fStartAngle_ = fStartAngle;
var fEndAngle = fStartAngle + fSweepAngle;
if(bLayout){
return this._calculateBestFitPositionOuter(fStartAngle_, fEndAngle, fRadius, fWidth, fHeight, fCenterX, fCenterY);
}
var oRet = this._calculateBestFitPositionInner(fStartAngle_, fEndAngle, fRadius, fWidth, fHeight, fCenterX, fCenterY);
if(!oRet.bError){
if(AscFormat.fCheckBoxIntersectionSegment(oRet.fX, oRet.fY, fWidth, fHeight, fCenterX, fCenterY, fCenterX + fRadius*Math.cos(fStartAngle_), fCenterY + fRadius*Math.sin(fStartAngle_))
|| AscFormat.fCheckBoxIntersectionSegment(oRet.fX, oRet.fY, fWidth, fHeight, fCenterX, fCenterY, fCenterX + fRadius*Math.cos(fEndAngle), fCenterY + fRadius*Math.sin(fEndAngle))){
oRet.bError = true;
}
}
if(oRet.bError){
return this._calculateBestFitPositionOuter(fStartAngle_, fEndAngle, fRadius, fWidth, fHeight, fCenterX, fCenterY);
}
return oRet;
},
_calculateBestFitPositionInner: function(fStartAngle, fEndAngle, fPieRadius, fLabelWidth, fLabelHeight, fCenterX, fCenterY){
var oResult = {bError: true};
var fBisectAngle = AscFormat.normalizeRotate((fStartAngle + fEndAngle)/2.0);
_calculateDLbl: function(chartSpace, ser, val, bLayout)
{
var pxToMm = this.chartProp.pxToMM;
if(AscFormat.fApproxEqual(fBisectAngle, 0) || AscFormat.fApproxEqual(fBisectAngle, Math.PI/2) || AscFormat.fApproxEqual(fBisectAngle, Math.PI) || AscFormat.fApproxEqual(fBisectAngle, 3*Math.PI/2)){
return this._calculateInEndDLblPosition(fStartAngle, fStartAngle + fEndAngle, fPieRadius, fLabelWidth, fLabelHeight, fCenterX, fCenterY);
}
var fBisectAngle2 = AscFormat.normalizeRotate(fBisectAngle + Math.PI/4) - Math.PI/4;
var nIndexArea = ((fBisectAngle2 + Math.PI/4)/(Math.PI/2)) >> 0;
var fLengthCoeff = ((fBisectAngle2 + Math.PI/4) - (Math.PI/2)*nIndexArea)/(Math.PI/2);
var fXs = fCenterX + fPieRadius*Math.cos(fBisectAngle);
var fYs = fCenterY + fPieRadius*Math.sin(fBisectAngle);
var fDeltaX, fDeltaY, oSolvation;
switch(nIndexArea){
case 0:{
if(fBisectAngle2 < 0){
fDeltaX = fLabelWidth;
fDeltaY = -(1 - fLengthCoeff)*fLabelHeight;
}
else{
fDeltaX = fLabelWidth;
fDeltaY = fLabelHeight*fLengthCoeff;
}
oSolvation = AscFormat.fSolveQuadraticEquation(fPieRadius*fPieRadius, 2*(fDeltaX*(fXs - fCenterX) + fDeltaY*(fYs - fCenterY)), fDeltaX*fDeltaX + fDeltaY*fDeltaY - fPieRadius*fPieRadius);
if(!oSolvation.bError){
if(oSolvation.x1 > 0 && oSolvation.x1 < 1){
oResult.bError = false;
oResult.fX = fCenterX + oSolvation.x1*(fXs - fCenterX);
oResult.fY = fCenterY + oSolvation.x1*(fYs - fCenterY) - (1 - fLengthCoeff)*fLabelHeight;
}
else if(oSolvation.x2 > 0 && oSolvation.x2 < 1){
oResult.bError = false;
oResult.fX = fCenterX + oSolvation.x2*(fXs - fCenterX);
oResult.fY = fCenterY + oSolvation.x2*(fYs - fCenterY) - (1 - fLengthCoeff)*fLabelHeight;
}
}
break;
}
case 1:{
if(fBisectAngle < Math.PI/2){
fDeltaX = (1 - fLengthCoeff)*fLabelWidth;
fDeltaY = fLabelHeight;
}
else{
fDeltaX = - fLengthCoeff*fLabelWidth;
fDeltaY = fLabelHeight;
}
oSolvation = AscFormat.fSolveQuadraticEquation(fPieRadius*fPieRadius, 2*(fDeltaX*(fXs - fCenterX) + fDeltaY*(fYs - fCenterY)), fDeltaX*fDeltaX + fDeltaY*fDeltaY - fPieRadius*fPieRadius);
if(!oSolvation.bError){
if(oSolvation.x1 > 0 && oSolvation.x1 < 1){
oResult.bError = false;
oResult.fX = fCenterX + oSolvation.x1*(fXs - fCenterX) - fLabelWidth*fLengthCoeff;
oResult.fY = fCenterY + oSolvation.x1*(fYs - fCenterY);
}
else if(oSolvation.x2 > 0 && oSolvation.x2 < 1){
oResult.bError = false;
oResult.fX = fCenterX + oSolvation.x2*(fXs - fCenterX) - fLabelWidth*fLengthCoeff;
oResult.fY = fCenterY + oSolvation.x2*(fYs - fCenterY);
}
}
break;
}
case 2:{
if(fBisectAngle < Math.PI){
fDeltaX = -fLabelWidth;
fDeltaY = (1 - fLengthCoeff)*fLabelHeight;
}
else{
fDeltaX = -fLabelWidth;
fDeltaY = - fLengthCoeff*fLabelHeight;
}
oSolvation = AscFormat.fSolveQuadraticEquation(fPieRadius*fPieRadius, 2*(fDeltaX*(fXs - fCenterX) + fDeltaY*(fYs - fCenterY)), fDeltaX*fDeltaX + fDeltaY*fDeltaY - fPieRadius*fPieRadius);
if(!oSolvation.bError){
if(oSolvation.x1 > 0 && oSolvation.x1 < 1){
oResult.bError = false;
oResult.fX = fCenterX + oSolvation.x1*(fXs - fCenterX) - fLabelWidth;
oResult.fY = fCenterY + oSolvation.x1*(fYs - fCenterY) - fLabelHeight*fLengthCoeff;
}
else if(oSolvation.x2 > 0 && oSolvation.x2 < 1){
oResult.bError = false;
oResult.fX = fCenterX + oSolvation.x2*(fXs - fCenterX) - fLabelWidth;
oResult.fY = fCenterY + oSolvation.x2*(fYs - fCenterY) - fLabelHeight*fLengthCoeff;
}
}
break;
}
case 3:{
fLengthCoeff = 1 - fLengthCoeff;
if(fBisectAngle < 3*Math.PI/2){
fDeltaX = -fLabelWidth*fLengthCoeff;
fDeltaY = -fLabelHeight;
}
else{
fDeltaX = (1 - fLengthCoeff)*fLabelWidth;
fDeltaY = -fLabelHeight;
}
oSolvation = AscFormat.fSolveQuadraticEquation(fPieRadius*fPieRadius, 2*(fDeltaX*(fXs - fCenterX) + fDeltaY*(fYs - fCenterY)), fDeltaX*fDeltaX + fDeltaY*fDeltaY - fPieRadius*fPieRadius);
if(!oSolvation.bError){
if(oSolvation.x1 > 0 && oSolvation.x1 < 1){
oResult.bError = false;
oResult.fX = fCenterX + oSolvation.x1*(fXs - fCenterX) - fLabelWidth*fLengthCoeff;
oResult.fY = fCenterY + oSolvation.x1*(fYs - fCenterY) - fLabelHeight;
}
else if(oSolvation.x2 > 0 && oSolvation.x2 < 1){
oResult.bError = false;
oResult.fX = fCenterX + oSolvation.x2*(fXs - fCenterX) - fLabelWidth*fLengthCoeff;
oResult.fY = fCenterY + oSolvation.x2*(fYs - fCenterY) - fLabelHeight;
}
}
break;
}
}
return oResult;
},
_calculateBestFitPositionOuter: function(fStartAngle, fEndAngle, fPieRadius, fLabelWidth, fLabelHeight, fCenterX, fCenterY){
var oResult = {bError: true};
var fBisectAngle = AscFormat.normalizeRotate((fStartAngle + fEndAngle)/2.0);
var fBisectAngle2 = AscFormat.normalizeRotate(fBisectAngle + Math.PI/4) - Math.PI/4;
var nIndexArea = ((fBisectAngle2 + Math.PI/4)/(Math.PI/2)) >> 0;
var fLengthCoeff = ((fBisectAngle2 + Math.PI/4) - (Math.PI/2)*nIndexArea)/(Math.PI/2);
var fXs = fCenterX + fPieRadius*Math.cos(fBisectAngle);
var fYs = fCenterY + fPieRadius*Math.sin(fBisectAngle);
var fDeltaX, fDeltaY, oSolvation;
var fAngleApproxDelta = 1e-4;
switch(nIndexArea){
case 0:{
if(AscFormat.fApproxEqual(fBisectAngle2, 0, fAngleApproxDelta)){
fDeltaX = 0;
fDeltaY = 0;
}
else if(fBisectAngle2 < 0){
fDeltaX = 0;
fDeltaY = fLengthCoeff*fLabelHeight;
}
else{
fDeltaX = 0;
fDeltaY = -(1 - fLengthCoeff)*fLabelHeight;
}
oSolvation = AscFormat.fSolveQuadraticEquation(fPieRadius*fPieRadius, 2*(fDeltaX*(fXs - fCenterX) + fDeltaY*(fYs - fCenterY)), fDeltaX*fDeltaX + fDeltaY*fDeltaY - fPieRadius*fPieRadius);
if(!oSolvation.bError){
if(oSolvation.x1 >= 1){
oResult.bError = false;
oResult.fX = fCenterX + oSolvation.x1*(fXs - fCenterX);
oResult.fY = fCenterY + oSolvation.x1*(fYs - fCenterY) - (1 - fLengthCoeff)*fLabelHeight;
}
else if(oSolvation.x2 >= 1){
oResult.bError = false;
oResult.fX = fCenterX + oSolvation.x2*(fXs - fCenterX);
oResult.fY = fCenterY + oSolvation.x2*(fYs - fCenterY) - (1 - fLengthCoeff)*fLabelHeight;
}
else if(oSolvation.x1 >= 0){
oResult.bError = false;
oResult.fX = fCenterX + oSolvation.x1*(fXs - fCenterX);
oResult.fY = fCenterY + oSolvation.x1*(fYs - fCenterY) - (1 - fLengthCoeff)*fLabelHeight;
}
else if(oSolvation.x2 >= 0){
oResult.bError = false;
oResult.fX = fCenterX + oSolvation.x2*(fXs - fCenterX);
oResult.fY = fCenterY + oSolvation.x2*(fYs - fCenterY) - (1 - fLengthCoeff)*fLabelHeight;
}
}
break;
}
case 1:{
if(AscFormat.fApproxEqual(fBisectAngle, Math.PI/2, fAngleApproxDelta)){
fDeltaX = 0;
fDeltaY = 0;
}
else if(fBisectAngle < Math.PI/2){
fDeltaX = -fLengthCoeff*fLabelWidth;
fDeltaY = 0;
}
else{
fDeltaX = (1 - fLengthCoeff)*fLabelWidth;
fDeltaY = 0;
}
oSolvation = AscFormat.fSolveQuadraticEquation(fPieRadius*fPieRadius, 2*(fDeltaX*(fXs - fCenterX) + fDeltaY*(fYs - fCenterY)), fDeltaX*fDeltaX + fDeltaY*fDeltaY - fPieRadius*fPieRadius);
if(!oSolvation.bError){
if(oSolvation.x1 >= 1){
oResult.bError = false;
oResult.fX = fCenterX + oSolvation.x1*(fXs - fCenterX) - fLabelWidth*fLengthCoeff;
oResult.fY = fCenterY + oSolvation.x1*(fYs - fCenterY);
}
else if(oSolvation.x2 >= 1){
oResult.bError = false;
oResult.fX = fCenterX + oSolvation.x2*(fXs - fCenterX) - fLabelWidth*fLengthCoeff;
oResult.fY = fCenterY + oSolvation.x2*(fYs - fCenterY);
}
else if(oSolvation.x1 >= 0){
oResult.bError = false;
oResult.fX = fCenterX + oSolvation.x1*(fXs - fCenterX) - fLabelWidth*fLengthCoeff;
oResult.fY = fCenterY + oSolvation.x1*(fYs - fCenterY);
}
else if(oSolvation.x2 >= 0){
oResult.bError = false;
oResult.fX = fCenterX + oSolvation.x2*(fXs - fCenterX) - fLabelWidth*fLengthCoeff;
oResult.fY = fCenterY + oSolvation.x2*(fYs - fCenterY);
}
}
break;
}
case 2:{
if(AscFormat.fApproxEqual(fBisectAngle, Math.PI, fAngleApproxDelta)){
fDeltaX = 0;
fDeltaY = 0;
}
else if(fBisectAngle < Math.PI){
fDeltaX = 0;
fDeltaY = -fLengthCoeff*fLabelHeight;
}
else{
fDeltaX = 0;
fDeltaY = (1 - fLengthCoeff)*fLabelHeight;
}
oSolvation = AscFormat.fSolveQuadraticEquation(fPieRadius*fPieRadius, 2*(fDeltaX*(fXs - fCenterX) + fDeltaY*(fYs - fCenterY)), fDeltaX*fDeltaX + fDeltaY*fDeltaY - fPieRadius*fPieRadius);
if(!oSolvation.bError){
if(oSolvation.x1 >= 1){
oResult.bError = false;
oResult.fX = fCenterX + oSolvation.x1*(fXs - fCenterX) - fLabelWidth;
oResult.fY = fCenterY + oSolvation.x1*(fYs - fCenterY) - fLabelHeight*fLengthCoeff;
}
else if(oSolvation.x2 >= 1){
oResult.bError = false;
oResult.fX = fCenterX + oSolvation.x2*(fXs - fCenterX) - fLabelWidth;
oResult.fY = fCenterY + oSolvation.x2*(fYs - fCenterY) - fLabelHeight*fLengthCoeff;
}
else if(oSolvation.x1 >= 0){
oResult.bError = false;
oResult.fX = fCenterX + oSolvation.x1*(fXs - fCenterX) - fLabelWidth;
oResult.fY = fCenterY + oSolvation.x1*(fYs - fCenterY) - fLabelHeight*fLengthCoeff;
}
else if(oSolvation.x2 >= 0){
oResult.bError = false;
oResult.fX = fCenterX + oSolvation.x2*(fXs - fCenterX) - fLabelWidth;
oResult.fY = fCenterY + oSolvation.x2*(fYs - fCenterY) - fLabelHeight*fLengthCoeff;
}
}
break;
}
case 3:{
if(fBisectAngle < 3*Math.PI/2){
fDeltaX = fLabelWidth*fLengthCoeff;
fDeltaY = 0;
}
else{
fDeltaX = -(1 - fLengthCoeff)*fLabelWidth;
fDeltaY = 0;
}
oSolvation = AscFormat.fSolveQuadraticEquation(fPieRadius*fPieRadius, 2*(fDeltaX*(fXs - fCenterX) + fDeltaY*(fYs - fCenterY)), fDeltaX*fDeltaX + fDeltaY*fDeltaY - fPieRadius*fPieRadius);
if(!oSolvation.bError){
if(oSolvation.x1 >= 1){
oResult.bError = false;
oResult.fX = fCenterX + oSolvation.x1*(fXs - fCenterX) - (1 - fLengthCoeff)*fLabelWidth;
oResult.fY = fCenterY + oSolvation.x1*(fYs - fCenterY) - fLabelHeight;
}
else if(oSolvation.x2 >= 1){
oResult.bError = false;
oResult.fX = fCenterX + oSolvation.x2*(fXs - fCenterX) - (1 - fLengthCoeff)*fLabelWidth;
oResult.fY = fCenterY + oSolvation.x2*(fYs - fCenterY) - fLabelHeight;
}
else if(oSolvation.x1 >= 0){
oResult.bError = false;
oResult.fX = fCenterX + oSolvation.x1*(fXs - fCenterX) - (1 - fLengthCoeff)*fLabelWidth;
oResult.fY = fCenterY + oSolvation.x1*(fYs - fCenterY) - fLabelHeight;
}
else if(oSolvation.x2 >= 0){
oResult.bError = false;
oResult.fX = fCenterX + oSolvation.x2*(fXs - fCenterX) - (1 - fLengthCoeff)*fLabelWidth;
oResult.fY = fCenterY + oSolvation.x2*(fYs - fCenterY) - fLabelHeight;
}
}
break;
}
}
return oResult;
},
_calculateInEndDLblPosition: function(fStartAngle, fSweepAngle, fPieRadius, fLabelWidth, fLabelHeight, fCenterX, fCenterY){
var fEndAngle = fStartAngle + fSweepAngle;
var oResult = {bError: true, fX: 0.0, fY: 0.0};
var fBisectAngle = AscFormat.normalizeRotate((fStartAngle + fEndAngle)/2);
var nQuadrantIndex = (2.0*fBisectAngle/Math.PI) >> 0;
var fHalfRectWidthVector = fLabelWidth/ 2, fHalfRectHeightVector = fLabelHeight/2;
if(nQuadrantIndex === 1 || nQuadrantIndex == 2){
fHalfRectWidthVector = -fHalfRectWidthVector;
}
if(nQuadrantIndex === 2 || nQuadrantIndex == 3){
fHalfRectHeightVector = -fHalfRectHeightVector;
}
var fXs = fCenterX + fPieRadius*Math.cos(fBisectAngle), fYs = fCenterY + fPieRadius*Math.sin(fBisectAngle);
var a = fPieRadius*fPieRadius, b = 2*( (fXs - fCenterX)*fHalfRectWidthVector + (fYs - fCenterY)*fHalfRectHeightVector), c = fHalfRectWidthVector*fHalfRectWidthVector + fHalfRectHeightVector*fHalfRectHeightVector - fPieRadius*fPieRadius;
var oSolution = AscFormat.fSolveQuadraticEquation(a, b, c);
if(oSolution.bError){
return oResult;
}
var D = b*b - 4*a*c;
if(D < 0){
return oResult;
}
var t1 = oSolution.x1, t2 = oSolution.x2;
if(t1 > 0 && t1 < 1){
oResult.bError = false;
oResult.fX = fCenterX + t1*(fXs - fCenterX) - fLabelWidth/2;
oResult.fY = fCenterY + t1*(fYs - fCenterY) - fLabelHeight/2;
return oResult
}
if(t2 > 0 && t2 < 1){
oResult.bError = false;
oResult.fX = fCenterX + t2*(fXs - fCenterX) - fLabelWidth/2;
oResult.fY = fCenterY + t2*(fYs - fCenterY) - fLabelHeight/2;
return oResult
}
return oResult;
},
_calculateDLbl: function(chartSpace, ser, val, bLayout)
{
var pxToMm = this.chartProp.pxToMM;
//TODO сделать через idx как у drawDoughnutChart!!!
if(!this.paths.series[val])
return;
var path;
if(this.cChartDrawer.nDimensionCount === 3)
{
if(this.paths.series[val][ser] && this.paths.series[val][ser].upPath)
{
path = this.paths.series[val][ser].upPath.ArrPathCommand;
}
}
else
{
path = this.paths.series[val].ArrPathCommand;
//TODO сделать через idx как у drawDoughnutChart!!!
if(!this.paths.series[val])
return;
var path;
if(this.cChartDrawer.nDimensionCount === 3)
{
if(this.paths.series[val][ser] && this.paths.series[val][ser].upPath)
{
path = this.paths.series[val][ser].upPath.ArrPathCommand;
}
}
else
{
path = this.paths.series[val].ArrPathCommand;
}
if(!path)
......@@ -8261,8 +7749,6 @@ drawPieChart.prototype =
if(!point)
return;
var constMargin = 5 / pxToMm;
var width = point.compiledDlb.extX;
var height = point.compiledDlb.extY;
......@@ -8371,7 +7857,7 @@ drawPieChart.prototype =
},
//****fast calulate and drawing(for switch on slow drawing: change name function _Slow)
_reсalculatePie3D: function ()
_recalculatePie3D: function ()
{
var trueWidth = this.chartProp.trueWidth;
var trueHeight = this.chartProp.trueHeight;
......@@ -8396,7 +7882,6 @@ drawPieChart.prototype =
for (var i = numCache.length - 1; i >= 0; i--)
{
var val = numCache[i].val;
var partOfSum = numCache[i].val / sumData;
var swapAngle = Math.abs((parseFloat(partOfSum)) * (Math.PI * 2));
......@@ -8411,8 +7896,7 @@ drawPieChart.prototype =
}
},
_reсalculatePie3DPerspective: function ()
_recalculatePie3DPerspective: function ()
{
var left = this.chartProp.chartGutter._left;
var right = this.chartProp.chartGutter._right;
......@@ -8420,7 +7904,6 @@ drawPieChart.prototype =
var bottom = this.chartProp.chartGutter._bottom;
var trueWidth = this.chartProp.trueWidth;
var trueHeight = this.chartProp.trueHeight;
var widthCanvas = this.chartProp.widthCanvas;
var heightCanvas = this.chartProp.heightCanvas;
......@@ -8442,13 +7925,13 @@ drawPieChart.prototype =
var point1 = this.cChartDrawer._convertAndTurnPoint(x1, y1, z1);
var point2 = this.cChartDrawer._convertAndTurnPoint(x2, y2, z2);
var point3 = this.cChartDrawer._convertAndTurnPoint(x3, y3, z3);
var point4 = this.cChartDrawer._convertAndTurnPoint(x4, y4, z4);
//var point3 = this.cChartDrawer._convertAndTurnPoint(x3, y3, z3);
//var point4 = this.cChartDrawer._convertAndTurnPoint(x4, y4, z4);
var point5 = this.cChartDrawer._convertAndTurnPoint(x5, y5, z5);
var point6 = this.cChartDrawer._convertAndTurnPoint(x6, y6, z6);
var point7 = this.cChartDrawer._convertAndTurnPoint(x7, y7, z7);
var point8 = this.cChartDrawer._convertAndTurnPoint(x8, y8, z8);
//var point7 = this.cChartDrawer._convertAndTurnPoint(x7, y7, z7);
//var point8 = this.cChartDrawer._convertAndTurnPoint(x8, y8, z8);
var radius3D1 = (z6 - z2) / 2;
......@@ -8488,9 +7971,7 @@ drawPieChart.prototype =
for(var i = 0; i < angles1.length; i++)
{
var start = angles1[i].start;
var swap = angles1[i].swap;
var start1 = angles2[i].start;
var swap1 = angles2[i].swap;
if(i === angles1.length - 1)
{
......@@ -8521,7 +8002,6 @@ drawPieChart.prototype =
{
var t = this;
var widthCanvas = this.chartProp.widthCanvas;
var heightCanvas = this.chartProp.heightCanvas;
var numCache = this._getFirstRealNumCache();
var sumData = this.cChartDrawer._getSumArray(numCache, true);
......@@ -8668,16 +8148,15 @@ drawPieChart.prototype =
{
var properties = this.cChartDrawer.processor3D.calculatePropertiesForPieCharts();
var depth = !depth ? properties.depth : depth;
var radius1 = !radius1 ? properties.radius1 : radius1;
var radius2 = !radius2 ? properties.radius2 : radius2;
depth = !depth ? properties.depth : depth;
radius1 = !radius1 ? properties.radius1 : radius1;
radius2 = !radius2 ? properties.radius2 : radius2;
var pxToMm = this.chartProp.pxToMM;
var pathH = this.chartProp.pathH;
var pathW = this.chartProp.pathW;
var t = this;
var gdLst = [];
gdLst["w"] = 1;
......@@ -8835,7 +8314,7 @@ drawPieChart.prototype =
path.recalculate(gdLst);
return path;
}
};
//FRONT FACES
//break front faces
......@@ -8893,7 +8372,6 @@ drawPieChart.prototype =
var pxToMm = this.chartProp.pxToMM;
var pathH = this.chartProp.pathH;
var pathW = this.chartProp.pathW;
var t = this;
var gdLst = [];
gdLst["w"] = 1;
......@@ -9032,9 +8510,7 @@ drawPieChart.prototype =
var calculateDownFace = function(startAng, swapAng)
{
var path = getNewPath();
var endAng = startAng + swapAng;
var radiusSpec = (radiusDown1 * radiusDown2) / Math.sqrt(Math.pow(radiusDown2, 2) * Math.pow((Math.cos(startAng)), 2) + Math.pow(radiusDown1, 2) * Math.pow(Math.sin(startAng),2));
//var radiusSpec2 = (radius11 * radius2) / Math.sqrt(Math.pow(radius2, 2) * Math.pow((Math.cos(endAng)), 2) + Math.pow(radius11, 2) * Math.pow(Math.sin(endAng),2))
......@@ -9049,7 +8525,7 @@ drawPieChart.prototype =
path.recalculate(gdLst);
return path;
}
};
//FRONT FACES
//break front faces
......@@ -9082,117 +8558,463 @@ drawPieChart.prototype =
}
//INSIDE FACES
var insidePath = null;
insidePath = calculateInsideFaces(upFaceSign*startAngle1, upFaceSign*swapAngle1, startAngle2, swapAngle2);
var insidePath = calculateInsideFaces(upFaceSign*startAngle1, upFaceSign*swapAngle1, startAngle2, swapAngle2);
//UP FACE
var upPath = null;
upPath = calculateUpFace(upFaceSign*startAngle1, upFaceSign*swapAngle1);
var upPath = calculateUpFace(upFaceSign*startAngle1, upFaceSign*swapAngle1);
//DOWN FACE
var downPath = null;
downPath = calculateDownFace(startAngle2, swapAngle2);
var downPath = calculateDownFace(startAngle2, swapAngle2);
return {frontPath: frontPath, upPath: upPath, insidePath: insidePath, downPath: downPath};
},
_drawPie3D: function ()
{
var numCache = this._getFirstRealNumCache();
var t = this;
var shade = "shade";
var shadeValue = 35000;
var drawPath = function(path, pen, brush, isShadePen, isShadeBrush)
{
if(path)
{
if(brush)
{
var props = t.cChartSpace.getParentObjects();
var duplicateBrush = brush.createDuplicate();
var cColorMod = new AscFormat.CColorMod;
cColorMod.val = shadeValue;
cColorMod.name = shade;
if(duplicateBrush)
{
duplicateBrush.addColorMod(cColorMod);
duplicateBrush.calculate(props.theme, props.slide, props.layout, props.master, new AscFormat.CUniColor().RGBA);
_drawPie3D: function ()
{
var numCache = this._getFirstRealNumCache();
var t = this;
var shade = "shade";
var shadeValue = 35000;
var drawPath = function(path, pen, brush, isShadePen, isShadeBrush)
{
if(path)
{
if(brush)
{
var props = t.cChartSpace.getParentObjects();
var duplicateBrush = brush.createDuplicate();
var cColorMod = new AscFormat.CColorMod;
cColorMod.val = shadeValue;
cColorMod.name = shade;
if(duplicateBrush)
{
duplicateBrush.addColorMod(cColorMod);
duplicateBrush.calculate(props.theme, props.slide, props.layout, props.master, new AscFormat.CUniColor().RGBA);
}
if(isShadePen)
{
pen = AscFormat.CreatePenFromParams(duplicateBrush, undefined, undefined, undefined, undefined, 0);
}
if(isShadeBrush)
{
brush = duplicateBrush;
}
}
t.cChartDrawer.drawPath(path, pen, brush);
}
};
var pen = numCache[0].pen;
drawPath(this.paths.test, pen, null);
var sides = {down: 0, inside: 1, up: 2, front: 3};
var drawPaths = function(side)
{
for (var i = 0,len = numCache.length; i < len; i++)
{
var val = numCache[i];
var brush = val.brush;
var pen = val.pen;
var path = t.paths.series[i];
if(path)
{
for(var j = path.length - 1; j >= 0; j--)
{
if(side === sides.down)
{
drawPath(path[j].downPath, pen, null);
}
else if(side === sides.inside)
{
drawPath(path[j].insidePath, pen, brush, null, true);
}
else if(side === sides.up)
{
drawPath(path[j].upPath, pen, brush);
}
else if(side === sides.frontPath)
{
for(var k = 0; k < path[j].frontPath.length;k++)
{
drawPath(path[j].frontPath[k], pen, brush, true, true);
}
}
}
}
}
};
drawPaths(sides.down);
drawPaths(sides.inside);
if(this.tempDrawOrder !== null)
{
drawPaths(sides.up);
drawPaths(sides.frontPath);
}
else
{
drawPaths(sides.frontPath);
drawPaths(sides.up);
}
},
//best fit DLbl
_calculateBestFitPosition: function(fStartAngle, fSweepAngle, fRadius, fWidth, fHeight, fCenterX, fCenterY, bLayout){
var fStartAngle_ = fStartAngle;
var fEndAngle = fStartAngle + fSweepAngle;
if(bLayout){
return this._calculateBestFitPositionOuter(fStartAngle_, fEndAngle, fRadius, fWidth, fHeight, fCenterX, fCenterY);
}
var oRet = this._calculateBestFitPositionInner(fStartAngle_, fEndAngle, fRadius, fWidth, fHeight, fCenterX, fCenterY);
if(!oRet.bError){
if(AscFormat.fCheckBoxIntersectionSegment(oRet.fX, oRet.fY, fWidth, fHeight, fCenterX, fCenterY, fCenterX + fRadius*Math.cos(fStartAngle_), fCenterY + fRadius*Math.sin(fStartAngle_))
|| AscFormat.fCheckBoxIntersectionSegment(oRet.fX, oRet.fY, fWidth, fHeight, fCenterX, fCenterY, fCenterX + fRadius*Math.cos(fEndAngle), fCenterY + fRadius*Math.sin(fEndAngle))){
oRet.bError = true;
}
}
if(oRet.bError){
return this._calculateBestFitPositionOuter(fStartAngle_, fEndAngle, fRadius, fWidth, fHeight, fCenterX, fCenterY);
}
return oRet;
},
_calculateBestFitPositionInner: function(fStartAngle, fEndAngle, fPieRadius, fLabelWidth, fLabelHeight, fCenterX, fCenterY){
var oResult = {bError: true};
var fBisectAngle = AscFormat.normalizeRotate((fStartAngle + fEndAngle)/2.0);
if(AscFormat.fApproxEqual(fBisectAngle, 0) || AscFormat.fApproxEqual(fBisectAngle, Math.PI/2) || AscFormat.fApproxEqual(fBisectAngle, Math.PI) || AscFormat.fApproxEqual(fBisectAngle, 3*Math.PI/2)){
return this._calculateInEndDLblPosition(fStartAngle, fStartAngle + fEndAngle, fPieRadius, fLabelWidth, fLabelHeight, fCenterX, fCenterY);
}
var fBisectAngle2 = AscFormat.normalizeRotate(fBisectAngle + Math.PI/4) - Math.PI/4;
var nIndexArea = ((fBisectAngle2 + Math.PI/4)/(Math.PI/2)) >> 0;
var fLengthCoeff = ((fBisectAngle2 + Math.PI/4) - (Math.PI/2)*nIndexArea)/(Math.PI/2);
var fXs = fCenterX + fPieRadius*Math.cos(fBisectAngle);
var fYs = fCenterY + fPieRadius*Math.sin(fBisectAngle);
var fDeltaX, fDeltaY, oSolvation;
switch(nIndexArea){
case 0:{
if(fBisectAngle2 < 0){
fDeltaX = fLabelWidth;
fDeltaY = -(1 - fLengthCoeff)*fLabelHeight;
}
else{
fDeltaX = fLabelWidth;
fDeltaY = fLabelHeight*fLengthCoeff;
}
oSolvation = AscFormat.fSolveQuadraticEquation(fPieRadius*fPieRadius, 2*(fDeltaX*(fXs - fCenterX) + fDeltaY*(fYs - fCenterY)), fDeltaX*fDeltaX + fDeltaY*fDeltaY - fPieRadius*fPieRadius);
if(!oSolvation.bError){
if(oSolvation.x1 > 0 && oSolvation.x1 < 1){
oResult.bError = false;
oResult.fX = fCenterX + oSolvation.x1*(fXs - fCenterX);
oResult.fY = fCenterY + oSolvation.x1*(fYs - fCenterY) - (1 - fLengthCoeff)*fLabelHeight;
}
else if(oSolvation.x2 > 0 && oSolvation.x2 < 1){
oResult.bError = false;
oResult.fX = fCenterX + oSolvation.x2*(fXs - fCenterX);
oResult.fY = fCenterY + oSolvation.x2*(fYs - fCenterY) - (1 - fLengthCoeff)*fLabelHeight;
}
}
break;
}
case 1:{
if(fBisectAngle < Math.PI/2){
fDeltaX = (1 - fLengthCoeff)*fLabelWidth;
fDeltaY = fLabelHeight;
}
else{
fDeltaX = - fLengthCoeff*fLabelWidth;
fDeltaY = fLabelHeight;
}
oSolvation = AscFormat.fSolveQuadraticEquation(fPieRadius*fPieRadius, 2*(fDeltaX*(fXs - fCenterX) + fDeltaY*(fYs - fCenterY)), fDeltaX*fDeltaX + fDeltaY*fDeltaY - fPieRadius*fPieRadius);
if(!oSolvation.bError){
if(oSolvation.x1 > 0 && oSolvation.x1 < 1){
oResult.bError = false;
oResult.fX = fCenterX + oSolvation.x1*(fXs - fCenterX) - fLabelWidth*fLengthCoeff;
oResult.fY = fCenterY + oSolvation.x1*(fYs - fCenterY);
}
else if(oSolvation.x2 > 0 && oSolvation.x2 < 1){
oResult.bError = false;
oResult.fX = fCenterX + oSolvation.x2*(fXs - fCenterX) - fLabelWidth*fLengthCoeff;
oResult.fY = fCenterY + oSolvation.x2*(fYs - fCenterY);
}
}
break;
}
case 2:{
if(fBisectAngle < Math.PI){
fDeltaX = -fLabelWidth;
fDeltaY = (1 - fLengthCoeff)*fLabelHeight;
}
else{
fDeltaX = -fLabelWidth;
fDeltaY = - fLengthCoeff*fLabelHeight;
}
oSolvation = AscFormat.fSolveQuadraticEquation(fPieRadius*fPieRadius, 2*(fDeltaX*(fXs - fCenterX) + fDeltaY*(fYs - fCenterY)), fDeltaX*fDeltaX + fDeltaY*fDeltaY - fPieRadius*fPieRadius);
if(!oSolvation.bError){
if(oSolvation.x1 > 0 && oSolvation.x1 < 1){
oResult.bError = false;
oResult.fX = fCenterX + oSolvation.x1*(fXs - fCenterX) - fLabelWidth;
oResult.fY = fCenterY + oSolvation.x1*(fYs - fCenterY) - fLabelHeight*fLengthCoeff;
}
else if(oSolvation.x2 > 0 && oSolvation.x2 < 1){
oResult.bError = false;
oResult.fX = fCenterX + oSolvation.x2*(fXs - fCenterX) - fLabelWidth;
oResult.fY = fCenterY + oSolvation.x2*(fYs - fCenterY) - fLabelHeight*fLengthCoeff;
}
}
break;
}
case 3:{
fLengthCoeff = 1 - fLengthCoeff;
if(fBisectAngle < 3*Math.PI/2){
fDeltaX = -fLabelWidth*fLengthCoeff;
fDeltaY = -fLabelHeight;
}
else{
fDeltaX = (1 - fLengthCoeff)*fLabelWidth;
fDeltaY = -fLabelHeight;
}
oSolvation = AscFormat.fSolveQuadraticEquation(fPieRadius*fPieRadius, 2*(fDeltaX*(fXs - fCenterX) + fDeltaY*(fYs - fCenterY)), fDeltaX*fDeltaX + fDeltaY*fDeltaY - fPieRadius*fPieRadius);
if(!oSolvation.bError){
if(oSolvation.x1 > 0 && oSolvation.x1 < 1){
oResult.bError = false;
oResult.fX = fCenterX + oSolvation.x1*(fXs - fCenterX) - fLabelWidth*fLengthCoeff;
oResult.fY = fCenterY + oSolvation.x1*(fYs - fCenterY) - fLabelHeight;
}
else if(oSolvation.x2 > 0 && oSolvation.x2 < 1){
oResult.bError = false;
oResult.fX = fCenterX + oSolvation.x2*(fXs - fCenterX) - fLabelWidth*fLengthCoeff;
oResult.fY = fCenterY + oSolvation.x2*(fYs - fCenterY) - fLabelHeight;
}
}
break;
}
}
return oResult;
},
_calculateBestFitPositionOuter: function(fStartAngle, fEndAngle, fPieRadius, fLabelWidth, fLabelHeight, fCenterX, fCenterY){
var oResult = {bError: true};
var fBisectAngle = AscFormat.normalizeRotate((fStartAngle + fEndAngle)/2.0);
var fBisectAngle2 = AscFormat.normalizeRotate(fBisectAngle + Math.PI/4) - Math.PI/4;
var nIndexArea = ((fBisectAngle2 + Math.PI/4)/(Math.PI/2)) >> 0;
var fLengthCoeff = ((fBisectAngle2 + Math.PI/4) - (Math.PI/2)*nIndexArea)/(Math.PI/2);
var fXs = fCenterX + fPieRadius*Math.cos(fBisectAngle);
var fYs = fCenterY + fPieRadius*Math.sin(fBisectAngle);
var fDeltaX, fDeltaY, oSolvation;
var fAngleApproxDelta = 1e-4;
switch(nIndexArea){
case 0:{
if(AscFormat.fApproxEqual(fBisectAngle2, 0, fAngleApproxDelta)){
fDeltaX = 0;
fDeltaY = 0;
}
else if(fBisectAngle2 < 0){
fDeltaX = 0;
fDeltaY = fLengthCoeff*fLabelHeight;
}
else{
fDeltaX = 0;
fDeltaY = -(1 - fLengthCoeff)*fLabelHeight;
}
oSolvation = AscFormat.fSolveQuadraticEquation(fPieRadius*fPieRadius, 2*(fDeltaX*(fXs - fCenterX) + fDeltaY*(fYs - fCenterY)), fDeltaX*fDeltaX + fDeltaY*fDeltaY - fPieRadius*fPieRadius);
if(!oSolvation.bError){
if(oSolvation.x1 >= 1){
oResult.bError = false;
oResult.fX = fCenterX + oSolvation.x1*(fXs - fCenterX);
oResult.fY = fCenterY + oSolvation.x1*(fYs - fCenterY) - (1 - fLengthCoeff)*fLabelHeight;
}
else if(oSolvation.x2 >= 1){
oResult.bError = false;
oResult.fX = fCenterX + oSolvation.x2*(fXs - fCenterX);
oResult.fY = fCenterY + oSolvation.x2*(fYs - fCenterY) - (1 - fLengthCoeff)*fLabelHeight;
}
else if(oSolvation.x1 >= 0){
oResult.bError = false;
oResult.fX = fCenterX + oSolvation.x1*(fXs - fCenterX);
oResult.fY = fCenterY + oSolvation.x1*(fYs - fCenterY) - (1 - fLengthCoeff)*fLabelHeight;
}
if(isShadePen)
{
pen = AscFormat.CreatePenFromParams(duplicateBrush, undefined, undefined, undefined, undefined, 0);
else if(oSolvation.x2 >= 0){
oResult.bError = false;
oResult.fX = fCenterX + oSolvation.x2*(fXs - fCenterX);
oResult.fY = fCenterY + oSolvation.x2*(fYs - fCenterY) - (1 - fLengthCoeff)*fLabelHeight;
}
if(isShadeBrush)
{
brush = duplicateBrush;
}
break;
}
case 1:{
if(AscFormat.fApproxEqual(fBisectAngle, Math.PI/2, fAngleApproxDelta)){
fDeltaX = 0;
fDeltaY = 0;
}
else if(fBisectAngle < Math.PI/2){
fDeltaX = -fLengthCoeff*fLabelWidth;
fDeltaY = 0;
}
else{
fDeltaX = (1 - fLengthCoeff)*fLabelWidth;
fDeltaY = 0;
}
oSolvation = AscFormat.fSolveQuadraticEquation(fPieRadius*fPieRadius, 2*(fDeltaX*(fXs - fCenterX) + fDeltaY*(fYs - fCenterY)), fDeltaX*fDeltaX + fDeltaY*fDeltaY - fPieRadius*fPieRadius);
if(!oSolvation.bError){
if(oSolvation.x1 >= 1){
oResult.bError = false;
oResult.fX = fCenterX + oSolvation.x1*(fXs - fCenterX) - fLabelWidth*fLengthCoeff;
oResult.fY = fCenterY + oSolvation.x1*(fYs - fCenterY);
}
else if(oSolvation.x2 >= 1){
oResult.bError = false;
oResult.fX = fCenterX + oSolvation.x2*(fXs - fCenterX) - fLabelWidth*fLengthCoeff;
oResult.fY = fCenterY + oSolvation.x2*(fYs - fCenterY);
}
else if(oSolvation.x1 >= 0){
oResult.bError = false;
oResult.fX = fCenterX + oSolvation.x1*(fXs - fCenterX) - fLabelWidth*fLengthCoeff;
oResult.fY = fCenterY + oSolvation.x1*(fYs - fCenterY);
}
}
t.cChartDrawer.drawPath(path, pen, brush);
}
else if(oSolvation.x2 >= 0){
oResult.bError = false;
oResult.fX = fCenterX + oSolvation.x2*(fXs - fCenterX) - fLabelWidth*fLengthCoeff;
oResult.fY = fCenterY + oSolvation.x2*(fYs - fCenterY);
}
}
break;
}
case 2:{
if(AscFormat.fApproxEqual(fBisectAngle, Math.PI, fAngleApproxDelta)){
fDeltaX = 0;
fDeltaY = 0;
}
else if(fBisectAngle < Math.PI){
fDeltaX = 0;
fDeltaY = -fLengthCoeff*fLabelHeight;
}
else{
fDeltaX = 0;
fDeltaY = (1 - fLengthCoeff)*fLabelHeight;
}
oSolvation = AscFormat.fSolveQuadraticEquation(fPieRadius*fPieRadius, 2*(fDeltaX*(fXs - fCenterX) + fDeltaY*(fYs - fCenterY)), fDeltaX*fDeltaX + fDeltaY*fDeltaY - fPieRadius*fPieRadius);
if(!oSolvation.bError){
if(oSolvation.x1 >= 1){
oResult.bError = false;
oResult.fX = fCenterX + oSolvation.x1*(fXs - fCenterX) - fLabelWidth;
oResult.fY = fCenterY + oSolvation.x1*(fYs - fCenterY) - fLabelHeight*fLengthCoeff;
};
var pen = numCache[0].pen;
drawPath(this.paths.test, pen, null);
var sides = {down: 0, inside: 1, up: 2, front: 3};
var drawPaths = function(side)
{
for (var i = 0,len = numCache.length; i < len; i++)
{
var val = numCache[i];
var brush = val.brush;
var pen = val.pen;
var path = t.paths.series[i];
if(path)
{
for(var j = path.length - 1; j >= 0; j--)
{
if(side === sides.down)
{
drawPath(path[j].downPath, pen, null);
}
else if(side === sides.inside)
{
drawPath(path[j].insidePath, pen, brush, null, true);
}
else if(side === sides.up)
{
drawPath(path[j].upPath, pen, brush);
}
else if(side === sides.frontPath)
{
for(var k = 0; k < path[j].frontPath.length;k++)
{
drawPath(path[j].frontPath[k], pen, brush, true, true);
}
}
}
else if(oSolvation.x2 >= 1){
oResult.bError = false;
oResult.fX = fCenterX + oSolvation.x2*(fXs - fCenterX) - fLabelWidth;
oResult.fY = fCenterY + oSolvation.x2*(fYs - fCenterY) - fLabelHeight*fLengthCoeff;
}
else if(oSolvation.x1 >= 0){
oResult.bError = false;
oResult.fX = fCenterX + oSolvation.x1*(fXs - fCenterX) - fLabelWidth;
oResult.fY = fCenterY + oSolvation.x1*(fYs - fCenterY) - fLabelHeight*fLengthCoeff;
}
else if(oSolvation.x2 >= 0){
oResult.bError = false;
oResult.fX = fCenterX + oSolvation.x2*(fXs - fCenterX) - fLabelWidth;
oResult.fY = fCenterY + oSolvation.x2*(fYs - fCenterY) - fLabelHeight*fLengthCoeff;
}
}
break;
}
case 3:{
if(fBisectAngle < 3*Math.PI/2){
fDeltaX = fLabelWidth*fLengthCoeff;
fDeltaY = 0;
}
else{
fDeltaX = -(1 - fLengthCoeff)*fLabelWidth;
fDeltaY = 0;
}
oSolvation = AscFormat.fSolveQuadraticEquation(fPieRadius*fPieRadius, 2*(fDeltaX*(fXs - fCenterX) + fDeltaY*(fYs - fCenterY)), fDeltaX*fDeltaX + fDeltaY*fDeltaY - fPieRadius*fPieRadius);
if(!oSolvation.bError){
if(oSolvation.x1 >= 1){
oResult.bError = false;
oResult.fX = fCenterX + oSolvation.x1*(fXs - fCenterX) - (1 - fLengthCoeff)*fLabelWidth;
oResult.fY = fCenterY + oSolvation.x1*(fYs - fCenterY) - fLabelHeight;
}
else if(oSolvation.x2 >= 1){
oResult.bError = false;
oResult.fX = fCenterX + oSolvation.x2*(fXs - fCenterX) - (1 - fLengthCoeff)*fLabelWidth;
oResult.fY = fCenterY + oSolvation.x2*(fYs - fCenterY) - fLabelHeight;
}
else if(oSolvation.x1 >= 0){
oResult.bError = false;
oResult.fX = fCenterX + oSolvation.x1*(fXs - fCenterX) - (1 - fLengthCoeff)*fLabelWidth;
oResult.fY = fCenterY + oSolvation.x1*(fYs - fCenterY) - fLabelHeight;
}
}
}
};
drawPaths(sides.down);
drawPaths(sides.inside);
if(this.tempDrawOrder !== null)
{
drawPaths(sides.up);
drawPaths(sides.frontPath);
}
else
{
drawPaths(sides.frontPath);
drawPaths(sides.up);
else if(oSolvation.x2 >= 0){
oResult.bError = false;
oResult.fX = fCenterX + oSolvation.x2*(fXs - fCenterX) - (1 - fLengthCoeff)*fLabelWidth;
oResult.fY = fCenterY + oSolvation.x2*(fYs - fCenterY) - fLabelHeight;
}
}
break;
}
}
return oResult;
},
_calculateInEndDLblPosition: function(fStartAngle, fSweepAngle, fPieRadius, fLabelWidth, fLabelHeight, fCenterX, fCenterY){
var fEndAngle = fStartAngle + fSweepAngle;
var oResult = {bError: true, fX: 0.0, fY: 0.0};
var fBisectAngle = AscFormat.normalizeRotate((fStartAngle + fEndAngle)/2);
var nQuadrantIndex = (2.0*fBisectAngle/Math.PI) >> 0;
var fHalfRectWidthVector = fLabelWidth/ 2, fHalfRectHeightVector = fLabelHeight/2;
if(nQuadrantIndex === 1 || nQuadrantIndex == 2){
fHalfRectWidthVector = -fHalfRectWidthVector;
}
if(nQuadrantIndex === 2 || nQuadrantIndex == 3){
fHalfRectHeightVector = -fHalfRectHeightVector;
}
var fXs = fCenterX + fPieRadius*Math.cos(fBisectAngle), fYs = fCenterY + fPieRadius*Math.sin(fBisectAngle);
var a = fPieRadius*fPieRadius, b = 2*( (fXs - fCenterX)*fHalfRectWidthVector + (fYs - fCenterY)*fHalfRectHeightVector), c = fHalfRectWidthVector*fHalfRectWidthVector + fHalfRectHeightVector*fHalfRectHeightVector - fPieRadius*fPieRadius;
var oSolution = AscFormat.fSolveQuadraticEquation(a, b, c);
if(oSolution.bError){
return oResult;
}
var D = b*b - 4*a*c;
if(D < 0){
return oResult;
}
var t1 = oSolution.x1, t2 = oSolution.x2;
if(t1 > 0 && t1 < 1){
oResult.bError = false;
oResult.fX = fCenterX + t1*(fXs - fCenterX) - fLabelWidth/2;
oResult.fY = fCenterY + t1*(fYs - fCenterY) - fLabelHeight/2;
return oResult
}
if(t2 > 0 && t2 < 1){
oResult.bError = false;
oResult.fX = fCenterX + t2*(fXs - fCenterX) - fLabelWidth/2;
oResult.fY = fCenterY + t2*(fYs - fCenterY) - fLabelHeight/2;
return oResult
}
return oResult;
},
//For test
_calculateTestFrame: function(point1, point2, point3, point4, point5, point6, point7, point8)
{
var pxToMm = this.chartProp.pxToMM;
......@@ -9233,7 +9055,170 @@ drawPieChart.prototype =
path.recalculate(gdLst);
this.paths.test = path;
}
},
//TODO delete after test
_recalculatePie3D_Slow: function ()
{
var trueWidth = this.chartProp.trueWidth;
var trueHeight = this.chartProp.trueHeight;
var numCache = this._getFirstRealNumCache();
var sumData = this.cChartDrawer._getSumArray(numCache, true);
var radius = Math.min(trueHeight, trueWidth) / 2;
if(radius < 0)
radius = 0;
var xCenter = this.chartProp.chartGutter._left + trueWidth/2;
var yCenter = this.chartProp.chartGutter._top + trueHeight/2;
var startAngle = this.cChartDrawer.processor3D.angleOy ? this.cChartDrawer.processor3D.angleOy : 0;
var startAngle3D = startAngle !== 0 && startAngle !== undefined ? this._changeAngle(radius, Math.PI/2, startAngle, xCenter, yCenter, this.properties3d) : 0;
this.tempAngle = Math.PI/2 + startAngle;
this.angleFor3D = Math.PI/2 - startAngle3D;
//рисуем против часовой стрелки, поэтому цикл с конца
var depth = this.properties3d.depth;
for(var n = 0; n < depth; n++)
{
if(!this.paths.series)
this.paths.series = [];
for (var i = numCache.length - 1; i >= 0; i--)
{
var angle = Math.abs((parseFloat(numCache[i].val / sumData)) * (Math.PI * 2));
if(!this.paths.series[n])
this.paths.series[n] = [];
if(sumData === 0)//TODO стоит пересмотреть
this.paths.series[n][i] = this._calculateEmptySegment(radius, xCenter, yCenter);
else
this.paths.series[n][i] = this._calculateSegment3D(angle, radius, xCenter, yCenter, n, i);
}
}
},
_calculateSegment3D_Slow: function (angle, radius, xCenter, yCenter, depth, i)
{
if(isNaN(angle))
return null;
var startAngle = (this.tempAngle);
var swapAngle = angle;
var path = this._calculateArc3D(radius, startAngle, swapAngle, xCenter, yCenter, depth, i);
this.tempAngle += angle;
return path;
},
_calculateArc3D_Slow : function(radius, stAng, swAng, xCenter, yCenter, depth, seriaNum)
{
var radius1 = this.properties3d.radius1;
var radius2 = this.properties3d.radius2;
var pxToMm = this.chartProp.pxToMM;
var t = this;
var x0, y0, radiusSpec;
var calculateProps = function()
{
if(t.usually3dPropsCalc && t.usually3dPropsCalc[seriaNum])
{
swAng = t.usually3dPropsCalc[seriaNum].swAng;
stAng = t.usually3dPropsCalc[seriaNum].stAng;
radiusSpec = t.usually3dPropsCalc[seriaNum].radiusSpec;
x0 = t.usually3dPropsCalc[seriaNum].x0;
yCenter = yCenter + t.properties3d.depth / 2 - depth;
y0 = (yCenter - radiusSpec*Math.sin(stAng));
}
else
{
swAng = t._changeAngle(radius, stAng, swAng, xCenter, yCenter, t.properties3d);
stAng = t.angleFor3D;
//корректируем центр
yCenter = yCenter + t.properties3d.depth / 2 - depth;
radiusSpec = (radius1 * radius2) / Math.sqrt(Math.pow(radius2, 2) * Math.pow((Math.cos(stAng)), 2) + Math.pow(radius1, 2) * Math.pow(Math.sin(stAng),2));
x0 = (xCenter + radiusSpec*Math.cos(stAng));
y0 = (yCenter - radiusSpec*Math.sin(stAng));
}
};
var path = new Path();
var pathH = this.chartProp.pathH;
var pathW = this.chartProp.pathW;
var gdLst = [];
path.pathH = pathH;
path.pathW = pathW;
gdLst["w"] = 1;
gdLst["h"] = 1;
calculateProps();
path.moveTo(xCenter /pxToMm * pathW, yCenter / pxToMm * pathH);
path.lnTo(x0 /pxToMm * pathW, y0 / pxToMm * pathH);
path.arcTo(radius1 / pxToMm * pathW, radius2 / pxToMm * pathH, -1 * stAng*cToDeg, -1 * swAng*cToDeg);
path.lnTo(xCenter /pxToMm * pathW, yCenter / pxToMm * pathH);
path.recalculate(gdLst);
this.angleFor3D += swAng;
if(!this.usually3dPropsCalc[seriaNum])
this.usually3dPropsCalc[seriaNum] = {swAng: swAng, stAng: stAng, xCenter: xCenter, x0: x0, radiusSpec: radiusSpec};
return path;
},
_drawPie3D_Slow: function ()
{
var numCache = this._getFirstRealNumCache();
var props = this.cChartSpace.getParentObjects();
var brush, pen, val;
var path;
for(var n = 0; n < this.paths.series.length; n++)
{
for (var i = 0, len = numCache.length; i < len; i++) {
val = numCache[i];
brush = val.brush;
if(n === 0 || n === this.paths.series.length - 1)
{
pen = val.pen;
}
else
{
pen = null;
}
path = this.paths.series[n][i];
var duplicateBrush = brush;
if(n !== this.paths.series.length - 1)
{
duplicateBrush = brush.createDuplicate();
var cColorMod = new AscFormat.CColorMod;
cColorMod.val = 35000;
cColorMod.name = "shade";
duplicateBrush.addColorMod(cColorMod);
duplicateBrush.calculate(props.theme, props.slide, props.layout, props.master, new AscFormat.CUniColor().RGBA);
}
this.cChartDrawer.drawPath(path, pen, duplicateBrush);
}
}
}
};
......@@ -9270,7 +9255,7 @@ drawDoughnutChart.prototype =
_drawPie: function ()
{
var brush, pen, val;
var brush, pen;
var path;
var idxPoint, numCache;
......@@ -9386,8 +9371,8 @@ drawDoughnutChart.prototype =
var x1 = xCenter + radius2*Math.cos(stAng);
var y1 = yCenter - radius2*Math.sin(stAng);
var x3 = xCenter + radius1*Math.cos(stAng + swAng);
var y3 = yCenter - radius1*Math.sin(stAng + swAng);
//var x3 = xCenter + radius1*Math.cos(stAng + swAng);
//var y3 = yCenter - radius1*Math.sin(stAng + swAng);
var x4 = xCenter + radius2*Math.cos(stAng + swAng);
var y4 = yCenter - radius2*Math.sin(stAng + swAng);
......@@ -9405,17 +9390,10 @@ drawDoughnutChart.prototype =
_calculateDLbl: function(chartSpace, ser, val)
{
var pxToMm = this.chartProp.pxToMM;
if(!this.paths.series[ser][val])
return;
var path = this.paths.series[ser][val].ArrPathCommand;
var x1 = path[0].X;
var y1 = path[0].Y;
var x2 = path[1].X;
var y2 = path[1].Y;
var radius1 = path[2].hR;
var stAng = path[2].stAng;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment