Кажется, это не так сложно, но я не могу найти что-то работающее... не могли бы вы мне помочь?
Это страница, которую я написал:
Код: Выделить всё
$(function () {
var data;
$.getJSON("1.json", function(json) {
var data = json;
});
var options = {
legend: {
show: true,
margin: 10,
backgroundOpacity: 0.5
},
points: {
show: true,
radius: 3
},
lines: {
show: true
}
};
var plotarea = $("#placeholder");
$.plot(plotarea , data, options);
});
Код: Выделить всё
{ label: "Values",
data: [
[1, 50.026],
[2, 50.028],
[3, 50.029],
[4, 50.026],
[5, 50.025],
[6, 50.016]
]
}
Это код страницы «1.htm»:
Код: Выделить всё
Graph
$(function () {
var data;
$.getJSON("1.json", function(json) {
var data = json;
});
console.log(data);
var plotarea = $("#placeholder");
$.plot(plotarea , data);
});
Код: Выделить всё
[{ label: "Values",
data: [
[1, 50.026],
[2, 50.028],
[3, 50.029],
[4, 50.026],
[5, 50.025],
[6, 50.016]
]
}}
Код: Выделить всё
Graph
$(document).ready(function(){
$.getJSON("1.json", function(json) {
//succes - data loaded, now use plot:
var plotarea = $("#placeholder");
var data=[json.data];
$.plot(plotarea , data);
});
});
Код: Выделить всё
{
"label": "Europe (EU27)",
"data": [[1999, 1], [2000, 0.23], [2001, 3], [2002, 4], [2003, 1.3], [2004, 2.5], [2005, 2.0], [2006, 3.1], [2007, 2.9], [2008, 0.9]]
}
Подробнее здесь: https://stackoverflow.com/questions/785 ... query-flot
Мобильная версия