Skip to content

Commit

Permalink
Pull request #5255: [DXCF-5508] Chart - Wrong vertical default size s…
Browse files Browse the repository at this point in the history
…ubgraphs calculations after add/deleting indicators // init

Merge in DXCHARTS/dxchart5 from bugfix/DXCF-5508-new/chart-wrong-vertical-default-size-subgraphs-calculations-after-add-deleting to master

* commit '343944c1b5e0d4edaf2301c4c17131dc282693de':
  [DXCF-5508] Chart - Wrong vertical default size subgraphs calculations after add/deleting indicators // pr fix
  [DXCF-5508] Chart - Wrong vertical default size subgraphs calculations after add/deleting indicators // init

GitOrigin-RevId: 004b21c1981d7bcca7c5788b8cf060e424649238
  • Loading branch information
Keelaro1 authored and dxcity committed Dec 11, 2024
1 parent 0126dee commit c990574
Showing 1 changed file with 31 additions and 3 deletions.
34 changes: 31 additions & 3 deletions src/chart/canvas/canvas-bounds-container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -540,14 +540,40 @@ export class CanvasBoundsContainer {
const oldPecNumber = visiblePecRatios.filter(ratio => ratio !== undefined).length;
// if ratio in undefined for a given pane it means that it's a new pane
const newPecNumber = pecRatios.filter(ratio => ratio === undefined).length;
const paneIsAdded = newPecNumber > 0;

let freeRatioForPec = 0;
let freeRatio = 0;
let ratioForOldPec = 1;
let ratioForNewPec = 0;
if (newPecNumber > 0) {
if (paneIsAdded) {
[ratioForOldPec, ratioForNewPec] = getHeightRatios(visiblePecNumber);
chartRatio *= ratioForOldPec;
}

//#region chart height ratio logic
if (this.graphsHeightRatio[CHART_UUID] === 0) {
chartRatio = 0;
}

if (this.graphsHeightRatio[CHART_UUID] !== 0) {
if (paneIsAdded) {
chartRatio = 1 * ratioForOldPec;
} else {
// pec ratio values before recalculating and new chart ratio
const currentHeightRatioValues = Object.values(this.graphsHeightRatio).reduce(
(prev, curr) => (curr += prev),
);

// chart is hidden and one of the pec is removed
// since the chart height ratio is new, the currentHeightRatioValues could be > 1, it happens if make chart visible again
if (currentHeightRatioValues < 1 && this.graphsHeightRatio[CHART_UUID] !== 0) {
chartRatio += 1 - currentHeightRatioValues;
}
}
}

//#endregion

// this means we should keep in mind only new panes
if (oldPecNumber === 0) {
chartRatio = 1 - ratioForNewPec * newPecNumber;
Expand Down Expand Up @@ -983,13 +1009,15 @@ export class CanvasBoundsContainer {
}

// paneCounter=chartHeightRatio: 0=1, 1=0.8, 2=0.6, 3=0.5, 4=0.4, 5=0.4
// ratios requirements table: https://confluence.in.devexperts.com/display/UI/Chart+Navigation#ChartNavigation-2Graphsadjustablesizes
const DEFAULT_RATIOS: Record<number, number> = {
0: 1,
1: 0.8,
2: 0.6,
3: 0.5,
4: 0.4,
5: 0.2,
5: 0.4,
6: 0.4,
};

// NOTE: pec stands for panes except main chart
Expand Down

0 comments on commit c990574

Please sign in to comment.