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

отрисовка каждого значения подписей диаграммы со своим форматом

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@47957 954022d7-b5bf-4e40-9824-e11837661b57
parent c45a74b8
......@@ -695,6 +695,7 @@ function insertChart(chart, activeWorkSheet, width, height, isNewChart) {
var styleManager = api_doc ? api_doc.chartStyleManager : api_sheet.chartStyleManager;
arrBaseColors = styleManager.getBaseColors( parseInt(chart.styleId) );
var arrFormatAdobeLabels = [];
if(chart.series && chart.series.length !=0 && api_sheet)
{
isSeries = true;
......@@ -720,6 +721,7 @@ function insertChart(chart, activeWorkSheet, width, height, isNewChart) {
var n = 0;
arrValues[l] = [];
arrFormatAdobeLabels[l] = [];
var formula = formulaToRange(series[l].Val.Formula,ws);
var xFormula = formulaToRange(series[l].xVal.Formula,ws);
......@@ -743,6 +745,7 @@ function insertChart(chart, activeWorkSheet, width, height, isNewChart) {
for(col = xfirstCol; col <= xlastCol; ++col)
{
arrValues[l][n] = [];
arrFormatAdobeLabels[l][n] = [];
var cell = ws.getCell(new CellAddress(row - 1, col - 1, 0));
var cellY = ws.getCell(new CellAddress(firstRow - 1, firstCol + n - 1, 0));
......@@ -777,6 +780,9 @@ function insertChart(chart, activeWorkSheet, width, height, isNewChart) {
else
arrValues[l][n][1] = valueY;
arrFormatAdobeLabels[l][n][0] = cell.getNumFormatStr();
arrFormatAdobeLabels[l][n][1] = cellY.getNumFormatStr();
if(value.toString() != '' && !isEn)
{
min = value;
......@@ -808,6 +814,7 @@ function insertChart(chart, activeWorkSheet, width, height, isNewChart) {
for(row = xfirstRow; row <= xlastRow; ++row)
{
arrValues[l][n] = [];
arrFormatAdobeLabels[l][n] = [];
var cell = ws.getCell(new CellAddress(row - 1, col - 1, 0));
var cellY = ws.getCell(new CellAddress(firstRow + n - 1, firstCol - 1, 0));
......@@ -837,6 +844,9 @@ function insertChart(chart, activeWorkSheet, width, height, isNewChart) {
else
arrValues[l][n][1] = valueY;
arrFormatAdobeLabels[l][n][0] = cell.getNumFormatStr();
arrFormatAdobeLabels[l][n][1] = cellY.getNumFormatStr();
if(value.toString() != '' && !isEn)
{
min = value;
......@@ -895,6 +905,7 @@ function insertChart(chart, activeWorkSheet, width, height, isNewChart) {
}
skipSeries[l] = false;
arrValues[numSeries] = [];
arrFormatAdobeLabels[numSeries] = [];
isSkip[numSeries] = true;
if(!isRow)//по строкам или по столбцам
......@@ -926,6 +937,7 @@ function insertChart(chart, activeWorkSheet, width, height, isNewChart) {
formatCellScOy = cell.getNumFormatStr();
}
formatAdobeLabel = cell.getNumFormatStr();
var orValue = cell.getValue();
if('' != orValue)
......@@ -951,6 +963,7 @@ function insertChart(chart, activeWorkSheet, width, height, isNewChart) {
arrValues[numSeries][n] = Math.abs(value);
else
arrValues[numSeries][n] = value;
arrFormatAdobeLabels[numSeries][n] = formatAdobeLabel;
n++;
}
}
......@@ -986,6 +999,8 @@ function insertChart(chart, activeWorkSheet, width, height, isNewChart) {
var orValue = cell.getValue();
if('' != orValue)
isSkip[numSeries] = false;
formatAdobeLabel = cell.getNumFormatStr();
var value = parseFloat(orValue)
if(!isEn && !isNaN(value))
{
......@@ -1008,7 +1023,7 @@ function insertChart(chart, activeWorkSheet, width, height, isNewChart) {
arrValues[numSeries][n] = Math.abs(value);
else
arrValues[numSeries][n] = value;
arrFormatAdobeLabels[numSeries][n] = formatAdobeLabel;
n++;
}
}
......@@ -1029,6 +1044,7 @@ function insertChart(chart, activeWorkSheet, width, height, isNewChart) {
var isSkipRev = [];
for (row = 0; row < data.length; ++row) {
arrValues[n] = [];
arrFormatAdobeLabels[n] = [];
var k = 0;
isSkip[row] = true;
for (col = 0; col < data[row].length; ++col) {
......@@ -1050,6 +1066,9 @@ function insertChart(chart, activeWorkSheet, width, height, isNewChart) {
formatCellScOy = data[row][col].numFormatStr;
var orValue = data[row][col].value;
var formatAdobeLabel = 'General';
if(data[row][col].numFormatStr)
formatAdobeLabel = data[row][col].numFormatStr;
var value = parseFloat(orValue);
//если все значения пустые, то в дальнейшем при отрисовке пропускаем
if(!isNaN(parseFloat(orValue)))
......@@ -1074,6 +1093,7 @@ function insertChart(chart, activeWorkSheet, width, height, isNewChart) {
arrValues[n][k] = Math.abs(value);
else
arrValues[n][k] = value;
arrFormatAdobeLabels[n][k] = formatAdobeLabel;
k++;
}
n++;
......@@ -1171,7 +1191,11 @@ function insertChart(chart, activeWorkSheet, width, height, isNewChart) {
}
if(isSeries)
{
var arrFormatAdobeLabelsRev = arrFormatAdobeLabels;
var arrValuesRev = arrValues;
}
isEn = false;
if(chart.type == 'Scatter' && !newArr)
{
......@@ -1279,7 +1303,11 @@ function insertChart(chart, activeWorkSheet, width, height, isNewChart) {
chart.ymax = maxY;
}
if(!arrValuesRev)
arrValuesRev = arrReverse(arrValues)
arrValuesRev = arrReverse(arrValues);
if(!arrFormatAdobeLabelsRev)
arrFormatAdobeLabelsRev = arrReverse(arrFormatAdobeLabels);
//if ((bbox.c2 - bbox.c1) < bbox.r2 - bbox.r1)
chart.isFormatCell = formatCell;
chart.isformatCellScOy = formatCellScOy;
......@@ -1298,24 +1326,29 @@ function insertChart(chart, activeWorkSheet, width, height, isNewChart) {
{
//надо перевернуть массив
arrValuesRev = arrReverse(arrValues);
chart.arrFormatAdobeLabels = arrReverse(arrFormatAdobeLabels);
drawChart(chart, arrValuesRev, width, height);
}
else
{
chart.arrFormatAdobeLabels = arrFormatAdobeLabels;
drawChart(chart, arrValues, width, height);
}
}
else
{
if (chart.range.rows)
{
if(chart.type == 'HBar' || chart.type == 'Bar' || chart.type == 'Stock')
{
//chart.isSkip = isSkipRev;
chart.isSkip = isSkip;
chart.arrFormatAdobeLabels = arrFormatAdobeLabelsRev;
drawChart(chart, arrValuesRev, width, height);
}
else
{
chart.isSkip = isSkip;
chart.arrFormatAdobeLabels = arrFormatAdobeLabels;
drawChart(chart, arrValues, width, height);
}
}
......@@ -1324,12 +1357,14 @@ function insertChart(chart, activeWorkSheet, width, height, isNewChart) {
if(chart.type == 'HBar' || chart.type == 'Bar' || chart.type == 'Stock')
{
chart.isSkip = isSkip;
chart.arrFormatAdobeLabels = arrFormatAdobeLabels;
drawChart(chart, arrValues, width, height);
}
else
{
//chart.isSkip = isSkipRev;
chart.isSkip = isSkip;
chart.arrFormatAdobeLabels = arrFormatAdobeLabelsRev;
drawChart(chart, arrValuesRev, width, height);
}
}
......@@ -1401,7 +1436,7 @@ function drawChart(chart, arrValues, width, height) {
var lengthOfSeries;
if(chart.series && chart.series.length != 0)
if(chart.series && chart.series.length != 0 && window["Asc"]["editor"])
{
lengthOfSeries = chart.series.length;
}
......@@ -1554,6 +1589,7 @@ function drawChart(chart, arrValues, width, height) {
bar._yAxisTitle._vpos = bar._chartGutter._top + (bar.canvas.height - bar._chartGutter._top - bar._chartGutter._bottom) / 2 ;
bar._yAxisTitle._hpos = 23 + keyLeft;
}
bar.arrFormatAdobeLabels = chart.arrFormatAdobeLabels;
//выставляем параметры текса
setFontChart(chart);
calcAllMargin(chart.isFormatCell,chart.isformatCellScOy,chart.min,chart.max,chart.ymin,chart.ymax, chart);
......@@ -1714,7 +1750,6 @@ function DrawLineChart(chartCanvas, chartType, chartSubType, data, chart) {
var copyData = $.extend(true, [], data);
bar = new OfficeExcel.Line(chartCanvas, data);
bar.firstData = copyData;
bar._otherProps._autoGrouping = chartType;
//в случае поверхностной диаграммы
......@@ -1758,6 +1793,12 @@ function DrawLineChart(chartCanvas, chartType, chartSubType, data, chart) {
bar.original_data = tempData;
}
if((bar._otherProps._autoGrouping == 'stacked' || bar._otherProps._autoGrouping == 'stackedPer') && bar._otherProps._filled)
{
copyData = OfficeExcel.array_reverse(copyData);
chart.arrFormatAdobeLabels = OfficeExcel.array_reverse(chart.arrFormatAdobeLabels);
}
bar.newData = data;
bar.firstData = copyData;
......@@ -1818,6 +1859,8 @@ function DrawLineChart(chartCanvas, chartType, chartSubType, data, chart) {
function DrawBarChart(chartCanvas, chartSubType, data, chart) {
bar = new OfficeExcel.Bar(chartCanvas, data);
var copyData = $.extend(true, [], data);
bar.firstData = copyData;
//меняем входные данные для нормированной диаграммы
bar._otherProps._autoGrouping = chartSubType;
//с накоплениями
......@@ -1881,10 +1924,13 @@ function DrawHBarChart(chartCanvas, chartSubType, data, chart) {
}
data = OfficeExcel.array_reverse(data);
var copyData = $.extend(true, [], data);
bar = new OfficeExcel.HBar(chartCanvas, data);
bar._otherProps._autoGrouping = chartSubType;
var originalData = $.extend(true, [], data);
chart.arrFormatAdobeLabels = OfficeExcel.array_reverse(chart.arrFormatAdobeLabels);
if (bar._otherProps._autoGrouping == 'stacked') {
for (var j = 0; j < (data.length); j++) {
......@@ -1892,6 +1938,8 @@ function DrawHBarChart(chartCanvas, chartSubType, data, chart) {
data[j][i] = findPrevValue(originalData, j, i)
}
data[j] = OfficeExcel.array_reverse(data[j]);
copyData[j] = OfficeExcel.array_reverse(copyData[j]);
chart.arrFormatAdobeLabels[j] = OfficeExcel.array_reverse(chart.arrFormatAdobeLabels[j]);
}
bar.original_data = data;
}
......@@ -1922,10 +1970,20 @@ function DrawHBarChart(chartCanvas, chartSubType, data, chart) {
tempData[j][i] = 0;
}
tempData[j] = OfficeExcel.array_reverse(tempData[j]);
copyData[j] = OfficeExcel.array_reverse(copyData[j]);
chart.arrFormatAdobeLabels[j] = OfficeExcel.array_reverse(chart.arrFormatAdobeLabels[j]);
}
bar.data = tempData;
bar.original_data = tempData;
}
else
{
for (var j = 0; j < (copyData.length); j++) {
chart.arrFormatAdobeLabels[j] = OfficeExcel.array_reverse(chart.arrFormatAdobeLabels[j]);
}
}
bar.firstData = copyData;
//bar._otherProps._labels = ['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'];
bar._otherProps._area_border = chart.bShowBorder;
......
......@@ -1345,14 +1345,16 @@
if (this.data[i][j] < 0) {
yPos += height + 6 + (this._otherProps._text_size - 4);
}
var formatCellTrue = formatCell;
if(this.arrFormatAdobeLabels && this.arrFormatAdobeLabels[i] && this.arrFormatAdobeLabels[i][j])
formatCellTrue = this.arrFormatAdobeLabels[i][j];
this.context.fillStyle = this._otherProps._text_color;
OfficeExcel.Text(this.context,
this._otherProps._labels_above_font,
typeof(this._otherProps._labels_above_size) == 'number' ? this._otherProps._labels_above_size : this._otherProps._text_size - 3,startX + (individualBarWidth / 2),
startY - 2 - (this._otherProps._variant == '3d' ? 5 : 0),
//OfficeExcel.number_format(this, OfficeExcel.num_round(this.data[i][j]),this._otherProps._units_pre,this._otherProps._units_post),
OfficeExcel.numToFormatText(OfficeExcel.num_round(this.data[i][j]),formatCell),
OfficeExcel.numToFormatText(OfficeExcel.num_round(this.firstData[i][j]),formatCellTrue),
null,
this._otherProps._labels_above_angle ? (this._otherProps._labels_above_angle > 0 ? 'right' : 'left') : 'center',
null,
......
......@@ -1027,7 +1027,10 @@
individualBarHeight,
this.context.fillStyle,
this.data[i][j],
true]);
true,
this.arrFormatAdobeLabels[i][j],
this.firstData[i][j]
]);
}
}
......@@ -1096,6 +1099,12 @@
OfficeExcel.NoShadow(this);
var border = (coords[i][0] + coords[i][2] + 7 + this.context.measureText(this._otherProps._units_pre + this.coords[i][5] + this._otherProps._units_post).width) > OfficeExcel.GetWidth(this) ? true : false;
var textLabel = this.coords[i][5];
var formatLabel = format;
if(this.coords[i][7])
formatLabel = this.coords[i][7];
if(this.coords[i][8])
textLabel = this.coords[i][8];
OfficeExcel.Text(this.context,
font,
......@@ -1103,7 +1112,7 @@
coords[i][0] + coords[i][2] + (border ? -5 : 5),
coords[i][1] + (coords[i][3] / 2),
//OfficeExcel.number_format(this, OfficeExcel.num_round(this.coords[i][5]), this._otherProps._units_pre, this._otherProps._units_post),
OfficeExcel.numToFormatText(OfficeExcel.num_round(this.coords[i][5]),format),
OfficeExcel.numToFormatText(OfficeExcel.num_round(textLabel),formatLabel),
'center',
border ? 'right' : 'left',
null,
......
......@@ -2014,16 +2014,22 @@
italic: this._otherProps._labels_above_italic
}
context.beginPath();
var formatLabels = [];
var tempData = [];
n = 0;
for (var i = 0; i < this.data.length; ++i) {
for (var j = 0; j < this.data[i].length; ++j) {
tempData[n++] = this.data[i][j]
for (var i = 0; i < this.firstData.length; ++i) {
for (var j = 0; j < this.firstData[i].length; ++j) {
tempData[n] = this.firstData[i][j];
if(this.arrFormatAdobeLabels && this.arrFormatAdobeLabels[i] && this.arrFormatAdobeLabels[i][j])
formatLabels[n] = this.arrFormatAdobeLabels[i][j];
else
formatLabels[n] = format;
n++;
}
}
for (var i = 0; i < this.coords.length; ++i) {
var coords = this.coords[i];
OfficeExcel.Text(context, font, size, coords[0], coords[1] - 5 - size,OfficeExcel.numToFormatText( OfficeExcel.num_round(tempData[i]),format), 'center', 'center', false, null, 'rgba(255, 255, 255, 0.7)', bold, null, textOptions);
OfficeExcel.Text(context, font, size, coords[0], coords[1] - 5 - size,OfficeExcel.numToFormatText( OfficeExcel.num_round(tempData[i]),formatLabels[i]), 'center', 'center', false, null, 'rgba(255, 255, 255, 0.7)', bold, null, textOptions);
// OfficeExcel.Text(context, font, size, coords[0], coords[1] - 5 - size, OfficeExcel.number_format(this, OfficeExcel.num_round(tempData[i]), units_pre, units_post), 'center', 'center', false, null, 'rgba(255, 255, 255, 0.7)');
}
......
......@@ -665,7 +665,9 @@
var text_size = this._otherProps._text_size;
for (i=0; i<labels.length; ++i) {
isFormatCellTrue = isFormatCell;
if(this.arrFormatAdobeLabels && this.arrFormatAdobeLabels[i])
isFormatCellTrue = this.arrFormatAdobeLabels[0][i];
/**
* T|his ensures that if we're given too many labels, that we don't get an error
*/
......@@ -729,7 +731,7 @@
text_size,
this.centerx + explosion_offsetx + ((this.radius + 10)* Math.cos(a)) + (this._otherProps._labels_sticks ? (a < 1.57 || a > 4.71 ? 2 : -2) : 0),
this.centery + explosion_offsety + (((this.radius + 10) * Math.sin(a))),
OfficeExcel.numToFormatText(labels[i],isFormatCell),
OfficeExcel.numToFormatText(labels[i],isFormatCellTrue),
vAlignment,
hAlignment, false, null,null, bold, null, textOptions);
}
......
......@@ -1880,7 +1880,9 @@
var x_val = this.data[_set][point][0];
var y_val = this.data[_set][point][1];
var formatTrue = format;
if(this.arrFormatAdobeLabels && this.arrFormatAdobeLabels[_set] && this.arrFormatAdobeLabels[_set][point] && this.arrFormatAdobeLabels[_set][point][1])
formatTrue = this.arrFormatAdobeLabels[_set][point][1];
var x_pos = this.coords[_set][point][0];
var y_pos = this.coords[_set][point][1];
......@@ -1891,7 +1893,7 @@
x_pos,
y_pos - 5 - size,
//x_val.toFixed(this._otherProps._labels_above_decimals) + ', ' + y_val.toFixed(this._otherProps._labels_above_decimals),
OfficeExcel.numToFormatText(OfficeExcel.num_round(y_val),format),
OfficeExcel.numToFormatText(OfficeExcel.num_round(y_val),formatTrue),
'center',
'center',
false,//ðàìêà
......
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