Can I´m asking for advice. I have function which should return javascript object
function get_temp(){
var datasets_temp = {
"sens1": {data: [[1340803113,22.9],[1340803474,23],[1340803836,23],[1340804197,23.1]] },
"sens2": {data: [[1340846482,23],[1340846843,23],[1340847204,23],[1340847566,23]] },
"sens3": {data: [[1340868157,23.1],[1340868518,22],[1340868879,23.2],[1340869241,23.2]] }};
return datasets_temp;
}
Drawing graph:
var plot = $.plot($("#temp_graph"), get_temp(), $.extend(true, {}, options, {
xaxis: {min: 0, max: 50}}));
I don´t know where is problem why is it not working.
You are on the right track, but the series data needs to be an array of series objects, not just one object with each set of data being a property of it.
What you should have is something like this:
You have another problem, which is that you are obviously plotting the x-axis as time, but your timestamps (i.e.
1340846482) are not javascript timestamps, they are “unix” ones. What you need to do is multiply every timestamp by 1000 (i.e.1340846482000is correct), because javascript counts them in milliseconds, not seconds. See the text in this example for other caveats.