Skip to content

Commit

Permalink
[chart] calculate line for trendline
Browse files Browse the repository at this point in the history
  • Loading branch information
SergeyLuzyanin committed Oct 10, 2023
1 parent 257bee0 commit 3093b75
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
23 changes: 23 additions & 0 deletions common/Drawings/Format/ChartFormat.js
Original file line number Diff line number Diff line change
Expand Up @@ -2329,6 +2329,13 @@
CBaseChartObject.prototype.isObjectInSmartArt = function() {
return false;
};
CBaseChartObject.prototype.getParentObjects = function() {
let oChartSpace = this.getChartSpace();
if(oChartSpace) {
return oChartSpace.getParentObjects();
}
return null;
};

function getMinMaxFromArrPoints(aPoints) {
if(Array.isArray(aPoints) && aPoints.length > 0) {
Expand Down Expand Up @@ -4409,6 +4416,12 @@
CSeriesBase.prototype.checkSeriesAfterChangeType = function() {

};
CSeriesBase.prototype.recalculateTrendline = function() {
let oTrendline = this.trendline;
if(oTrendline) {
oTrendline.recalculate();
}
};
CSeriesBase.prototype.asc_getName = function() {
var oThis = this;
return AscFormat.ExecuteNoHistory(function() {
Expand Down Expand Up @@ -14115,6 +14128,16 @@
}
this.applyStyleEntry(oChartStyle.trendline, oColors.generateColors(1), 0, bReset);
};
CTrendLine.prototype.recalculate = function() {
this.pen = null;
if(this.spPr && this.spPr.ln && this.spPr.ln.Fill) {
let oChartSpace = this.getChartSpace();
if(oChartSpace) {
this.pen = this.spPr.ln.createDuplicate();
this.pen.Fill.check(oChartSpace.Get_Theme(), oChartSpace.Get_ColorMap())
}
}
};

function CUpDownBars() {
CBaseChartObject.call(this);
Expand Down
4 changes: 3 additions & 1 deletion common/Drawings/Format/ChartSpace.js
Original file line number Diff line number Diff line change
Expand Up @@ -7098,7 +7098,7 @@ function(window, undefined) {
var ser = series[ii];
var pts = ser.getNumPts();
this.ptsCount += pts.length;

ser.recalculateTrendline();
ser.compiledSeriesBrush = new AscFormat.CUniFill();
ser.compiledSeriesBrush.merge(base_fills2[ser.idx]);
if (ser.spPr && ser.spPr.Fill) {
Expand Down Expand Up @@ -7368,6 +7368,7 @@ function(window, undefined) {
for(var i = 0; i < series.length; ++i) {
var default_line = parents.theme.themeElements.fmtScheme.lnStyleLst[0];
var ser = series[i];
ser.recalculateTrendline();
var pts = ser.getNumPts();
this.ptsCount += pts.length;
if(oChart.scatterStyle === AscFormat.SCATTER_STYLE_SMOOTH || oChart.scatterStyle === AscFormat.SCATTER_STYLE_SMOOTH_MARKER) {
Expand Down Expand Up @@ -7529,6 +7530,7 @@ function(window, undefined) {
base_line_fills = getArrayFillsFromBase(style.line2, nMaxSeriesIdx);
for(var i = 0; i < series.length; ++i) {
var ser = series[i];
ser.recalculateTrendline();
var compiled_brush = new AscFormat.CUniFill();
compiled_brush.merge(base_fills[ser.idx]);
if(ser.spPr && ser.spPr.Fill) {
Expand Down

0 comments on commit 3093b75

Please sign in to comment.