Exchange data chart type
amelenetwork opened this issue ยท 5 comments
amelenetwork commented
Hello there !
I need help again.. I hope you can answer...
Which chart is this ? Highchart or what ? Where can i found this chart sources ? I want to build same as like this look for mobile resolutions .
What is your ideas fellows ?
Thank you for sharing.
jaggedsoft commented
This is kline: https://github.com/chxj1992/kline
I have code to make it work with this library. My version uses PHP to get around CORS security issues
jaggedsoft commented
jaggedsoft commented
amelenetwork commented
Thank you so much....
jaggedsoft commented
no problem, there are two undocumented built-in functions in this library that are very useful for charting.
.highstock(chart)
will return the data in array format [open, high, low, close, volume]
.ohlc(chart)
will return the data in object format .open .high .low .close .volume
// convert chart data to highstock array [timestamp,open,high,low,close]
highstock: function(chart, include_volume = false) {
let array = [];
for ( let timestamp in chart ) {
let obj = chart[timestamp];
let line = [
Number(timestamp),
parseFloat(obj.open),
parseFloat(obj.high),
parseFloat(obj.low),
parseFloat(obj.close)
];
if ( include_volume ) line.push(parseFloat(obj.volume));
array.push(line);
}
return array;
},
ohlc: function(chart) {
let open = [], high = [], low = [], close = [], volume = [];
for ( let timestamp in chart ) { //ohlc[symbol][interval]
let obj = chart[timestamp];
open.push(parseFloat(obj.open));
high.push(parseFloat(obj.high));
low.push(parseFloat(obj.low));
close.push(parseFloat(obj.close));
volume.push(parseFloat(obj.volume));
}
return {open:open, high:high, low:low, close:close, volume:volume};
},