Commit d88f7638 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@49087 954022d7-b5bf-4e40-9824-e11837661b57
parent 017eb504
...@@ -1578,76 +1578,97 @@ function drawChart(chart, arrValues, width, height) { ...@@ -1578,76 +1578,97 @@ function drawChart(chart, arrValues, width, height) {
if((!chart.header.title || chart.header.title == null || chart.header.title == undefined || chart.header.title == '') && chart.header.bDefaultTitle) if((!chart.header.title || chart.header.title == null || chart.header.title == undefined || chart.header.title == '') && chart.header.bDefaultTitle)
chart.header.title = defaultTitle; chart.header.title = defaultTitle;
// Легенда
if (chart.legend.bShow && chart.legend.position != '') { // *****Легенда******
bar._otherProps._key_position = 'graph'; bar._otherProps._key_position = 'graph';
bar._otherProps._key = []; bar._otherProps._key = [];
bar._otherProps._key_halign = chart.legend.position; bar._otherProps._key_halign = chart.legend.position;
var legendCnt = (chart.type == "Scatter") ? data.length : data.length; var legendCnt = (chart.type == "Scatter") ? data.length : data.length;
var curColor; var curColor;
var rgba; var rgba;
if(chart.type == 'Pie' || chart.type == 'Bar' || chart.type == 'HBar') if(chart.type == 'Pie' || chart.type == 'Bar' || chart.type == 'HBar')
legendCnt = data[0].length legendCnt = data[0].length
if(chart.type == "Stock") if(chart.type == "Stock")
legendCnt = 4; legendCnt = 4;
//если есть объект series //если есть объект series
if(chart.series && chart.series.length != 0 && (chart.series[0].Tx || chart.series[0].OutlineColor) ) var theme;
{ var colorMap;
for (var j = 0; j < chart.series.length; j++) { var RGBA;
if(chart.series[j].Tx) if(api_sheet && chart.worksheet)
bar._otherProps._key[j] = chart.series[j].Tx; {
if(chart.series[j].OutlineColor && chart.series[j].OutlineColor.color.RGBA) var wb = api_sheet.wbModel;
{ theme = wb.theme;
rgba = chart.series[j].OutlineColor.color.RGBA; colorMap = GenerateDefaultColorMap().color_map;
curColor = getHexColor(rgba.R, rgba.G, rgba.B); RGBA = {R: 0, G: 0, B: 0, A: 255};
bar._otherProps._colors[j] = curColor; }
} else if(api_doc)
{
theme = api.WordControl.m_oLogicDocument.theme;
colorMap = api.WordControl.m_oLogicDocument.clrSchemeMap.color_map;
RGBA = {R: 0, G: 0, B: 0, A: 255};
if(colorMap==null)
colorMap = GenerateDefaultColorMap().color_map;
}
if(chart.series && chart.series.length != 0 && (chart.series[0].Tx || chart.series[0].OutlineColor) && (theme && colorMap))
{
for (var j = 0; j < chart.series.length; j++) {
if(chart.series[j].Tx)
bar._otherProps._key[j] = chart.series[j].Tx;
if(chart.series[j].OutlineColor)
{
chart.series[j].OutlineColor.Calculate(theme, colorMap, RGBA);
rgba = chart.series[j].OutlineColor.RGBA;
curColor = getHexColor(rgba.R, rgba.G, rgba.B);
bar._otherProps._colors[j] = curColor;
} }
} }
if(!chart.series[0].Tx || !chart.series[0].OutlineColor) }
if((chart.series && chart.series[0]) && (chart.series[0].Tx || chart.series[0].OutlineColor))
{
if(!chart.series[0].Tx)
{ {
if(!chart.series[0].Tx) for (var j = 0; j < legendCnt; j++) {
{ bar._otherProps._key[j] = 'Series' + (j + 1);
for (var j = 0; j < legendCnt; j++) {
bar._otherProps._key[j] = 'Series' + (j + 1);
}
}
if(!chart.series[0].OutlineColor)
{
bar._otherProps._colors = generateColors(lengthOfSeries, arrBaseColors, true);
if(chart.type == 'HBar')
bar._otherProps._colors = OfficeExcel.array_reverse(bar._otherProps._colors);
} }
} }
if(!chart.series[0].OutlineColor)
// без рамки
bar._otherProps._key_rounded = null;
if (bar._otherProps._filled != true && bar.type != 'bar' && bar.type != 'hbar' && bar.type != 'pie')
bar._otherProps._key_color_shape = 'line';
if(chart.type == 'HBar' && chart.subType != 'stacked' && chart.subType != 'stackedPer')
{ {
bar._otherProps._key = OfficeExcel.array_reverse(bar._otherProps._key); bar._otherProps._colors = generateColors(lengthOfSeries, arrBaseColors, true);
if(chart.type == 'HBar')
bar._otherProps._colors = OfficeExcel.array_reverse(bar._otherProps._colors);
} }
}
if((chart.legend.position == 'left' || chart.legend.position == 'right' )) // без рамки
bar._otherProps._key_rounded = null;
if (bar._otherProps._filled != true && bar.type != 'bar' && bar.type != 'hbar' && bar.type != 'pie')
bar._otherProps._key_color_shape = 'line';
if(chart.type == 'HBar' && chart.subType != 'stacked' && chart.subType != 'stackedPer')
{
bar._otherProps._key = OfficeExcel.array_reverse(bar._otherProps._key);
}
if((chart.legend.position == 'left' || chart.legend.position == 'right' ))
{
var heightKey = bar._otherProps._key.length*23.5;
if(heightKey > bar.canvas.height - 50)
{ {
var heightKey = bar._otherProps._key.length*23.5; var lengthKey = Math.round((bar.canvas.height - 50)/23.5)
if(heightKey > bar.canvas.height - 50) bar._otherProps._key = bar._otherProps._key.slice(0,lengthKey);
{
var lengthKey = Math.round((bar.canvas.height - 50)/23.5)
bar._otherProps._key = bar._otherProps._key.slice(0,lengthKey);
}
} }
} }
else{ if (!chart.legend.bShow || chart.legend.position == '')
bar._otherProps._key_halign = 'none'; {
bar._otherProps._key = []; bar._otherProps._key = [];
bar._otherProps._key_halign = 'none';
} }
//в случае наличия скрытых строчек или столбов(в итоге скрытых серий) //в случае наличия скрытых строчек или столбов(в итоге скрытых серий)
if(chart.skipSeries) if(chart.skipSeries)
{ {
......
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