This is my problem:
- there is binary file (containing short int - 16 bit) on the server
- I'd like to load it and create data for graphs (I use http://dygraphs.com/ - it must be native format array [ [0,1], [1,2] ])
I've tried this code:
window.addEvent(
"domready",
function()
{
var dataRequest = new Request(
{
url: "data.dat",
onSuccess: function(response)
{
var timestart = new Date();
var tempArray = response.match(/.{2}/g);
for(var i=0; i<tempArray.length; ++i) {
graphDataArray[i] = [i, (tempArray[i].charCodeAt(0)<<8) + tempArray[i].charCodeAt(1) ];
}
new Dygraph(
document.getElementById("graphdiv"),
graphDataArray,
{}
);
document.getElementById("timemsg").innerHTML = "Generated in " + (new Date() - timestart).toString() + " ms";
}
}
).send();
);
It doesn't work because charCodeAt() has nothing to do with binary data, it interprets ASCII. What should I do?