mirror of
https://github.com/ONLYOFFICE/sdkjs.git
synced 2026-04-07 14:09:12 +08:00
remove unused baseColors; calculate labels for series axis
This commit is contained in:
@ -90,7 +90,6 @@ CChartSpace.prototype.setRecalculateInfo = function()
|
||||
recalculateTransform: true,
|
||||
recalculateBounds: true,
|
||||
recalculateChart: true,
|
||||
recalculateBaseColors: true,
|
||||
recalculateSeriesColors: true,
|
||||
recalculateMarkers: true,
|
||||
recalculateGridLines: true,
|
||||
@ -114,7 +113,6 @@ CChartSpace.prototype.setRecalculateInfo = function()
|
||||
recalculateTextPr : true,
|
||||
recalculateBBoxRange: true
|
||||
};
|
||||
this.baseColors = [];
|
||||
this.chartObj = null;
|
||||
this.rectGeometry = AscFormat.ExecuteNoHistory(function(){return AscFormat.CreateGeometry("rect");}, this, []);
|
||||
this.lockType = AscCommon.c_oAscLockTypes.kLockTypeNone;
|
||||
@ -131,10 +129,6 @@ CChartSpace.prototype.recalcChart = function()
|
||||
{
|
||||
this.recalcInfo.recalculateChart = true;
|
||||
};
|
||||
CChartSpace.prototype.recalcBaseColors = function()
|
||||
{
|
||||
this.recalcInfo.recalculateBaseColors = true;
|
||||
};
|
||||
CChartSpace.prototype.recalcSeriesColors = function()
|
||||
{
|
||||
this.recalcInfo.recalculateSeriesColors = true;
|
||||
@ -301,11 +295,6 @@ CChartSpace.prototype.recalculate = function()
|
||||
this.recalculateBBox();
|
||||
this.recalcInfo.recalculateBBox = false;
|
||||
}
|
||||
if(this.recalcInfo.recalculateBaseColors)
|
||||
{
|
||||
this.recalculateBaseColors();
|
||||
this.recalcInfo.recalculateBaseColors = false;
|
||||
}
|
||||
if(this.recalcInfo.recalculateMarkers)
|
||||
{
|
||||
this.recalculateMarkers();
|
||||
|
||||
@ -2228,6 +2228,7 @@ function CPlotArea()
|
||||
//ТоDo
|
||||
this.valAx = null;
|
||||
this.catAx = null;
|
||||
this.serAx = null;
|
||||
this.dateAx = null;
|
||||
this.chart = null;
|
||||
|
||||
@ -2307,7 +2308,6 @@ CPlotArea.prototype =
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
getContentChangesByType: function(type){
|
||||
switch(type){
|
||||
case AscDFH.historyitem_PlotArea_AddAxis:
|
||||
@ -2552,7 +2552,7 @@ CPlotArea.prototype =
|
||||
|
||||
getAxisByTypes: function()
|
||||
{
|
||||
var ret = {valAx:[], catAx: [], dateAx: []};
|
||||
var ret = {valAx:[], catAx: [], dateAx: [], serAx: []};
|
||||
for(var i = 0; i < this.axId.length; ++i)
|
||||
{
|
||||
var axis = this.axId[i];
|
||||
@ -2560,7 +2560,6 @@ CPlotArea.prototype =
|
||||
{
|
||||
case AscDFH.historyitem_type_CatAx:
|
||||
case AscDFH.historyitem_type_DateAx:
|
||||
case AscDFH.historyitem_type_SerAx:
|
||||
{
|
||||
ret.catAx.push(axis);
|
||||
break;
|
||||
@ -2570,7 +2569,11 @@ CPlotArea.prototype =
|
||||
ret.valAx.push(axis);
|
||||
break;
|
||||
}
|
||||
//TODO DATE Axis
|
||||
case AscDFH.historyitem_type_SerAx:
|
||||
{
|
||||
ret.serAx.push(axis);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
|
||||
@ -5057,13 +5057,21 @@ CChartSpace.prototype.recalculateAxis = function()
|
||||
else if(chart_type !== AscDFH.historyitem_type_BarChart && (chart_type !== AscDFH.historyitem_type_PieChart && chart_type !== AscDFH.historyitem_type_DoughnutChart)
|
||||
|| (chart_type === AscDFH.historyitem_type_BarChart && chart_object.barDir !== AscFormat.BAR_DIR_BAR))
|
||||
{
|
||||
var cat_ax, val_ax;
|
||||
var cat_ax, val_ax, ser_ax;
|
||||
val_ax = this.chart.plotArea.valAx;
|
||||
cat_ax = this.chart.plotArea.catAx;
|
||||
ser_ax = this.chart.plotArea.serAx;
|
||||
if(val_ax && cat_ax)
|
||||
{
|
||||
val_ax.labels = null;
|
||||
cat_ax.labels = null;
|
||||
if(ser_ax){
|
||||
ser_ax.labels = null;
|
||||
ser_ax.posY = null;
|
||||
ser_ax.posX = null;
|
||||
ser_ax.xPoints = null;
|
||||
ser_ax.yPoints = null;
|
||||
}
|
||||
|
||||
val_ax.posX = null;
|
||||
cat_ax.posY = null;
|
||||
@ -5250,6 +5258,8 @@ CChartSpace.prototype.recalculateAxis = function()
|
||||
string_pts.splice(pts_len, string_pts.length - pts_len);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*---------------------расчет позиции блока с подписями вертикальной оси-----------------------------------------------------------------------------*/
|
||||
//расчитаем ширину интервала без учета горизонтальной оси;
|
||||
var crosses;//номер категории в которой вертикалная ось пересекает горизонтальную;
|
||||
@ -6052,6 +6062,67 @@ CChartSpace.prototype.recalculateAxis = function()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//series axis
|
||||
if(ser_ax){
|
||||
if(c_oAscTickLabelsPos.TICK_LABEL_POSITION_NONE !== ser_ax.tickLblPos && !(ser_ax.bDelete === true)){
|
||||
var arr_series_labels_str = [];
|
||||
var aSeries = chart_object.series;
|
||||
for(var i = 0; i < aSeries.length; ++i){
|
||||
if(aSeries[i].getSeriesName){
|
||||
arr_series_labels_str.push(aSeries[i].getSeriesName());
|
||||
}
|
||||
else{
|
||||
arr_series_labels_str.push('Series ' + (i+1));
|
||||
}
|
||||
}
|
||||
ser_ax.labels = new AscFormat.CValAxisLabels(this, ser_ax);
|
||||
tick_lbl_skip = AscFormat.isRealNumber(ser_ax.tickLblSkip) ? ser_ax.tickLblSkip : 1;
|
||||
|
||||
var lastStyleObject = null;
|
||||
max_val_labels_text_height = 0;
|
||||
max_width = 0;
|
||||
for(i = 0; i < arr_series_labels_str.length; ++i)
|
||||
{
|
||||
var dlbl = null;
|
||||
if(i%tick_lbl_skip === 0)
|
||||
{
|
||||
var dlbl = new AscFormat.CDLbl();
|
||||
if(lastStyleObject)
|
||||
{
|
||||
dlbl.lastStyleObject = lastStyleObject;
|
||||
}
|
||||
dlbl.parent = val_ax;
|
||||
dlbl.chart = this;
|
||||
dlbl.spPr = val_ax.spPr;
|
||||
dlbl.txPr = val_ax.txPr;
|
||||
dlbl.tx = new AscFormat.CChartText();
|
||||
dlbl.tx.rich = AscFormat.CreateTextBodyFromString(arr_series_labels_str[i], this.getDrawingDocument(), dlbl);
|
||||
var t = dlbl.tx.rich.recalculateByMaxWord();
|
||||
if(!lastStyleObject)
|
||||
{
|
||||
lastStyleObject = dlbl.lastStyleObject;
|
||||
}
|
||||
var cur_width = t.w;
|
||||
if(cur_width > max_width)
|
||||
max_width = cur_width;
|
||||
if(t.h > max_val_labels_text_height)
|
||||
max_val_labels_text_height = t.h;
|
||||
val_ax.labels.arrLabels.push(dlbl);
|
||||
}
|
||||
ser_ax.labels.arrLabels.push(dlbl);
|
||||
}
|
||||
|
||||
var ser_axis_labels_gap = ser_ax.labels.arrLabels[0].tx.rich.content.Content[0].CompiledPr.Pr.TextPr.FontSize*25.4/72;
|
||||
ser_ax.labels.extX = max_width + ser_axis_labels_gap;
|
||||
ser_ax.labels.extY = max_val_labels_text_height;
|
||||
}
|
||||
else{
|
||||
ser_ax.labels = null;
|
||||
}
|
||||
}
|
||||
|
||||
//расчет позиции блока с подписями горизонтальной оси
|
||||
var cat_labels_align_bottom = true;
|
||||
/*-----------------------------------------------------------------------*/
|
||||
@ -10697,18 +10768,6 @@ CChartSpace.prototype.recalculateAxisLabels = function()
|
||||
}
|
||||
};
|
||||
|
||||
CChartSpace.prototype.recalculateBaseColors = function()
|
||||
{
|
||||
if ( this.style && (typeof(this.style) == 'number') )
|
||||
{
|
||||
if ( this.style % 8 === 0 )
|
||||
this.baseColors = CreateColorMapByIndex(8);
|
||||
else
|
||||
this.baseColors = CreateColorMapByIndex(this.style % 8);
|
||||
}
|
||||
else
|
||||
this.baseColors = CreateColorMapByIndex(2);
|
||||
};
|
||||
|
||||
CChartSpace.prototype.updateLinks = function()
|
||||
{
|
||||
@ -10717,6 +10776,7 @@ CChartSpace.prototype.updateLinks = function()
|
||||
if(this.chart && this.chart.plotArea)
|
||||
{
|
||||
this.chart.plotArea.chart = this.chart.plotArea.charts[0];
|
||||
this.chart.plotArea.serAx = null;
|
||||
if(this.chart.plotArea.charts[0].getAxisByTypes)
|
||||
{
|
||||
var axis_by_types = this.chart.plotArea.charts[0].getAxisByTypes();
|
||||
@ -10730,7 +10790,6 @@ CChartSpace.prototype.updateLinks = function()
|
||||
{
|
||||
if(axis_by_types.catAx[j] === axis_by_types.valAx[i].crossAx)
|
||||
{
|
||||
|
||||
this.chart.plotArea.valAx = axis_by_types.valAx[i];
|
||||
this.chart.plotArea.catAx = axis_by_types.catAx[j];
|
||||
break;
|
||||
@ -10747,6 +10806,17 @@ CChartSpace.prototype.updateLinks = function()
|
||||
this.chart.plotArea.valAx = axis_by_types.valAx[0];
|
||||
this.chart.plotArea.catAx = axis_by_types.catAx[0];
|
||||
}
|
||||
if(this.chart.plotArea.valAx && this.chart.plotArea.catAx)
|
||||
{
|
||||
for(i = 0; i < axis_by_types.serAx.length; ++i)
|
||||
{
|
||||
if(axis_by_types.serAx[i].crossAx === this.chart.plotArea.valAx)
|
||||
{
|
||||
this.chart.plotArea.serAx = axis_by_types.serAx[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -195,7 +195,6 @@ CChartSpace.prototype.setRecalculateInfo = function()
|
||||
recalculateTransform: true,
|
||||
recalculateBounds: true,
|
||||
recalculateChart: true,
|
||||
recalculateBaseColors: true,
|
||||
recalculateSeriesColors: true,
|
||||
recalculateMarkers: true,
|
||||
recalculateGridLines: true,
|
||||
@ -219,7 +218,6 @@ CChartSpace.prototype.setRecalculateInfo = function()
|
||||
recalculateTextPr : true,
|
||||
recalculateBBoxRange: true
|
||||
};
|
||||
this.baseColors = [];
|
||||
this.chartObj = null;
|
||||
this.rectGeometry = AscFormat.ExecuteNoHistory(function(){return AscFormat.CreateGeometry("rect");}, this, []);
|
||||
this.lockType = AscCommon.c_oAscLockTypes.kLockTypeNone;
|
||||
@ -236,10 +234,6 @@ CChartSpace.prototype.recalcChart = function()
|
||||
{
|
||||
this.recalcInfo.recalculateChart = true;
|
||||
};
|
||||
CChartSpace.prototype.recalcBaseColors = function()
|
||||
{
|
||||
this.recalcInfo.recalculateBaseColors = true;
|
||||
};
|
||||
CChartSpace.prototype.recalcSeriesColors = function()
|
||||
{
|
||||
this.recalcInfo.recalculateSeriesColors = true;
|
||||
@ -395,11 +389,6 @@ CChartSpace.prototype.recalculate = function()
|
||||
this.recalculateBBox();
|
||||
this.recalcInfo.recalculateBBox = false;
|
||||
}
|
||||
if(this.recalcInfo.recalculateBaseColors)
|
||||
{
|
||||
this.recalculateBaseColors();
|
||||
this.recalcInfo.recalculateBaseColors = false;
|
||||
}
|
||||
if(this.recalcInfo.recalculateMarkers)
|
||||
{
|
||||
this.recalculateMarkers();
|
||||
|
||||
@ -102,7 +102,6 @@ CChartSpace.prototype.setRecalculateInfo = function()
|
||||
recalculateTransform: true,
|
||||
recalculateBounds: true,
|
||||
recalculateChart: true,
|
||||
recalculateBaseColors: true,
|
||||
recalculateSeriesColors: true,
|
||||
recalculateMarkers: true,
|
||||
recalculateGridLines: true,
|
||||
@ -124,7 +123,6 @@ CChartSpace.prototype.setRecalculateInfo = function()
|
||||
recalculatePenBrush: true,
|
||||
recalculateTextPr: true
|
||||
};
|
||||
this.baseColors = [];
|
||||
|
||||
this.chartObj = null;
|
||||
this.rectGeometry = AscFormat.ExecuteNoHistory(function(){return AscFormat.CreateGeometry("rect");}, this, []);
|
||||
@ -146,10 +144,6 @@ CChartSpace.prototype.recalcChart = function()
|
||||
{
|
||||
this.recalcInfo.recalculateChart = true;
|
||||
};
|
||||
CChartSpace.prototype.recalcBaseColors = function()
|
||||
{
|
||||
this.recalcInfo.recalculateBaseColors = true;
|
||||
};
|
||||
CChartSpace.prototype.recalcSeriesColors = function()
|
||||
{
|
||||
this.recalcInfo.recalculateSeriesColors = true;
|
||||
@ -304,11 +298,6 @@ CChartSpace.prototype.recalculate = function()
|
||||
this.rectGeometry.Recalculate(this.extX, this.extY);
|
||||
this.recalcInfo.recalculateTransform = false;
|
||||
}
|
||||
if(this.recalcInfo.recalculateBaseColors)
|
||||
{
|
||||
this.recalculateBaseColors();
|
||||
this.recalcInfo.recalculateBaseColors = false;
|
||||
}
|
||||
if(this.recalcInfo.recalculateMarkers)
|
||||
{
|
||||
this.recalculateMarkers();
|
||||
|
||||
Reference in New Issue
Block a user