Commit 9ae2c1eb authored by Sergey Luzyanin's avatar Sergey Luzyanin

fix Bug 32514 - [Charts] JS ошибка после удаления одного из элементов в легенде диаграммы

fix Bug 32483 - Ошибка в консоли при увеличении размера кегли в легенде до размеров диаграммы
parent 09cab972
...@@ -429,6 +429,7 @@ CShape.prototype.recalculate = function () ...@@ -429,6 +429,7 @@ CShape.prototype.recalculate = function ()
}, this, []); }, this, []);
}; };
CShape.prototype.recalculateBounds = function() CShape.prototype.recalculateBounds = function()
{ {
var boundsChecker = new AscFormat.CSlideBoundsChecker(); var boundsChecker = new AscFormat.CSlideBoundsChecker();
......
...@@ -333,7 +333,7 @@ function handleInternalChart(drawing, drawingObjectsController, e, x, y, group, ...@@ -333,7 +333,7 @@ function handleInternalChart(drawing, drawingObjectsController, e, x, y, group,
selector.selectObject(drawing, pageIndex); selector.selectObject(drawing, pageIndex);
selector.selection.chartSelection = drawing; selector.selection.chartSelection = drawing;
drawing.selection.legend = legend; drawing.selection.legend = legend;
drawing.selection.legendEntry = i; drawing.selection.legendEntry = aCalcEntries[i].idx;
drawingObjectsController.updateSelectionState(); drawingObjectsController.updateSelectionState();
drawingObjectsController.updateOverlay(); drawingObjectsController.updateOverlay();
return true; return true;
......
...@@ -547,6 +547,8 @@ CDLbl.prototype = ...@@ -547,6 +547,8 @@ CDLbl.prototype =
}, },
getStyles: function() getStyles: function()
{ {
return AscFormat.ExecuteNoHistory(function(){ return AscFormat.ExecuteNoHistory(function(){
...@@ -2110,6 +2112,7 @@ CPlotArea.prototype = ...@@ -2110,6 +2112,7 @@ CPlotArea.prototype =
{ {
case AscDFH.historyitem_type_CatAx: case AscDFH.historyitem_type_CatAx:
case AscDFH.historyitem_type_DateAx: case AscDFH.historyitem_type_DateAx:
case AscDFH.historyitem_type_SerAx:
{ {
ret.catAx.push(axis); ret.catAx.push(axis);
break; break;
...@@ -6805,6 +6808,11 @@ CSerAx.prototype = ...@@ -6805,6 +6808,11 @@ CSerAx.prototype =
this.parent && this.parent.parent && this.parent.parent.Refresh_RecalcData2(pageIndex, object); this.parent && this.parent.parent && this.parent.parent.Refresh_RecalcData2(pageIndex, object);
}, },
getMenuProps: CCatAx.prototype.getMenuProps,
setMenuProps: CCatAx.prototype.setMenuProps,
getDrawingDocument: function() getDrawingDocument: function()
{ {
return this.parent && this.parent.parent && this.parent.parent.getDrawingDocument && this.parent.parent.getDrawingDocument(); return this.parent && this.parent.parent && this.parent.parent.getDrawingDocument && this.parent.parent.getDrawingDocument();
...@@ -13745,6 +13753,16 @@ CLegend.prototype = ...@@ -13745,6 +13753,16 @@ CLegend.prototype =
this.Refresh_RecalcData2(); this.Refresh_RecalcData2();
}, },
findCalcEntryByIdx: function(idx)
{
for(var i = 0; i < this.calcEntryes.length; ++i){
if(this.calcEntryes[i] && this.calcEntryes[i].idx === idx){
return this.calcEntryes[i];
}
}
return null;
},
createDuplicate: function() createDuplicate: function()
{ {
var c = new CLegend(); var c = new CLegend();
...@@ -13769,6 +13787,24 @@ CLegend.prototype = ...@@ -13769,6 +13787,24 @@ CLegend.prototype =
return c; return c;
}, },
getCalcEntryByIdx: function(idx, drawingDocument)
{
for(var i = 0; i < this.calcEntryes.length; ++i)
{
if(this.calcEntryes[i] && this.calcEntryes[i].idx == idx)
{
return this.calcEntryes[i];
}
}
return AscFormat.ExecuteNoHistory(function(){
var calcEntry = new AscFormat.CalcLegendEntry(this, this.chart, idx);
calcEntry.txBody = AscFormat.CreateTextBodyFromString("" + idx, drawingDocument, calcEntry);
calcEntry.txBody.getRectWidth(2000);
return calcEntry;
}, this, []);
},
Write_ToBinary2: function (w) Write_ToBinary2: function (w)
{ {
w.WriteLong(this.getObjectType()); w.WriteLong(this.getObjectType());
......
...@@ -585,11 +585,13 @@ CChartSpace.prototype.drawSelect = function(drawingDocument, nPageIndex) ...@@ -585,11 +585,13 @@ CChartSpace.prototype.drawSelect = function(drawingDocument, nPageIndex)
} }
else if(this.selection.legend) else if(this.selection.legend)
{ {
if(AscFormat.isRealNumber(this.selection.legendEntry) && this.chart.legend.calcEntryes[this.selection.legendEntry]) if(AscFormat.isRealNumber(this.selection.legendEntry))
{ {
var oEntry = this.chart.legend.calcEntryes[this.selection.legendEntry]; var oEntry = this.chart.legend.findCalcEntryByIdx(this.selection.legendEntry);
if(oEntry){
drawingDocument.DrawTrack(AscFormat.TYPE_TRACK.CHART_TEXT, oEntry.transformText, 0, 0, oEntry.contentWidth, oEntry.contentHeight, false, false); drawingDocument.DrawTrack(AscFormat.TYPE_TRACK.CHART_TEXT, oEntry.transformText, 0, 0, oEntry.contentWidth, oEntry.contentHeight, false, false);
} }
}
else else
{ {
drawingDocument.DrawTrack(AscFormat.TYPE_TRACK.CHART_TEXT, this.selection.legend.transform, 0, 0, this.selection.legend.extX, this.selection.legend.extY, false, false); drawingDocument.DrawTrack(AscFormat.TYPE_TRACK.CHART_TEXT, this.selection.legend.transform, 0, 0, this.selection.legend.extX, this.selection.legend.extY, false, false);
...@@ -791,13 +793,23 @@ CChartSpace.prototype.getParagraphTextPr = function() ...@@ -791,13 +793,23 @@ CChartSpace.prototype.getParagraphTextPr = function()
{ {
if(!AscFormat.isRealNumber(this.selection.legendEntry)) if(!AscFormat.isRealNumber(this.selection.legendEntry))
{ {
if(AscFormat.isRealNumber(this.legendLength))
{
var arrForProps = [];
for(var i = 0; i < this.legendLength; ++i)
{
arrForProps.push(this.chart.legend.getCalcEntryByIdx(i, this.getDrawingDocument()))
}
return GetTextPrFormArrObjects(arrForProps);
}
return GetTextPrFormArrObjects(this.chart.legend.calcEntryes); return GetTextPrFormArrObjects(this.chart.legend.calcEntryes);
} }
else else
{ {
if(this.chart.legend.calcEntryes[this.selection.legendEntry]) var calcLegendEntry = this.chart.legend.getCalcEntryByIdx(this.selection.legendEntry, this.getDrawingDocument());
if(calcLegendEntry)
{ {
return GetTextPrFormArrObjects([this.chart.legend.calcEntryes[this.selection.legendEntry]]); return GetTextPrFormArrObjects([calcLegendEntry]);
} }
} }
} }
...@@ -860,20 +872,11 @@ CChartSpace.prototype.applyLabelsFunction = function(fCallback, value) ...@@ -860,20 +872,11 @@ CChartSpace.prototype.applyLabelsFunction = function(fCallback, value)
} }
else else
{ {
var aCalcEntries = this.selection.legend.calcEntryes; var entry = this.selection.legend.findLegendEntryByIndex(this.selection.legendEntry);
var idx;
if(aCalcEntries && aCalcEntries[this.selection.legendEntry])
{
idx = aCalcEntries[this.selection.legendEntry].idx;
}
var entry;
if(AscFormat.isRealNumber(idx))
{
entry = this.selection.legend.findLegendEntryByIndex(idx);
if(!entry) if(!entry)
{ {
entry = new AscFormat.CLegendEntry(); entry = new AscFormat.CLegendEntry();
entry.setIdx(idx); entry.setIdx(this.selection.legendEntry);
if(this.selection.legend.txPr) if(this.selection.legend.txPr)
{ {
entry.setTxPr(this.selection.legend.txPr.createDuplicate()); entry.setTxPr(this.selection.legend.txPr.createDuplicate());
...@@ -887,7 +890,6 @@ CChartSpace.prototype.applyLabelsFunction = function(fCallback, value) ...@@ -887,7 +890,6 @@ CChartSpace.prototype.applyLabelsFunction = function(fCallback, value)
} }
} }
} }
}
else if(this.selection.axisLbls) else if(this.selection.axisLbls)
{ {
fCallback(this.selection.axisLbls, value, this.getDrawingDocument(), 10); fCallback(this.selection.axisLbls, value, this.getDrawingDocument(), 10);
...@@ -1587,7 +1589,7 @@ CChartSpace.prototype.clearFormatting = function(bNoClearShapeProps) ...@@ -1587,7 +1589,7 @@ CChartSpace.prototype.clearFormatting = function(bNoClearShapeProps)
var ser = this.chart.plotArea.chart.series[this.selection.dataLbls]; var ser = this.chart.plotArea.chart.series[this.selection.dataLbls];
if(ser) if(ser)
{ {
var oDlbls = !ser.dLbls; var oDlbls = ser.dLbls;
if(!ser.dLbls) if(!ser.dLbls)
{ {
...@@ -6393,19 +6395,22 @@ CChartSpace.prototype.recalculateLegend = function() ...@@ -6393,19 +6395,22 @@ CChartSpace.prototype.recalculateLegend = function()
this.chart.legend.chart = this; this.chart.legend.chart = this;
var b_scatter_no_line = false;/*(this.chart.plotArea.chart.getObjectType() === AscDFH.historyitem_type_ScatterChart && var b_scatter_no_line = false;/*(this.chart.plotArea.chart.getObjectType() === AscDFH.historyitem_type_ScatterChart &&
(this.chart.plotArea.chart.scatterStyle === AscFormat.SCATTER_STYLE_MARKER || this.chart.plotArea.chart.scatterStyle === AscFormat.SCATTER_STYLE_NONE)); */ (this.chart.plotArea.chart.scatterStyle === AscFormat.SCATTER_STYLE_MARKER || this.chart.plotArea.chart.scatterStyle === AscFormat.SCATTER_STYLE_NONE)); */
this.legendLength = null;
if( !this.chart.plotArea.chart.varyColors || (this.chart.plotArea.chart.getObjectType() !== AscDFH.historyitem_type_PieChart && this.chart.plotArea.chart.getObjectType() !== AscDFH.historyitem_type_DoughnutChart) && series.length !== 1) if( !this.chart.plotArea.chart.varyColors || (this.chart.plotArea.chart.getObjectType() !== AscDFH.historyitem_type_PieChart && this.chart.plotArea.chart.getObjectType() !== AscDFH.historyitem_type_DoughnutChart) && series.length !== 1)
{ {
this.legendLength = series.length;
for(i = 0; i < series.length; ++i) for(i = 0; i < series.length; ++i)
{ {
ser = series[i]; ser = series[i];
arr_str_labels.push(ser.getSeriesName());
if(ser.isHiddenForLegend) if(ser.isHiddenForLegend)
continue; continue;
entry = legend.findLegendEntryByIndex(i); entry = legend.findLegendEntryByIndex(i);
if(entry && entry.bDelete) if(entry && entry.bDelete)
continue; continue;
arr_str_labels.push(ser.getSeriesName());
calc_entry = new AscFormat.CalcLegendEntry(legend, this, i); calc_entry = new AscFormat.CalcLegendEntry(legend, this, i);
calc_entry.txBody = AscFormat.CreateTextBodyFromString(arr_str_labels[i], this.getDrawingDocument(), calc_entry); calc_entry.txBody = AscFormat.CreateTextBodyFromString(arr_str_labels[arr_str_labels.length - 1], this.getDrawingDocument(), calc_entry);
//if(entry) //if(entry)
// calc_entry.txPr = entry.txPr; // calc_entry.txPr = entry.txPr;
...@@ -6489,6 +6494,7 @@ CChartSpace.prototype.recalculateLegend = function() ...@@ -6489,6 +6494,7 @@ CChartSpace.prototype.recalculateLegend = function()
} }
var pts = AscFormat.getPtsFromSeries(ser), pt; var pts = AscFormat.getPtsFromSeries(ser), pt;
var cat_str_lit = getCatStringPointsFromSeries(ser); var cat_str_lit = getCatStringPointsFromSeries(ser);
this.legendLength = pts.length;
for(i = 0; i < pts.length; ++i) for(i = 0; i < pts.length; ++i)
{ {
entry = legend.findLegendEntryByIndex(i); entry = legend.findLegendEntryByIndex(i);
...@@ -6502,7 +6508,7 @@ CChartSpace.prototype.recalculateLegend = function() ...@@ -6502,7 +6508,7 @@ CChartSpace.prototype.recalculateLegend = function()
arr_str_labels.push((pt.idx + 1) + ""); arr_str_labels.push((pt.idx + 1) + "");
calc_entry = new AscFormat.CalcLegendEntry(legend, this, pt.idx); calc_entry = new AscFormat.CalcLegendEntry(legend, this, pt.idx);
calc_entry.txBody = AscFormat.CreateTextBodyFromString(arr_str_labels[i], this.getDrawingDocument(), calc_entry); calc_entry.txBody = AscFormat.CreateTextBodyFromString(arr_str_labels[arr_str_labels.length - 1], this.getDrawingDocument(), calc_entry);
//if(entry) //if(entry)
// calc_entry.txPr = entry.txPr; // calc_entry.txPr = entry.txPr;
......
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