Commit 4004c3e3 authored by Alexander.Trofimov's avatar Alexander.Trofimov

arrCachedSparklines -> oCacheView in sparkline

fix bug with clear all
parent 665f45a8
...@@ -4717,7 +4717,6 @@ CellArea.prototype = { ...@@ -4717,7 +4717,6 @@ CellArea.prototype = {
this.f = null; this.f = null;
this.arrSparklines = []; this.arrSparklines = [];
this.arrCachedSparklines = {};
//for drawing preview //for drawing preview
this.canvas = null; this.canvas = null;
...@@ -5187,21 +5186,23 @@ CellArea.prototype = { ...@@ -5187,21 +5186,23 @@ CellArea.prototype = {
return res; return res;
}; };
sparklineGroup.prototype.addView = function (oSparklineView, index) {
this.arrCachedSparklines[index] = oSparklineView;
};
sparklineGroup.prototype.draw = function (oDrawingContext) { sparklineGroup.prototype.draw = function (oDrawingContext) {
var oCacheView;
var graphics = new AscCommon.CGraphics(); var graphics = new AscCommon.CGraphics();
graphics.init(oDrawingContext.ctx, oDrawingContext.getWidth(0), oDrawingContext.getHeight(0), graphics.init(oDrawingContext.ctx, oDrawingContext.getWidth(0), oDrawingContext.getHeight(0),
oDrawingContext.getWidth(3), oDrawingContext.getHeight(3)); oDrawingContext.getWidth(3), oDrawingContext.getHeight(3));
graphics.m_oFontManager = AscCommon.g_fontManager; graphics.m_oFontManager = AscCommon.g_fontManager;
for (var i in this.arrCachedSparklines) { for (var i = 0; i < this.arrSparklines.length; ++i) {
this.arrCachedSparklines[i].draw(graphics); if (oCacheView = this.arrSparklines[i].oCacheView) {
oCacheView.draw(graphics);
}
} }
}; };
sparklineGroup.prototype.cleanCache = function () { sparklineGroup.prototype.cleanCache = function () {
// ToDo clean only colors (for color scheme) // ToDo clean only colors (for color scheme)
this.arrCachedSparklines = {}; for (var i = 0; i < this.arrSparklines.length; ++i) {
this.arrSparklines[i].oCacheView = null;
}
}; };
sparklineGroup.prototype.updateCache = function (sheet, ranges) { sparklineGroup.prototype.updateCache = function (sheet, ranges) {
var sparklineRange; var sparklineRange;
...@@ -5209,7 +5210,7 @@ CellArea.prototype = { ...@@ -5209,7 +5210,7 @@ CellArea.prototype = {
sparklineRange = this.arrSparklines[i]._f; sparklineRange = this.arrSparklines[i]._f;
for (var j = 0; j < ranges.length; ++j) { for (var j = 0; j < ranges.length; ++j) {
if (sparklineRange.isIntersect(ranges[j], sheet)) { if (sparklineRange.isIntersect(ranges[j], sheet)) {
delete this.arrCachedSparklines[i]; this.arrSparklines[i].oChacheView = null;
break; break;
} }
} }
...@@ -5227,7 +5228,6 @@ CellArea.prototype = { ...@@ -5227,7 +5228,6 @@ CellArea.prototype = {
for (var i = 0; i < this.arrSparklines.length; ++i) { for (var i = 0; i < this.arrSparklines.length; ++i) {
if (this.arrSparklines[i].checkInRange(range)) { if (this.arrSparklines[i].checkInRange(range)) {
this.arrSparklines.splice(i, 1); this.arrSparklines.splice(i, 1);
delete this.arrCachedSparklines[i];
--i; --i;
} }
} }
...@@ -5536,6 +5536,7 @@ CellArea.prototype = { ...@@ -5536,6 +5536,7 @@ CellArea.prototype = {
//for preview //for preview
this.oCache = null; this.oCache = null;
this.oCacheView = null;
} }
sparkline.prototype.clone = function () { sparkline.prototype.clone = function () {
......
...@@ -2875,18 +2875,18 @@ function DrawingObjects() { ...@@ -2875,18 +2875,18 @@ function DrawingObjects() {
_this.checkSparklineGroupMinMaxVal = function(oSparklineGroup) _this.checkSparklineGroupMinMaxVal = function(oSparklineGroup)
{ {
var maxVal = null, minVal = null, i, j; var maxVal = null, minVal = null, i, j, sparkline;
if(oSparklineGroup.type !== Asc.c_oAscSparklineType.Stacked && if(oSparklineGroup.type !== Asc.c_oAscSparklineType.Stacked &&
(Asc.c_oAscSparklineAxisMinMax.Group === oSparklineGroup.minAxisType || Asc.c_oAscSparklineAxisMinMax.Group === oSparklineGroup.maxAxisType)) (Asc.c_oAscSparklineAxisMinMax.Group === oSparklineGroup.minAxisType || Asc.c_oAscSparklineAxisMinMax.Group === oSparklineGroup.maxAxisType))
{ {
for(i = 0; i < oSparklineGroup.arrSparklines.length; ++i) for(i = 0; i < oSparklineGroup.arrSparklines.length; ++i)
{ {
if (!oSparklineGroup.arrCachedSparklines[i]) { sparkline = oSparklineGroup.arrSparklines[i];
var oSparklineView = new CSparklineView(); if (!sparkline.oCacheView) {
oSparklineView.initFromSparkline(oSparklineGroup.arrSparklines[i], oSparklineGroup, worksheet); sparkline.oCacheView = new CSparklineView();
oSparklineGroup.addView(oSparklineView, i); sparkline.oCacheView.initFromSparkline(sparkline, oSparklineGroup, worksheet);
} }
var aPoints = AscFormat.getPtsFromSeries(oSparklineGroup.arrCachedSparklines[i].chartSpace.chart.plotArea.charts[0].series[0]); var aPoints = AscFormat.getPtsFromSeries(sparkline.oCacheView.chartSpace.chart.plotArea.charts[0].series[0]);
for(j = 0; j < aPoints.length; ++j) for(j = 0; j < aPoints.length; ++j)
{ {
if(Asc.c_oAscSparklineAxisMinMax.Group === oSparklineGroup.maxAxisType) if(Asc.c_oAscSparklineAxisMinMax.Group === oSparklineGroup.maxAxisType)
...@@ -2923,7 +2923,7 @@ function DrawingObjects() { ...@@ -2923,7 +2923,7 @@ function DrawingObjects() {
{ {
for(i = 0; i < oSparklineGroup.arrSparklines.length; ++i) for(i = 0; i < oSparklineGroup.arrSparklines.length; ++i)
{ {
oSparklineGroup.arrCachedSparklines[i].setMinMaxValAx(minVal, maxVal, oSparklineGroup); oSparklineGroup.arrSparklines[i].oCacheView.setMinMaxValAx(minVal, maxVal, oSparklineGroup);
} }
} }
} }
...@@ -2932,7 +2932,7 @@ function DrawingObjects() { ...@@ -2932,7 +2932,7 @@ function DrawingObjects() {
_this.drawSparkLineGroups = function(oDrawingContext, aSparklineGroups, range, offsetX, offsetY) _this.drawSparkLineGroups = function(oDrawingContext, aSparklineGroups, range, offsetX, offsetY)
{ {
var graphics, i, j; var graphics, i, j, sparkline;
if(oDrawingContext instanceof AscCommonExcel.CPdfPrinter) if(oDrawingContext instanceof AscCommonExcel.CPdfPrinter)
{ {
graphics = oDrawingContext.DocumentRenderer; graphics = oDrawingContext.DocumentRenderer;
...@@ -2956,13 +2956,14 @@ function DrawingObjects() { ...@@ -2956,13 +2956,14 @@ function DrawingObjects() {
_this.checkSparklineGroupMinMaxVal(oSparklineGroup); _this.checkSparklineGroupMinMaxVal(oSparklineGroup);
} }
for(j = 0; j < oSparklineGroup.arrSparklines.length; ++j) { for(j = 0; j < oSparklineGroup.arrSparklines.length; ++j) {
if (!oSparklineGroup.arrCachedSparklines[j]) { sparkline = oSparklineGroup.arrSparklines[j];
var oSparklineView = new CSparklineView(); if (!sparkline.checkInRange(range)) {
oSparklineView.initFromSparkline(oSparklineGroup.arrSparklines[j], oSparklineGroup, worksheet); continue;
oSparklineGroup.addView(oSparklineView, j); }
}
if (!oSparklineGroup.arrSparklines[j].checkInRange(range)) { if (!sparkline.oCacheView) {
continue; sparkline.oCacheView = new CSparklineView();
sparkline.oCacheView.initFromSparkline(sparkline, oSparklineGroup, worksheet);
} }
if(oDrawingContext instanceof AscCommonExcel.CPdfPrinter) if(oDrawingContext instanceof AscCommonExcel.CPdfPrinter)
...@@ -2975,7 +2976,7 @@ function DrawingObjects() { ...@@ -2975,7 +2976,7 @@ function DrawingObjects() {
graphics.SetBaseTransform(_baseTransform); graphics.SetBaseTransform(_baseTransform);
} }
oSparklineGroup.arrCachedSparklines[j].draw(graphics, _offX, _offY); sparkline.oCacheView.draw(graphics, _offX, _offY);
if(oDrawingContext instanceof AscCommonExcel.CPdfPrinter) if(oDrawingContext instanceof AscCommonExcel.CPdfPrinter)
{ {
......
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