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

переделал отрисовку bar/hbar

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@55502 954022d7-b5bf-4e40-9824-e11837661b57
parent 22fcf9e5
...@@ -2551,6 +2551,12 @@ CChartsDrawer.prototype = ...@@ -2551,6 +2551,12 @@ CChartsDrawer.prototype =
var manualMin = chartProp.chart.plotArea.valAx && chartProp.chart.plotArea.valAx.scaling && chartProp.chart.plotArea.valAx.scaling.min !== null ? chartProp.chart.plotArea.valAx.scaling.min : null; var manualMin = chartProp.chart.plotArea.valAx && chartProp.chart.plotArea.valAx.scaling && chartProp.chart.plotArea.valAx.scaling.min !== null ? chartProp.chart.plotArea.valAx.scaling.min : null;
var manualMax = chartProp.chart.plotArea.valAx && chartProp.chart.plotArea.valAx.scaling && chartProp.chart.plotArea.valAx.scaling.max !== null ? chartProp.chart.plotArea.valAx.scaling.max : null; var manualMax = chartProp.chart.plotArea.valAx && chartProp.chart.plotArea.valAx.scaling && chartProp.chart.plotArea.valAx.scaling.max !== null ? chartProp.chart.plotArea.valAx.scaling.max : null;
if(this.calcProp.subType == 'stackedPer' && manualMin != null)
manualMin = manualMin * 100;
if(this.calcProp.subType == 'stackedPer' && manualMax != null)
manualMax = manualMax * 100;
axisMin = manualMin ? manualMin : trueMinMax.min; axisMin = manualMin ? manualMin : trueMinMax.min;
axisMax = manualMax ? manualMax : trueMinMax.max; axisMax = manualMax ? manualMax : trueMinMax.max;
...@@ -3195,28 +3201,30 @@ CChartsDrawer.prototype = ...@@ -3195,28 +3201,30 @@ CChartsDrawer.prototype =
resPos = Math.abs(yPoints[s + 1].pos - yPoints[s].pos); resPos = Math.abs(yPoints[s + 1].pos - yPoints[s].pos);
resVal = yPoints[s + 1].val - yPoints[s].val; resVal = yPoints[s + 1].val - yPoints[s].val;
var startPos = yPoints[s].pos;
if(!isOx) if(!isOx)
{ {
if(plotArea.valAx.scaling.orientation == ORIENTATION_MIN_MAX) if(plotArea.valAx.scaling.orientation == ORIENTATION_MIN_MAX)
result = - (resPos / resVal) * (Math.abs(val - yPoints[s].val)) + yPoints[s].pos; result = - (resPos / resVal) * (Math.abs(val - yPoints[s].val)) + startPos;
else else
result = (resPos / resVal) * (Math.abs(val - yPoints[s].val)) + yPoints[s].pos; result = (resPos / resVal) * (Math.abs(val - yPoints[s].val)) + startPos;
} }
else else
{ {
if(this.calcProp.type == "Scatter") if(this.calcProp.type == "Scatter")
{ {
if(plotArea.catAx.scaling.orientation != ORIENTATION_MIN_MAX) if(plotArea.catAx.scaling.orientation != ORIENTATION_MIN_MAX)
result = - (resPos / resVal) * (Math.abs(val - yPoints[s].val)) + yPoints[s].pos; result = - (resPos / resVal) * (Math.abs(val - yPoints[s].val)) + startPos;
else else
result = (resPos / resVal) * (Math.abs(val - yPoints[s].val)) + yPoints[s].pos; result = (resPos / resVal) * (Math.abs(val - yPoints[s].val)) + startPos;
} }
else else
{ {
if((plotArea.valAx.scaling.orientation == ORIENTATION_MIN_MAX && this.calcProp.type != "Line") || (plotArea.catAx.scaling.orientation == ORIENTATION_MIN_MAX && this.calcProp.type == "Line")) if((plotArea.valAx.scaling.orientation == ORIENTATION_MIN_MAX && this.calcProp.type != "Line") || (plotArea.catAx.scaling.orientation == ORIENTATION_MIN_MAX && this.calcProp.type == "Line"))
result = (resPos / resVal) * (Math.abs(val - yPoints[s].val)) + yPoints[s].pos; result = (resPos / resVal) * (Math.abs(val - yPoints[s].val)) + startPos;
else else
result = - (resPos / resVal) * (Math.abs(val - yPoints[s].val)) + yPoints[s].pos; result = - (resPos / resVal) * (Math.abs(val - yPoints[s].val)) + startPos;
} }
} }
...@@ -3722,7 +3730,7 @@ drawBarChart.prototype = ...@@ -3722,7 +3730,7 @@ drawBarChart.prototype =
tempValues[i][idx] = val; tempValues[i][idx] = val;
startYColumnPosition = this._getStartYColumnPosition(seriesHeight, idx, val, yPoints, prevVal); startYColumnPosition = this._getStartYColumnPosition(seriesHeight, i, idx, val, yPoints, prevVal);
startY = startYColumnPosition.startY; startY = startYColumnPosition.startY;
height = startYColumnPosition.height; height = startYColumnPosition.height;
...@@ -3784,87 +3792,41 @@ drawBarChart.prototype = ...@@ -3784,87 +3792,41 @@ drawBarChart.prototype =
} }
}, },
_getStartYColumnPosition: function (seriesHeight, i, j, val, yPoints, prevVal)
_getStartYColumnPosition: function (seriesHeight, j, val, yPoints, prevVal)
{ {
var startY, diffYVal, height, numCache, tempLogVal, tempPrevLogVal; var startY, diffYVal, height, numCache, tempLogVal, tempPrevLogVal, curVal, prevVal, endBlockPosition, startBlockPosition;
var nullPositionOX = this.cShapeDrawer.chart.plotArea.valAx && this.cShapeDrawer.chart.plotArea.valAx.scaling.logBase ? this.chartProp.nullPositionOXLog : this.cShapeDrawer.chart.plotArea.catAx.posY * this.chartProp.pxToMM; var nullPositionOX = this.cShapeDrawer.chart.plotArea.valAx && this.cShapeDrawer.chart.plotArea.valAx.scaling.logBase ? this.chartProp.nullPositionOXLog : this.cShapeDrawer.chart.plotArea.catAx.posY * this.chartProp.pxToMM;
if(this.chartProp.subType == "stacked") if(this.chartProp.subType == "stacked")
{ {
diffYVal = 0; curVal = this._getStackedValue(this.chartProp.series, i, j, val);
for(var k = 0; k < seriesHeight.length; k++) prevVal = this._getStackedValue(this.chartProp.series, i - 1, j, val);
{
if(seriesHeight[k][j] && ((val > 0 && seriesHeight[k][j] > 0) || (val < 0 && seriesHeight[k][j] < 0)))
diffYVal += seriesHeight[k][j];
}
if(this.cShapeDrawer.chart.plotArea.valAx.scaling.orientation != ORIENTATION_MIN_MAX)
startY = nullPositionOX + diffYVal;
else
startY = nullPositionOX - diffYVal;
//исключение для логарифмической шкалы
if(prevVal && this.cShapeDrawer.chart.plotArea.valAx && this.cShapeDrawer.chart.plotArea.valAx.scaling.logBase)
{
tempLogVal = this.cChartDrawer.getYPosition(val + prevVal, yPoints, null,this.cShapeDrawer.chart.plotArea.valAx.scaling.logBase);
tempPrevLogVal = this.cChartDrawer.getYPosition(prevVal, yPoints, null,this.cShapeDrawer.chart.plotArea.valAx.scaling.logBase);
height = (tempPrevLogVal - tempLogVal) * this.chartProp.pxToMM;
}
else if(this.cShapeDrawer.chart.plotArea.valAx && this.cShapeDrawer.chart.plotArea.valAx.scaling.logBase)
height = nullPositionOX - this.cChartDrawer.getYPosition(val, yPoints, null,this.cShapeDrawer.chart.plotArea.valAx.scaling.logBase) * this.chartProp.pxToMM;
else
height = nullPositionOX - this.cChartDrawer.getYPosition(val, yPoints) * this.chartProp.pxToMM;
endBlockPosition = this.cChartDrawer.getYPosition((curVal), yPoints) * this.chartProp.pxToMM;
startBlockPosition = prevVal ? this.cChartDrawer.getYPosition((prevVal), yPoints) * this.chartProp.pxToMM : nullPositionOX;
startY = startBlockPosition;
height = startBlockPosition - endBlockPosition;
if(this.cShapeDrawer.chart.plotArea.valAx.scaling.orientation != ORIENTATION_MIN_MAX) if(this.cShapeDrawer.chart.plotArea.valAx.scaling.orientation != ORIENTATION_MIN_MAX)
height = - height; height = - height;
} }
else if(this.chartProp.subType == "stackedPer") else if(this.chartProp.subType == "stackedPer")
{ {
diffYVal = 0; this._calculateSummStacked(j);
for(var k = 0; k < seriesHeight.length; k++)
{
if(seriesHeight[k][j] && ((val > 0 && seriesHeight[k][j] > 0) || (val < 0 && seriesHeight[k][j] < 0)))
diffYVal += seriesHeight[k][j];
}
var tempVal;
var temp = 0;
if(!this.summBarVal[j])
{
for(var k = 0; k < this.chartProp.series.length; k++)
{
numCache = this.chartProp.series[k].val.numRef ? this.chartProp.series[k].val.numRef.numCache : this.chartProp.series[k].val.numLit;
tempVal = parseFloat(numCache.pts[j].val);
if(tempVal)
temp += Math.abs(tempVal);
}
this.summBarVal[j] = temp;
}
curVal = this._getStackedValue(this.chartProp.series, i, j, val);
prevVal = this._getStackedValue(this.chartProp.series, i - 1, j, val);
//исключение для логарифмической шкалы endBlockPosition = this.cChartDrawer.getYPosition((curVal / this.summBarVal[j]), yPoints) * this.chartProp.pxToMM;
if(prevVal && this.cShapeDrawer.chart.plotArea.valAx && this.cShapeDrawer.chart.plotArea.valAx.scaling.logBase) startBlockPosition = this.summBarVal[j] ? this.cChartDrawer.getYPosition((prevVal / this.summBarVal[j]), yPoints) * this.chartProp.pxToMM : nullPositionOX;
{
tempLogVal = this.cChartDrawer.getYPosition(val / this.summBarVal[j] + prevVal / this.summBarVal[j], yPoints, null,this.cShapeDrawer.chart.plotArea.valAx.scaling.logBase);
tempPrevLogVal = this.cChartDrawer.getYPosition(prevVal / this.summBarVal[j], yPoints, null,this.cShapeDrawer.chart.plotArea.valAx.scaling.logBase);
height = (tempPrevLogVal - tempLogVal) * this.chartProp.pxToMM;
}
else if(this.cShapeDrawer.chart.plotArea.valAx && this.cShapeDrawer.chart.plotArea.valAx.scaling.logBase)
height = nullPositionOX - this.cChartDrawer.getYPosition(val / this.summBarVal[j], yPoints, null,this.cShapeDrawer.chart.plotArea.valAx.scaling.logBase) * this.chartProp.pxToMM;
else
height = nullPositionOX - this.cChartDrawer.getYPosition((val / this.summBarVal[j]), yPoints) * this.chartProp.pxToMM;
startY = startBlockPosition;
height = startBlockPosition - endBlockPosition;
if(this.cShapeDrawer.chart.plotArea.valAx.scaling.orientation != ORIENTATION_MIN_MAX) if(this.cShapeDrawer.chart.plotArea.valAx.scaling.orientation != ORIENTATION_MIN_MAX)
height = - height; height = - height;
if(this.cShapeDrawer.chart.plotArea.valAx.scaling.orientation != ORIENTATION_MIN_MAX)
startY = nullPositionOX + diffYVal;
else
startY = nullPositionOX - diffYVal;
} }
else else
{ {
...@@ -3882,6 +3844,42 @@ drawBarChart.prototype = ...@@ -3882,6 +3844,42 @@ drawBarChart.prototype =
return {startY : startY, height: height}; return {startY : startY, height: height};
}, },
_calculateSummStacked : function(j)
{
if(!this.summBarVal[j])
{
var tempVal;
var temp = 0;
var numCache;
for(var k = 0; k < this.chartProp.series.length; k++)
{
numCache = this.chartProp.series[k].val.numRef ? this.chartProp.series[k].val.numRef.numCache : this.chartProp.series[k].val.numLit;
tempVal = parseFloat(this.chartProp.series[k].val.numRef.numCache.pts[j].val);
if(tempVal)
temp += Math.abs(tempVal);
}
this.summBarVal[j] = temp;
}
},
_getStackedValue: function(series, i, j, val)
{
var numCache, result = 0, curVal, idxPoint;
for(var nSer = 0; nSer <= i; nSer++)
{
numCache = series[nSer].val.numRef ? series[nSer].val.numRef.numCache.pts : series[nSer].val.numLit.pts;
idxPoint = this.cChartDrawer.getIdxPoint(this.chartProp.series[nSer], j);
curVal = idxPoint ? idxPoint.val : 0;
if(idxPoint && val > 0 && curVal > 0)
result += parseFloat(curVal);
else if(idxPoint && val < 0 && curVal < 0)
result += parseFloat(curVal);
};
return result;
},
_getYPosition: function(val, yPoints) _getYPosition: function(val, yPoints)
{ {
//позиция в заисимости от положения точек на оси OY //позиция в заисимости от положения точек на оси OY
...@@ -4853,64 +4851,34 @@ drawHBarChart.prototype = ...@@ -4853,64 +4851,34 @@ drawHBarChart.prototype =
_getStartYColumnPosition: function (seriesHeight, j, i, val, xPoints, summBarVal) _getStartYColumnPosition: function (seriesHeight, j, i, val, xPoints, summBarVal)
{ {
var startY, diffYVal, width, numCache; var startY, diffYVal, width, numCache, dVal, curVal, prevVal, endBlockPosition, startBlockPosition;
var nullPositionOX = this.cShapeDrawer.chart.plotArea.catAx.posX * this.chartProp.pxToMM; var nullPositionOX = this.cShapeDrawer.chart.plotArea.catAx.posX * this.chartProp.pxToMM;
if(this.chartProp.subType == "stacked") if(this.chartProp.subType == "stacked")
{ {
//TODO TEST curVal = this._getStackedValue(this.chartProp.series, i, j, val);
if(this.cShapeDrawer.chart.plotArea.valAx.xPoints[0].val > 0 && i != 0) prevVal = this._getStackedValue(this.chartProp.series, i - 1, j, val);
val += this.cShapeDrawer.chart.plotArea.valAx.xPoints[0].val;
diffYVal = 0; endBlockPosition = this.cChartDrawer.getYPosition((curVal), xPoints, true) * this.chartProp.pxToMM;
for(var k = 0; k < seriesHeight.length; k++) startBlockPosition = prevVal ? this.cChartDrawer.getYPosition((prevVal), xPoints, true) * this.chartProp.pxToMM : nullPositionOX;
{
if(seriesHeight[k][j] && ((val > 0 && seriesHeight[k][j] > 0) || (val < 0 && seriesHeight[k][j] < 0)))
diffYVal += seriesHeight[k][j];
}
if(this.cShapeDrawer.chart.plotArea.valAx.scaling.orientation != ORIENTATION_MIN_MAX) startY = startBlockPosition;
startY = nullPositionOX - diffYVal; width = endBlockPosition - startBlockPosition;
else
startY = nullPositionOX + diffYVal;
width = this.cChartDrawer.getYPosition(val, xPoints, true) * this.chartProp.pxToMM - nullPositionOX;
if(this.cShapeDrawer.chart.plotArea.valAx.scaling.orientation != ORIENTATION_MIN_MAX) if(this.cShapeDrawer.chart.plotArea.valAx.scaling.orientation != ORIENTATION_MIN_MAX)
width = - width; width = - width;
} }
else if(this.chartProp.subType == "stackedPer") else if(this.chartProp.subType == "stackedPer")
{ {
//TODO сделать по аналогиий с stacked this._calculateSummStacked(j);
/*if(this.cShapeDrawer.chart.plotArea.valAx.xPoints[0].val > 0 && i != 0)
val += this.cShapeDrawer.chart.plotArea.valAx.xPoints[0].val;*/
diffYVal = 0;
for(var k = 0; k < seriesHeight.length; k++)
{
if(seriesHeight[k][j] && ((val > 0 && seriesHeight[k][j] > 0) || (val < 0 && seriesHeight[k][j] < 0)))
diffYVal += seriesHeight[k][j];
}
var tempVal; curVal = this._getStackedValue(this.chartProp.series, i, j, val);
var temp = 0; prevVal = this._getStackedValue(this.chartProp.series, i - 1, j, val);
if(!this.summBarVal[j])
{ endBlockPosition = this.cChartDrawer.getYPosition((curVal / this.summBarVal[j]), xPoints, true) * this.chartProp.pxToMM;
for(var k = 0; k < this.chartProp.series.length; k++) startBlockPosition = this.summBarVal[j] ? this.cChartDrawer.getYPosition((prevVal / this.summBarVal[j]), xPoints, true) * this.chartProp.pxToMM : nullPositionOX;
{
numCache = this.chartProp.series[k].val.numRef ? this.chartProp.series[k].val.numRef.numCache : this.chartProp.series[k].val.numLit; startY = startBlockPosition;
tempVal = parseFloat(this.chartProp.series[k].val.numRef.numCache.pts[j].val); width = endBlockPosition - startBlockPosition;
if(tempVal)
temp += Math.abs(tempVal);
}
this.summBarVal[j] = temp;
}
if(this.cShapeDrawer.chart.plotArea.valAx.scaling.orientation != ORIENTATION_MIN_MAX)
startY = nullPositionOX - diffYVal;
else
startY = nullPositionOX + diffYVal;
width = this.cChartDrawer.getYPosition((val / this.summBarVal[j]), xPoints, true) * this.chartProp.pxToMM - nullPositionOX;
if(this.cShapeDrawer.chart.plotArea.valAx.scaling.orientation != ORIENTATION_MIN_MAX) if(this.cShapeDrawer.chart.plotArea.valAx.scaling.orientation != ORIENTATION_MIN_MAX)
width = - width; width = - width;
...@@ -4924,6 +4892,41 @@ drawHBarChart.prototype = ...@@ -4924,6 +4892,41 @@ drawHBarChart.prototype =
return {startY: startY, width: width}; return {startY: startY, width: width};
}, },
_calculateSummStacked : function(j)
{
if(!this.summBarVal[j])
{
var tempVal;
var temp = 0, numCache;
for(var k = 0; k < this.chartProp.series.length; k++)
{
numCache = this.chartProp.series[k].val.numRef ? this.chartProp.series[k].val.numRef.numCache : this.chartProp.series[k].val.numLit;
tempVal = parseFloat(this.chartProp.series[k].val.numRef.numCache.pts[j].val);
if(tempVal)
temp += Math.abs(tempVal);
}
this.summBarVal[j] = temp;
}
},
_getStackedValue: function(series, i, j, val)
{
var numCache, result = 0, curVal, idxPoint;
for(var nSer = 0; nSer <= i; nSer++)
{
numCache = series[nSer].val.numRef ? series[nSer].val.numRef.numCache.pts : series[nSer].val.numLit.pts;
idxPoint = this.cChartDrawer.getIdxPoint(this.chartProp.series[nSer], j);
curVal = idxPoint ? idxPoint.val : 0;
if(idxPoint && val > 0 && curVal > 0)
result += parseFloat(curVal);
else if(idxPoint && val < 0 && curVal < 0)
result += parseFloat(curVal);
};
return result;
},
_getYPosition: function(val, yPoints, isOx) _getYPosition: function(val, yPoints, isOx)
{ {
//позиция в заисимости от положения точек на оси OY //позиция в заисимости от положения точек на оси OY
......
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