Commit 846d472f authored by Sergey Luzyanin's avatar Sergey Luzyanin

Оси спарклайнов

parent 919452a6
...@@ -427,16 +427,38 @@ CSparklineView.prototype.initFromSparkline = function(oSparkline, oSparklineGrou ...@@ -427,16 +427,38 @@ CSparklineView.prototype.initFromSparkline = function(oSparkline, oSparklineGrou
var val_ax_props = new asc_ValAxisSettings(); var val_ax_props = new asc_ValAxisSettings();
val_ax_props.putMinValRule(c_oAscValAxisRule.auto); if(settings.type !== c_oAscChartTypeSettings.barStackedPer)
val_ax_props.putMaxValRule(c_oAscValAxisRule.auto); {
val_ax_props.putMinValRule(c_oAscValAxisRule.auto);
val_ax_props.putMaxValRule(c_oAscValAxisRule.auto);
}
else
{
val_ax_props.putMinValRule(c_oAscValAxisRule.fixed);
val_ax_props.putMinVal(-1);
val_ax_props.putMaxValRule(c_oAscValAxisRule.fixed);
val_ax_props.putMaxVal(1);
}
val_ax_props.putTickLabelsPos(c_oAscTickLabelsPos.TICK_LABEL_POSITION_NONE); val_ax_props.putTickLabelsPos(c_oAscTickLabelsPos.TICK_LABEL_POSITION_NONE);
val_ax_props.putInvertValOrder(false); if(oSparklineGroup.rightToLeft)
{
val_ax_props.putInvertValOrder(true);
}
else
{
val_ax_props.putInvertValOrder(false);
}
val_ax_props.putDispUnitsRule(c_oAscValAxUnits.none); val_ax_props.putDispUnitsRule(c_oAscValAxUnits.none);
val_ax_props.putMajorTickMark(c_oAscTickMark.TICK_MARK_NONE); val_ax_props.putMajorTickMark(c_oAscTickMark.TICK_MARK_NONE);
val_ax_props.putMinorTickMark(c_oAscTickMark.TICK_MARK_NONE); val_ax_props.putMinorTickMark(c_oAscTickMark.TICK_MARK_NONE);
val_ax_props.putCrossesRule(c_oAscCrossesRule.auto); val_ax_props.putCrossesRule(c_oAscCrossesRule.auto);
var cat_ax_props = new asc_CatAxisSettings(); var cat_ax_props = new asc_CatAxisSettings();
cat_ax_props.putIntervalBetweenLabelsRule(c_oAscBetweenLabelsRule.auto); cat_ax_props.putIntervalBetweenLabelsRule(c_oAscBetweenLabelsRule.auto);
cat_ax_props.putLabelsPosition(c_oAscLabelsPosition.betweenDivisions); cat_ax_props.putLabelsPosition(c_oAscLabelsPosition.betweenDivisions);
...@@ -2291,16 +2313,36 @@ function DrawingObjects() { ...@@ -2291,16 +2313,36 @@ function DrawingObjects() {
oSparklineGroup.updateCache(range); oSparklineGroup.updateCache(range);
} }
}; };
_this.checkSparklineGroupMinMaxVal = function(oSparklineGroup)
{
var maxVal = null, minVal = null;
if(oSparklineGroup.type !== Asc.ESparklineType.Stacked &&
(Asc.SparklineAxisMinMax.Group === oSparklineGroup.minAxisType || Asc.SparklineAxisMinMax.Group === oSparklineGroup.maxAxisType))
{
for(var i = 0; i < oSparklineGroup.arrSparklines.length; ++i)
{
if (!oSparklineGroup.arrCachedSparklines[j]) {
var oSparklineView = new CSparklineView();
oSparklineView.initFromSparkline(oSparklineGroup.arrSparklines[j], oSparklineGroup, worksheet);
oSparklineGroup.addView(oSparklineView, j);
}
var aPoints = getPtsFromSeries(oSparklineView.chartSpace.chart.plotArea.charts[0].series[0]);
}
}
};
_this.drawSparkLineGroups = function(oDrawingContext, oSparklineGroups, range) _this.drawSparkLineGroups = function(oDrawingContext, oSparklineGroups, range)
{ {
oDrawingContext.save();
var graphics = new CGraphics(); var graphics = new CGraphics();
graphics.init(oDrawingContext.ctx, oDrawingContext.getWidth(0), oDrawingContext.getHeight(0), graphics.init(oDrawingContext.ctx, oDrawingContext.getWidth(0), oDrawingContext.getHeight(0),
oDrawingContext.getWidth(3)*nSparklineMultiplier, oDrawingContext.getHeight(3)*nSparklineMultiplier); oDrawingContext.getWidth(3)*nSparklineMultiplier, oDrawingContext.getHeight(3)*nSparklineMultiplier);
graphics.m_oFontManager = g_fontManager; graphics.m_oFontManager = g_fontManager;
graphics.SaveGrState();
for(var i = 0; i < oSparklineGroups.arrSparklineGroup.length; ++i) { for(var i = 0; i < oSparklineGroups.arrSparklineGroup.length; ++i) {
var oSparklineGroup = oSparklineGroups.arrSparklineGroup[i]; var oSparklineGroup = oSparklineGroups.arrSparklineGroup[i];
for(var j = 0; j < oSparklineGroup.arrSparklines.length; ++j) { for(var j = 0; j < oSparklineGroup.arrSparklines.length; ++j) {
if (!oSparklineGroup.arrCachedSparklines[j]) { if (!oSparklineGroup.arrCachedSparklines[j]) {
var oSparklineView = new CSparklineView(); var oSparklineView = new CSparklineView();
...@@ -2312,8 +2354,9 @@ function DrawingObjects() { ...@@ -2312,8 +2354,9 @@ function DrawingObjects() {
} }
oSparklineGroup.arrCachedSparklines[j].draw(graphics); oSparklineGroup.arrCachedSparklines[j].draw(graphics);
} }
} }
oDrawingContext.restore(); graphics.RestoreGrState();
}; };
_this.rebuildChartGraphicObjects = function(data) _this.rebuildChartGraphicObjects = function(data)
......
...@@ -2317,128 +2317,130 @@ CChartSpace.prototype = ...@@ -2317,128 +2317,130 @@ CChartSpace.prototype =
}, },
recalculateReferences: function() checkValByNumRef: function(workbook, ser, val, bVertical)
{ {
var worksheet = this.worksheet; if(val && val.numRef && typeof val.numRef.f === "string"/*(!val.numRef.numCache || val.numRef.numCache.pts.length === 0)*/)
//this.pointsMap = {};
if(!worksheet)
return;
if(this.recalcInfo.recalculateBBox)
{ {
this.recalculateBBox(); var first_slice = 0, last_slice = 0;
this.recalcInfo.recalculateBBox = false; if(val.numRef.f[0] === "(")
}
var checkValByNumRef = function(oThis, ser, val, bVertical)
{
if(val && val.numRef && typeof val.numRef.f === "string"/*(!val.numRef.numCache || val.numRef.numCache.pts.length === 0)*/)
{ {
var first_slice = 0, last_slice = 0; first_slice = 1;
if(val.numRef.f[0] === "(") }
{ if(val.numRef.f[val.numRef.f.length - 1] === ")")
first_slice = 1; {
} last_slice = -1;
if(val.numRef.f[val.numRef.f.length - 1] === ")") }
{ else
last_slice = -1; {
} last_slice = val.numRef.f.length;
else }
{ var f1 = val.numRef.f.slice(first_slice, last_slice);
last_slice = val.numRef.f.length; var arr_f = f1.split(",");
}
var f1 = val.numRef.f.slice(first_slice, last_slice);
var arr_f = f1.split(",");
var num_cache; var num_cache;
if(!val.numRef.numCache ) if(!val.numRef.numCache )
{ {
num_cache = new CNumLit(); num_cache = new CNumLit();
num_cache.setFormatCode("General"); num_cache.setFormatCode("General");
} }
else else
{ {
num_cache = val.numRef.numCache; num_cache = val.numRef.numCache;
removePtsFromLit(num_cache); removePtsFromLit(num_cache);
} }
var lit_format_code = typeof num_cache.formatCode === "string" && num_cache.formatCode.length > 0 ? num_cache.formatCode : "General"; var lit_format_code = typeof num_cache.formatCode === "string" && num_cache.formatCode.length > 0 ? num_cache.formatCode : "General";
var pt_index = 0, i, j, cell, pt, worksheet_id, hidden = true, row_hidden, col_hidden, nPtCount; var pt_index = 0, i, j, cell, pt, worksheet_id, hidden = true, row_hidden, col_hidden, nPtCount;
for(i = 0; i < arr_f.length; ++i) for(i = 0; i < arr_f.length; ++i)
{
var parsed_ref = parserHelp.parse3DRef(arr_f[i]);
if(parsed_ref)
{ {
var parsed_ref = parserHelp.parse3DRef(arr_f[i]); var source_worksheet = workbook.getWorksheetByName(parsed_ref.sheet);
if(parsed_ref) if(source_worksheet)
{ {
var source_worksheet = oThis.worksheet.workbook.getWorksheetByName(parsed_ref.sheet); worksheet_id = source_worksheet.getId() + "";
if(source_worksheet) var range1 = source_worksheet.getRange2(parsed_ref.range);
if(range1)
{ {
worksheet_id = source_worksheet.getId() + ""; var range = range1.bbox;
var range1 = source_worksheet.getRange2(parsed_ref.range);
if(range1)
{
var range = range1.bbox;
if(range.r1 === range.r2 || bVertical === true) if(range.r1 === range.r2 || bVertical === true)
{
row_hidden = source_worksheet.getRowHidden(range.r1);
for(j = range.c1; j <= range.c2; ++j)
{ {
row_hidden = source_worksheet.getRowHidden(range.r1); if(!row_hidden && !source_worksheet.getColHidden(j))
for(j = range.c1; j <= range.c2; ++j)
{ {
if(!row_hidden && !source_worksheet.getColHidden(j)) cell = source_worksheet.getCell3(range.r1, j);
if(typeof cell.getValueWithFormat() === "string" && cell.getValueWithFormat().length > 0)
{ {
cell = source_worksheet.getCell3(range.r1, j); hidden = false;
if(typeof cell.getValueWithFormat() === "string" && cell.getValueWithFormat().length > 0) pt = new CNumericPoint();
pt.setIdx(pt_index);
pt.setVal(parseFloat(cell.getValue()));
if(cell.getNumFormatStr() !== lit_format_code)
{ {
hidden = false; pt.setFormatCode(cell.getNumFormatStr())
pt = new CNumericPoint();
pt.setIdx(pt_index);
pt.setVal(parseFloat(cell.getValue()));
if(cell.getNumFormatStr() !== lit_format_code)
{
pt.setFormatCode(cell.getNumFormatStr())
}
num_cache.addPt(pt);
//addPointToMap(oThis.pointsMap, source_worksheet, range.r1, j, pt);
} }
num_cache.addPt(pt);
} }
pt_index++;
} }
pt_index++;
} }
else }
else
{
col_hidden = source_worksheet.getColHidden(range.c1);
for(j = range.r1; j <= range.r2; ++j)
{ {
col_hidden = source_worksheet.getColHidden(range.c1); if(!col_hidden && !source_worksheet.getRowHidden(j))
for(j = range.r1; j <= range.r2; ++j)
{ {
if(!col_hidden && !source_worksheet.getRowHidden(j)) cell = source_worksheet.getCell3(j, range.c1);
if(typeof cell.getValueWithFormat() === "string" && cell.getValueWithFormat().length > 0)
{ {
cell = source_worksheet.getCell3(j, range.c1); hidden = false;
if(typeof cell.getValueWithFormat() === "string" && cell.getValueWithFormat().length > 0) pt = new CNumericPoint();
pt.setIdx(pt_index);
pt.setVal(parseFloat(cell.getValue()));
if(cell.getNumFormatStr() !== lit_format_code)
{ {
hidden = false; pt.setFormatCode(cell.getNumFormatStr())
pt = new CNumericPoint();
pt.setIdx(pt_index);
pt.setVal(parseFloat(cell.getValue()));
if(cell.getNumFormatStr() !== lit_format_code)
{
pt.setFormatCode(cell.getNumFormatStr())
}
num_cache.addPt(pt);
//addPointToMap(oThis.pointsMap, source_worksheet, j, range.c1, pt);
} }
num_cache.addPt(pt);
} }
pt_index++;
} }
pt_index++;
} }
} }
} }
} }
} }
num_cache.setPtCount(pt_index);
val.numRef.setNumCache(num_cache);
if(!(val instanceof CCat))
{
ser.isHidden = hidden;
ser.isHiddenForLegend = hidden;
}
} }
}; num_cache.setPtCount(pt_index);
val.numRef.setNumCache(num_cache);
if(!(val instanceof CCat))
{
ser.isHidden = hidden;
ser.isHiddenForLegend = hidden;
}
}
},
recalculateReferences: function()
{
var worksheet = this.worksheet;
//this.pointsMap = {};
if(!worksheet)
return;
if(this.recalcInfo.recalculateBBox)
{
this.recalculateBBox();
this.recalcInfo.recalculateBBox = false;
}
var checkCatByNumRef = function(oThis, ser, cat, bVertical) var checkCatByNumRef = function(oThis, ser, cat, bVertical)
{ {
...@@ -2543,9 +2545,9 @@ CChartSpace.prototype = ...@@ -2543,9 +2545,9 @@ CChartSpace.prototype =
{ {
ser = series[j]; ser = series[j];
//val //val
checkValByNumRef(this, ser, ser.val); this.checkValByNumRef(this.worksheet.workbook, ser, ser.val);
//cat //cat
checkValByNumRef(this, ser, ser.cat, bVert); this.checkValByNumRef(this.worksheet.workbook, ser, ser.cat, bVert);
checkCatByNumRef(this, ser, ser.cat, bVert); checkCatByNumRef(this, ser, ser.cat, bVert);
//tx //tx
checkCatByNumRef(this, ser, ser.tx, isRealBool(bVert) ? !bVert : undefined); checkCatByNumRef(this, ser, ser.tx, isRealBool(bVert) ? !bVert : undefined);
...@@ -2566,8 +2568,8 @@ CChartSpace.prototype = ...@@ -2566,8 +2568,8 @@ CChartSpace.prototype =
for(j = 0; j < series.length; ++j) for(j = 0; j < series.length; ++j)
{ {
ser = series[j]; ser = series[j];
checkValByNumRef(this, ser, ser.xVal, bVert); this.checkValByNumRef(this.worksheet.workbook, ser, ser.xVal, bVert);
checkValByNumRef(this, ser, ser.yVal); this.checkValByNumRef(this.worksheet.workbook, ser, ser.yVal);
checkCatByNumRef(this, ser, ser.tx, isRealBool(bVert) ? !bVert : undefined); checkCatByNumRef(this, ser, ser.tx, isRealBool(bVert) ? !bVert : undefined);
if(ser.isHidden) if(ser.isHidden)
......
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