I have an array of gradients that I am trying to pass to a charting library each time a function is called.
The library requires the gradient to be passed in as an object in this format:
[0, 'rgba(73,115,214,.15)'],
[1, 'rgba(73,115,214,.07)']
I have built an array of gradients like so:
var gradients = [
[
['rgba(73,115,214,.15)'],
['rgba(148,196,168,.1)']
],
[
['rgba(73,115,214,.07)'],
['rgba(41,189,102,.12)']
]
]
Each time a function is called, I store an index value, and need to retrieve the corresponding gradient in the array. How do I retrieve a specific index value from gradients and construct it into the necessary format?
var index = -1;
function setData() {
index = index + 1;
//I Need a gradient!
}
For instance, if the index was 2, I would want to return:
[0, 'rgba(73,115,214,.07)'],
[1, 'rgba(41,189,102,.12)']