Commit ae90e533 authored by Alexander.Trofimov's avatar Alexander.Trofimov

asc_getThumbBySparklineGroup -> getThumbBySparklineGroup

delete asc_createSparklineGroupByStyle
parent fe0502b0
...@@ -4986,48 +4986,36 @@ CellArea.prototype = { ...@@ -4986,48 +4986,36 @@ CellArea.prototype = {
return oExcellColor; return oExcellColor;
}; };
sparklineGroup.prototype.asc_createSparklineGroupByStyle = function (nStyleIndex) { sparklineGroup.prototype.generateCache = function () {
var oSparklineGroup = this.clone(true);
var oStyle = AscFormat.aSparklinesStyles[nStyleIndex];
if (oStyle) {
oSparklineGroup.colorSeries = this.createExcellColor(oStyle[0]);
oSparklineGroup.colorNegative = this.createExcellColor(oStyle[1]);
oSparklineGroup.colorAxis = this.createExcellColor(0xff000000);
oSparklineGroup.colorMarkers = this.createExcellColor(oStyle[2]);
oSparklineGroup.colorFirst = this.createExcellColor(oStyle[3]);
oSparklineGroup.colorLast = this.createExcellColor(oStyle[4]);
oSparklineGroup.colorHigh = this.createExcellColor(oStyle[5]);
oSparklineGroup.colorLow = this.createExcellColor(oStyle[6]);
}
return oSparklineGroup;
};
sparklineGroup.prototype.generateCache = function(){
function createItem(value) { function createItem(value) {
return { numFormatStr: "General", isDateTimeFormat: false, val: value, isHidden: false }; return {numFormatStr: "General", isDateTimeFormat: false, val: value, isHidden: false};
} }
switch(this.type){
switch (this.type) {
case Asc.c_oAscSparklineType.Line: { case Asc.c_oAscSparklineType.Line: {
return [createItem(128), createItem(56), createItem(175), createItem(0), createItem(248), createItem(184)]; return [createItem(128), createItem(56), createItem(175), createItem(0), createItem(248), createItem(184)];
} }
case Asc.c_oAscSparklineType.Column: { case Asc.c_oAscSparklineType.Column: {
return [createItem(88), createItem(56), createItem(144), createItem(64), createItem(-56), createItem(-104), createItem(-40), createItem(-24), createItem(-56), createItem(104), createItem(56), createItem(80), createItem(-56), createItem(88)]; return [createItem(88), createItem(56), createItem(144), createItem(64), createItem(-56), createItem(-104),
createItem(-40), createItem(-24), createItem(-56), createItem(104), createItem(56), createItem(80),
createItem(-56), createItem(88)];
} }
case Asc.c_oAscSparklineType.Stacked: { case Asc.c_oAscSparklineType.Stacked: {
return [createItem(1), createItem(-1), createItem(-1), createItem(-2), createItem(1), createItem(1), createItem(-1), createItem(1), createItem(1), createItem(1), createItem(1), createItem(2), createItem(-1), createItem(1)]; return [createItem(1), createItem(-1), createItem(-1), createItem(-2), createItem(1), createItem(1),
createItem(-1), createItem(1), createItem(1), createItem(1), createItem(1), createItem(2), createItem(-1),
createItem(1)];
} }
} }
return []; return [];
}; };
sparklineGroup.prototype.asc_getThumbBySparklineGroup = function(oSparklineGroup){ sparklineGroup.prototype.getThumbBySparklineGroup = function (oSparklineGroup) {
if(!this.canvas) { if (!this.canvas) {
this.canvas = document.createElement('canvas'); this.canvas = document.createElement('canvas');
if(AscCommon.AscBrowser.isRetina) { if (AscCommon.AscBrowser.isRetina) {
this.canvas.width = 100; this.canvas.width = 100;
this.canvas.height = 100; this.canvas.height = 100;
} } else {
else{
this.canvas.width = 50; this.canvas.width = 50;
this.canvas.height = 50; this.canvas.height = 50;
} }
...@@ -5039,8 +5027,7 @@ CellArea.prototype = { ...@@ -5039,8 +5027,7 @@ CellArea.prototype = {
this.sparklineView.initFromSparkline(oSparkline, oSparklineGroup, null, true); this.sparklineView.initFromSparkline(oSparkline, oSparklineGroup, null, true);
var api_sheet = Asc['editor']; var api_sheet = Asc['editor'];
AscFormat.ExecuteNoHistory( AscFormat.ExecuteNoHistory(function () {
function () {
this.sparklineView.chartSpace.setWorksheet(api_sheet.wb.getWorksheet().model); this.sparklineView.chartSpace.setWorksheet(api_sheet.wb.getWorksheet().model);
}, this, []); }, this, []);
...@@ -5048,25 +5035,25 @@ CellArea.prototype = { ...@@ -5048,25 +5035,25 @@ CellArea.prototype = {
this.sparklineView.chartSpace.extY = 100; this.sparklineView.chartSpace.extY = 100;
this.sparklineView.chartSpace.x = 0; this.sparklineView.chartSpace.x = 0;
this.sparklineView.chartSpace.y = 0; this.sparklineView.chartSpace.y = 0;
if(oSparklineGroup.type === Asc.c_oAscSparklineType.Stacked){ if (oSparklineGroup.type === Asc.c_oAscSparklineType.Stacked) {
AscFormat.ExecuteNoHistory(function(){ AscFormat.ExecuteNoHistory(function () {
var oPlotArea = this.sparklineView.chartSpace.chart.plotArea; var oPlotArea = this.sparklineView.chartSpace.chart.plotArea;
if(!oPlotArea.layout){ if (!oPlotArea.layout) {
oPlotArea.setLayout(new AscFormat.CLayout()); oPlotArea.setLayout(new AscFormat.CLayout());
} }
var fPos = 0.32; var fPos = 0.32;
oPlotArea.layout.setWMode(AscFormat.LAYOUT_MODE_FACTOR); oPlotArea.layout.setWMode(AscFormat.LAYOUT_MODE_FACTOR);
oPlotArea.layout.setW(1.0); oPlotArea.layout.setW(1.0);
oPlotArea.layout.setHMode(AscFormat.LAYOUT_MODE_FACTOR); oPlotArea.layout.setHMode(AscFormat.LAYOUT_MODE_FACTOR);
oPlotArea.layout.setH(1 - 2*fPos); oPlotArea.layout.setH(1 - 2 * fPos);
oPlotArea.layout.setYMode(AscFormat.LAYOUT_MODE_EDGE); oPlotArea.layout.setYMode(AscFormat.LAYOUT_MODE_EDGE);
oPlotArea.layout.setY(fPos); oPlotArea.layout.setY(fPos);
}, this, []); }, this, []);
} }
if(oSparklineGroup.type === Asc.c_oAscSparklineType.Line){ if (oSparklineGroup.type === Asc.c_oAscSparklineType.Line) {
AscFormat.ExecuteNoHistory(function(){ AscFormat.ExecuteNoHistory(function () {
var oPlotArea = this.sparklineView.chartSpace.chart.plotArea; var oPlotArea = this.sparklineView.chartSpace.chart.plotArea;
if(!oPlotArea.layout){ if (!oPlotArea.layout) {
oPlotArea.setLayout(new AscFormat.CLayout()); oPlotArea.setLayout(new AscFormat.CLayout());
} }
var fPos = 0.16; var fPos = 0.16;
...@@ -5084,36 +5071,44 @@ CellArea.prototype = { ...@@ -5084,36 +5071,44 @@ CellArea.prototype = {
// } // }
var oGraphics = new AscCommon.CGraphics(); var oGraphics = new AscCommon.CGraphics();
oGraphics.init(this.canvas.getContext('2d'), this.canvas.width, this.canvas.height, this.sparklineView.chartSpace.extX, this.sparklineView.chartSpace.extY); oGraphics.init(this.canvas.getContext('2d'), this.canvas.width, this.canvas.height,
this.sparklineView.chartSpace.extX, this.sparklineView.chartSpace.extY);
oGraphics.m_oFontManager = AscCommon.g_fontManager; oGraphics.m_oFontManager = AscCommon.g_fontManager;
oGraphics.transform(1,0,0,1,0,0); oGraphics.transform(1, 0, 0, 1, 0, 0);
this.sparklineView.chartSpace.draw(oGraphics); this.sparklineView.chartSpace.draw(oGraphics);
return this.canvas.toDataURL("image/png"); return this.canvas.toDataURL("image/png");
}; };
sparklineGroup.prototype.isEqualColors = function(oSparklineGroup){ sparklineGroup.prototype.isEqualColors = function (oSparklineGroup) {
if(this.colorSeries && !this.colorSeries.isEqual(oSparklineGroup.colorSeries) || !this.colorSeries && oSparklineGroup.colorSeries){ if (this.colorSeries && !this.colorSeries.isEqual(oSparklineGroup.colorSeries) ||
!this.colorSeries && oSparklineGroup.colorSeries) {
return false; return false;
} }
if(this.colorNegative && !this.colorNegative.isEqual(oSparklineGroup.colorNegative) || !this.colorNegative && oSparklineGroup.colorNegative){ if (this.colorNegative && !this.colorNegative.isEqual(oSparklineGroup.colorNegative) ||
!this.colorNegative && oSparklineGroup.colorNegative) {
return false; return false;
} }
/*if(this.colorAxis && !this.colorAxis.isEqual(oSparklineGroup.colorAxis) || !this.colorAxis && oSparklineGroup.colorAxis){ /*if(this.colorAxis && !this.colorAxis.isEqual(oSparklineGroup.colorAxis) || !this.colorAxis && oSparklineGroup.colorAxis){
return false; return false;
}*/ }*/
if(this.colorMarkers && !this.colorMarkers.isEqual(oSparklineGroup.colorMarkers) || !this.colorMarkers && oSparklineGroup.colorMarkers){ if (this.colorMarkers && !this.colorMarkers.isEqual(oSparklineGroup.colorMarkers) ||
!this.colorMarkers && oSparklineGroup.colorMarkers) {
return false; return false;
} }
if(this.colorFirst && !this.colorFirst.isEqual(oSparklineGroup.colorFirst) || !this.colorFirst && oSparklineGroup.colorFirst){ if (this.colorFirst && !this.colorFirst.isEqual(oSparklineGroup.colorFirst) ||
!this.colorFirst && oSparklineGroup.colorFirst) {
return false; return false;
} }
if(this.colorLast && !this.colorLast.isEqual(oSparklineGroup.colorLast) || !this.colorLast && oSparklineGroup.colorLast){ if (this.colorLast && !this.colorLast.isEqual(oSparklineGroup.colorLast) ||
!this.colorLast && oSparklineGroup.colorLast) {
return false; return false;
} }
if(this.colorHigh && !this.colorHigh.isEqual(oSparklineGroup.colorHigh) || !this.colorHigh && oSparklineGroup.colorHigh){ if (this.colorHigh && !this.colorHigh.isEqual(oSparklineGroup.colorHigh) ||
!this.colorHigh && oSparklineGroup.colorHigh) {
return false; return false;
} }
if(this.colorLow && !this.colorLow.isEqual(oSparklineGroup.colorLow) || !this.colorLow && oSparklineGroup.colorLow){ if (this.colorLow && !this.colorLow.isEqual(oSparklineGroup.colorLow) ||
!this.colorLow && oSparklineGroup.colorLow) {
return false; return false;
} }
return true; return true;
...@@ -5122,12 +5117,13 @@ CellArea.prototype = { ...@@ -5122,12 +5117,13 @@ CellArea.prototype = {
sparklineGroup.prototype.asc_getStyles = function () { sparklineGroup.prototype.asc_getStyles = function () {
var aRet = []; var aRet = [];
var nStyleIndex = -1; var nStyleIndex = -1;
var oSparklineGroup = this.clone(true);
for (var i = 0; i < 36; ++i) { for (var i = 0; i < 36; ++i) {
var oSparklineGroup = this.asc_createSparklineGroupByStyle(i); oSparklineGroup.asc_setStyle(i);
if (nStyleIndex === -1 && this.isEqualColors(oSparklineGroup)) { if (nStyleIndex === -1 && this.isEqualColors(oSparklineGroup)) {
nStyleIndex = i; nStyleIndex = i;
} }
aRet.push(this.asc_getThumbBySparklineGroup(oSparklineGroup)); aRet.push(this.getThumbBySparklineGroup(oSparklineGroup));
} }
aRet.push(nStyleIndex); aRet.push(nStyleIndex);
return aRet; return aRet;
...@@ -7395,8 +7391,6 @@ function getCurrencyFormat(opt_cultureInfo, opt_fraction, opt_currency, opt_curr ...@@ -7395,8 +7391,6 @@ function getCurrencyFormat(opt_cultureInfo, opt_fraction, opt_currency, opt_curr
prot["asc_setColorLast"] = prot.asc_setColorLast; prot["asc_setColorLast"] = prot.asc_setColorLast;
prot["asc_setColorHigh"] = prot.asc_setColorHigh; prot["asc_setColorHigh"] = prot.asc_setColorHigh;
prot["asc_setColorLow"] = prot.asc_setColorLow; prot["asc_setColorLow"] = prot.asc_setColorLow;
prot["asc_createSparklineGroupByStyle"] = prot.asc_createSparklineGroupByStyle;
prot["asc_getThumbBySparklineGroup"] = prot.asc_getThumbBySparklineGroup;
prot["asc_getStyles"] = prot.asc_getStyles; prot["asc_getStyles"] = prot.asc_getStyles;
prot["asc_setStyle"] = prot.asc_setStyle; prot["asc_setStyle"] = prot.asc_setStyle;
window['AscCommonExcel'].sparkline = sparkline; window['AscCommonExcel'].sparkline = sparkline;
......
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