Commit 35620b3c authored by GoshaZotov's avatar GoshaZotov

add new class for surface charts

parent 79212c99
......@@ -226,7 +226,7 @@ Processor3D.prototype._recalculateScaleWithMaxWidth = function()
var subType = this.chartsDrawer.calcProp.subType;
var type = this.chartsDrawer.calcProp.type;
var isStandardType = !!(subType === "standard" || type === AscFormat.c_oChartTypes.Line || type === AscFormat.c_oChartTypes.Area && subType === "normal");
var isStandardType = !!(subType === "standard" || type === AscFormat.c_oChartTypes.Line || (type === AscFormat.c_oChartTypes.Area && subType === "normal") || type === AscFormat.c_oChartTypes.Surface);
var optimalWidthLine, kF;
if(!isStandardType)
......@@ -1065,7 +1065,7 @@ Processor3D.prototype._calculateDepth = function()
var heightOriginalChart = this.heightCanvas - (this.top + this.bottom);
var subType = this.chartsDrawer.calcProp.subType;
var type = this.chartsDrawer.calcProp.type;
var defaultOverlap = (subType == "stacked" || subType == "stackedPer" || subType == "standard" || type == AscFormat.c_oChartTypes.Line || type == AscFormat.c_oChartTypes.Area) ? 100 : 0;
var defaultOverlap = (subType == "stacked" || subType == "stackedPer" || subType == "standard" || type == AscFormat.c_oChartTypes.Line || type == AscFormat.c_oChartTypes.Area || type == AscFormat.c_oChartTypes.Surface) ? 100 : 0;
var overlap = this.chartSpace.chart.plotArea.chart.overlap ? (this.chartSpace.chart.plotArea.chart.overlap / 100) : (defaultOverlap / 100);
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) : type === AscFormat.c_oChartTypes.Area && subType !== "normal" ? 1 : (150 / 100);
......@@ -1078,13 +1078,13 @@ Processor3D.prototype._calculateDepth = function()
var depthPercent = this.view3D.depthPercent !== null ? this.view3D.depthPercent / 100 : 1;
var t = this;
var areaStackedKf = type === AscFormat.c_oChartTypes.Area && subType !== "normal" ? (ptCount / (2 * (ptCount - 1))) : 1;
var areaStackedKf = (type === AscFormat.c_oChartTypes.Area && subType !== "normal") || type === AscFormat.c_oChartTypes.Surface ? (ptCount / (2 * (ptCount - 1))) : 1;
var depth = 0;
var chartWidth = 0;
var standardType = false;
if(subType == "standard" || type == AscFormat.c_oChartTypes.Line || (type == AscFormat.c_oChartTypes.Area && subType == "normal"))
if(subType == "standard" || type == AscFormat.c_oChartTypes.Line || (type == AscFormat.c_oChartTypes.Area && subType == "normal") || (type === AscFormat.c_oChartTypes.Surface))
standardType = true;
var heightHPercent = heightOriginalChart / hPercent;
......@@ -1115,7 +1115,7 @@ Processor3D.prototype._calculateDepth = function()
var widthChart = (widthOriginalChart / t.aspectRatioX) / t.specialStandardScaleX;
b = (seriesCount - (seriesCount - 1) * overlap + gapWidth);
if(subType == "standard" || type == AscFormat.c_oChartTypes.Line || type == AscFormat.c_oChartTypes.Area)
if(subType == "standard" || type == AscFormat.c_oChartTypes.Line || type == AscFormat.c_oChartTypes.Area || type === AscFormat.c_oChartTypes.Surface)
b = b / seriesCount;
angleOxKf = sinOx === 0 ? 1 : sinOx;
......@@ -1129,7 +1129,7 @@ Processor3D.prototype._calculateDepth = function()
{
angleOxKf = sinOx === 0 ? 0 : sinOx;
if(type == AscFormat.c_oChartTypes.Area)
if(type == AscFormat.c_oChartTypes.Area || type === AscFormat.c_oChartTypes.Surface)
depth = (depthPercent / (angleOxKf*depthPercent + ((ptCount + (Math.floor((seriesCount - ptCount) / 2 - 0.5))) / seriesCount * hPercent))) * (heightOriginalChart);
else
depth = (depthPercent / (angleOxKf*depthPercent + ((ptCount + (Math.floor((seriesCount - ptCount) / 2))) / seriesCount * hPercent))) * (heightOriginalChart);
......@@ -1154,7 +1154,7 @@ Processor3D.prototype._calculateDepthPerspective = function()
var width = widthChart / this.chartsDrawer.calcProp.ptCount;
var isNormalArea = !!(this.chartsDrawer.calcProp.subType == "normal" && this.chartsDrawer.calcProp.type == AscFormat.c_oChartTypes.Area);
var isNormalArea = !!((this.chartsDrawer.calcProp.subType == "normal" && this.chartsDrawer.calcProp.type == AscFormat.c_oChartTypes.Area) || this.chartsDrawer.calcProp.type === AscFormat.c_oChartTypes.Surface);
var defaultOverlap = (this.chartsDrawer.calcProp.subType == "stacked" || this.chartsDrawer.calcProp.subType == "stackedPer" || this.chartsDrawer.calcProp.subType == "standard" || this.chartsDrawer.calcProp.type == AscFormat.c_oChartTypes.Line || isNormalArea) ? 100 : 0;
var overlap = this.chartSpace.chart.plotArea.chart.overlap ? (this.chartSpace.chart.plotArea.chart.overlap / 100) : (defaultOverlap / 100);
......@@ -1162,7 +1162,7 @@ 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)
if(AscFormat.c_oChartTypes.Area === this.chartsDrawer.calcProp.type || AscFormat.c_oChartTypes.Surface === this.chartsDrawer.calcProp.type)
{
gapWidth = 0;
gapDepth = 0;
......@@ -1200,7 +1200,7 @@ Processor3D.prototype._calculateDepthPerspective = function()
Processor3D.prototype._calcSpecialStandardScaleX = function()
{
if(!(this.chartsDrawer.calcProp.subType == "standard" || this.chartsDrawer.calcProp.type == AscFormat.c_oChartTypes.Line || (this.chartsDrawer.calcProp.type === AscFormat.c_oChartTypes.Area && this.chartsDrawer.calcProp.subType == "normal")))
if(!(this.chartsDrawer.calcProp.subType == "standard" || this.chartsDrawer.calcProp.type == AscFormat.c_oChartTypes.Line || (this.chartsDrawer.calcProp.type === AscFormat.c_oChartTypes.Area && this.chartsDrawer.calcProp.subType == "normal") || this.chartsDrawer.calcProp.type === AscFormat.c_oChartTypes.Surface))
return;
//calculate width in 3d standard charts with rAngAx
......@@ -2502,7 +2502,7 @@ Processor3D.prototype._calcAspectRatio = function()
var aspectRatioY = 1;
var subType = this.chartsDrawer.calcProp.subType;
if((subType === "standard" || this.chartsDrawer.calcProp.type === AscFormat.c_oChartTypes.Line || (this.chartsDrawer.calcProp.type === AscFormat.c_oChartTypes.Area && subType == "normal")) && !this.view3D.rAngAx)
if((subType === "standard" || this.chartsDrawer.calcProp.type === AscFormat.c_oChartTypes.Line || (this.chartsDrawer.calcProp.type === AscFormat.c_oChartTypes.Area && subType == "normal") || this.chartsDrawer.calcProp.type === AscFormat.c_oChartTypes.Surface) && !this.view3D.rAngAx)
{
this._calcSpecialStandardScaleX();
......
......@@ -60,7 +60,8 @@ var c_oChartTypes =
Stock: 6,
DoughnutChart: 7,
Radar: 8,
BubbleChart: 9
BubbleChart: 9,
Surface: 10
};
var c_oChartBar3dFaces =
......@@ -215,6 +216,11 @@ CChartsDrawer.prototype =
newChart = new drawBubbleChart();
break;
}
case c_oChartTypes.Surface:
{
newChart = new drawSurfaceChart();
break;
}
}
this.chart = newChart;
......@@ -1884,6 +1890,11 @@ CChartsDrawer.prototype =
this.calcProp.type = c_oChartTypes.Scatter;
break;
}
case AscDFH.historyitem_type_SurfaceChart:
{
this.calcProp.type = c_oChartTypes.Surface;
break;
}
}
var grouping = chartProp.chart.plotArea.chart.grouping;
......@@ -3118,12 +3129,13 @@ CChartsDrawer.prototype =
var isLine = typeChart === AscDFH.historyitem_type_LineChart;
var isPie = typeChart === AscDFH.historyitem_type_PieChart;
var isArea = typeChart === AscDFH.historyitem_type_AreaChart;
var isSurface = typeChart === AscDFH.historyitem_type_SurfaceChart;
if(!isPerspective && (isBar || isLine || isHBar || isPie || isArea))
if(!isPerspective && (isBar || isLine || isHBar || isPie || isArea || isSurface))
{
res = true;
}
else if(isPerspective && (isBar || isLine|| isHBar || isArea || isPie))
else if(isPerspective && (isBar || isLine|| isHBar || isArea || isPie || isSurface))
{
res = true;
}
......@@ -10839,6 +10851,147 @@ drawBubbleChart.prototype =
};
/** @constructor */
function drawSurfaceChart()
{
this.chartProp = null;
this.cChartDrawer = null;
this.cChartSpace = null;
this.paths = {};
}
drawSurfaceChart.prototype =
{
constructor: drawSurfaceChart,
recalculate: function(chartsDrawer)
{
this.chartProp = chartsDrawer.calcProp;
this.cChartDrawer = chartsDrawer;
this.cChartSpace = chartsDrawer.cChartSpace;
this.paths = {};
this._recalculate();
},
draw: function(chartsDrawer)
{
this.chartProp = chartsDrawer.calcProp;
this.cChartDrawer = chartsDrawer;
this.cChartSpace = chartsDrawer.cChartSpace;
this._draw();
},
_recalculate: function()
{
var yPoints = this.cChartSpace.chart.plotArea.valAx.yPoints;
var xPoints = this.cChartSpace.chart.plotArea.catAx.xPoints;
var perspectiveDepth = this.cChartDrawer.processor3D.depthPerspective;
var y, x, z, val, seria, dataSeries, compiledMarkerSize, compiledMarkerSymbol, idx, numCache, idxPoint, points = [];
for (var i = 0; i < this.chartProp.series.length; i++) {
seria = this.chartProp.series[i];
numCache = seria.val.numRef ? seria.val.numRef.numCache : seria.val.numLit;
if(!numCache)
{
continue;
}
dataSeries = numCache.pts;
for(var n = 0; n < numCache.ptCount; n++)
{
//рассчитываем значения
idx = dataSeries[n] && dataSeries[n].idx != null ? dataSeries[n].idx : n;
val = this._getYVal(idx, i);
x = xPoints[n].pos * this.chartProp.pxToMM;
y = this.cChartDrawer.getYPosition(val, yPoints) * this.chartProp.pxToMM;
z = (perspectiveDepth / (this.chartProp.series.length - 1)) * (i);
if(!points)
points = [];
if(!points[i])
points[i] = [];
if(val != null)
{
var convertResult = this.cChartDrawer._convertAndTurnPoint(x, y, z);
var x1 = convertResult.x;
var y1 = convertResult.y;
points[i][n] = {x: x1, y: y1};
}
else
{
points[i][n] = null;
}
}
}
this.test(points);
},
test: function(points)
{
for (var i = 0; i < points.length; i++)
{
for(var j = 0; j < points[i].length - 1; j++)
{
var p = points[i][j];
var p1 = points[i][j + 1];
if(!this.paths.series)
{
this.paths.series = [];
}
this.paths.series.push(this._calculatePath(p.x, p.y, p1.x, p1.y));
}
}
},
_getYVal: function(n, i)
{
var idxPoint = this.cChartDrawer.getIdxPoint(this.chartProp.series[i], n);
var val = idxPoint ? parseFloat(idxPoint.val) : null;
return val;
},
_calculatePath: function(x, y, x1, y1)
{
var pxToMm = this.chartProp.pxToMM;
var path = new Path();
var pathH = this.chartProp.pathH;
var pathW = this.chartProp.pathW;
var gdLst = [];
path.pathH = pathH;
path.pathW = pathW;
gdLst["w"] = 1;
gdLst["h"] = 1;
path.moveTo(x / pxToMm * pathW, y / pxToMm * pathH);
path.lnTo(x1 / pxToMm * pathW, y1 / pxToMm * pathH);
path.recalculate(gdLst);
return path;
},
_draw: function()
{
for(var i = 0; i < this.paths.series.length; i++)
{
var pen = this.cChartSpace.chart.plotArea.catAx.compiledLn;
this.cChartDrawer.drawPath(this.paths.series[i], pen, null, false);
}
}
}
/** @constructor */
function gridChart()
......
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