Commit 50aea9d5 authored by Sergey.Luzyanin's avatar Sergey.Luzyanin Committed by Alexander.Trofimov

Bug 25240 - Добавить подходящие данные для биржевой диаграммы

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@57629 954022d7-b5bf-4e40-9824-e11837661b57
parent 9f52c6a6
......@@ -2671,8 +2671,18 @@ function DrawingObjects() {
function fillTableFromRef(ref)
{
var cache = ref.numCache ? ref.numCache : (ref.strCache ? ref.strCache : null);
var lit_format_code;
if(cache)
{
if(typeof cache.formatCode === "string" && cache.formatCode.length > 0)
{
lit_format_code = cache.formatCode;
}
else
{
lit_format_code = "General"
}
var f1 = ref.f.replace(/\(|\)/g,"");
var arr_f = f1.split(",");
var pt_index = 0, i, j, cell, pt;
......@@ -2722,7 +2732,7 @@ function DrawingObjects() {
pt = cache.getPtByIndex(pt_index);
if(pt)
{
cell.setNumFormat(typeof pt.formatCode === "string" && pt.formatCode.length > 0 ? pt.formatCode : "General");
cell.setNumFormat(typeof pt.formatCode === "string" && pt.formatCode.length > 0 ? pt.formatCode : lit_format_code);
cell.setValue(pt.val + "");
}
++pt_index;
......@@ -2736,7 +2746,7 @@ function DrawingObjects() {
pt = cache.getPtByIndex(pt_index);
if(pt)
{
cell.setNumFormat(typeof pt.formatCode === "string" && pt.formatCode.length > 0 ? pt.formatCode : "General");
cell.setNumFormat(typeof pt.formatCode === "string" && pt.formatCode.length > 0 ? pt.formatCode : lit_format_code);
cell.setValue(pt.val + "");
}
++pt_index;
......
......@@ -2945,49 +2945,96 @@ DrawingObjectsController.prototype =
getSeriesDefault: function (type) {
// Обновлены тестовые данные для новой диаграммы
function createItem(value) {
return { numFormatStr: "General", isDateTimeFormat: false, val: value, isHidden: false };
}
var bIsScatter = (c_oAscChartTypeSettings.scatter <= type && type <= c_oAscChartTypeSettings.scatterSmoothMarker);
var Cat = { Formula: "Sheet1!A2:A7", NumCache: [createItem("USA"), createItem("CHN"), createItem("RUS"), createItem("GBR"), createItem("GER"), createItem("JPN")] };
var series = [];
var seria = new asc_CChartSeria();
seria.Val.Formula = "Sheet1!B2:B7";
seria.Val.NumCache = [ createItem(46), createItem(38), createItem(24), createItem(29), createItem(11), createItem(7) ];
seria.TxCache.Formula = "Sheet1!B1";
seria.TxCache.Tx = "Gold";
if (!bIsScatter)
seria.Cat = Cat;
else
seria.xVal = Cat;
series.push(seria);
seria = new asc_CChartSeria();
seria.Val.Formula = "Sheet1!C2:C7";
seria.Val.NumCache = [ createItem(29), createItem(27), createItem(26), createItem(17), createItem(19), createItem(14) ];
seria.TxCache.Formula = "Sheet1!C1";
seria.TxCache.Tx = "Silver";
if (!bIsScatter)
seria.Cat = Cat;
else
seria.xVal = Cat;
series.push(seria);
seria = new asc_CChartSeria();
seria.Val.Formula = "Sheet1!D2:D7";
seria.Val.NumCache = [ createItem(29), createItem(23), createItem(32), createItem(19), createItem(14), createItem(17) ];
seria.TxCache.Formula = "Sheet1!D1";
seria.TxCache.Tx = "Bronze";
if (!bIsScatter)
seria.Cat = Cat;
else
seria.xVal = Cat;
series.push(seria);
return series;
var series = [], seria, Cat;
var createItem = function(value) {
return { numFormatStr: "General", isDateTimeFormat: false, val: value, isHidden: false };
};
var createItem2 = function(value, formatCode) {
return { numFormatStr: formatCode, isDateTimeFormat: false, val: value, isHidden: false };
};
if(type !== c_oAscChartTypeSettings.stock)
{
var bIsScatter = (c_oAscChartTypeSettings.scatter <= type && type <= c_oAscChartTypeSettings.scatterSmoothMarker);
Cat = { Formula: "Sheet1!A2:A7", NumCache: [createItem("USA"), createItem("CHN"), createItem("RUS"), createItem("GBR"), createItem("GER"), createItem("JPN")] };
seria = new asc_CChartSeria();
seria.Val.Formula = "Sheet1!B2:B7";
seria.Val.NumCache = [ createItem(46), createItem(38), createItem(24), createItem(29), createItem(11), createItem(7) ];
seria.TxCache.Formula = "Sheet1!B1";
seria.TxCache.Tx = "Gold";
if (!bIsScatter)
seria.Cat = Cat;
else
seria.xVal = Cat;
series.push(seria);
seria = new asc_CChartSeria();
seria.Val.Formula = "Sheet1!C2:C7";
seria.Val.NumCache = [ createItem(29), createItem(27), createItem(26), createItem(17), createItem(19), createItem(14) ];
seria.TxCache.Formula = "Sheet1!C1";
seria.TxCache.Tx = "Silver";
if (!bIsScatter)
seria.Cat = Cat;
else
seria.xVal = Cat;
series.push(seria);
seria = new asc_CChartSeria();
seria.Val.Formula = "Sheet1!D2:D7";
seria.Val.NumCache = [ createItem(29), createItem(23), createItem(32), createItem(19), createItem(14), createItem(17) ];
seria.TxCache.Formula = "Sheet1!D1";
seria.TxCache.Tx = "Bronze";
if (!bIsScatter)
seria.Cat = Cat;
else
seria.xVal = Cat;
series.push(seria);
return series;
}
else
{
Cat = { Formula: "Sheet1!A2:A5", NumCache: [createItem2(38719, "d\-mmm\-yy"), createItem2(38720, "d\-mmm\-yy"), createItem2(38721, "d\-mmm\-yy"), createItem2(38722, "d\-mmm\-yy"), createItem2(38723, "d\-mmm\-yy")], formatCode: "d\-mmm\-yy" };
seria = new asc_CChartSeria();
seria.Val.Formula = "Sheet1!B2:B5";
seria.Val.NumCache = [ createItem(40), createItem(21), createItem(37), createItem(49), createItem(32)];
seria.TxCache.Formula = "Sheet1!B1";
seria.TxCache.Tx = "Open";
seria.Cat = Cat;
series.push(seria);
seria = new asc_CChartSeria();
seria.Val.Formula = "Sheet1!C2:C5";
seria.Val.NumCache = [ createItem(57), createItem(54), createItem(52), createItem(59), createItem(34)];
seria.TxCache.Formula = "Sheet1!C1";
seria.TxCache.Tx = "High";
seria.Cat = Cat;
series.push(seria);
seria = new asc_CChartSeria();
seria.Val.Formula = "Sheet1!D2:D5";
seria.Val.NumCache = [ createItem(10), createItem(14), createItem(14), createItem(12), createItem(6)];
seria.TxCache.Formula = "Sheet1!D1";
seria.TxCache.Tx = "Low";
seria.Cat = Cat;
series.push(seria);
seria = new asc_CChartSeria();
seria.Val.Formula = "Sheet1!E2:E5";
seria.Val.NumCache = [ createItem(24), createItem(35), createItem(48), createItem(35), createItem(15)];
seria.TxCache.Formula = "Sheet1!E1";
seria.TxCache.Tx = "Close";
seria.Cat = Cat;
series.push(seria);
return series;
}
},
changeCurrentState: function(newState)
......
......@@ -1968,9 +1968,16 @@ CChartSpace.prototype =
}
}
if(series[0].cat && series[0].cat.strRef)
if(series[0].cat)
{
ref = series[0].cat.strRef;
if(series[0].cat.strRef)
{
ref = series[0].cat.strRef;
}
else if(series[0].cat.numRef)
{
ref = series[0].cat.numRef;
}
}
else if(series[0].xVal)
{
......@@ -5698,7 +5705,7 @@ CChartSpace.prototype =
/*string_pts pts_len*/
if(ser && ser.cat)
{
var lit;
var lit, b_num_lit = true;
if(ser.cat.strRef && ser.cat.strRef.strCache)
{
lit = ser.cat.strRef.strCache;
......@@ -5710,20 +5717,55 @@ CChartSpace.prototype =
else if(ser.cat.numRef && ser.cat.numRef.numCache)
{
lit = ser.cat.numRef.numCache;
b_num_lit = true;
}
else if(ser.cat.numLit)
{
lit = ser.cat.numLit;
b_num_lit = true;
}
if(lit)
{
var lit_format = null, pt_format = null;
if(b_num_lit && typeof lit.formatCode === "string" && lit.formatCode.length > 0)
{
lit_format = oNumFormatCache.get(lit.formatCode);
}
pts_len = lit.ptCount;
for(i = 0; i < pts_len; ++i)
{
var pt = lit.getPtByIndex(i);
if(pt)
{
string_pts.push({val: pt.val + ""});
var str_pt;
if(b_num_lit)
{
if(typeof pt.formatCode === "string" && pt.formatCode.length > 0)
{
pt_format = oNumFormatCache.get(lit.formatCode);
if(pt_format)
{
str_pt = pt_format.formatToChart(pt.val);
}
else
{
str_pt = pt.val;
}
}
else if(lit_format)
{
str_pt = lit_format.formatToChart(pt.val);
}
else
{
str_pt = pt.val;
}
}
else
{
str_pt = pt.val;
}
string_pts.push({val: str_pt + ""});
}
else
{
......@@ -6730,33 +6772,101 @@ CChartSpace.prototype =
//расчитаем подписи для горизонтальной оси
var ser = chart_object.series[0];
var string_pts = [], pts_len = 0;
/*string_pts pts_len*/
if(ser && ser.cat)
{
var lit, b_num_lit = true;
if(ser.cat.strRef && ser.cat.strRef.strCache)
{
string_pts = ser.cat.strRef.strCache.pt;
pts_len = string_pts.length;
lit = ser.cat.strRef.strCache;
}
else if(ser.cat.strLit)
{
string_pts = ser.cat.strLit.pt;
pts_len = string_pts.length;
lit = ser.cat.strLit;
}
else if(ser.cat.numRef && ser.cat.numRef.numCache)
{
lit = ser.cat.numRef.numCache;
b_num_lit = true;
}
else if(ser.cat.numLit)
{
lit = ser.cat.numLit;
b_num_lit = true;
}
if(lit)
{
var lit_format = null, pt_format = null;
if(b_num_lit && typeof lit.formatCode === "string" && lit.formatCode.length > 0)
{
lit_format = oNumFormatCache.get(lit.formatCode);
}
pts_len = lit.ptCount;
for(i = 0; i < pts_len; ++i)
{
var pt = lit.getPtByIndex(i);
if(pt)
{
var str_pt;
if(b_num_lit)
{
if(typeof pt.formatCode === "string" && pt.formatCode.length > 0)
{
pt_format = oNumFormatCache.get(lit.formatCode);
if(pt_format)
{
str_pt = pt_format.formatToChart(pt.val);
}
else
{
str_pt = pt.val;
}
}
else if(lit_format)
{
str_pt = lit_format.formatToChart(pt.val);
}
else
{
str_pt = pt.val;
}
}
else
{
str_pt = pt.val;
}
string_pts.push({val: str_pt + ""});
}
else
{
string_pts.push({val: i + ""});
}
}
}
}
var pts_len2 = pts_len;
// if(string_pts.length === 0)
//if(string_pts.length === 0)
{
if(ser.val)
pts_len = 0;
for(i = 0; i < chart_object.series.length; ++i)
{
if(ser.val.numRef && ser.val.numRef.numCache)
pts_len2 = ser.val.numRef.numCache.pts.length;
else if(ser.val.numLit)
pts_len2 = ser.val.numLit.pts.length;
var cur_pts= null;
ser = chart_object.series[i];
if(ser.val)
{
if(ser.val.numRef && ser.val.numRef.numCache)
cur_pts = ser.val.numRef.numCache;
else if(ser.val.numLit)
cur_pts = ser.val.numLit;
if(cur_pts)
{
pts_len = Math.max(pts_len, cur_pts.ptCount);
}
}
}
if(pts_len2 > pts_len)
if(pts_len > string_pts.length)
{
pts_len = pts_len2;
for(i = 0; i < pts_len2; ++i)
for(i = 0; i < pts_len; ++i)
{
string_pts.push({val:i+1 + ""});
}
......@@ -13002,6 +13112,10 @@ function CreateStockChart(chartSeries)
series.setIdx(i);
series.setOrder(i);
series.setMarker(new CMarker());
series.setSpPr(new CSpPr());
series.spPr.setLn(new CLn());
series.spPr.ln.setW(28575);
series.spPr.ln.setFill(CreateNoFillUniFill());
series.marker.setSymbol(SYMBOL_NONE);
series.setSmooth(false);
series.setVal(new CYVal());
......@@ -13025,20 +13139,47 @@ function CreateStockChart(chartSeries)
{
series.setCat(new CCat());
var cat = series.cat;
cat.setStrRef(new CStrRef());
var str_ref = cat.strRef;
str_ref.setF(asc_series[i].Cat.Formula);
str_ref.setStrCache(new CStrCache());
var str_cache = str_ref.strCache;
var cat_num_cache = asc_series[i].Cat.NumCache;
str_cache.setPtCount(cat_num_cache.length);
for(var j= 0; j < cat_num_cache.length; ++j)
if(typeof asc_series[i].Cat.formatCode === "string" && asc_series[i].Cat.formatCode.length > 0)
{
var string_pt = new CStringPoint();
string_pt.setIdx(j);
string_pt.setVal(cat_num_cache[j].val);
str_cache.addPt(string_pt);
cat.setNumRef(new CNumRef());
var num_ref = cat.numRef;
num_ref.setF(asc_series[i].Cat.Formula);
num_ref.setNumCache(new CNumLit());
var num_cache = num_ref.numCache;
var cat_num_cache = asc_series[i].Cat.NumCache;
num_cache.setPtCount(cat_num_cache.length);
num_cache.setFormatCode(asc_series[i].Cat.formatCode);
for(var j= 0; j < cat_num_cache.length; ++j)
{
var pt = new CNumericPoint();
pt.setIdx(j);
pt.setVal(cat_num_cache[j].val);
if(cat_num_cache[j].numFormatStr !== asc_series[i].Cat.formatCode)
{
pt.setFormatCode(cat_num_cache[j].numFormatStr);
}
num_cache.addPt(pt);
}
}
else
{
cat.setStrRef(new CStrRef());
var str_ref = cat.strRef;
str_ref.setF(asc_series[i].Cat.Formula);
str_ref.setStrCache(new CStrCache());
var str_cache = str_ref.strCache;
var cat_num_cache = asc_series[i].Cat.NumCache;
str_cache.setPtCount(cat_num_cache.length);
for(var j= 0; j < cat_num_cache.length; ++j)
{
var string_pt = new CStringPoint();
string_pt.setIdx(j);
string_pt.setVal(cat_num_cache[j].val);
str_cache.addPt(string_pt);
}
}
}
if(parsedHeaders.bLeft && asc_series[i].TxCache && typeof asc_series[i].TxCache.Formula === "string" && asc_series[i].TxCache.Formula.length > 0)
{
......
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