Commit 9ee4703d 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@47499 954022d7-b5bf-4e40-9824-e11837661b57
parent 0daa352e
This diff is collapsed.
...@@ -1743,10 +1743,10 @@ ...@@ -1743,10 +1743,10 @@
OfficeExcel.drawTurnedText = function(drawingCtx,textOptions, text, angle) OfficeExcel.drawTurnedText = function(drawingCtx,textOptions, text, angle)
{ {
var cx = textOptions.x; // center offset x var cx = textOptions.x;
var cy = textOptions.y; // center offset y var cy = textOptions.y;
var textWidth = textOptions.width; // NOTE: measure text (width * 0.5) var textWidth = 0;
var textHeight = textOptions.height; // NOTE: measure text (height * 0.5) var textHeight = 0;
var font = textOptions.font; var font = textOptions.font;
var size = textOptions.size; var size = textOptions.size;
var asc = Asc; var asc = Asc;
...@@ -1966,7 +1966,10 @@ ...@@ -1966,7 +1966,10 @@
*/ */
OfficeExcel.DrawTitle = function (canvas, text, gutterTop) OfficeExcel.DrawTitle = function (canvas, text, gutterTop)
{ {
var obj = canvas.__object__;
var obj = canvas.__object__;
if(obj._chartTitle._text == '')
return;
var context = canvas.getContext('2d'); var context = canvas.getContext('2d');
var gutterLeft = obj._chartGutter._left; var gutterLeft = obj._chartGutter._left;
var gutterRight = obj._chartGutter._right; var gutterRight = obj._chartGutter._right;
...@@ -2050,7 +2053,13 @@ ...@@ -2050,7 +2053,13 @@
vpos = obj._chartTitle._vpos; vpos = obj._chartTitle._vpos;
vCenter = 'bottom'; vCenter = 'bottom';
} }
OfficeExcel.Text(context, font, size, centerx, vpos, text, vCenter, 'center', bgcolor != null, null, bgcolor, bold, null, textOptions); var props = calculatePosiitionObjects("title");
if(props)
{
centerx = props.x;
vpos = props.y;
}
OfficeExcel.Text(context, font, size, centerx, vpos, text, null, null, bgcolor != null, null, bgcolor, bold, null, textOptions);
// Reset the fill colour // Reset the fill colour
context.fillStyle = oldColor; context.fillStyle = oldColor;
...@@ -2302,6 +2311,9 @@ ...@@ -2302,6 +2311,9 @@
vpos = obj._xAxisTitle._vpos vpos = obj._xAxisTitle._vpos
if (obj._xAxisTitle._hpos != 'null') if (obj._xAxisTitle._hpos != 'null')
hpos = obj._xAxisTitle._hpos hpos = obj._xAxisTitle._hpos
var props = calculatePosiitionObjects("xAxisTitle");
hpos = props.x;
vpos = props.y;
context.beginPath(); context.beginPath();
OfficeExcel.Text(context, OfficeExcel.Text(context,
font, font,
...@@ -2309,8 +2321,8 @@ ...@@ -2309,8 +2321,8 @@
hpos, hpos,
vpos, vpos,
obj._xAxisTitle._text, obj._xAxisTitle._text,
'center', null,
'center', null,
false, false,
false, false,
false, false,
...@@ -2355,13 +2367,18 @@ ...@@ -2355,13 +2367,18 @@
obj.canvas.width - obj._chartGutter._right + obj._otherProps._text_size + 5; obj.canvas.width - obj._chartGutter._right + obj._otherProps._text_size + 5;
} else } else
hpos = hpos; hpos = hpos;
if(obj._yAxisTitle._angle != 'null' && obj._yAxisTitle._angle != undefined) if(obj._yAxisTitle._angle != 'null' && obj._yAxisTitle._angle != undefined)
angle = obj._yAxisTitle._angle; angle = obj._yAxisTitle._angle;
if (obj._yAxisTitle._vpos != 'null') if (obj._yAxisTitle._vpos != 'null')
vpos = obj._yAxisTitle._vpos; vpos = obj._yAxisTitle._vpos;
if (obj._yAxisTitle._hpos != 'null') if (obj._yAxisTitle._hpos != 'null')
hpos = obj._yAxisTitle._hpos; hpos = obj._yAxisTitle._hpos;
var props = calculatePosiitionObjects("yAxisTitle");
hpos = props.x;
vpos = props.y;
context.beginPath(); context.beginPath();
OfficeExcel.Text(context, OfficeExcel.Text(context,
font, font,
...@@ -2370,7 +2387,7 @@ ...@@ -2370,7 +2387,7 @@
vpos, vpos,
obj._yAxisTitle._text, obj._yAxisTitle._text,
'center', 'center',
'right',//change with center null,//change with center
false, false,
angle, angle,
false, false,
...@@ -2509,7 +2526,7 @@ ...@@ -2509,7 +2526,7 @@
} }
// Draw the title if one is set // Draw the title if one is set
if ( typeof(obj._chartTitle._text) == 'string') { if ( typeof(obj._chartTitle._text) == 'string' && obj._chartTitle._text != '') {
if (obj.type == 'gantt') { if (obj.type == 'gantt') {
gutterTop -= 10; gutterTop -= 10;
......
...@@ -79,8 +79,13 @@ ...@@ -79,8 +79,13 @@
var strokestyle = '#333'; var strokestyle = '#333';
var height = 0; var height = 0;
var width = 0; var width = 0;
var scale = 1;
if(OfficeExcel.drawingCtxCharts && OfficeExcel.drawingCtxCharts.scaleFactor)
scale = OfficeExcel.drawingCtxCharts.scaleFactor;
var sizeLine = 26*scale;
if(bar._otherProps._key_color_shape != 'line')
sizeLine = 8*scale;
obj.coordsKey = []; obj.coordsKey = [];
...@@ -120,19 +125,12 @@ ...@@ -120,19 +125,12 @@
/** /**
* Horizontal alignment * Horizontal alignment
*/ */
/*if (typeof(obj._otherProps._key_halign) == 'string') {
if (obj._otherProps._key_halign == 'left') {
hpos = gutterLeft + 10;
} else if (obj._otherProps._key_halign == 'right') {
hpos = OfficeExcel.GetWidth(obj) - gutterRight - width;
}
}*/
var scale = 1;
if(OfficeExcel.drawingCtxCharts && OfficeExcel.drawingCtxCharts.scaleFactor)
scale = OfficeExcel.drawingCtxCharts.scaleFactor;
var widthAllKey = 70*(key.length); var widthAllKey = 70*(key.length);
if((obj._otherProps._key_halign == 'top' || obj._otherProps._key_halign == 'bottom' )) /*if((obj._otherProps._key_halign == 'top' || obj._otherProps._key_halign == 'bottom' ))
{ {
if(widthAllKey > obj.canvas.width - 50) if(widthAllKey > obj.canvas.width - 50)
{ {
...@@ -143,33 +141,52 @@ ...@@ -143,33 +141,52 @@
key = obj._otherProps._key; key = obj._otherProps._key;
} }
widthAllKey = 70*(key.length); widthAllKey = 70*(key.length);
}*/
var drwContext = OfficeExcel.drawingCtxCharts;
var font = getFontProperties("key");
if(obj._otherProps._key_halign == 'top' || obj._otherProps._key_halign == 'bottom' && key.length != 0)
{
widthAllKey = 0;
var widthEveryElemKey = [];
for(var l = 0; l < key.length; l++)
{
var props1 = getMaxPropertiesText(drwContext,font,key[l]);
widthAllKey += props1.width + (3)*scale + sizeLine;
widthEveryElemKey[l] = props1.width + (3)*scale + sizeLine;
}
} }
var heightKeyVer = key.length*24; heigthTextKey = 24;
if(key && key.length != 0)
{
var props = getMaxPropertiesText(drwContext,font,bar._otherProps._key);
heigthTextKey = (drwContext.getHeightText()/0.75)*scale;
}
var heightKeyVer = key.length*heigthTextKey;
var heightKey = 24; var heightKey = 24;
var widthKey = textWidth*key.length + key.length*30 + 11*(key.length-1); var widthKey = textWidth*key.length + key.length*30 + 11*(key.length-1);
//var widthKeyVer = textWidth + 30; //var widthKeyVer = textWidth + 30;
var widthKeyVer = 31 + 30; var widthKeyVer = 61;
//var margin = obj._chartGutter._top - 14; //var margin = obj._chartGutter._top - 14;
if (typeof(obj._otherProps._key_halign) == 'string') { if (typeof(obj._otherProps._key_halign) == 'string') {
if (obj._otherProps._key_halign == 'left') { if (obj._otherProps._key_halign == 'left') {
hpos = 20; hpos = calculatePosiitionObjects("key_hpos");
vpos = canvas.height/2 - heightKeyVer/2; vpos = canvas.height/2 - heightKeyVer/2;
} else if (obj._otherProps._key_halign == 'right') { } else if (obj._otherProps._key_halign == 'right') {
hpos = canvas.width - widthKeyVer - 10; hpos = calculatePosiitionObjects("key_hpos");
vpos = canvas.height/2 - heightKeyVer/2; vpos = canvas.height/2 - heightKeyVer/2;
} }
else if (obj._otherProps._key_halign == 'top') { else if (obj._otherProps._key_halign == 'top') {
hpos = canvas.width/2 - widthAllKey/2; hpos = canvas.width/2 - widthAllKey/2;
if(obj._chartTitle._text != null && obj._chartTitle._text != '') vpos = calculatePosiitionObjects("key_hpos");
vpos = text_size + 20 + obj._chartTitle._size + 20;
else
vpos = text_size + 20;
} }
else if (obj._otherProps._key_halign == 'bottom') { else if (obj._otherProps._key_halign == 'bottom') {
hpos = canvas.width/2 - widthAllKey/2; hpos = canvas.width/2 - widthAllKey/2;
vpos = canvas.height - 10; vpos = calculatePosiitionObjects("key_hpos");
} }
} }
...@@ -245,19 +262,17 @@ ...@@ -245,19 +262,17 @@
if('hbar' != obj.type) if('hbar' != obj.type)
key = OfficeExcel.array_reverse(key) key = OfficeExcel.array_reverse(key)
} }
var horPos = false;
if(obj._otherProps._key_halign == 'bottom' || obj._otherProps._key_halign == 'top')
{
horPos = true;
//colors = OfficeExcel.array_reverse(colors)
//key = OfficeExcel.array_reverse(key)
}
if(horPos) if(obj._otherProps._key_halign == 'bottom' || obj._otherProps._key_halign == 'top')
{ {
for (var i=0; i<key.length; i++) { for (var i=0; i<key.length; i++) {
// Draw the blob of color // Draw the blob of color
var leftDiff = 0;
for(var n = 0 ; n < i; n++)
{
leftDiff += widthEveryElemKey[n];
}
if (obj._otherProps._key_color_shape == 'circle') { if (obj._otherProps._key_color_shape == 'circle') {
context.beginPath(); context.beginPath();
...@@ -271,14 +286,14 @@ ...@@ -271,14 +286,14 @@
context.strokeStyle = colors[i]; context.strokeStyle = colors[i];
context.lineWidth = '2.7' context.lineWidth = '2.7'
context.moveTo(hpos + (65 * i) + (text_size * i) ,vpos - text_size); context.moveTo(hpos + leftDiff + 2*scale,vpos - props.height/2);
context.lineTo(hpos + blob_size + (65 * i) + (text_size * i) + 16, vpos - text_size); context.lineTo(hpos + leftDiff + sizeLine + 2*scale, vpos - props.height/2);
context.stroke(); context.stroke();
} else { } else {
context.fillStyle = colors[i]; context.fillStyle = colors[i];
context.fillRect(hpos + blob_size + (65 * i) + (text_size * i), vpos - text_size - 10, text_size - 2, text_size + 1 - 2); context.fillRect(hpos + leftDiff + 2*scale, vpos - 7*scale, 7*scale, 7*scale);
//context.fillRect(hpos, vpos + (10 * j) + (text_size * j) - text_size, 22, obj._otherProps._linewidth); //context.fillRect(hpos, vpos + (10 * j) + (text_size * j) - text_size, 22, obj._otherProps._linewidth);
} }
...@@ -288,8 +303,8 @@ ...@@ -288,8 +303,8 @@
OfficeExcel.Text(context, OfficeExcel.Text(context,
text_font, text_font,
text_size, text_size,
hpos + blob_size + (65 * i) + (text_size * i) + 19, hpos + leftDiff + sizeLine + 3*scale,
vpos-text_size, vpos,
key[i]); key[i]);
} }
} }
...@@ -301,7 +316,7 @@ ...@@ -301,7 +316,7 @@
// Draw the blob of color // Draw the blob of color
var diffKeyAndLine = 3*scale;
if (obj._otherProps._key_color_shape == 'circle') { if (obj._otherProps._key_color_shape == 'circle') {
context.beginPath(); context.beginPath();
context.strokeStyle = 'rgba(0,0,0,0)'; context.strokeStyle = 'rgba(0,0,0,0)';
...@@ -314,16 +329,16 @@ ...@@ -314,16 +329,16 @@
context.strokeStyle = colors[i]; context.strokeStyle = colors[i];
context.lineWidth = '2.7' context.lineWidth = '2.7'
context.moveTo(hpos - 8, vpos + (15 * j) + (text_size * j) - text_size + (blob_size / 2)); context.moveTo(hpos, vpos + heigthTextKey*j - heigthTextKey + (heigthTextKey / 2));
context.lineTo(hpos + blob_size + 8, vpos + (15 * j) + (text_size * j) - text_size + (blob_size / 2)); context.lineTo(hpos + sizeLine, vpos + heigthTextKey*j - heigthTextKey + (heigthTextKey / 2));
//context.moveTo(hpos + 5, vpos + (5 * j) + (text_size * j) - text_size + (blob_size / 2)); //context.moveTo(hpos + 5, vpos + (5 * j) + (text_size * j) - text_size + (blob_size / 2));
//context.lineTo(hpos + blob_size + 5, vpos + (5 * j) + (text_size * j) - text_size + (blob_size / 2)); //context.lineTo(hpos + blob_size + 5, vpos + (5 * j) + (text_size * j) - text_size + (blob_size / 2));
context.stroke(); context.stroke();
} else { } else {
context.fillStyle = colors[i]; context.fillStyle = colors[i];
context.fillRect(hpos + 5 + 2, vpos + (15 * j) + (text_size * j) - text_size, text_size - 2, text_size + 1 - 2); context.fillRect(hpos, vpos + heigthTextKey*j - props.height/2 - 7*scale, 7*scale, 7*scale);
//context.fillRect(hpos, vpos + (10 * j) + (text_size * j) - text_size, 22, obj._otherProps._linewidth); diffKeyAndLine = 5;
} }
context.beginPath(); context.beginPath();
...@@ -333,8 +348,8 @@ ...@@ -333,8 +348,8 @@
OfficeExcel.Text(context, OfficeExcel.Text(context,
text_font, text_font,
text_size, text_size,
hpos + blob_size + 5 + 5, hpos + sizeLine + diffKeyAndLine,
vpos + (15 * j) + (text_size * j), vpos + heigthTextKey*j - props.height/2,
key[i]); key[i]);
} }
} }
......
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