-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1444 from tradingview/fix-timescale-shifting-on-u…
…pdates fix shiftVisibleRangeOnNewBar behaviour
- Loading branch information
Showing
10 changed files
with
369 additions
and
42 deletions.
There are no files selected for viewing
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
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
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
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
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
50 changes: 50 additions & 0 deletions
50
tests/e2e/graphics/test-cases/time-scale/allow-shift-range-whitespace-replacement.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,50 @@ | ||
const seriesOneData = [ | ||
{ time: '2019-04-11', value: 80.01 }, | ||
{ time: '2019-04-12', value: 96.63 }, | ||
{ time: '2019-04-13', value: 76.64 }, | ||
{ time: '2019-04-14', value: 81.89 }, | ||
{ time: '2019-04-15', value: 74.43 }, | ||
{ time: '2019-04-16', value: 80.01 }, | ||
{ time: '2019-04-17' }, | ||
]; | ||
|
||
const seriesTwoWhitespaceData = [ | ||
{ time: '2019-04-17' }, | ||
{ time: '2019-04-18' }, | ||
{ time: '2019-04-19' }, | ||
{ time: '2019-04-20' }, | ||
]; | ||
|
||
function runTestCase(container) { | ||
const chart = window.chart = LightweightCharts.createChart(container, { | ||
timeScale: { | ||
barSpacing: 30, | ||
rightOffset: 0, | ||
shiftVisibleRangeOnNewBar: true, | ||
allowShiftVisibleRangeOnWhitespaceReplacement: true, | ||
}, | ||
}); | ||
|
||
const s1 = chart.addAreaSeries({ | ||
lineColor: 'rgb(0, 50, 200)', | ||
topColor: 'rgba(0, 50, 200, 0.2)', | ||
bottomColor: 'rgba(0, 50, 200, 0.2)', | ||
}); | ||
s1.setData(seriesOneData); | ||
|
||
return new Promise(resolve => { | ||
requestAnimationFrame(() => { | ||
const s2 = chart.addLineSeries({ | ||
color: 'black', | ||
}); | ||
s2.setData(seriesTwoWhitespaceData); | ||
requestAnimationFrame(() => { | ||
s1.update({ time: '2019-04-17', value: 84.43, lineColor: 'green', topColor: 'rgba(0, 200, 50, 0.2)', bottomColor: 'rgba(0, 200, 50, 0.2)' }); | ||
requestAnimationFrame(() => { | ||
s1.update({ time: '2019-04-18', value: 86.43, lineColor: 'green', topColor: 'rgba(0, 200, 50, 0.2)', bottomColor: 'rgba(0, 200, 50, 0.2)' }); | ||
requestAnimationFrame(resolve); | ||
}); | ||
}); | ||
}); | ||
}); | ||
} |
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
134 changes: 134 additions & 0 deletions
134
...aphics/test-cases/time-scale/updates-after-replacing-whitespace-should-shift-timescale.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,134 @@ | ||
/* | ||
It is expected that 10 bars should be visible. | ||
*/ | ||
const startData = [ | ||
{ | ||
time: '2019-05-23', | ||
open: 59.0, | ||
high: 59.27, | ||
low: 58.54, | ||
close: 58.87, | ||
}, | ||
{ | ||
time: '2019-05-24', | ||
open: 59.07, | ||
high: 59.36, | ||
low: 58.67, | ||
close: 59.32, | ||
}, | ||
{ | ||
time: '2019-05-28', | ||
open: 59.21, | ||
high: 59.66, | ||
low: 59.02, | ||
close: 59.57, | ||
}, | ||
]; | ||
|
||
const updates = [ | ||
{ | ||
time: '2019-05-29', | ||
open: 59.0, | ||
high: 59.27, | ||
low: 58.54, | ||
close: 58.87, | ||
}, | ||
{ | ||
time: '2019-05-29', | ||
open: 59.07, | ||
high: 59.36, | ||
low: 58.67, | ||
close: 59.32, | ||
}, | ||
{ | ||
time: '2019-05-29', | ||
open: 59.21, | ||
high: 59.66, | ||
low: 59.02, | ||
close: 59.57, | ||
}, | ||
{ | ||
time: '2019-05-30', | ||
open: 59.0, | ||
high: 59.27, | ||
low: 58.54, | ||
close: 58.87, | ||
}, | ||
{ | ||
time: '2019-05-31', | ||
open: 59.07, | ||
high: 59.36, | ||
low: 58.67, | ||
close: 59.32, | ||
}, | ||
{ | ||
time: '2019-06-01', | ||
}, | ||
{ | ||
time: '2019-06-01', | ||
open: 59.0, | ||
high: 59.27, | ||
low: 58.54, | ||
close: 58.87, | ||
}, | ||
{ | ||
time: '2019-06-02', | ||
open: 59.0, | ||
high: 59.27, | ||
low: 58.54, | ||
close: 58.87, | ||
}, | ||
{ | ||
time: '2019-06-03', | ||
}, | ||
{ | ||
time: '2019-06-03', | ||
open: 59.21, | ||
high: 59.66, | ||
low: 59.02, | ||
close: 59.57, | ||
}, | ||
{ | ||
time: '2019-06-04', | ||
open: 59.0, | ||
high: 59.27, | ||
low: 58.54, | ||
close: 58.87, | ||
color: 'rgb(0,0,255)', | ||
wickColor: 'rgb(0,0,255)', | ||
borderColor: 'rgb(0,0,255)', | ||
}, | ||
]; | ||
|
||
function runTestCase(container) { | ||
const chart = (window.chart = LightweightCharts.createChart(container, { | ||
timeScale: { | ||
barSpacing: 12, | ||
shiftVisibleRangeOnNewBar: true, | ||
/* | ||
! NOTE ! | ||
We need to set a rightOffset to a number large enough to cover the | ||
amount of whitespaces we will be adding. Since adding whitespace isn't | ||
meant to shift the timescale, and shifting only works when the last | ||
bar is visible. We need to make sure that the whitespaces are visible | ||
so the updates are on on a visible bar. | ||
*/ | ||
rightOffset: 2, | ||
}, | ||
})); | ||
|
||
const s1 = chart.addCandlestickSeries(); | ||
s1.setData(startData); | ||
|
||
return new Promise(resolve => { | ||
let index = 0; | ||
const intervalId = setInterval(() => { | ||
s1.update(updates[index]); | ||
index += 1; | ||
if (index >= updates.length) { | ||
clearInterval(intervalId); | ||
requestAnimationFrame(resolve); | ||
} | ||
}, 10); | ||
}); | ||
} |
Oops, something went wrong.