Skip to content

Commit

Permalink
add test for fit content resize issue #966
Browse files Browse the repository at this point in the history
  • Loading branch information
Ffloriel committed Jan 17, 2022
1 parent 41fd114 commit 24e475c
Showing 1 changed file with 45 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
function generateData(down) {
const res = [];
const time = new Date(Date.UTC(2018, 0, 1, 0, 0, 0, 0));
const points = down ? 1000 : 10000;
for (let i = 0; i < points; ++i) {
res.push({
time: time.getTime() / 1000,
value: down ? 1000 - i : i,
});

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

function runTestCase(container) {
const chart = LightweightCharts.createChart(container, {
width: 600,
height: 300,
});
chart.applyOptions({
timeScale: {
fixLeftEdge: true,
fixRightEdge: true,
},
});

const data1 = generateData(false);
const data2 = generateData(true);

const areaSeries = chart.addAreaSeries();
areaSeries.setData(data1);
chart.timeScale().fitContent();

chart.applyOptions({
timeScale: {
fixLeftEdge: true,
fixRightEdge: true,
},
});
chart.removeSeries(areaSeries);
chart.addAreaSeries().setData(data2);
chart.timeScale().fitContent();
}

0 comments on commit 24e475c

Please sign in to comment.