Commit dde95331 authored by GoshaZotov's avatar GoshaZotov

changes for angles calculating

parent e1834561
...@@ -8513,10 +8513,12 @@ drawPieChart.prototype = ...@@ -8513,10 +8513,12 @@ drawPieChart.prototype =
var numCache = this._getFirstRealNumCache(); var numCache = this._getFirstRealNumCache();
var sumData = this.cChartDrawer._getSumArray(numCache, true); var sumData = this.cChartDrawer._getSumArray(numCache, true);
var startAngle = this.cChartSpace.chart.view3D && this.cChartSpace.chart.view3D.rotY ? (- this.cChartSpace.chart.view3D.rotY / 360) * (Math.PI * 2) : 0 var startAngle = Math.PI / 2;
startAngle += Math.PI / 2;
var newStartAngle = startAngle; var newStartAngle = startAngle;
var firstAngle = this.cChartSpace.chart.view3D && this.cChartSpace.chart.view3D.rotY ? (- this.cChartSpace.chart.view3D.rotY / 360) * (Math.PI * 2) : 0;
var getAngleByCoordsSidesTriangle = function(aC, bC, cC) var getAngleByCoordsSidesTriangle = function(aC, bC, cC)
{ {
var res; var res;
...@@ -8550,14 +8552,35 @@ drawPieChart.prototype = ...@@ -8550,14 +8552,35 @@ drawPieChart.prototype =
}; };
var angles = []; var angles = [];
for (var i = numCache.length - 1; i >= 0; i--) for (var i = numCache.length; i >= 0; i--)
{ {
//рассчитываем угол //рассчитываем угол
if(i === numCache.length)
{
var swapAngle = firstAngle
}
else
{
var partOfSum = numCache[i].val / sumData; var partOfSum = numCache[i].val / sumData;
var swapAngle = Math.abs((parseFloat(partOfSum)) * (Math.PI * 2)); var swapAngle = Math.abs((parseFloat(partOfSum)) * (Math.PI * 2));
}
var tempSwapAngle = 0, newSwapAngle = 0, tempStartAngle = startAngle; var tempSwapAngle = 0, newSwapAngle = 0, tempStartAngle = startAngle;
while(true) while(true)
{
if(i === numCache.length && swapAngle < 0)
{
if(tempStartAngle - Math.PI / 2 > startAngle + swapAngle)
{
tempSwapAngle = -Math.PI / 2;
}
else
{
tempSwapAngle = (startAngle + swapAngle) - tempStartAngle;
}
}
else
{ {
if(tempStartAngle + Math.PI / 2 < startAngle + swapAngle) if(tempStartAngle + Math.PI / 2 < startAngle + swapAngle)
{ {
...@@ -8567,26 +8590,63 @@ drawPieChart.prototype = ...@@ -8567,26 +8590,63 @@ drawPieChart.prototype =
{ {
tempSwapAngle = (startAngle + swapAngle) - tempStartAngle; tempSwapAngle = (startAngle + swapAngle) - tempStartAngle;
} }
}
var p1 = getPointsByAngle(tempStartAngle); var p1 = getPointsByAngle(tempStartAngle);
var p2 = getPointsByAngle(tempStartAngle + tempSwapAngle); var p2 = getPointsByAngle(tempStartAngle + tempSwapAngle);
newSwapAngle += getAngleByCoordsSidesTriangle({x: p2.x - p1.x, y: p2.y - p1.y}, {x: xCenter - p1.x, y: yCenter - p1.y}, {x: xCenter - p2.x, y: yCenter - p2.y}); newSwapAngle += getAngleByCoordsSidesTriangle({x: p2.x - p1.x, y: p2.y - p1.y}, {x: xCenter - p1.x, y: yCenter - p1.y}, {x: xCenter - p2.x, y: yCenter - p2.y});
if(i === numCache.length && swapAngle < 0)
{
if(tempStartAngle - Math.PI / 2 > startAngle + swapAngle)
{
tempStartAngle -= Math.PI / 2;
}
else
{
if(i !== numCache.length)
angles.push({start: newStartAngle, swap: newSwapAngle, end: newStartAngle + newSwapAngle});
break;
}
}
else
{
if(tempStartAngle + Math.PI / 2 < startAngle + swapAngle) if(tempStartAngle + Math.PI / 2 < startAngle + swapAngle)
{ {
tempStartAngle += Math.PI / 2; tempStartAngle += Math.PI / 2;
} }
else else
{ {
if(i !== numCache.length)
angles.push({start: newStartAngle, swap: newSwapAngle, end: newStartAngle + newSwapAngle}); angles.push({start: newStartAngle, swap: newSwapAngle, end: newStartAngle + newSwapAngle});
break; break;
} }
} }
}
startAngle += swapAngle; startAngle += swapAngle;
if(i === numCache.length)
{
if(swapAngle < 0)
{
newStartAngle -= newSwapAngle;
}
else
{
newStartAngle += newSwapAngle;
}
}
else
{
newStartAngle += newSwapAngle; newStartAngle += newSwapAngle;
} }
}
return angles; return angles;
}, },
......
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