-
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.
Merge pull request #1739 from tradingview/get_pricelines_from_iseriesapi
Add method priceLines in ISeriesAPI
- Loading branch information
Showing
4 changed files
with
59 additions
and
2 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
44 changes: 44 additions & 0 deletions
44
tests/e2e/graphics/test-cases/series/price-lines-getter.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,44 @@ | ||
function generateData() { | ||
const res = []; | ||
const time = new Date(Date.UTC(2018, 0, 1, 0, 0, 0, 0)); | ||
for (let i = 0; i < 60; ++i) { | ||
res.push({ | ||
time: time.getTime() / 1000, | ||
value: i, | ||
}); | ||
|
||
time.setUTCDate(time.getUTCDate() + 1); | ||
} | ||
return res; | ||
} | ||
|
||
function runTestCase(container) { | ||
const chart = window.chart = LightweightCharts.createChart(container, { layout: { attributionLogo: false } }); | ||
|
||
const series = chart.addSeries(LightweightCharts.LineSeries); | ||
series.setData(generateData()); | ||
|
||
series.createPriceLine({ price: 10 }); | ||
series.createPriceLine({ price: 20 }); | ||
series.createPriceLine({ price: 30 }); | ||
|
||
return new Promise(resolve => { | ||
setTimeout(() => { | ||
const priceLines = series.priceLines(); | ||
const [line1, line2] = priceLines; | ||
|
||
// remove line 3 from array, however line3 should still be visible on the chart | ||
priceLines.splice(2, 1); | ||
|
||
// still check it can be removed | ||
series.removePriceLine(line1); | ||
|
||
// modify line 2 returned from the getter | ||
line2.applyOptions({ | ||
price: 15, | ||
color: 'red', | ||
}); | ||
resolve(); | ||
}, 1000); | ||
}); | ||
} |