I’m trying to get red/green candlesticks in a eCharts graph starting by the example on eCharts site.
The starting example it’s called “Large Scale Candlestick” that generates random data from a custom function called generateOHLC
.
In an other example there’s a link that gets data from a JSON file also from eCharts site you can see at this link: https://echarts.apache.org/…
The values of each array (in the big array) are respectively [date ,open, close, low, high, volume]
Now, I have taken some of this value and I have adapted it to get an other value in the inners array with this small easy JavaScript code:
data.forEach(function (point, point_index){
point.push ( getSign(data, point_index, point[1], point[2], 2) )
//console.log(point)
})
by using the same function getSign
used from the previous example.
So the last value added (pushed in the array as 1
or -1
) should make the candle turn red or green.
You can see the result of the adapted example here:
So, why the candles are always red and the ones in the first example are red and green?
Where’s my error and what I’m doing wrong?