Commit addf2669 authored by GoshaZotov's avatar GoshaZotov Committed by GitHub

Merge pull request #90 from ONLYOFFICE/Feature/3d_perspective_pie

Feature/3d perspective pie
parents 3328c59d d621e895
......@@ -90,11 +90,10 @@ function Processor3D(width, height, left, right, bottom, top, chartSpace, charts
this.angleOy = this.view3D && this.view3D.rotY ? (- this.view3D.rotY / 360) * (Math.PI * 2) : 0;
this.angleOz = this.view3D && this.view3D.rotZ ? (- this.view3D.rotZ / 360) * (Math.PI * 2) : 0;
/*if(this.view3D.rAngAx && this.view3D.rotX < 0)
if(!this.view3D.rAngAx && AscFormat.c_oChartTypes.Pie === this.chartsDrawer.calcProp.type)
{
this.angleOx = - this.angleOx;
this.angleOy = - this.angleOy;
}*/
this.angleOy = 0;
}
this.orientationCatAx = null;
this.orientationValAx = null;
......@@ -139,6 +138,55 @@ Processor3D.prototype.calaculate3DProperties = function(baseDepth, gapDepth, bIs
this._recalculateScaleWithMaxWidth();
}
}
if(AscFormat.c_oChartTypes.Pie === this.chartsDrawer.calcProp.type && !this.view3D.rAngAx)
{
//TODO пересмотреть функцию
this.tempChangeAspectRatioForPie();
}
};
Processor3D.prototype.tempChangeAspectRatioForPie = function()
{
var perspectiveDepth = this.depthPerspective;
var widthCanvas = this.widthCanvas;
var originalWidthChart = widthCanvas - this.left - this.right;
var heightCanvas = this.heightCanvas;
var heightChart = heightCanvas - this.top - this.bottom;
var points = [], faces = [];
points.push(new Point3D(this.left + originalWidthChart / 2, this.top, perspectiveDepth, this));
points.push(new Point3D(this.left, this.top, perspectiveDepth / 2, this));
points.push(new Point3D(this.left + originalWidthChart, this.top, perspectiveDepth / 2, this));
points.push(new Point3D(this.left + originalWidthChart / 2, this.top, 0, this));
points.push(new Point3D(this.left + originalWidthChart / 2, this.top + heightChart, perspectiveDepth, this));
points.push(new Point3D(this.left, this.top + heightChart, perspectiveDepth / 2, this));
points.push(new Point3D(this.left + originalWidthChart, this.top + heightChart, perspectiveDepth / 2, this));
points.push(new Point3D(this.left + originalWidthChart / 2, this.top + heightChart, 0, this));
faces.push([0,1,2,3]);
faces.push([2,5,4,3]);
faces.push([1,6,7,0]);
faces.push([6,5,4,7]);
faces.push([7,4,3,0]);
faces.push([1,6,2,5]);
var minMaxOx = this._getMinMaxOx(points, faces);
var minMaxOy = this._getMinMaxOy(points, faces);
var kF = ((minMaxOx.right - minMaxOx.left) / originalWidthChart);
if((minMaxOy.bottom - minMaxOy.top) / kF > heightChart)
{
kF = ((minMaxOy.bottom - minMaxOy.top) / heightChart);
}
this.aspectRatioX = this.aspectRatioX * kF;
this.aspectRatioY = this.aspectRatioY * kF;
this.aspectRatioZ = this.aspectRatioZ * kF;
};
Processor3D.prototype.calculateCommonOptions = function()
......@@ -157,6 +205,13 @@ Processor3D.prototype._calculateAutoHPercent = function()
this.hPercent = this.view3D.hPercent === null ? (heightLine / widthLine) : this.view3D.hPercent / 100;
if(this.chartsDrawer.calcProp.type === AscFormat.c_oChartTypes.HBar && ((this.view3D.hPercent === null && this.view3D.rAngAx) || (this.view3D.hPercent !== null && !this.view3D.rAngAx)))
this.hPercent = 1 / this.hPercent;
if(AscFormat.c_oChartTypes.Pie === this.chartsDrawer.calcProp.type)
{
this.hPercent = 0.12;
//this.view3D.depthPercent = 180;
}
}
};
......@@ -1107,6 +1162,12 @@ Processor3D.prototype._calculateDepthPerspective = function()
var gapWidth = this.chartSpace.chart.plotArea.chart.gapWidth != null ? (this.chartSpace.chart.plotArea.chart.gapWidth / 100) : (150 / 100);
var gapDepth = this.chartSpace.chart.plotArea.chart.gapDepth != null ? (this.chartSpace.chart.plotArea.chart.gapDepth / 100) : (150 / 100);
if(AscFormat.c_oChartTypes.Area === this.chartsDrawer.calcProp.type)
{
gapWidth = 0;
gapDepth = 0;
}
var baseDepth = width / (seriesCount - (seriesCount - 1) * overlap + gapWidth);
if(this.chartsDrawer.calcProp.subType == "standard" || this.chartsDrawer.calcProp.type == AscFormat.c_oChartTypes.Line || isNormalArea)
baseDepth = (width / (seriesCount - (seriesCount - 1) * overlap + gapWidth)) * seriesCount;
......@@ -1187,14 +1248,30 @@ Processor3D.prototype._calculateCameraDiff = function (/*isSkip*/)
//add test points for parallelepiped rect
var points = [];
var faces = [];
points.push(new Point3D(this.left, this.top, perspectiveDepth, this));
points.push(new Point3D(this.left, heightChart + this.top, perspectiveDepth, this));
points.push(new Point3D(originalWidthChart + this.left, heightChart + this.top, perspectiveDepth, this));
points.push(new Point3D(originalWidthChart + this.left, this.top, perspectiveDepth, this));
points.push(new Point3D(originalWidthChart + this.left, this.top, 0, this));
points.push(new Point3D(originalWidthChart + this.left, heightChart + this.top, 0, this));
points.push(new Point3D(this.left, heightChart + this.top, 0, this));
points.push(new Point3D(this.left, this.top, 0, this));
/*if(AscFormat.c_oChartTypes.Pie === this.chartsDrawer.calcProp.type)
{
points.push(new Point3D(this.left + originalWidthChart / 2, this.top, perspectiveDepth, this));
points.push(new Point3D(this.left, this.top, perspectiveDepth / 2, this));
points.push(new Point3D(this.left + originalWidthChart, this.top, perspectiveDepth / 2, this));
points.push(new Point3D(this.left + originalWidthChart / 2, this.top, 0, this));
points.push(new Point3D(this.left + originalWidthChart / 2, this.top + heightChart, perspectiveDepth, this));
points.push(new Point3D(this.left, this.top + heightChart, perspectiveDepth / 2, this));
points.push(new Point3D(this.left + originalWidthChart, this.top + heightChart, perspectiveDepth / 2, this));
points.push(new Point3D(this.left + originalWidthChart / 2, this.top + heightChart, 0, this));
}
else
{*/
points.push(new Point3D(this.left, this.top, perspectiveDepth, this));
points.push(new Point3D(this.left, heightChart + this.top, perspectiveDepth, this));
points.push(new Point3D(originalWidthChart + this.left, heightChart + this.top, perspectiveDepth, this));
points.push(new Point3D(originalWidthChart + this.left, this.top, perspectiveDepth, this));
points.push(new Point3D(originalWidthChart + this.left, this.top, 0, this));
points.push(new Point3D(originalWidthChart + this.left, heightChart + this.top, 0, this));
points.push(new Point3D(this.left, heightChart + this.top, 0, this));
points.push(new Point3D(this.left, this.top, 0, this));
//}
faces.push([0,1,2,3]);
faces.push([2,5,4,3]);
......@@ -1449,6 +1526,7 @@ Processor3D.prototype.checkOutSideArea = function(newPoints)
}
};
calculateZ(100);
calculateZ(10);
calculateZ(1);
......
This diff is collapsed.
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