-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add test for fit content resize issue #966
- Loading branch information
Showing
1 changed file
with
45 additions
and
0 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
tests/e2e/graphics/test-cases/time-scale/fit-content-pricescale-changes.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
|