diff --git a/common/Charts/ChartsDrawer.js b/common/Charts/ChartsDrawer.js index 34337e9eb4..706422f974 100644 --- a/common/Charts/ChartsDrawer.js +++ b/common/Charts/ChartsDrawer.js @@ -414,8 +414,6 @@ CChartsDrawer.prototype = //draw trendline this.trendline.draw(); - //draw up and down bars - this.upDownBars.draw(); } }, @@ -1698,13 +1696,13 @@ CChartsDrawer.prototype = } this.upDownBars.provideInfo(valNumCache.ptCount, subType, charts[i].upDownBars); - for (let i = 0; i < valPts.length; i++) { - let index = counter !== null ? counter++ : valPts[i].idx; - if (index !== valPts[i].idx && index < valNumCache.ptCount) { - i -= 1; - this.upDownBars.addCoordinate(index, 0, j); + for (let k = 0; k < valPts.length; k++) { + let index = counter !== null ? counter++ : valPts[k].idx; + if (index !== valPts[k].idx && index < valNumCache.ptCount) { + k -= 1; + this.upDownBars.addCoordinate(charts[i].Id, index, 0, j); } else { - this.upDownBars.addCoordinate(valPts[i].idx, valPts[i].val, j); + this.upDownBars.addCoordinate(charts[i].Id, valPts[k].idx, valPts[k].val, j); } } } @@ -8350,7 +8348,7 @@ drawLineChart.prototype = { if(!xPoints || !yPoints) { return; } - + // this.upDownBars.draw(); var points, y, x, val, seria, dataSeries, compiledMarkerSize, compiledMarkerSymbol, idx, numCache, idxPoint; for (var i = 0; i < this.chart.series.length; i++) { @@ -8592,7 +8590,12 @@ drawLineChart.prototype = { this.cChartDrawer.cShapeDrawer.Graphics.SaveGrState(); this.cChartDrawer.cShapeDrawer.Graphics.AddClipRect(leftRect, topRect, rightRect, bottomRect); + this.cChartDrawer.drawPaths(this.paths, this.chart.series, true); + if (this.chart.upDownBars && this.cChartDrawer.upDownBars) { + this.cChartDrawer.upDownBars.draw(this.chart.Id); + } + this.cChartDrawer.cShapeDrawer.Graphics.RestoreGrState(); this.cChartDrawer.drawPathsPoints(this.paths, this.chart.series); @@ -14352,6 +14355,9 @@ drawStockChart.prototype = { draw: function () { this._drawLines(); + if (this.chart.upDownBars && this.cChartDrawer.upDownBars) { + this.cChartDrawer.upDownBars.draw(this.chart.Id); + } }, recalculate: function () { @@ -18967,7 +18973,7 @@ CColorObj.prototype = this.cChartDrawer = chartsDrawer; this.upDownBars = null; - this.storage = []; + this.storage = {}; this.ptsCount = 0; this.subtype = "normal"; this.lastIndex = null; @@ -18989,20 +18995,23 @@ CColorObj.prototype = }, // add coordinates one by one - addCoordinate: function (catPoint, valPoint, index) { + addCoordinate: function (chartId, catPoint, valPoint, index) { + if(!this.storage[chartId]) { + this.storage[chartId] = []; + } if (this.lastIndex === null || index !== this.lastIndex) { this.lastIndex = index; this.lastIdx = 0; } //index will help indicate the order of the series it can be either 0 or any positive number; - if (index === 0 && this.storage.length === 0) { - this.storage.push([]); + if (index === 0 && this.storage[chartId].length === 0) { + this.storage[chartId].push([]); } - if (index !== 0 && this.storage.length === 1) { - this.storage.push([]); + if (index !== 0 && this.storage[chartId].length === 1) { + this.storage[chartId].push([]); } - const lastElem = this.storage[this.storage.length - 1]; + const lastElem = this.storage[chartId][this.storage[chartId].length - 1]; // the jump indicates that everythin between lastIdx and current idx, is null while (this.lastIdx < catPoint) { @@ -19028,14 +19037,11 @@ CColorObj.prototype = }, recalculate: function (charts) { - if (this.storage.length !== 2) { - return; - } let diff; let chosenPath; - for (let i in charts) { - if (charts.hasOwnProperty(i) && charts[i] && this.upDownBars && this.upDownBars.parent.Id === i) { + if (charts.hasOwnProperty(i) && charts[i] && this.upDownBars && this.storage[i] && this.storage[i].length === 2 + && this.storage[i][0].length === this.ptsCount && this.storage[i][1].length === this.ptsCount) { const valAxis = charts[i].chart.axId[1]; const catStart = this.cChartDrawer.calcProp.chartGutter._left; @@ -19048,34 +19054,37 @@ CColorObj.prototype = const gapBetween = (koffX - barWidth) / 2; let start = catStart + gapBetween; - for (let i = 0; i < this.ptsCount; i++) { - if (i >= this.storage[0].length || this.storage[0][i].x === null || i >= this.storage[1].length || this.storage[1][i].x === null) { + for (let j = 0; j < this.ptsCount; j++) { + if (j >= this.storage[i][0].length || this.storage[i][0][j].x === null || j >= this.storage[i][1].length || this.storage[i][1][j].x === null) { start += barWidth + (gapBetween * 2); continue; } - if (valAxis && valAxis.scaling && valAxis.scaling.logBase && (this.storage[0][i].y === 0 || this.storage[1][i].y === 0)) { + if (valAxis && valAxis.scaling && valAxis.scaling.logBase && (this.storage[i][0][j].y === 0 || this.storage[i][1][j].y === 0)) { start += barWidth + (gapBetween * 2); continue; } let firstY, secondY; if (this.subtype === "stackedPer") { - firstY = this.cChartDrawer.getYPosition(this.storage[0][i].y / (this.storage[0][i].y + this.storage[1][i].y), valAxis, true) * this.cChartDrawer.calcProp.pxToMM; + firstY = this.cChartDrawer.getYPosition(this.storage[i][0][j].y / (this.storage[i][0][j].y + this.storage[i][1][j].y), valAxis, true) * this.cChartDrawer.calcProp.pxToMM; secondY = this.cChartDrawer.getYPosition(1, valAxis, true) * this.cChartDrawer.calcProp.pxToMM; } else if (this.subtype === "stacked") { - firstY = this.cChartDrawer.getYPosition(this.storage[0][i].y, valAxis, true) * this.cChartDrawer.calcProp.pxToMM; - secondY = this.cChartDrawer.getYPosition(this.storage[0][i].y + this.storage[1][i].y, valAxis, true) * this.cChartDrawer.calcProp.pxToMM; + firstY = this.cChartDrawer.getYPosition(this.storage[i][0][j].y, valAxis, true) * this.cChartDrawer.calcProp.pxToMM; + secondY = this.cChartDrawer.getYPosition(this.storage[i][0][j].y + this.storage[i][1][j].y, valAxis, true) * this.cChartDrawer.calcProp.pxToMM; } else { - firstY = this.cChartDrawer.getYPosition(this.storage[0][i].y, valAxis, true) * this.cChartDrawer.calcProp.pxToMM; - secondY = this.cChartDrawer.getYPosition(this.storage[1][i].y, valAxis, true) * this.cChartDrawer.calcProp.pxToMM; + firstY = this.cChartDrawer.getYPosition(this.storage[i][0][j].y, valAxis, true) * this.cChartDrawer.calcProp.pxToMM; + secondY = this.cChartDrawer.getYPosition(this.storage[i][1][j].y, valAxis, true) * this.cChartDrawer.calcProp.pxToMM; } diff = firstY - secondY; chosenPath = diff > 0 ? this.upPaths : this.downPaths; if (!chosenPath[i]) { - chosenPath[i] = this.cChartDrawer._calculateRect(start, diff > 0 ? firstY : secondY, barWidth, Math.abs(diff)); + chosenPath[i] = {}; + } + if (!chosenPath[j]) { + chosenPath[i][j] = this.cChartDrawer._calculateRect(start, diff > 0 ? firstY : secondY, barWidth, Math.abs(diff)); start += barWidth + (gapBetween * 2); } } @@ -19083,7 +19092,7 @@ CColorObj.prototype = } }, - draw: function () { + draw: function (id) { if (!this.upDownBars) { return; } @@ -19099,15 +19108,19 @@ CColorObj.prototype = this.cChartDrawer.cShapeDrawer.Graphics.SaveGrState(); this.cChartDrawer.cShapeDrawer.Graphics.AddClipRect(leftRect, topRect, rightRect, bottomRect); - for (let i in this.upPaths) { - if (this.upPaths.hasOwnProperty(i) && this.upPaths[i] && this.upDownBars.upBarsBrush && this.upDownBars.upBarsPen) { - this.cChartDrawer.drawPath(this.upPaths[i], this.upDownBars.upBarsPen, this.upDownBars.upBarsBrush); + if (this.upPaths[id]) { + for (let j in this.upPaths[id]) { + if (this.upPaths[id].hasOwnProperty(j) && this.upPaths[id][j] && this.upDownBars.upBarsBrush && this.upDownBars.upBarsPen) { + this.cChartDrawer.drawPath(this.upPaths[id][j], this.upDownBars.upBarsPen, this.upDownBars.upBarsBrush); + } } } - for (let i in this.downPaths) { - if (this.downPaths.hasOwnProperty(i) && this.downPaths[i] && this.upDownBars.downBarsBrush && this.upDownBars.downBarsPen) { - this.cChartDrawer.drawPath(this.downPaths[i], this.upDownBars.downBarsPen, this.upDownBars.downBarsBrush); + if (this.downPaths[id]) { + for (let j in this.downPaths[id]) { + if (this.downPaths[id].hasOwnProperty(j) && this.downPaths[id][j] && this.upDownBars.downBarsBrush && this.upDownBars.downBarsPen) { + this.cChartDrawer.drawPath(this.downPaths[id][j], this.upDownBars.downBarsPen, this.upDownBars.downBarsBrush); + } } }