function drawChart(chartData, lineChartId) {
var data = new google.visualization.DataTable();
data.addColumn('date', 'Time of Day');
data.addColumn('number', 'KWR');
data.addColumn('number', 'BSR');
data.addRows(chartData);
var options = {
colors: ['#000000','#ff9000'],
hAxis: {
format: 'M/d/yy',
gridlines: {count: 10}
},
vAxis: {
direction: -1
}
};
var chart = new google.visualization.LineChart(document.getElementById(lineChartId));
chart.draw(data, options);
}
function unpackObj(obj, user={}) {
for ( var property in obj ) {
if ( obj.hasOwnProperty(property) ) {
if (typeof obj[property] === 'object' && ! Array.isArray(obj[property])) {
user = unpackObj(obj[property], user);
} else {
user[property] = obj[property]
}
}
}
return user
}
{
"id": 9,
"url": "http://127.0.0.1:8000/api/users/yufghbfcv/",
"first_name": "dsdsds",
"last_name": "htghtghgfhgfh",
"username": "yufghbfcv",
"email": "dsuhd@mail.com",
"birthday": "2017-12-18",
"is_active": true,
"address": {
"zip_code": "123456",
"country": "wewedasdscxc",
"city": "xcxcxcx",
"district": "dadada",
"street": "cxcxc"
},
"groups": [],
"date_joined": "2017-10-20 20:31:30",
"last_update": "2017-11-28 13:26:55"
}
А потом в темплейте:
upd:
А с моделью даже подготавливать почти ничего не нужно: