Commit 0e0e8fc9 authored by Igor.Zotov's avatar Igor.Zotov Committed by Alexander.Trofimov

правка для случае,когда линии диаграммы(линейной) выходят за пределы области построения

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@54531 954022d7-b5bf-4e40-9824-e11837661b57
parent e8a18742
...@@ -2321,7 +2321,7 @@ drawBarChart.prototype = ...@@ -2321,7 +2321,7 @@ drawBarChart.prototype =
} }
height = nullPositionOX - this._getYPosition((val / this.summBarVal[j]), yPoints) * this.chartProp.pxToMM; height = nullPositionOX - this._getYPosition((val / this.summBarVal[j]), yPoints) * this.chartProp.pxToMM;
startY = tnullPositionOX - diffYVal; startY = nullPositionOX - diffYVal;
} }
else else
{ {
...@@ -2505,11 +2505,42 @@ drawLineChart.prototype = ...@@ -2505,11 +2505,42 @@ drawLineChart.prototype =
val = this._getYVal(n, i); val = this._getYVal(n, i);
nextVal = this._getYVal(n + 1, i); nextVal = this._getYVal(n + 1, i);
y = this._getYPosition(val, yPoints); //точки находятся внутри диапазона
y1 = this._getYPosition(nextVal, yPoints); if(val >= yPoints[0].val && val <= yPoints[yPoints.length - 1].val && nextVal >= yPoints[0].val && nextVal <= yPoints[yPoints.length - 1].val)
{
y = this._getYPosition(val, yPoints);
y1 = this._getYPosition(nextVal, yPoints);
x = xPoints[n].pos;
x1 = xPoints[n + 1].pos;
}
//первая точка выходит за пределы диапазона || вторая точка выходит за пределы диапазона
else if(( nextVal >= yPoints[0].val && nextVal <= yPoints[yPoints.length - 1].val ) || ( val >= yPoints[0].val && val <= yPoints[yPoints.length - 1].val ))
{
y = this._getYPosition(val, yPoints);
y1 = this._getYPosition(nextVal, yPoints);
if(val < yPoints[0].val)
yk = this._getYPosition(yPoints[0].val, yPoints);
else
yk = this._getYPosition(yPoints[yPoints.length - 1].val, yPoints);
x = xPoints[n].pos;
x1 = xPoints[n + 1].pos;
//находим из двух точек уравнение, из третьей координаты y находим x
if(nextVal >= yPoints[0].val && nextVal <= yPoints[yPoints.length - 1].val)
{
x = (yk * (x - x1) + x1 * y + x1 * y1) / (y - y1);
y = yk;
}
else
{
x1 = (yk * (x - x1) + x1 * y + x1 * y1) / (y - y1);
y1 = yk;
}
}
x = xPoints[n].pos;
x1 = xPoints[n + 1].pos;
if(!this.paths.series) if(!this.paths.series)
this.paths.series = []; this.paths.series = [];
...@@ -2527,16 +2558,35 @@ drawLineChart.prototype = ...@@ -2527,16 +2558,35 @@ drawLineChart.prototype =
var result; var result;
var resPos; var resPos;
var resVal; var resVal;
for(var s = 0; s < yPoints.length; s++) var diffVal;
if(val < yPoints[0].val)
{ {
if(val >= yPoints[s].val && val <= yPoints[s + 1].val) resPos = Math.abs(yPoints[1].pos - yPoints[0].pos);
resVal = yPoints[1].val - yPoints[0].val;
diffVal = Math.abs(yPoints[0].val) - Math.abs(val);
result = yPoints[0].pos - (diffVal / resVal) * resPos;
}
else if(val > yPoints[yPoints.length - 1].val)
{
resPos = Math.abs(yPoints[1].pos - yPoints[0].pos);
resVal = yPoints[1].val - yPoints[0].val;
diffVal = Math.abs(yPoints[0].val) - Math.abs(val);
result = yPoints[0].pos + (diffVal / resVal) * resPos;
}
else
{
for(var s = 0; s < yPoints.length; s++)
{ {
resPos = Math.abs(yPoints[s + 1].pos - yPoints[s].pos); if(val >= yPoints[s].val && val <= yPoints[s + 1].val)
resVal = yPoints[s + 1].val - yPoints[s].val; {
result = - (resPos / resVal) * (Math.abs(val - yPoints[s].val)) + yPoints[s].pos; resPos = Math.abs(yPoints[s + 1].pos - yPoints[s].pos);
break; resVal = yPoints[s + 1].val - yPoints[s].val;
result = - (resPos / resVal) * (Math.abs(val - yPoints[s].val)) + yPoints[s].pos;
break;
}
} }
} }
return result; return result;
}, },
......
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