-
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.
Added support for having custom colors per data item for candlestick …
…and bar series Fixes #195 (the first part)
- Loading branch information
Showing
7 changed files
with
166 additions
and
19 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
35 changes: 35 additions & 0 deletions
35
tests/e2e/graphics/test-cases/series/bar-with-custom-colors.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,35 @@ | ||
function generateCandle(i, target) { | ||
const step = (i % 20) / 5000; | ||
const base = i / 5; | ||
target.open = base * (1 - step); | ||
target.high = base * (1 + 2 * step); | ||
target.low = base * (1 - 2 * step); | ||
target.close = base * (1 + step); | ||
|
||
if (i % 2 === 0) { | ||
target.color = 'yellow'; | ||
} | ||
} | ||
|
||
function generateData() { | ||
const res = []; | ||
const time = new Date(Date.UTC(2018, 0, 1, 0, 0, 0, 0)); | ||
for (let i = 0; i < 500; ++i) { | ||
const item = { | ||
time: time.getTime() / 1000, | ||
}; | ||
time.setUTCDate(time.getUTCDate() + 1); | ||
|
||
generateCandle(i, item); | ||
res.push(item); | ||
} | ||
return res; | ||
} | ||
|
||
function runTestCase(container) { | ||
const chart = LightweightCharts.createChart(container); | ||
|
||
const mainSeries = chart.addBarSeries(); | ||
|
||
mainSeries.setData(generateData()); | ||
} |
37 changes: 37 additions & 0 deletions
37
tests/e2e/graphics/test-cases/series/candlesticks-with-custom-colors.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,37 @@ | ||
function generateCandle(i, target) { | ||
const step = (i % 20) / 5000; | ||
const base = i / 5; | ||
target.open = base * (1 - step); | ||
target.high = base * (1 + 2 * step); | ||
target.low = base * (1 - 2 * step); | ||
target.close = base * (1 + step); | ||
|
||
if (i % 2 === 0) { | ||
target.color = 'yellow'; | ||
target.borderColor = 'black'; | ||
target.wickColor = 'blue'; | ||
} | ||
} | ||
|
||
function generateData() { | ||
const res = []; | ||
const time = new Date(Date.UTC(2018, 0, 1, 0, 0, 0, 0)); | ||
for (let i = 0; i < 500; ++i) { | ||
const item = { | ||
time: time.getTime() / 1000, | ||
}; | ||
time.setUTCDate(time.getUTCDate() + 1); | ||
|
||
generateCandle(i, item); | ||
res.push(item); | ||
} | ||
return res; | ||
} | ||
|
||
function runTestCase(container) { | ||
const chart = LightweightCharts.createChart(container); | ||
|
||
const mainSeries = chart.addCandlestickSeries(); | ||
|
||
mainSeries.setData(generateData()); | ||
} |
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