Commit 9d18b2d0 authored by GoshaZotov's avatar GoshaZotov

changes for stacked hbar charts

parent 5b3ee017
...@@ -243,7 +243,7 @@ Processor3D.prototype._calculateScaleNStandard = function() ...@@ -243,7 +243,7 @@ Processor3D.prototype._calculateScaleNStandard = function()
var widthLine = this.widthCanvas - (this.left + this.right); var widthLine = this.widthCanvas - (this.left + this.right);
var heightLine = this.heightCanvas - (this.top + this.bottom); var heightLine = this.heightCanvas - (this.top + this.bottom);
var trueDepth = this.depthPerspective * Math.sin(-this.angleOx); var trueDepth = Math.abs(this.depthPerspective * Math.sin(-this.angleOx));
var mustHeight = heightLine - trueDepth; var mustHeight = heightLine - trueDepth;
var mustWidth = this.chartsDrawer.calcProp.type === AscFormat.c_oChartTypes.HBar ? mustHeight * this.hPercent : mustHeight / this.hPercent; var mustWidth = this.chartsDrawer.calcProp.type === AscFormat.c_oChartTypes.HBar ? mustHeight * this.hPercent : mustHeight / this.hPercent;
...@@ -846,7 +846,7 @@ Processor3D.prototype._calculateDepth = function() ...@@ -846,7 +846,7 @@ Processor3D.prototype._calculateDepth = function()
var basePercent = this.view3D && this.view3D.depthPercent ? this.view3D.depthPercent / 100 : globalBasePercent / 100;//процент от базовой глубины var basePercent = this.view3D && this.view3D.depthPercent ? this.view3D.depthPercent / 100 : globalBasePercent / 100;//процент от базовой глубины
var seriesCount = this.chartsDrawer.calcProp.seriesCount; var seriesCount = this.chartsDrawer.calcProp.seriesCount;
var ptCount = this.chartsDrawer.calcProp.ptCount; var ptCount = this.chartsDrawer.calcProp.ptCount;
var sinOx = Math.sin(-this.angleOx); var sinOx = Math.abs(Math.sin(-this.angleOx));
var sinOy = Math.sin(-this.angleOy); var sinOy = Math.sin(-this.angleOy);
var hPercent = type == AscFormat.c_oChartTypes.HBar ? 1 : this.hPercent; var hPercent = type == AscFormat.c_oChartTypes.HBar ? 1 : this.hPercent;
var depthPercent = this.view3D.depthPercent !== null ? this.view3D.depthPercent / 100 : 1; var depthPercent = this.view3D.depthPercent !== null ? this.view3D.depthPercent / 100 : 1;
...@@ -872,7 +872,7 @@ Processor3D.prototype._calculateDepth = function() ...@@ -872,7 +872,7 @@ Processor3D.prototype._calculateDepth = function()
{ {
chartWidth = widthOneBar + heightHPercent; chartWidth = widthOneBar + heightHPercent;
} }
else if(this.angleOx !== 0/* && this.angleOy !== 0*/)//AngleOYNoAut + AngleOYNoAutPerHeight + (ANGLEOX+ANGLEOY) + AngleOYOXNoAut + ANGLEOXANGLEOYHPerDPer(ANGLEOX+ANGLEOY HPercent) else if(this.angleOx !== 0)//AngleOYNoAut + AngleOYNoAutPerHeight + (ANGLEOX+ANGLEOY) + AngleOYOXNoAut + ANGLEOXANGLEOYHPerDPer(ANGLEOX+ANGLEOY HPercent)
{ {
//если выставить ширину 255 будет так же, как и в документе с расчётами //если выставить ширину 255 будет так же, как и в документе с расчётами
b = (seriesCount - (seriesCount - 1) * overlap + gapWidth); b = (seriesCount - (seriesCount - 1) * overlap + gapWidth);
...@@ -912,7 +912,7 @@ Processor3D.prototype._calculateDepth = function() ...@@ -912,7 +912,7 @@ Processor3D.prototype._calculateDepth = function()
depth = depth * Math.sin(-this.angleOx); depth = depth * Math.sin(-this.angleOx);
} }
return sinOx !== 0 ? depth / Math.sin(-this.angleOx) : depth; return sinOx !== 0 ? depth / sinOx : depth;
}; };
Processor3D.prototype._calculateDepthPerspective = function() Processor3D.prototype._calculateDepthPerspective = function()
......
...@@ -1075,6 +1075,10 @@ CChartsDrawer.prototype = ...@@ -1075,6 +1075,10 @@ CChartsDrawer.prototype =
this.calcProp.max = this.calcProp.scale[this.calcProp.scale.length -1]; this.calcProp.max = this.calcProp.scale[this.calcProp.scale.length -1];
this.calcProp.min = this.calcProp.scale[0]; this.calcProp.min = this.calcProp.scale[0];
} }
this.calcProp.axisMin = this.calcProp.scale[0] < this.calcProp.scale[this.calcProp.scale.length - 1] ? this.calcProp.scale[0] : this.calcProp.scale[this.calcProp.scale.length - 1];
this.calcProp.axisMax = this.calcProp.scale[0] < this.calcProp.scale[this.calcProp.scale.length - 1] ? this.calcProp.scale[this.calcProp.scale.length - 1] : this.calcProp.scale[0];
}, },
//****new calculate data**** //****new calculate data****
...@@ -1397,9 +1401,9 @@ CChartsDrawer.prototype = ...@@ -1397,9 +1401,9 @@ CChartsDrawer.prototype =
axisMax = manualMax !== null && manualMax !== undefined ? manualMax : trueMinMax.max; axisMax = manualMax !== null && manualMax !== undefined ? manualMax : trueMinMax.max;
var percentChartMax = 100; var percentChartMax = 100;
if(this.calcProp.subType == 'stackedPer' && axisMax > percentChartMax) if(this.calcProp.subType == 'stackedPer' && axisMax > percentChartMax && manualMax === null)
axisMax = percentChartMax; axisMax = percentChartMax;
if(this.calcProp.subType == 'stackedPer' && axisMin < - percentChartMax) if(this.calcProp.subType == 'stackedPer' && axisMin < - percentChartMax && manualMin === null)
axisMin = - percentChartMax; axisMin = - percentChartMax;
...@@ -1418,6 +1422,10 @@ CChartsDrawer.prototype = ...@@ -1418,6 +1422,10 @@ CChartsDrawer.prototype =
if(axis && axis.majorUnit !== null) if(axis && axis.majorUnit !== null)
{ {
step = axis.majorUnit; step = axis.majorUnit;
if(this.calcProp.subType == 'stackedPer')
{
step = step * 100;
}
} }
else else
{ {
...@@ -1553,9 +1561,11 @@ CChartsDrawer.prototype = ...@@ -1553,9 +1561,11 @@ CChartsDrawer.prototype =
_getArrayAxisValues: function(minUnit, axisMin, axisMax, step, manualMin, manualMax) _getArrayAxisValues: function(minUnit, axisMin, axisMax, step, manualMin, manualMax)
{ {
var arrayValues = []; var arrayValues = [];
var stackedPerMax = null !== manualMax ? manualMax : 100;
for(var i = 0; i < 20; i++) for(var i = 0; i < 20; i++)
{ {
if(this.calcProp.subType == 'stackedPer' && (minUnit + step * i) > 100) if(this.calcProp.subType == 'stackedPer' && (minUnit + step * i) > stackedPerMax)
break; break;
arrayValues[i] = minUnit + step * i; arrayValues[i] = minUnit + step * i;
...@@ -6522,30 +6532,57 @@ drawHBarChart.prototype = ...@@ -6522,30 +6532,57 @@ drawHBarChart.prototype =
_getStartYColumnPosition: function (seriesHeight, j, i, val, xPoints, summBarVal) _getStartYColumnPosition: function (seriesHeight, j, i, val, xPoints, summBarVal)
{ {
var startY, diffYVal, width, numCache, dVal, curVal, prevVal, endBlockPosition, startBlockPosition; var startY, diffYVal, width, numCache, dVal, curVal, prevVal, endBlockPosition, startBlockPosition;
var nullPositionOX = this.cChartSpace.chart.plotArea.catAx.posX ? this.cChartSpace.chart.plotArea.catAx.posX * this.chartProp.pxToMM : this.cChartSpace.chart.plotArea.catAx.xPos * this.chartProp.pxToMM; var catAx = this.cChartSpace.chart.plotArea.catAx;
if(this.chartProp.subType == "stacked") var nullPositionOX = catAx.posX ? catAx.posX * this.chartProp.pxToMM : catAx.xPos * this.chartProp.pxToMM;
if(this.chartProp.subType == "stacked" || this.chartProp.subType == "stackedPer")
{ {
curVal = this._getStackedValue(this.chartProp.series, i, j, val); curVal = this._getStackedValue(this.chartProp.series, i, j, val);
prevVal = this._getStackedValue(this.chartProp.series, i - 1, j, val); prevVal = this._getStackedValue(this.chartProp.series, i - 1, j, val);
endBlockPosition = this.cChartDrawer.getYPosition((curVal), xPoints, true) * this.chartProp.pxToMM; if(this.chartProp.subType == "stacked")
startBlockPosition = prevVal ? this.cChartDrawer.getYPosition((prevVal), xPoints, true) * this.chartProp.pxToMM : nullPositionOX; {
//если максимальное значение задано вручную, и присутвуют точки, которые больше этого значения
startY = startBlockPosition; if(curVal > this.cChartDrawer.calcProp.axisMax)
width = endBlockPosition - startBlockPosition; {
curVal = this.cChartDrawer.calcProp.axisMax;
if(this.cChartSpace.chart.plotArea.valAx.scaling.orientation != ORIENTATION_MIN_MAX) }
width = - width; if(curVal < this.cChartDrawer.calcProp.axisMin)
} {
else if(this.chartProp.subType == "stackedPer") curVal = this.cChartDrawer.calcProp.axisMin;
{ }
this._calculateSummStacked(j);
endBlockPosition = this.cChartDrawer.getYPosition((curVal), xPoints, true) * this.chartProp.pxToMM;
curVal = this._getStackedValue(this.chartProp.series, i, j, val); startBlockPosition = prevVal ? this.cChartDrawer.getYPosition((prevVal), xPoints, true) * this.chartProp.pxToMM : nullPositionOX;
prevVal = this._getStackedValue(this.chartProp.series, i - 1, j, val); }
else
endBlockPosition = this.cChartDrawer.getYPosition((curVal / this.summBarVal[j]), xPoints, true) * this.chartProp.pxToMM; {
startBlockPosition = this.summBarVal[j] ? this.cChartDrawer.getYPosition((prevVal / this.summBarVal[j]), xPoints, true) * this.chartProp.pxToMM : nullPositionOX; this._calculateSummStacked(j);
var test = this.summBarVal[j];
//если максимальное значение задано вручную, и присутвуют точки, которые больше этого значения
if(curVal / test > this.cChartDrawer.calcProp.axisMax)
{
curVal = this.cChartDrawer.calcProp.axisMax * test;
}
if(curVal / test < this.cChartDrawer.calcProp.axisMin)
{
curVal = this.cChartDrawer.calcProp.axisMin * test;
}
if(prevVal / test > this.cChartDrawer.calcProp.axisMax)
{
prevVal = this.cChartDrawer.calcProp.axisMax * test;
}
if(prevVal / test < this.cChartDrawer.calcProp.axisMin)
{
prevVal = this.cChartDrawer.calcProp.axisMin * test;
}
endBlockPosition = this.cChartDrawer.getYPosition((curVal / test), xPoints, true) * this.chartProp.pxToMM;
startBlockPosition = test ? this.cChartDrawer.getYPosition((prevVal / test), xPoints, true) * this.chartProp.pxToMM : nullPositionOX;
}
startY = startBlockPosition; startY = startBlockPosition;
width = endBlockPosition - startBlockPosition; width = endBlockPosition - startBlockPosition;
......
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