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

правка для #17869 + перерисовка диаграммы при скрытии строк/столбцов

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@47804 954022d7-b5bf-4e40-9824-e11837661b57
parent f3d6c135
...@@ -2380,6 +2380,7 @@ function DrawingObjects() { ...@@ -2380,6 +2380,7 @@ function DrawingObjects() {
_this.intervalToIntervalObject(obj.chart); _this.intervalToIntervalObject(obj.chart);
obj.chart.rebuildSeries(); obj.chart.rebuildSeries();
obj.chart.worksheet = worksheet;
var chartBase64 = chartRender.insertChart(obj.chart, null, obj.getWidthFromTo(), obj.getHeightFromTo()); var chartBase64 = chartRender.insertChart(obj.chart, null, obj.getWidthFromTo(), obj.getHeightFromTo());
if ( !chartBase64 ) if ( !chartBase64 )
continue; continue;
......
...@@ -707,6 +707,7 @@ function insertChart(chart, activeWorkSheet, width, height, isNewChart) { ...@@ -707,6 +707,7 @@ function insertChart(chart, activeWorkSheet, width, height, isNewChart) {
var minY = 0; var minY = 0;
var maxY = 0; var maxY = 0;
var isSkip = []; var isSkip = [];
var skipSeries = [];
var isEn = false; var isEn = false;
var isEnY = false; var isEnY = false;
...@@ -872,19 +873,29 @@ function insertChart(chart, activeWorkSheet, width, height, isNewChart) { ...@@ -872,19 +873,29 @@ function insertChart(chart, activeWorkSheet, width, height, isNewChart) {
} }
else//для всех остальных диаграмм при условии что данные приходят в виде серий else//для всех остальных диаграмм при условии что данные приходят в виде серий
{ {
var numSeries = 0;
for(l = 0; l < series.length; ++l) for(l = 0; l < series.length; ++l)
{ {
arrValues[l] = [];
var formula = formulaToRange(series[l].Val.Formula,ws); var formula = formulaToRange(series[l].Val.Formula,ws);
var firstCol = formula.first.col; var firstCol = formula.first.col;
var firstRow = formula.first.row; var firstRow = formula.first.row;
var lastCol = formula.last.col; var lastCol = formula.last.col;
var lastRow = formula.last.row; var lastRow = formula.last.row;
skipSeries[l] = true;
var isRow = false; var isRow = false;
if(firstCol == lastCol) if(firstCol == lastCol)
isRow = true; isRow = true;
isSkip[l] = true; if(chart.worksheet && chart.worksheet.model._getRow && chart.worksheet.model._getRow(firstRow - 1).hd == true && !isRow)
{
continue;
}
else if(chart.worksheet && chart.worksheet.model._getCol && chart.worksheet.model._getCol(firstCol - 1).hd == true && isRow)
{
continue;
}
skipSeries[l] = false;
arrValues[numSeries] = [];
isSkip[numSeries] = true;
if(!isRow)//по строкам или по столбцам if(!isRow)//по строкам или по столбцам
{ {
...@@ -892,14 +903,18 @@ function insertChart(chart, activeWorkSheet, width, height, isNewChart) { ...@@ -892,14 +903,18 @@ function insertChart(chart, activeWorkSheet, width, height, isNewChart) {
var n = 0; var n = 0;
for(col = firstCol; col <= lastCol; ++col) for(col = firstCol; col <= lastCol; ++col)
{ {
if(chart.worksheet && chart.worksheet.model._getCol && chart.worksheet.model._getCol(col - 1).hd == true)
{
continue;
}
var cell = ws.getCell(new CellAddress(row - 1, col - 1, 0)); var cell = ws.getCell(new CellAddress(row - 1, col - 1, 0));
if(l == 0 && col == firstCol && chart.subType != 'stackedPer' && chart.type != 'Stock') if(numSeries == 0 && col == firstCol && chart.subType != 'stackedPer' && chart.type != 'Stock')
{ {
formatCell = cell.getNumFormatStr(); formatCell = cell.getNumFormatStr();
isDateTimeFormat = cell.getNumFormat().isDateTimeFormat(); isDateTimeFormat = cell.getNumFormat().isDateTimeFormat();
} }
else if(chart.type == 'Stock' && l == 0 && col == firstCol) else if(chart.type == 'Stock' && numSeries == 0 && col == firstCol)
{ {
formatCellScOy = cell.getNumFormatStr(); formatCellScOy = cell.getNumFormatStr();
isDateTimeFormat = cell.getNumFormat().isDateTimeFormat(); isDateTimeFormat = cell.getNumFormat().isDateTimeFormat();
...@@ -907,14 +922,14 @@ function insertChart(chart, activeWorkSheet, width, height, isNewChart) { ...@@ -907,14 +922,14 @@ function insertChart(chart, activeWorkSheet, width, height, isNewChart) {
if(chart.type == 'Scatter') if(chart.type == 'Scatter')
{ {
if(l == 1 && col == firstCol && chart.subType != 'stackedPer' && chart.type != 'Stock') if(numSeries == 1 && col == firstCol && chart.subType != 'stackedPer' && chart.type != 'Stock')
formatCellScOy = cell.getNumFormatStr(); formatCellScOy = cell.getNumFormatStr();
} }
var orValue = cell.getValue(); var orValue = cell.getValue();
if('' != orValue) if('' != orValue)
isSkip[l] = false; isSkip[numSeries] = false;
var value = parseFloat(orValue) var value = parseFloat(orValue)
if(!isEn && !isNaN(value)) if(!isEn && !isNaN(value))
{ {
...@@ -933,9 +948,9 @@ function insertChart(chart, activeWorkSheet, width, height, isNewChart) { ...@@ -933,9 +948,9 @@ function insertChart(chart, activeWorkSheet, width, height, isNewChart) {
else if (isNaN(value)) else if (isNaN(value))
value = 0; value = 0;
if(chart.type == 'Pie') if(chart.type == 'Pie')
arrValues[l][n] = Math.abs(value); arrValues[numSeries][n] = Math.abs(value);
else else
arrValues[l][n] = value; arrValues[numSeries][n] = value;
n++; n++;
} }
} }
...@@ -945,9 +960,13 @@ function insertChart(chart, activeWorkSheet, width, height, isNewChart) { ...@@ -945,9 +960,13 @@ function insertChart(chart, activeWorkSheet, width, height, isNewChart) {
var n = 0; var n = 0;
for(row = firstRow; row <= lastRow; ++row) for(row = firstRow; row <= lastRow; ++row)
{ {
if(chart.worksheet && chart.worksheet.model._getRow && chart.worksheet.model._getRow(row - 1).hd == true)
{
continue;
}
var cell = ws.getCell(new CellAddress(row - 1, col - 1, 0)); var cell = ws.getCell(new CellAddress(row - 1, col - 1, 0));
if(l == 0 && row == firstRow && chart.subType != 'stackedPer' && chart.type != 'Stock') if(numSeries == 0 && row == firstRow && chart.subType != 'stackedPer' && chart.type != 'Stock')
{ {
formatCell = cell.getNumFormatStr(); formatCell = cell.getNumFormatStr();
isDateTimeFormat = cell.getNumFormat().isDateTimeFormat(); isDateTimeFormat = cell.getNumFormat().isDateTimeFormat();
...@@ -960,13 +979,13 @@ function insertChart(chart, activeWorkSheet, width, height, isNewChart) { ...@@ -960,13 +979,13 @@ function insertChart(chart, activeWorkSheet, width, height, isNewChart) {
if(chart.type == 'Scatter') if(chart.type == 'Scatter')
{ {
if(l == 1 && row == firstRow && chart.subType != 'stackedPer' && chart.type != 'Stock') if(numSeries == 1 && row == firstRow && chart.subType != 'stackedPer' && chart.type != 'Stock')
formatCellScOy = cell.getNumFormatStr(); formatCellScOy = cell.getNumFormatStr();
} }
var orValue = cell.getValue(); var orValue = cell.getValue();
if('' != orValue) if('' != orValue)
isSkip[l] = false; isSkip[numSeries] = false;
var value = parseFloat(orValue) var value = parseFloat(orValue)
if(!isEn && !isNaN(value)) if(!isEn && !isNaN(value))
{ {
...@@ -986,13 +1005,14 @@ function insertChart(chart, activeWorkSheet, width, height, isNewChart) { ...@@ -986,13 +1005,14 @@ function insertChart(chart, activeWorkSheet, width, height, isNewChart) {
value = 0; value = 0;
if(chart.type == 'Pie') if(chart.type == 'Pie')
arrValues[l][n] = Math.abs(value); arrValues[numSeries][n] = Math.abs(value);
else else
arrValues[l][n] = value; arrValues[numSeries][n] = value;
n++; n++;
} }
} }
numSeries++;
} }
} }
...@@ -1265,6 +1285,8 @@ function insertChart(chart, activeWorkSheet, width, height, isNewChart) { ...@@ -1265,6 +1285,8 @@ function insertChart(chart, activeWorkSheet, width, height, isNewChart) {
chart.isformatCellScOy = formatCellScOy; chart.isformatCellScOy = formatCellScOy;
chart.min = min; chart.min = min;
chart.max = max; chart.max = max;
if(skipSeries)
chart.skipSeries = skipSeries;
if(newArr != undefined) if(newArr != undefined)
drawChart(chart, newArr, width, height); drawChart(chart, newArr, width, height);
else else
...@@ -1376,12 +1398,23 @@ function drawChart(chart, arrValues, width, height) { ...@@ -1376,12 +1398,23 @@ function drawChart(chart, arrValues, width, height) {
// Цвета и шрифты // Цвета и шрифты
bar._otherProps._axis_color = 'grey'; bar._otherProps._axis_color = 'grey';
bar._otherProps._background_grid_color = 'graytext'; bar._otherProps._background_grid_color = 'graytext';
if('Line' == chart.type || 'Area' == chart.type)
bar._otherProps._colors = generateColors(data.length, arrBaseColors, true);
else if(chart.type == 'HBar') var lengthOfSeries;
bar._otherProps._colors = OfficeExcel.array_reverse(generateColors(data[0].length, arrBaseColors, true)); if(chart.series && chart.series.length != 0)
{
lengthOfSeries = chart.series.length;
}
else else
bar._otherProps._colors = generateColors(data[0].length, arrBaseColors, true); {
if('Line' == chart.type || 'Area' == chart.type)
lengthOfSeries = data.length;
else if(chart.type == 'HBar')
lengthOfSeries = data[0].length;
else
lengthOfSeries = data[0].length;
}
bar._otherProps._colors = generateColors(lengthOfSeries, arrBaseColors, true);
//check default title //check default title
if((!chart.yAxis.title || chart.yAxis.title == null || chart.yAxis.title == undefined || chart.yAxis.title == '') && chart.yAxis.bDefaultTitle) if((!chart.yAxis.title || chart.yAxis.title == null || chart.yAxis.title == undefined || chart.yAxis.title == '') && chart.yAxis.bDefaultTitle)
...@@ -1445,6 +1478,27 @@ function drawChart(chart, arrValues, width, height) { ...@@ -1445,6 +1478,27 @@ function drawChart(chart, arrValues, width, height) {
bar._otherProps._key_halign = 'none'; bar._otherProps._key_halign = 'none';
bar._otherProps._key = []; bar._otherProps._key = [];
} }
//в случае наличия скрытых строчек или столбов(в итоге скрытых серий)
if(chart.skipSeries)
{
var skipSeries = chart.skipSeries;
if(chart.type == 'Scatter' && chart.series && chart.series[0].xVal.Formula == null)
{
bar._otherProps._key.splice(bar._otherProps._key.length - 1, 1);
bar._otherProps._colors.splice(bar._otherProps._colors.length - 1, 1);
skipSeries.splice(0, 1);
}
for(var i = 0; i < skipSeries.length; i++)
{
if(skipSeries[i])
{
bar._otherProps._key.splice(i, 1);
bar._otherProps._colors.splice(i, 1);
skipSeries.splice(i, 1);
i--;
}
}
}
// Подписи данных // Подписи данных
if(chart.type != 'Stock') if(chart.type != 'Stock')
......
...@@ -383,7 +383,7 @@ ...@@ -383,7 +383,7 @@
* Draw the key if necessary * Draw the key if necessary
*/ */
if (this._otherProps._key && this._otherProps._key.length) { if (this._otherProps._key && this._otherProps._key.length) {
OfficeExcel.DrawKey(this, this._otherProps._key, this._otherProps._line_colors); OfficeExcel.DrawKey(this, this._otherProps._key, this._otherProps._colors);
} }
...@@ -1265,7 +1265,11 @@ ...@@ -1265,7 +1265,11 @@
var xCoord = data_point[j][0]; var xCoord = data_point[j][0];
var yCoord = data_point[j][1]; var yCoord = data_point[j][1];
var color = data_point[j][2] ? data_point[j][2] : default_color; var color;
if(this._otherProps._colors[i])
color = this._otherProps._colors[i];
else
color = data_point[j][2] ? data_point[j][2] : default_color
var tooltip = (data_point[j] && data_point[j][3]) ? data_point[j][3] : null; var tooltip = (data_point[j] && data_point[j][3]) ? data_point[j][3] : null;
if(yCoord.toString() == "" || xCoord.toString() == "") if(yCoord.toString() == "" || xCoord.toString() == "")
{ {
...@@ -1574,7 +1578,7 @@ ...@@ -1574,7 +1578,7 @@
this.context.lineJoin = 'round'; this.context.lineJoin = 'round';
//this.context.lineWidth = this.GetLineWidth(i);// i is the index of the set of coordinates //this.context.lineWidth = this.GetLineWidth(i);// i is the index of the set of coordinates
this.context.lineWidth = 3; this.context.lineWidth = 3;
this.context.strokeStyle = this._otherProps._line_colors[i]; this.context.strokeStyle = this._otherProps._colors[i];
this.context.beginPath(); this.context.beginPath();
var len = this.coords[i].length; var len = this.coords[i].length;
......
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