Skip to content

Commit

Permalink
Merge pull request #1377 from tradingview/fix-reenabling-of-autoSize
Browse files Browse the repository at this point in the history
fix re-enabling of autoSize after disabling it
  • Loading branch information
SlicedSilver committed Jun 13, 2023
2 parents 38d6040 + cf5b3da commit 8ee7bb9
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/gui/chart-widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -820,6 +820,7 @@ export class ChartWidget implements IDestroyable {
if (this._observer !== null) {
this._observer.disconnect();
}
this._observer = null;
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
window.ignoreMouseMove = true;
function generateData() {
const res = [];
const time = new Date(Date.UTC(2018, 0, 1, 0, 0, 0, 0));
for (let i = 0; i < 500; ++i) {
res.push({
time: time.getTime() / 1000,
value: i,
});

time.setUTCDate(time.getUTCDate() + 1);
}

return res;
}

function runTestCase(container) {
const box = document.createElement('div');
box.style.position = 'absolute';
box.style.top = 0;
box.style.left = 0;
box.style.width = '200px';
box.style.height = '200px';
container.appendChild(box);

const chart = LightweightCharts.createChart(box, { autoSize: true, height: 200, width: 200 });
const mainSeries = chart.addAreaSeries();

mainSeries.setData(generateData());

return new Promise(resolve => {
requestAnimationFrame(() => {
// remove autoSize
chart.applyOptions({ autoSize: false });
box.style.height = '225px';
requestAnimationFrame(() => {
// enable autoSize again.
// This test case is checking that you can have autoSize enabled, then removed, and then re-added again
chart.applyOptions({ autoSize: true });
box.style.height = '250px';
setTimeout(resolve, 300);
});
});
});
}

0 comments on commit 8ee7bb9

Please sign in to comment.